Yesterday I was working on something simple where a bot on command of !name Barty
would print back Hello Barty
@bot.command()
async def name(ctx, args):
await ctx.send("hello {}".format(args)
However the problem I am facing at this moment is that the bot would response to any channel where I do use the !name XXXX
and what I am trying to do is that I want only to react to given specific channel in discord.
I tried to do:
@bot.event
async def on_message(message):
if message.channel.id == 1234567:
@bot.command()
async def name(ctx, args):
await ctx.send("hello {}".format(args)
but that was completely not working and I am out of ideas and here I am.
How can I send command to a given specific channel and get back response from there?
name
". But this doesn't work for two reasons: the function isn't called and commands should be top-level functions (i.e. not nested). Are you intending to apply this "channel restriction" to other commands as well (not just "name")? – TrebledJasync def name(ctx, args):
but some will have more args etcasync def birthday(ctx, args, args2):
- But yes. I want to apply the "channel restriction" to other commands aswell. :) – Thrillofit86