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.