I'm making a bot on Discord.py and I'm trying to set the channel I want to send a message to using an argument. The code is this:
@client.command()
async def send(ctx, arg1):
channel = client.get_channel(arg1)
await channel.send('Message')
When I type the channel id instead of arg1, it works, but when I type the command on Discord (!send 282772187812) it doesn't work and I get this error: discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'send'
Thanks in advance.
try : except:
to send a message on error and attempt to resume execution – elite gamer88