Python Forum
[Discord.py] Bot not responding? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: [Discord.py] Bot not responding? (/thread-5540.html)



[Discord.py] Bot not responding? - Ouindoze - Oct-09-2017

Here is the code : https://hastebin.com/fugurelagu.py

So the error is that the _help does not respond, whenever a user types _help, nothing happens.
There is no error in the console which is really weird, and something else that is weird
is that the _magicball command works correctly with no problem/error.

It's my first time here so i'm trying to explain my problem the most clearly i can (sorry if my english is bad i don't speak english)

The code (added by buran)
import discord
import asyncio
import random
import pickle
import os

client = discord.Client()

@client.event
async def on_ready():
    print('Ready and with')
    print(client.user.name)

@client.event
async def on_message(message):
    if message.content.startswith('_help'):
        msg1 = await client.send_message(message.channel, ('```Heres what i can do :```'))
        msg2 = await client.send_message(message.channel, ('```-_help for help```'))
        msg3 = await client.send_message(message.channel, ('```-_8ball to ask the magic 8ball```'))
        msg4 = await client.send_message(message.channel, ('```Bot powered by Ouindoze™, message will auto destruct in 15s :boom: ```'))


@client.event
async def on_message(message):
    if message.content.startswith('_magicball'):
        ball8 = random.choice(['It is certain','As i see it, yes', 'Dont count on it', 'Without a doubt', 'Definitely', 'Very doubtful', 'Outlook not so good', 'My sources say no', 'My reply is no', 'Most likely', 'You may rely on it', 'Ask again later'])
        msg5 = await client.send_message(message.channel, ball8)



client.run('My token here, i will obviously not give it freely')



RE: [Discord.py] Bot not responding? - buran - Oct-09-2017

it doesn't make sense to have two functions with same signature:
@client.event
async def on_message(message):
the second one will overwrite the first one. that is why magic_ball is working and _help - not.
look at the example here how they use if/else in on_message function:
https://github.com/Rapptz/discord.py
ho


RE: [Discord.py] Bot not responding? - Ouindoze - Oct-10-2017

Alright thanks a lot, sorry for the late response i was busy all day so