P
P
Pavel2020-09-24 12:49:27
Python
Pavel, 2020-09-24 12:49:27

[Python] Discord bot not responding to commands?

I wrote a bot discord, made a couple of checks in the on_message event and decided to write a command, but in the end the bot does not respond to this or any other command, that is, it does not even say in the console that there is no such command. I think it's because of the on_message event but I don't know how to fix it.
Here is the code

import discord
from discord.ext import commands
from discord.utils import get
import asyncio
import random

client = commands.Bot( command_prefix = 'pls')

@client.event
async def on_ready():
 	print('Connected')

@client.event
async def on_message(message):
    if message.mention_everyone == True:
        muted = message.author
        role = get(message.author.guild.roles, id=758265276956409907)
        await message.author.add_roles(role)
        ChanneL=client.get_channel(757894938313752629)
        await message.delete()
        await ChanneL.send(f'{message.author.mention}, Why did you call me, noob? ' + '<:pingtrollet:758228406357065778>')
        await asyncio.sleep(30)
        await message.author.remove_roles(role)
    else:
      if message.content == 'u' or message.content == ':Utrollet:' or message.content == 'U':
          ay = random.randint(0,8)
          if ay == 1:
              if message.author.id == 757897897948872794:
                  pass
              else:
                  ChanneL=client.get_channel(message.channel.id)
                  await ChanneL.send('<:Utrollet:758293129433841694>')

@client.command(aliases = [' asktrollet'])
async def __asktrollet( ctx, *, agr ):
  print('yes')
  answers = ['1','2']
  randoma = random.randint(0,1)
  embed.set_thumbnail(url="https://i.ibb.co/ZSxhjwY/trollet.png")
  embed.add_field(name="", value=f"{ctx.author.name}: {arg}", inline=False)
  embed.add_field(name="", value=f"Trollet: {aswers[randoma]}", inline=False)
  await ctx.send(embed=embed)
            
client.run('токен')

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
shurshur, 2020-09-24
@Anime-pdf

Standard trouble, everyone stumbles, so this answer is even the first item in the official FAQ: https://discordpy.readthedocs.io/en/latest/faq.htm...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question