Home > Mobile >  edit message doesnt work discordpy (nextcord)
edit message doesnt work discordpy (nextcord)

Time:01-17

Im making this command where if i said =help fun, fun commands should show up and if i said =help economy, economy commands should show up too. But this code doesnt work any fixes?

    @commands.command()
    async def help(self, ctx, arg1):
        if arg1 != "fun":
            return
        else:
            #Help fun
            embedFun = nextcord.Embed(
                title="Need help?",
                description="Fun: ",
                color=nextcord.Color.green())

            embedFun.set_thumbnail(url="https://www.freeiconspng.com/thumbs/money-icons/money-icon-29.png")

            embedFun.add_field(
                name="`=howsimp`",
                value="Shows how simp you or your friends are.",
                inline=False
            )
            embedFun.add_field(
                name="`=help economy`",
                value="Shows you the economy category commands.",
                inline=False
            )   
            funHelp = await ctx.reply(embed=embedFun)

        if arg1 != "economy":
            return
        else:
           #Help economy
            embedEconomy = nextcord.Embed(
                title="Need help?",
                description="Economy: ",
                color=nextcord.Color.green())

            embedEconomy.set_thumbnail(url="https://www.freeiconspng.com/thumbs/money-icons/money-icon-29.png")

            embedEconomy.add_field(
                name="`=balance`",
                value="Shows how simp you or your friends are.",
                inline=False
            )
            embedEconomy.add_field(
                name="`=help economy`",
                value="Shows you the economy category commands.",
                inline=False
            )   
            await funHelp.edit(embed=embedEconomy)

btw im using discord.py's fork "nextcord"


CodePudding user response:

  1. you should not use this weird "if != else" structure. Use elif or Structural Pattern Matching.

  2. funHelp is not a global variable therefore .edit is called to a NoneType

  3. to accomplish what you are trying try .history or buttons

CodePudding user response:

you shall change != for is not fun like this

if arg1 is not "fun":

or you can simply do a group like that:

@commands.group(invoke_without_command=True)
async def help(self, ctx):
    # content

@help.command()
async def fun(self, ctx):
    # content
  •  Tags:  
  • Related