-4

Is my code supposed to be working fine? because it was doing well before. Right now after I start running the code. And input and relay the messages . It wouldnt be sending it anymore. And would getting the channel name better rather than getting the channel id? if getting the channel id is better, What should I replace with if channel.name in? , If my code is fine does that mean the issue is gonna be the discod permissions?

@commands.has_permissions(kick_members=True)
async def alert(ctx, *, msg): #ALERT
    for guild in client.guilds:
        role = get(guild.roles, name = 'RayGunOptions Alerts') # roles
        for channel in guild.channels:
            if channel.name in ('-','gunvir-gay'):  # change for the list of channel names you got in your discord server
                one = Button(style=ButtonStyle.URL, label='Twitter', url="https://twitter.com/RayGunsOptions")
                two = Button(style=ButtonStyle.URL, label='Discord', url="https://discord.gg/6Fh4MTZN")
                three = Button(style=ButtonStyle.URL, label='Trading Journal', url="https://tradingjournal.com") 
                embed=discord.Embed(title= ':moneybag: **Option Alert** :moneybag:', description= (msg), url='https://twitter.com/RayGunsOptions', color=0x33FF9F, timestamp=datetime.datetime.utcnow())
                """embed.set_author(name="Crypto Alert", icon_url = ctx.author.avatar_url)""" #Top left name # IGNORE
                embed.set_thumbnail(url='https://pbs.twimg.com/profile_images/1383574983645962246/kD6PNI_L_400x400.jpg')
                embed.set_footer(icon_url = ctx.author.avatar_url, text='Powered by Duck Programming',)
                await channel.send(f"{role.mention}")                 
                await channel.send(embed=embed)
                await channel.send(
                    '**  **',
                    components=[
                        [one,]
                    ]
                )
Wafaduck
  • 25
  • 4

1 Answers1

0

If you have a on_message_function in your code please add this in the end:

await self.bot.process_commands(message) # or client if you don't use bot

Source: https://discordpy.readthedocs.io/en/stable/faq.html?highlight=on_message#why-does-on-message-make-my-commands-stop-working

Also if your command is not in your cog please don't do:

commands.command()

Instead do:

bot.command() #or client.command()
Jerry
  • 153
  • 1
  • 10