How to make a Giveaway bot with Discord.py | Giveaway Command [ Part 1 ]

Sdílet
Vložit
  • čas přidán 3. 10. 2020
  • In this video, we will learn how to make a giveaway bot with python using discord.py (rewrite) in 2020.
    If you have any suggestions for future videos, leave it in the comments below.
    Some Useful Links -
    Discord Developer Portal- / discord
    My Discord Server- / discord
    My Twitter - / codewithswastik
    My Instagram - / code_with_swastik
    Discord.py Documentation: discordpy.readthedocs.io/en/l...
    Sublime Text: www.sublimetext.com/
    Music Used:
    Found You - Atch / atch-music
    Creative Commons - Attribution 3.0 Unported - CC BY 3.0
    Free Download / Stream: bit.ly/_found-you
    Music promoted by Audio Library • Found You - Atch (No C...
    Queries solved in the video:
    1) How to make a Giveaway bot with discord,py
    2) How to giveaway command in Discord.py
    #discord #discordbot #giveawaybot
  • Věda a technologie

Komentáře • 126

  • @parthiv3255
    @parthiv3255 Před 3 lety +7

    wow! 2 uploads in 1 week noice! noice video helped me a ton man!

  • @zyadkareem523
    @zyadkareem523 Před 3 lety +4

    O.m.g it actually this is the first time to make a bot from discord THANKS

  • @obotify7430
    @obotify7430 Před 3 lety

    thanks! ur videos always work for me!

  • @Scott170c
    @Scott170c Před 3 lety +5

    your tutorials help me become a really good discord dev thanks for them :D

  • @customdevvv
    @customdevvv Před 3 lety +1

    Nice vid :D

  • @ConnorDanky
    @ConnorDanky Před 3 lety +3

    your videos are the best! Please make one on welcome messages

  • @eliericksson.8950
    @eliericksson.8950 Před 3 lety +3

    print("congratulations, your bot worked and earned a sub and like and more views as I will check out all your videos now.")

  • @Hiphop602y
    @Hiphop602y Před 3 lety +1

    Woah, Will try this!! Amazing video!

  • @dhruv5827
    @dhruv5827 Před 3 lety +1

    Hey I need help hosting the bot on a server. How do deploy multiple files

  • @kevinsalins1661
    @kevinsalins1661 Před 2 lety

    Hey, thanks a lot but I get a 403 Forbidden Error whenever I use the fetch_message() method. Can you please tell me how to resolve it?

  • @balazs5668
    @balazs5668 Před rokem

    can u help me i getting the Command raised an exception: AttributeError: 'async_generator' object has no attribute 'flatten' error when the giveaway needs to end

  • @mazyop
    @mazyop Před 3 lety +4

    thanks !
    can you make a video to do role react with the bot ?

  • @darkzbutgaming5037
    @darkzbutgaming5037 Před 3 lety +2

    How do u input ur bot id so it will work?

  • @starfityt2880
    @starfityt2880 Před 3 lety +2

    can you create a github stp for the code?

  • @zorodjuro9115
    @zorodjuro9115 Před 3 lety

    love ur videos

  • @light-owo
    @light-owo Před 3 lety +3

    I need to use the any () function in an event in my bot, but I never used it, can you help me?

  • @deuldmarinho3434
    @deuldmarinho3434 Před rokem

    what i can change to choose the winner by my self ??

  • @keshavgoyalshorts5321
    @keshavgoyalshorts5321 Před 2 lety

    I have a problem with utc I want the result to come with IST can u pls help?

  • @mikeyparker8207
    @mikeyparker8207 Před 2 lety

    I get the error AttributeError: 'giveaway' object has no attribute 'user' I am trying to use it with in a cog

  • @fahimmiah3438
    @fahimmiah3438 Před 3 lety +1

    I keep getting this error:
    “TypeError: object of type ‘coroutine’ has no len()”
    This error is pointed to line 38 of the code in this video “winner = random.choice(users)”
    I also get an error saying that “pop” is not an attribute of coroutine.
    Please help!
    Thank you!

    • @fahimmiah3438
      @fahimmiah3438 Před 3 lety

      @Floomy I apologize for the delayed response!
      I had to “await” the “new_msg.reactions[0]”.
      I had forgotten to await it so it didn’t work. Now it works after I added it.
      If you have any concerns please join the discord server. Many members are willing to help!
      discord.gg/programmers

  • @albertdinh3059
    @albertdinh3059 Před 3 lety +2

    Hey swas can you make a video about the bot joining, playing music and leaving voice channels pls? It would help me a LOT. ty

  • @corgi1g
    @corgi1g Před 3 lety

    Yes I need this

  • @Zsombys-cookie
    @Zsombys-cookie Před 2 měsíci

    Hey swastik! I get error: "Unterminated string literal at **{prize}**!"
    I tried removing everything from there but i didn't work.

  • @bueno8016
    @bueno8016 Před 2 lety

    can you make a tutorial on a giveaway command thats ">currentgiveaway" and it will show the giveaway thats happening at the current time

  • @sdasdadasdasda1583
    @sdasdadasdasda1583 Před 2 lety

    where should i put my bot token or how can i make my bot with this code

  • @NightcoreBlade
    @NightcoreBlade Před 3 lety +2

    Great keep it up

  • @coso_man
    @coso_man Před rokem

    Error: 'async_generator' object has no attribute 'flatten'
    How can I solve?

  • @furiousdropper
    @furiousdropper Před 3 lety +1

    I have a problem, when I run the code, it marks me
    : mins is a required argument that is missing.

  • @noemitruran5076
    @noemitruran5076 Před 3 lety

    how can you make the datetime for spain¿

  • @olihasamassivewood4556

    Hey could you please one about making custom help boxes

  • @spacereporter-official

    where do we insert the bot token

  • @kshamasrivastava5846
    @kshamasrivastava5846 Před 3 lety

    Thx

  • @joshuapritchard4086
    @joshuapritchard4086 Před 3 lety +1

    Fact: you don't need to do that back /:tada: command, just press and hold you windows key and press ">" key, it bings up all the emojis

  • @Duhitzme12
    @Duhitzme12 Před 3 lety

    umm, what website are you using for this

  • @mohitmimani2565
    @mohitmimani2565 Před 3 lety

    can we use it in repls site

  • @eliericksson.8950
    @eliericksson.8950 Před 3 lety

    How do you make it so that everyone who react gets pinged??? Thanks!

  • @iceyvision3124
    @iceyvision3124 Před 3 lety +2

    Can you make a tutorial for corona statistics command? Thanks

  • @ftjakub
    @ftjakub Před 3 lety

    When I do this I get the error datetime.datetime has no attribute in utncow. Can you pls help me?

  • @kenhenry573
    @kenhenry573 Před 3 lety

    can you with glitch?

  • @gentle6063
    @gentle6063 Před 3 lety

    Hello which application or website is it?

  • @leonmagnes3077
    @leonmagnes3077 Před 3 lety +2

    yo can we pre define the winners of the gaw? Like choose who wins? (Get your judgy eyes off me..)

  • @kattyuii2109
    @kattyuii2109 Před 3 lety

    Hmm weird i can't find "main" in glitch.com

  • @eliericksson.8950
    @eliericksson.8950 Před 3 lety

    When I ran the bot it worked perfectly until it was supposed to end the script. It sent this: "raise CommandInvokeError(exc) from exc
    discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'new_msg' is not defined"
    help please

  • @liamv2836
    @liamv2836 Před 3 lety

    it keeps making my bot turn off trash ?

  • @Thunder_AB
    @Thunder_AB Před 3 lety

    it is saying missing mins argument which is required

  • @haroonsaleem6543
    @haroonsaleem6543 Před 3 lety

    Hi, When i start the giveaway it works, but there is no winner selected! PLS HELP!

  • @galoreot
    @galoreot Před 2 lety

    my_msg = await ctx.send(embed=embed) has a invalid syntax on it

  • @naenae382
    @naenae382 Před 3 lety

    TypeError: object of type 'method' has no len() :c

  • @ReptileReplays
    @ReptileReplays Před 3 lety

    i cant ad a reaction i cant paste

  • @okt5805
    @okt5805 Před 3 lety +4

    17 seconds ago nice

  • @ae-co5ue
    @ae-co5ue Před 3 lety

    in the line users.pop(users.index(client.user)) it says that client is not defined, and when i defined it as client = commands.Bot(command_prefix='.') it just says discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ValueError: None is not in list
    anyone know how to fix
    it works in the main file but not the cog

    • @Duhitzme12
      @Duhitzme12 Před 3 lety

      what website do you use to code it? I'm not sure

    • @ae-co5ue
      @ae-co5ue Před 3 lety

      @@Duhitzme12 its fine i learnt that i needed to use self.client because it was in a cog

  • @mairochondria
    @mairochondria Před 3 lety

    Hey Swastik. How can I have my bot pick 2 winners? Thanks

    • @lakshyakumar4459
      @lakshyakumar4459 Před 2 lety

      do it twice.
      winner = random.choice(users)
      winner2 = random.choice(users)
      but make sure to remove winner 1 from users to prevent same user from winning

  • @hackingpsycho6189
    @hackingpsycho6189 Před 3 lety +1

    can u please provide source code on github please

  • @m1pug
    @m1pug Před 3 lety

    can u cop and paste what u put there to me

  • @pranshusabharwal6738
    @pranshusabharwal6738 Před 3 lety +1

    iNtErEsTiNg

  • @Cizzy2727
    @Cizzy2727 Před 2 lety

    it saying datetime is not valid

  • @niikxyy9344
    @niikxyy9344 Před 3 lety

    jes

  • @sakon4466
    @sakon4466 Před 3 lety

    idk why i was trying to do something with raw_reaction_add event and after watching the video I realized never needed that lol

  • @voidroblox426
    @voidroblox426 Před 3 lety

    make bot with requirment please

  • @akaza5490
    @akaza5490 Před 3 lety

    does not work for me :C

  • @mattiamoschella9461
    @mattiamoschella9461 Před 3 lety

    hi, it gives me error in the code here, wait for my_msg.add_reaction (": tada:")

  • @Yeectorsama
    @Yeectorsama Před 3 lety

    Sir help, I've tried pasting emoji in idle and it crashes,any solution is appreciated

    • @CodeWithSwastik
      @CodeWithSwastik  Před 3 lety

      what crashes?

    • @Yeectorsama
      @Yeectorsama Před 3 lety

      @@CodeWithSwastik i did the same thing to copy any emoji,but whenever I press ctrl+v in my IDLE it crashed,it stopped working and the windows gone, no warning at all,i didnt even press run module or anything,as soon as I try to paste the emoji it stopped working

    • @NightcoreBlade
      @NightcoreBlade Před 3 lety

      Vector's Gaming send the Error bruh

    • @Yeectorsama
      @Yeectorsama Před 3 lety

      @@NightcoreBlade there's no error,the idle crashes,no log or error what so ever (、._. )、

    • @NightcoreBlade
      @NightcoreBlade Před 3 lety

      Vector's Gaming uhh then its not the problem from the code

  • @userhtu1818
    @userhtu1818 Před 3 lety +1

    error says datetime not defined HELP

  • @demonplayz8179
    @demonplayz8179 Před 3 lety +1

    Can you make a tutorial video for a dashboard controlled discord bot like mee6?

  • @unitytechnical7367
    @unitytechnical7367 Před 3 lety

    But You Not Written token

  • @DRAK01
    @DRAK01 Před 3 lety +2

    how come it didn't work for me...

    • @DRAK01
      @DRAK01 Před 3 lety +1

      @client.command()
      async def gstart(ctx, mins : int, * , prize: str):
      embed = discord.Embed(title = "Giveaway!", description = f"{prize}", color = ctx.author.color)
      end = datetime.datetime.utcnow() + datetime.timedelta(seconds = mins*60)
      embed.add_field(name = "Ends At:", value = f"{end} UTC")
      embed.set_footer(text = f"Ends {mins} mintues from now!")
      my_msg = await ctx.send(embed = embed)
      await my_msg.add_reaction("")
      await asyncio.sleep(mins)
      new_msg = await ctx.channel.fetch_message(my_msg.id)
      users = await new_msg.reactions[0].users().flatten()
      users.pop(users.index(client.user))
      winner = random.choice(users)
      await ctx.send(f"Congratulations! {winner.mention} won {prize}!")

    • @CodeWithSwastik
      @CodeWithSwastik  Před 3 lety

      What's the error

    • @DRAK01
      @DRAK01 Před 3 lety

      @@CodeWithSwastik there is no error

    • @DRAK01
      @DRAK01 Před 3 lety

      just not working

    • @MrTopHype
      @MrTopHype Před 3 lety

      @@DRAK01 same the bot doesnt respond and theres no error

  • @malligalliblaa9025
    @malligalliblaa9025 Před 3 lety +1

    i think you are going to be the next pewdiepie

  • @piousbansal874
    @piousbansal874 Před 3 lety +2

    ANYONE CAN u send code pls whoever has don e
    it

  • @PunchLoverFF
    @PunchLoverFF Před 2 lety

    Source Code Please

  • @malligalliblaa9025
    @malligalliblaa9025 Před 3 lety

    can you make a video on how to make a pokemon bot

  • @aladdin122
    @aladdin122 Před 2 lety

    lazy to watch? any idea where the code of this is??

  • @Eric-sp8nm
    @Eric-sp8nm Před 3 lety

    Does this still work

  • @teamsplash3668
    @teamsplash3668 Před 3 lety

    datetime.datetime has no attribute to datetime

  • @hifazmh
    @hifazmh Před 3 lety

    My verified bot got hacked 😢😢

  • @dead2675
    @dead2675 Před 3 lety +1

    Make a rigged giveaway bot

  • @tathyagarg2018
    @tathyagarg2018 Před 2 lety

    none of your videos work for me

  • @CrunchySpon
    @CrunchySpon Před rokem

    (there was an error in his code, i fixed it here you go)
    import discord
    from discord import ui
    from discord import app_commands
    from discord.ext import commands
    from discord.ext.commands import Bot
    from discord import Permissions, channel, guild, utils
    import random
    import asyncio
    import time as pyTime
    import json
    import math
    import pypokedex
    import os
    import datetime
    bot = commands.Bot(command_prefix=">", intents=discord.Intents.all())
    intents = discord.Intents.default()
    intents.message_content = True
    TOKEN = "{insert your token here}"
    @bot.event
    async def on_ready():

    print("Bot is up and ready!")
    try:
    synced = await bot.tree.sync()
    print(f"Synced {len(synced)} commands(s)")
    except Exception as e:
    print(e)
    @bot.command()
    @commands.has_permissions(manage_messages=True)
    async def giveaway(ctx, prize: str, mins: int, role: str):

    await ctx.send(f"{role}")
    embed = discord.Embed(title = "Giveaway!", description = f"{prize}", color = discord.Colour.yellow())
    end = datetime.datetime.utcnow() + datetime.timedelta(seconds = mins*60)
    embed.add_field(name = "Ends at:", value = f"{end} UTC")
    embed.set_footer(text = f"End {mins} minute(s) from now!")
    my_msg = await ctx.send(embed = embed)
    await my_msg.add_reaction("🎉")
    await asyncio.sleep(mins*60)
    new_msg = await ctx.channel.fetch_message(my_msg.id)
    users = [x async for x in new_msg.reactions[0].users()]


    users.pop(users.index(bot.user))
    winner = random.choice(users)
    await ctx.send(f"Congratulations! {winner.mention} won {prize}!")
    bot.run(TOKEN)
    (ik there are a lot of imports you don't need to do all of them)