hello, i have a little trouble with my discord bot, the thing is in my mind the code should work, only one thing is not working on discord, i think might be permisions problem or idk, but my boot look online on discord but is not doing any of the comands he should do
and there is the code
import discord
intents = discord.Intents.default()
intents.members = True
client = discord.Client(intents=intents)
bot_channel_id = 1049596119279222854 # Replace with the ID of the channel you want to assign to the bot
@client.event
async def on_ready():
channel = client.get_channel(bot_channel_id)
print(f"Bot is active in {channel.name} channel.")
@client.event
async def on_message(message):
if message.content.startswith('^addrole'):
# Check if the user has the necessary permissions to add roles
if message.author.guild_permissions.manage_roles:
# Get the role name from the command arguments
command_args = message.content.split()[1:]
role_name = "Tank".join(command_args)
# Get the role object that you want to add
role = discord.utils.get(message.guild.roles, name='Tank')
if role is not None:
# Get a list of all the user mentions in the message
mentions = message.mentions
# Loop through each mentioned user and add the role to them
for user in mentions:
await user.add_roles(role)
# Send a confirmation message in the same channel
await message.channel.send(f"Added role '{role.name}' to {', '.join([user.name for user in mentions])}")
else:
# If the role was not found, send an error message
await message.channel.send(f"Role '{role_name}' not found.")
else:
# If the user doesn't have the necessary permissions, send an error message
await message.channel.send("You do not have the necessary permissions to add roles.")
client.run('bot_token')
ofc i was using the right Discord bot token
well if someone can test it and tell me why is this not working …