0
votes

command is not working and when i start it ( when it was working) bot doesnt ask question like in which channel he should host giveaway , time and winner . i am noob in coding and also giveaway dont end after time up , please check it i am new to python and also dumb somehow i wrote this code but its no use

from http import client
from lib2to3.pytree import convert
from turtle import color, pos, title
import discord
from discord.ext import commands
import asyncio
import datetime
import random

class Giveawayk(commands.Cog):

    def __init__(self , bot):
        self.bot = bot


    

    def convert(time):
        time_dict = {"s" : 1 , "m" : 60, "h" : 3600, "d" :3600*24}

        unit = time[-1]

        if unit not in pos:
            return -1 
        try:
            val = int(time[:-1])
        except:
            return -2
        
        return val * time_dict[unit]
  
        


        

    @commands.command
    @commands.has_permissions(administrator = True)
    async def giveaway(self, ctx):
        await ctx.send("let's start with this giveaway! . Plz answer all question under 15 minutes ")

        questions = ["In which channel you want me to start a giveaway . Anser dont be shy",
                    "what should be the duration of giveaway? (s|m|h|d",
                    "what is the prize of giveaway dont tell me you want to do a giveaway without price"]

        anwers = []

        def check(m):
            return m.author ** ctx.author and m.channel == ctx.channel

        for i in questions:
            await ctx.send(i)

            
                

# idk what to call this
       
            c_id = int(anwers[0][2:-1])
            channel = client.get_channel(c_id)

        time = convert(anwers[1])
        if time == -1:
            await ctx.send("Bruh tell me time i cant host a giveaway without it btw i want to become next iron man")
            return
        elif time== -2:
            await ctx.send('time must be an integer  - Smart bot')

        prize = anwers[2]


        await ctx.send(f"Ok i do for you in {channel.mention}")

        embed = discord.Embed(title = "Giveaway" , description = f"{prize}", color = ctx.guild.me.top_role.color,)
        embed.add_field(name="Hosted by" , value = ctx.author.mention)
        embed.set_footer(text=f"ends {anwers[1]} From now")

        my_msg = await channel.send(embed = embed)

        await my_msg.add_reaction("????")

        await asyncio.sleep(time)

        users = await users.reactions[0].users().flatten()
        users.pop(users.index(client.user))

        King = random.choice(users)

        await channel.send(f"congratulations {King.mention} you won i never won a giveaway but you won wait does this mean you are better then me ?")
              

    @commands.command()
    @commands.has_permissions(administrator = True)
    async def reroll(self, ctx , channel : discord.TextChannel, id_ : int):
        try:
            new_msg = await channel.fetch_message(id_)
        except:
            await ctx.send('ID was entered incorrectly hmmm , wait Batman ?')
            return
        users = await new_msg.reactions[0].users().flatten()
        users.pop(users.index(client.user))

        winner = random.choice(users)

        await channel.send(f"Congratulations the new winner is {winner.mention} Rip old winner")

          

#end
def setup(bot):
    bot.add_cog(Giveawayk(bot))


Try to help plz