Answer the question
In order to leave comments, you need to log in
How to make functions work together with discord.py?
If you send a message to the channel, then the bot will give a reaction, but !clear does not work
@bot.command(pass_context=True)
async def clear(ctx, arg):
await ctx.message.delete()
async for msg in ctx.message.channel.history(limit=int(arg)):
if msg is not None:
await msg.delete()
embed = discord.Embed(title="Удалено "+str(arg)+" сообщений!", description="", color=0x00ff00)
new_message = await ctx.send(embed=embed)
await asyncio.sleep(5)
await new_message.delete()
@bot.event
async def on_message(message):
suggestion_channel_id = 782338760275918849
if message.channel.id == suggestion_channel_id:
if message.content.startswith('!'):
pass
else:
await message.add_reaction("")
Answer the question
In order to leave comments, you need to log in
You need to get the Context Then you need to invoke CTRL+C
ctx = await bot.get_context(message)
await bot.invoke(ctx)
@bot.event
async def on_message(message):
ctx = await bot.get_context(message)
await bot.invoke(ctx)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question