#python #discord.py
#python #discord.py
Вопрос:
У меня есть скрипт как с bot.command, так и с bot.event, но по какой-то причине работает только bot.command
bot.command и bot.event работают отдельно, но по какой-то причине не вместе
Вот код:
# bot.py
import discord
from discord.ext import commands
from discord.utils import get
TOKEN = ('token')
bot = commands.Bot(command_prefix=',')
@bot.event
async def on_ready():
print(f'{bot.user} has connected to Discord!')
@bot.event
async def on_message(message):
if foo:
await message.channel.send("foo")
@bot.command(pass_context=True)
async def foo(ctx, args):
foo = bot.get_user(args)
await ctx.send(foo)
bot.run(TOKEN)
Спасибо
Ответ №1:
В on_message
вам нужно обработать команды вашего бота:
await bot.process_commands(message)
Также вам больше не нужно использовать pass_context=True
, теперь он всегда передается.