Reputation: 1
I want the code to work what I wrote-test2 #chat and the bot sent a message there, but my code doesn't work. Please help me with the code and tell me where I made the mistake. I will be grateful! My code:
@client.command()
async def test2(ctx, name):
chans = get(ctx.guild.channels, name = name)
e = discord.Embed(title = f'hello')
await chans.send(embed = e)
Upvotes: 0
Views: 45
Reputation: 15728
If you print the name
argument, you'll get something like this <#771335478372204575>
, it's not a channel name, neither an ID
Top fix it you can use converters
@client.command()
async def test2(ctx, channel: discord.TextChannel):
e = discord.Embed(title='hello')
await channel.send(embed=e)
Upvotes: 2