Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23131

How to invoke a chain/other commands using one command in discord bot?

$
0
0

I have created a discord bot. i want something like i invoke a command "-f" in an channel. i wnat this to invoke other commands ot fuction in other channels and thread automatically like "-f a" in b,"-f +emote2" in c and so on,

here is a snip of code

 @bot.command()    async def f(ctx, *args):      result = False      if not args:          await ctx.channel.purge(limit=900)          await asyncio.sleep(0.21)          channel_A = discord.utils.get(ctx.guild.channels, name="pins")          if channel_A:              await channel_A.send("-f +🥰")              await ctx.invoke(bot.get_command('-f +🥰'))           else:             await ctx.send("Channel A not found.")     //there more code but it long and irelevant i think

i can see the mesage being send but it is not invoking the other command.it shows an error as well

Traceback (most recent call last):  File "c:\Users\M Muzammil\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 235, in wrapped    ret = await coro(*args, **kwargs)  File "D:\Personal\Auto upload\BOT.py", line 60, in f    await ctx.invoke(bot.get_command('-f +🥰'))  File "c:\Users\M Muzammil\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\context.py", line 336, in invoke    return await command(self, *args, **kwargs)TypeError: 'NoneType' object is not callableThe above exception was the direct cause of the following exception:

Viewing all articles
Browse latest Browse all 23131

Trending Articles