so I wanted to disable command in one channel.
This is my code:
@bot.command()
async def test(ctx):
if ctx.message.channel.id != '923252963105976341':
await ctx.send('Test')
elif ctx.message.channel.id == '923252963105976341':
pass
The problem is that this command is still working.
Can someone help?
>Solution :
In discord.py the channel.id attribute is always int type.
>>> ctx.channel.id
852838885389762581 #Possible output
>>> ctx.channel.id
'852838885389762581' #Impossible output
In your case you only have to change you code to this:
@bot.command()
async def test(ctx):
if ctx.message.channel.id != 923252963105976341:
await ctx.send('Test')
You can remove the last two lines, since they’re completely useless.
Notice than not(id != x) => id == x.