Хотелось бы чтобы в один момент параллельно работало несколько обработчиков process_command. Пробовал через threading, ругается ибо функция async. asyncio.run бросает TypeError: run() argument after * must be an iterable, not NoneType. Есть ли возможность реализовать параллельное выполнение?
Код:
import discord
from discord.ext import commands
import time
token="token"
prefix = "s!"
owner_id=0
# ----------
print("Загрузка...")
bot = commands.Bot(command_prefix=prefix)
@bot.event
async def on_ready():
print("Бот типа готов")
@bot.event
async def on_message(message):
if message.content.lower().startswith(prefix):
await process_command(message.content[len(prefix):].split(' '), message.channel, message.author)
if message.author.id!=owner_id:
return
if message.content=='<@%s>'%bot.user.id:
await message.channel.send('Сейчас в сети.')
async def process_command(args, channel, author):
args[0]=args[0].lower()
if author.id!=owner_id:
return
if args[0]=="say":
await bot.get_channel(int(args[1])).send(" ".join(args[2:]))
elif args[0]=="em":
await bot.get_channel(int(args[1])).send(bot.get_emoji(int(args[2])))
elif args[0]=="status":
await bot.change_presence(activity=discord.Game(name=" ".join(args[2:]), type=int(args[1])))
elif args[0]=="sleep":
time.sleep(int(args[1]))
if __name__=='__main__':
bot.run(token)