• Noxive

    Ok finally solved it. I missed this fragment in the docs:

    Overriding the default provided on_message forbids any extra commands from running. To fix this, add a bot.process_commands(message) line at the end of your on_message
    

    Thanks everyone for help.

    posted in Pythonista read more
  • Noxive

    @JonB Tried the function, nothing no response not on the server or the terminal

    @bot.command()
    async def test(ctx):
        print("test Called")
        await ctx.send('test')
    

    I changed the client.event to bot.event, the on_message event and on_ready work fine. The command still doesn't respond

    import discord
    from discord.ext.commands import Bot
    
    TOKEN = 'MyToken'
    
    bot = Bot(command_prefix='$')
    
    
    @bot.command()
    async def test(ctx):
        print("test Called")
        await ctx.send('test')
    
    
    @bot.event
    async def on_ready():
        print("We have logged in as: {0.user}".format(bot))
    
    
    @bot.event
    async def on_message(message):
    
        if message.author == bot.user:
            return
    
        if message.content.startswith("shrug"):
            print("shrug")
            await message.channel.send('¯\_(ツ)_/¯')
    
    bot.run(TOKEN)

    posted in Pythonista read more
  • Noxive

    @ellie_ff1493 I did. Nothing happens. Like the command event never even occured.

    @ccc @cvp I deleted all the comments and PyDoc, there is no change.

    posted in Pythonista read more
  • Noxive

    Ok, so I'm trying to create Discord Bot and i can't figure out why my commands don't work. The on_message() events work properly if i type shrug the bot sends the emoji but when i try to call the $test command bot doesn't respond literraly no errors and no response on the channel. I've spent like 2 hours reading the documentation and everything is ok, but its not.

    Python 3.6.8
    discord-py 1.2.2

    Please somebody help.

    from discord.ext.commands import Bot
    
    TOKEN = 'Here goes my token'
    
    client = discord.Client()
    bot = Bot(command_prefix='$') """ Command prefix is marked red in PyCharm"""
    
    
    @bot.command()
    async def test(ctx, arg):
        await ctx.send(arg)
    
    """
    After the bot logging on to the server 
    on_ready event occurs and prints the name of the logged in Bot
    """
    
    
    @client.event
    async def on_ready():
        print("We have logged in as: {0.user}".format(client))
    
    """
    When the message is sent event on_message() occurs
    """
    
    
    @client.event
    async def on_message(message):
    
        """
        If the message is from the bot nothing happens.
        ...
        When the user inputs $hello bot sends Hello! message on the channel.
        ...
        For the message = 'shrug' bot sends shrug emoji in ASCII onto the channel.
        """
    
        if message.author == client.user:
            return
    
        if message.content.startswith('$hello'):
            await message.channel.send("Hello!")
    
        if message.content.startswith("shrug"):
            await message.channel.send('¯\_(ツ)_/¯')
    
    client.run(TOKEN)
    
    

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!