0
votes

I need help getting my bot to work

# Import Discord Package
import discord

# Client (our bot)
client = discord.Client()

@client.event
async def on_ready():
    # DO STUFF....
    general_channel = client.get_channel()

    await general_channel.send('yo')

# Run the client on the server
client.run('')

when I run it i get AttributeError: 'NoneType' object has no attribute 'send' in terminal and nothing shows up on discord if you could fix it that would be great

1

1 Answers

0
votes

The common reasons why get_ would return None are: a) The channel ID is not found b) The bot is not connected c) get_ method is called before the bot is started.

In your case there are 2 obvious misses

  1. get_channel method requires a parameter which is the channel ID. https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild.get_channel

  2. The bot is likely not loggedIn as client.run() also requires a token parameter. client.run('your_token')