I'm trying to create a slash command with discord.py. The command will iterate through a list of user IDs and give the role A to those users. My problem is the command only give the role to the first user of the list and it won't go on. Here is my block of code. Please let me know what I'm doing wrong.
from pydoc import describe
from unicodedata import name
import discord
import logging
import asyncio
from discord.ext import commands
from discord import app_commands
from gsheet_utility import gc, get_user_from_gsheet
import os
from dotenv import load_dotenv
load_dotenv()
token = os.getenv('TOKEN')
logging.basicConfig(level=logging.INFO)
intents = discord.Intents.default()
intents.message_content = True
intents.members = True
bot = commands.Bot(command_prefix="-", intents=intents)
@bot.event
async def on_ready():
print("Bot is up and ready!")
try:
synced = await bot.tree.sync()
print(f"Synced {len(synced)} command(s)")
except Exception as e:
print(e)
@bot.tree.command(name="give-role")
async def give_elite(ctx):
user_list = [user_id1, user_id2, user_id3]
role = ctx.guild.get_role(role_id)
for user in user_list:
user = ctx.guild.get_member(int(user))
await user.add_roles(role)
continue
await ctx.send('Roles have been given')
bot.run(token=token)