Giveaway bot

Everything works fine but when I execute command pops up this:

in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: IndexError: list index out of range

If someone could send this code but edited I would appreciate it. ;)

from asyncio import sleep
from discord.ext import commands
import discord
from discord import Embed, TextChannel

intents = discord.Intents.default()

intents.members = True
client = commands.Bot(command_prefix = "-", intents = intents)

async def giveaway(ctx, duration: int, channel: discord.TextChannel, *, prize: str):
    reaction = discord.Reaction
    embed = Embed(title=prize,
                  description=f"Hosted by - {}\nReact with :tada: to enter!\nTime Remaining: **{duration}** seconds",

    msg = await":tada: **GIVEAWAY** :tada:", embed=embed)
    await msg.add_reaction("🎉")

    users = await msg.reactions[0].users().flatten()

    while duration:
        await sleep(2)
        duration -= 2
        embed.description = f"Hosted by - {}\nReact with :tada: to enter!\nTime Remaining: **{duration}** seconds"
        await msg.edit(embed=embed)
    winner = random.choice(users)
    await ctx.send(f"**Congrats to: {winner}!**")
    embed.description = f"Winner: {winner.mention}\nHosted by: {}"
    await msg.edit(embed=embed)'TOKEN')

Read more here:

Content Attribution

This content was originally published by carmel dev at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: