Все необходимое файлы, которые необходимо выполнить, хранятся в одной папке ./files/
Мой код:
Код: Выделить всё
@bot.event #p.s. i'm use on_message event for commands
async def on_message(message: discord.Message):
# prefix check
if not message.content.startswith('k.'): return
command = message.content[2:].split()
# getting all python files from ./files/
ctx = await bot.get_context(message)
all_commands = []
for subdir, dirs, files in os.walk('files'):
for file in files:
filepath = subdir + os.sep + file
if filepath.endswith(".py"):
cmd_name = file.split('.')[0]
all_commands.append(cmd_name)
if command[0] == 'sync':
# there i need to import all python files
if command[0] in all_commands:
# 1 file in the "files" folder
# equals one command with prefix "k."
Также не хочу использовать винтики, так как не могу удалить все винтики с помощью команды
< п>Как мне это сделать? Если это возможно
Подробнее здесь: https://stackoverflow.com/questions/786 ... is-running