How to make a Giveaway bot with Discord.py | Giveaway Command [ Part 1 ]
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
wow! 2 uploads in 1 week noice! noice video helped me a ton man!
O.m.g it actually this is the first time to make a bot from discord THANKS
thanks! ur videos always work for me!
your tutorials help me become a really good discord dev thanks for them :D
Nice vid :D
your videos are the best! Please make one on welcome messages
Thank you! Will do!
print("congratulations, your bot worked and earned a sub and like and more views as I will check out all your videos now.")
Thanks for the sub!
Woah, Will try this!! Amazing video!
Hope you like it!
Hey I need help hosting the bot on a server. How do deploy multiple files
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?
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
thanks !
can you make a video to do role react with the bot ?
Yes, soon
How do u input ur bot id so it will work?
can you create a github stp for the code?
love ur videos
Thanks 😊
I need to use the any () function in an event in my bot, but I never used it, can you help me?
No u don’t need to put () in event command
what i can change to choose the winner by my self ??
I have a problem with utc I want the result to come with IST can u pls help?
I get the error AttributeError: 'giveaway' object has no attribute 'user' I am trying to use it with in a cog
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!
@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
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
Yeah sure!
Yes I need this
Hey swastik! I get error: "Unterminated string literal at **{prize}**!"
I tried removing everything from there but i didn't work.
can you make a tutorial on a giveaway command thats ">currentgiveaway" and it will show the giveaway thats happening at the current time
where should i put my bot token or how can i make my bot with this code
Great keep it up
Error: 'async_generator' object has no attribute 'flatten'
How can I solve?
I have a problem, when I run the code, it marks me
: mins is a required argument that is missing.
Same does anyone have an answer for this?
how can you make the datetime for spain¿
Hey could you please one about making custom help boxes
where do we insert the bot token
Thx
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
umm, what website are you using for this
can we use it in repls site
How do you make it so that everyone who react gets pinged??? Thanks!
Can you make a tutorial for corona statistics command? Thanks
Sure
@@CodeWithSwastik Thanks! I will be waiting for that upload XD
When I do this I get the error datetime.datetime has no attribute in utncow. Can you pls help me?
did you import datetime?
can you with glitch?
Hello which application or website is it?
yo can we pre define the winners of the gaw? Like choose who wins? (Get your judgy eyes off me..)
LMFAO
Hmm weird i can't find "main" in glitch.com
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
Basically it never selects a winner
Wait I think Ik why I'll let you know if It doesn't work though ok
it keeps making my bot turn off trash ?
it is saying missing mins argument which is required
Hi, When i start the giveaway it works, but there is no winner selected! PLS HELP!
saaame
my_msg = await ctx.send(embed=embed) has a invalid syntax on it
Try await ctx.channel.send(embed=embed)
TypeError: object of type 'method' has no len() :c
i cant ad a reaction i cant paste
17 seconds ago nice
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
what website do you use to code it? I'm not sure
@@Duhitzme12 its fine i learnt that i needed to use self.client because it was in a cog
Hey Swastik. How can I have my bot pick 2 winners? Thanks
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
can u please provide source code on github please
can u cop and paste what u put there to me
iNtErEsTiNg
it saying datetime is not valid
jes
idk why i was trying to do something with raw_reaction_add event and after watching the video I realized never needed that lol
Nice lol
make bot with requirment please
does not work for me :C
hi, it gives me error in the code here, wait for my_msg.add_reaction (": tada:")
🎉
Sir help, I've tried pasting emoji in idle and it crashes,any solution is appreciated
what crashes?
@@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
Vector's Gaming send the Error bruh
@@NightcoreBlade there's no error,the idle crashes,no log or error what so ever (、._. )、
Vector's Gaming uhh then its not the problem from the code
error says datetime not defined HELP
Import datetime
Can you make a tutorial video for a dashboard controlled discord bot like mee6?
Sure
@@CodeWithSwastik thanks:D
But You Not Written token
how come it didn't work for me...
@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}!")
What's the error
@@CodeWithSwastik there is no error
just not working
@@DRAK01 same the bot doesnt respond and theres no error
i think you are going to be the next pewdiepie
👍
ANYONE CAN u send code pls whoever has don e
it
@Austin Leiwant yep
Source Code Please
can you make a video on how to make a pokemon bot
like pokecord? I'll probably livestream that
@@CodeWithSwastik thnx
lazy to watch? any idea where the code of this is??
Does this still work
datetime.datetime has no attribute to datetime
import datetime
abit late but thx mate
My verified bot got hacked 😢😢
Oh rip make sure to not leak your token again!
Make a rigged giveaway bot
none of your videos work for me
(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)