pythondiscord.pybotsreplit

I had programmed a Discord Bot command in Replit but the command is not showing in Discord Server


import discord
from discord.ext import commands

intents = discord.Intents.default()
intents.messages = True
intents.message_content = True

bot = commands.Bot(command_prefix='!', intents=intents)

roles_to_monitor = [ROLE_ID]

monitored_channels = [CHANNEL_ID]


@bot.event
async def on_ready():
  print(f'We have logged in as {bot.user}')


@bot.event
async def on_message(message):
  if message.channel.id in monitored_channels and message.mentions:
    for mentioned_user in message.mentions:
      mentioned_roles = [
          role for role in mentioned_user.roles if role.id in roles_to_monitor
      ]
      if mentioned_roles:
        role_names = ', '.join([role.name for role in mentioned_roles])

        warning_message = f"{message.author.mention}, be careful, you pinged HR+ !"
        await message.channel.send(warning_message)

        embed = discord.Embed(description=warning_message,
                              color=discord.Color.red())
        embed.set_image(
            url="IMAGE_LINK")
        embed.add_field(
            name="Additional Message",
            value=("MESSGAE")
        await message.channel.send(embed=embed)

        break


allowed_roles = [ROLE_ID]


@bot.command()
async def kick(ctx, member: discord.Member):
  if any(role.id in allowed_roles for role in ctx.author.roles):
    await member.kick()
    await ctx.send(f"{member.mention} has been kicked.")
    print(f"Command enabled: /kick invoked by {ctx.author.name}")
  else:
    await ctx.send("You don't have permission to use this command.")


bot.run('BOT_TOKEN')

Console Output:
2023-07-31 03:51:55 INFO discord.client logging in using static token

2023-07-31 03:51:56 INFO discord.gateway Shard ID None has connected to Gateway (Session ID: ############).

We have logged in as AURP#4566

Probelm:

The Bot is not supporting command. I tried to fix it through Invite links and Debug the Code but the problem still exits.
The Bot is not getting the "Support Commnad" Badge on it due to unkown reason which simple shows that the Kick command is not implemented successfully in the bot.


Solution

  • The "Supports Commands" badge will only appear if your bot has at least 1 global or guild application command registered in Discord. A legacy prefix command (ones that are handled using a prefix and the MESSAGE_CREATE event) do not count towards this badge.

    See this page on application commands, and this message in the official Discord Developers Discord, which I have pasted below:

    Hey everyone! We’ve got an announcement to share with you: we're testing a commands badge on bot profiles, which will help draw attention to the fact that a bot supports commands - as well as help educate users on features that bots have, which we know is something you all have requested.
    
    If your app has at least one global command, you will see this badge show today!
    
    What to know:
    
    :dot: The badge will be displayed on the bot's user profile
    :dot: The tooltip (when hovering over the badge) will say "Supports Commands"
    :dot: Clicking on the badge itself will direct users to a web page that describes in more detail what slash commands are, what additional features bots can support, and other FAQ. If you haven’t seen this page yet, it’s here: https://discord.com/blog/welcome-to-the-new-era-of-discord-apps
    :dot: All bots and apps are eligible! Slash commands, user commands, and message commands all count. All you need to do is register at least one global command for your app. (You can learn more about how to do this here: https://discord.com/developers/docs/tutorials/upgrading-to-application-commands)
    :dot: If your app already meets this criteria, congrats!
    
    Helping users understand how to get the most out of apps has been and will continue to be one of our top priorities. This is one thing we’re trying out, and there will be more coming soon! Enjoy.