I have asked in a lot of places, but I have yet no answer still.
Me and my friend want to make a bot that if a user says “I love baguettes”, they get the baguette team role. I keep getting “role not found” error even though the id is correct. Please help.
Here is the code:
import os, re, discord
from discord.ext import commands
from discord.utils import get
DISCORD_TOKEN = os.getenv("DISCORD_TOKEN")
client = commands.Bot(command_prefix="!", intents= discord.Intents.all())
@client.event
async def on_ready():
print(f'We have logged in as {client.user}')
@client.event
async def on_message(message):
print("message was: " + message.content)
if message.author == client.user:
return
if message.content == 'I love baguettes':
member = message.author
role = discord.utils.get(message.guild.roles, id="1085983212855115887")
print(role)
await member.add_roles(role)
#discord.utils.get(message.guild.roles, id=1085983212855115887)
#discord.utils.get(message.guild.roles, id="1085983212855115887")
await message.channel.send('So do I! In fact, I have given you the Baguette Team role!')
client.run(DISCORD_TOKEN)