#discord-bots
1 messages · Page 456 of 1
i already have python but when i run the code it says discord not found or something.
Refer back to this then
I'd assume vsc is using the wrong python version. That is if you have already installed discord.py in the first place
Ok.
Unless I'm mistaking what you are saying this extension is not discord.py
Its an extension that makes discord.py snippets
You install discord.py via pip on your terminal
How do you make a verification system where a user has to type in the command so they have access to the rest of the server?
Make a verify command then once the user did the command you'll receive the role
hey anyone know how i can restrict a command to a specific user and a specific channel at the same time?
how do i get the single missing argument??
is there a rough estimate on how long i can keep using discordpy to develop bots
ah wait, pins
is there a event called when a user leaves a voice channel
just voicestate change iirc
can i compare a user object gained by fetch_user to members in bans() list
since im checking for it, but errors that the user isnt there when he is
you spelled error wrong in the last line {errore}
items in the bans() list are BanEntry objects
not user object
BanEntry.user exists however
ah mb, i forgot bans is a tuple of users and reasons
something like await guild.bans().BanEntry(user) ? @agile goblet
for entry in guild.bans():
print(f"{entry.user.id} is banned")
how to do reply?
glooks
except not send its reply
ight
if you don't want to mention the author then ctx.reply("blah", mention_author = False)
no, bans() returns a list of BanEntry objects
each object has the attribute user so you can get the User object instead
either iterate over it or use an index
Hi
Hey, need any help?
@slate swanyea
raise errors.ExtensionFailed(key, e) from e
discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.ReportAnswers' raised an error: AttributeError: module 'discord.ext.commands' has no attribute 'cogs'
Try Cogs
Not cogs
File "C:\Users\Danny\AppData\Local\Programs\Python\Python39\lib\importlib\util.py", line 94, in find_spec
parent = __import__(parent_name, fromlist=['__path__'])
ModuleNotFoundError: No module named 'Cogs'
!d discord.ext.commands.Cog
class discord.ext.commands.Cog```
The base class that all cogs must inherit from.
A cog is a collection of commands, listeners, and optional state to help group commands together. More information on them can be found on the [Cogs](https://discordpy.readthedocs.io/en/stable/ext/commands/cogs.html#ext-commands-cogs) page.
When inheriting from this class, the options shown in [`CogMeta`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.CogMeta "discord.ext.commands.CogMeta") are equally valid here.
?
@commands.command(aliases=['p'])
async def play(self, ctx, url):
ctx.voice_client.stop()
FFMPEG_OPTIONS = {'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5', 'options': '-vn'}
YDL_OPTIONS = {'format':"bestaudio"}
vc = ctx.voice_client
with youtube_dl.YoutubeDL(YDL_OPTIONS) as ydl:
info = ydl.extract_info(url, download=False)
url2 = info['formats'][0]['url']
source = await discord.FFmpegOpusAudio.from_probe(url2, **FFMPEG_OPTIONS)
vc.play(source)
i am trying to play url's from my bot but it appears as a command invoke error
anything wrong?
You may be doing wrong
!ytdl. Don't ask for help
Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders as their usage violates YouTube's Terms of Service.
For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:
The following restrictions apply to your use of the Service. You are not allowed to:
1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service; (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;
3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;
9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
How doe-
ok
Show your imports please
@slate swan
Not called Cogs?
Am i supposed to import Cogs from discord.ext?
If you notice, it's discord.ext.commands.Cog
Lemme
Import-
Yep
From commands import Cog
Right?
From discord.ext.commands import Cog yes
@slate swan
Yeah
@slate swan
await ctx.reply isnt working
can you show your code?
Show code
Hello,
Is slash commands now available with python ?
In discord.py no
they have not been released and will never be released because discord.py is deprecated
😮
so no idea?
but there are 3rd party library's that offer slash command support
Any error? I haven't really worked with buttons that much.
deprecated, which framework use then ?
it was working then i changed it to await ctx.reply() from await ctx.send()
its not a big deal tho
Well I still use discord.py since it still works and gets the job done, but if you want a supported lib I would use https://github.com/hikari-py/hikari
I haven't used it but I have heard others say it's pretty good
https://github.com/tandemdude/hikari-lightbulb here is the command handler extension
what should i do to make it look better ?
i feel like the "Moderation Commands" part is to bland
Well I mean you could get rid of those labels as you don't really need them since they are already in the dropdown menu
so you would use 3 ticks
i'll take a look
Thanks
mhm
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
okay thx
So you would just use 3 tick marks
would hikari require a full rewrite?
and don't add the py because that will add syntax highlighting
Why would it?
different syntax etc
looks way better
well syntax ain't the right word, I meant different functions, parameters etc
Why would it require a rewrite though?
point taken
@pallid meadow Do you know what is the best framework to use to create a bot not necessarily in python that's maintained ?
anyone here use sqlite3 that can help me make welcome channels for multiple guilds so i can get out of the habit of using configs
I have already make a bot with discord.py but now deprecated, i'm so sad :/
I'm getting kind of burnt out with coding my bot. Are there any ways I can keep myself motivated?
have a schedule when to code your bot and when to stop
Tbh I just have no idea what to do
I was planning on making an audio play command but thats not allowed anymore
keep getting error
Command raised an exception: AttributeError: 'User' object has no attribute '_roles'
which i dont get since im not affiliating with that attr
how do i get the number of lines from a txt file
read() split it with a new line and loop through it with a simple counter
literally never tried it before so i have no clue what u meant
A discord.User object doesn't have a roles attribute. And you don't have to only take the user's id, instead you can typhint it to discord.User.
!d discord.User
class discord.User```
Represents a Discord user.
`x == y` Checks if two users are equal.
`x != y` Checks if two users are not equal.
`hash(x)` Return the user’s hash.
`str(x)` Returns the user’s name with discriminator.
use read() on your file then split('\n') then loop through that with a simple counter
i cant typehint, since that will error usernotfound, and i want to hackban the user if they are not in the server
all im thinking of is: `with open ("cmds.txt") as f:
?
thats basics of working with a file in python yes
kinda new so
But that's a user object not a member object? I'm not sure if the user has to be in the cache or if an API call is made.
yeah, thats the problem, i have to call fetch_user to compare it with guild.members
Ah alright then.
!d discord.ext.commands.Bot.commands
commands```
A unique set of commands without aliases that are registered.
thats working with dict values
discord.js is pretty good
im just trying to get a way to see how many commands i have
but discord.py will most likely be fine for you
i used to have one but i forget
which one do u like more?
you can just loop through bot.commands iirc
Use len(bot.commands).
No problem. 
i dont think theres anyway i can pull this off then
either or tbh
I am more comfortable with python so ig discord.py
but node is pretty good
I already created bot with discord.py and I was waiting for the slash commands :x
See the message I replied to
Yeah, well they aren't coming sadly
I can give you a 3rd party library that you would use along side discord.py
I am thinking of learning game dev now 

!autodelete
oh, im a girl 
how can i except a commands.MemberNotFound ?
!d await message.delete
6.4. Await expression
Suspend the execution of coroutine on an awaitable object. Can only be used inside a coroutine function.
await_expr ::= "await" primary
``` New in version 3.5.
!d discord.on_command_error
bruh
discord.on_command_error(ctx, error)```
An error handler that is called when an error is raised inside a command either through user input error, check failure, or an error in your own code.
A default one is provided ([`Bot.on_command_error()`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Bot.on_command_error "discord.ext.commands.Bot.on_command_error")).
hey
So I gonna learn js ... 👀 😢
try:
#code
except discord.MemberNotFound:
#code
@tulip oracle
hey how do you make it so the bot deletes its message when a command is executed
ctx.delete
that will not be efficient 
rather then commands?
|| await ||
@bot.command(aliases=['c'])
@commands.has_permissions(manage_messages = True)
async def clear(ctx,amount=1):
await ctx.channel.purge(limit = amount)
embed = discord.Embed(
title= f":x: Purge command issued",
description = f'{ctx.author.mention} cleared {amount} messages',
colour= discord.Color.green())
await ctx.send(embed=embed)
async def on_message(ctx):
await message.delete()
i did this wrong
it is possibly the only way i can ban then hackban in one command
Yeah, so on_message is a listener function so you would need to have the listener decorator on it
so @bot.event?
so in your clear function you would do something like
@bot.command(aliases=['c'])
@commands.has_permissions(manage_messages = True)
async def clear(ctx,amount=1):
await ctx.delete()
# code
ctx.message.delete() iirc no?
ohhh
waoh
try await ctx.message.delete()
never tried
maybe if i pute await ctx.delete(embed=embed)
No that won't work

@broken turtle do await ctx.message.delete()
alright
Can I create an Error class that I raise and it sends a message in a channel?
ie can I raise an error asyncronously
on_command_error
got this after adding await ctx.message.delete
Lmao
interesting error indeed
share code man
I could create Errors, run a function, if some condition happens I raise the error, the try block catches it, but it does stuff when there's an error? Or what, like does oncommanderror just work with discord commands related errors or hmmm
@bot.command(aliases=['c'])
@commands.has_permissions(manage_messages = True)
async def clear(ctx,amount=1):
await ctx.channel.purge(limit = amount)
embed = discord.Embed(
title= f"❌ Purge command issued",
description = f'{ctx.author.mention} cleared {amount} messages',
colour= discord.Color.green())
await ctx.send(embed=embed)
await ctx.message.delete()
I could google on_command_error instead of asking to save your time lol okay I'll do that now and let you know if I got trouble
it is called when an error is raised
Okok that makes sense

The message is already getting deleted with the purge bro
!d discord.on_command_error
discord.on_command_error(ctx, error)```
An error handler that is called when an error is raised inside a command either through user input error, check failure, or an error in your own code.
A default one is provided ([`Bot.on_command_error()`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Bot.on_command_error "discord.ext.commands.Bot.on_command_error")).
its not
didn't think of that
i want the bot to delete its own message
ctx.message refers to the command message
Use the delete_after kwarg in the send() method
send(delete_after=3)
confused
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
@client.command
async def userinfo(self, ctx, target: Optional[Member]):
target = target or ctx.author
embed = Embed(title="User information",
colour=target.colour,
timestamp=datetime.utcnow())
embed.set_thumbnail(url=target.avatar_url)
fields = [("Name", str(target), True),
("ID", target.id, True),
("Bot?", target.bot, True),
("Top role", target.top_role.mention, True),
("Status", str(target.status).title(), True),
("Activity", f"{str(target.activity.type).split('.')[-1].title() if target.activity else 'N/A'} {target.activity.name if target.activity else ''}", True),
("Joined at", target.joined_at.strftime("%d/%m/%Y %H:%M:%S"), True),
("Boosted", bool(target.premium_since), True)]
for name, value, inline in fields:
embed.add_field(name=name, value=value, inline=inline)
await ctx.send(embed=embed)
it says inconsistent use of tabs and spaces but theres not can someone double check?
You don't need self BTW
i was gonna say
lol no use of inline like that
Use either only tabs or only spaces. Don't mix them... Your IDE isn't converting tabs to spaces
shoudl jsut be ctx, target
Indeed
waht ide are you useing?
replit?
oh
@crude crater Try to reindent the command
🤢
Maybe that'll work
even when i type tabs, it makes them spaces
why? replits not bad lmao
u type tabs?
yes
Tabs r 4 spaces..
i tried, it makes them spaces
no 4 lol
TABS ARE SPACES
for me its 2
well change it to 4
so what i do to fix it?
reindent the command
my problem

how i do dat
why dont it work
b-believe me cries
u said u didnt know how to reindent a command

@crude crater Change the indent size to 4
@bot.command(aliases=['c'])
@commands.has_permissions(manage_messages = True)
async def clear(ctx,amount=1):
await ctx.channel.purge(limit = amount+1)
embed = discord.Embed(
title= f":x: Purge command issued",
description = f'{ctx.author.mention} cleared {amount} messages',
colour = discord.Color.green())
await ctx.send(embed=embed)
await ctx.channel.purge(limit = amount)
i added await ctx.channel.purge(limit = amount) and it works
Yea
yes
im smort
@crude crater By default replit changes indents to 2 spaces and not 4. The default is 4. Change it and reindent it again
Can I make a Discord bot that regularly changes my status message? For example, I can feed it a list of strings and it would pick one at random and set my status to it? I know how to do the random message part, but not actually assigning a message.
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
selfbot?
You can't change your status with a bot@worn tapir
So what can bots do? Do they just send messages in servers?
yes
They can do many things but that's one of them, yes
@crude crater y not just make a default embed
i fixed it either way
You need to close the bracket
he doesnt
fields = [("Name", str(target), True),
("ID", target.id, True),
("Bot?", target.bot, True),
("Top role", target.top_role.mention, True),
("Status", str(target.status).title(), True),
("Activity", f"{str(target.activity.type).split('.')[-1].title() if target.activity else 'N/A'} {target.activity.name if target.activity else ''}", True),
("Joined at", target.joined_at.strftime("%d/%m/%Y %H:%M:%S"), True),
("Boosted", bool(target.premium_since), True)]
he has a closing bracket at the end
the bracket already closed at the end
i have no idea how to put a time interavl inmy mute command
@bot.command()
@commands.has_permissions(manage_roles = True)
async def mute(ctx, user : discord.Member,*,reason= "No reason provided idot"):
roleobject = discord.utils.get(ctx.message.guild.roles, id=870577969477857289)
await user.add_roles(roleobject)
await user.send("You have been muted in **Aurora | Social • Icons • Anime** because:"+reason)
await user.mute(reason=reason)
await ctx.send(f":white_check_mark: {user} was muted")
@broken turtle y put it manually
@client.command(description="Mutes the specified user.")
@commands.has_permissions(manage_messages=True)
async def mute(ctx, member: discord.Member, *, reason=None):
guild = ctx.guild
mutedRole = discord.utils.get(guild.roles, name="Muted")
if not mutedRole:
mutedRole = await guild.create_role(name="Muted")
for channel in guild.channels:
await channel.set_permissions(mutedRole, speak=False, send_messages=False, read_message_history=True, read_messages=False)
await member.add_roles(mutedRole, reason=reason)
await ctx.send(f"Muted {member.mention} for reason {reason}")
just use that brotha man
bruh
thoughts ?
bro who cares lmao
idk i use 1.6
Ignoring exception in on_message
Traceback (most recent call last):
File "C:\Users\luffy\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "c:\Users\luffy\Desktop\All Things\Code File\Python\Discord.py\MineHardcore.py", line 165, in on_message
if Member.mention in message.content:
AttributeError: 'NoneType' object has no attribute 'mention'
they wont learn that way.
help me
they're asking for help not for a tutor session lmao
not an on_message
and im trying to help them
wait i though of soemthing
if they want to learn they just wont use it
yes help
so how do i fix it
Use 1.7
Thats the point of asking for help we teach them and they'll teach others
no, i'm checking in message
Some new features, many bug fixes
not command
oh then go head
how to fix??
there i got 1.7.1
1.7.3
ugh
help me pls
bruh my command works but i get this
what are u tryna do @supple storm
@bot.command()
@commands.has_permissions(manage_roles = True)
async def mute(ctx, user : discord.Member,*,reason= "No reason provided idot", unit = None):
roleobject = discord.utils.get(ctx.message.guild.roles, id=870577969477857289)
await user.add_roles(roleobject)
if unit == "s":
wait = 1 * duration
time.sleep(wait)
elif unit == "m":
wait = 60 * duration
time.sleep(wait)
await user.send("You have been muted in **Aurora | Social • Icons • Anime** because:"+reason)
await user.mute(reason=reason)
await ctx.send(f":white_check_mark: {user} was muted for {duration}")
there is no mute command in d.py
lmao
u need to add the role 2 the member
i want to checking if guild owner mentioned in message.content
it does get added
then remove the .mute line
what should i replace it with then
mute cmds r easy
i'm gonna try nd make a snipe cmd
Me who uses asyncio.sleep in mute commands: 
lmao
me too 😭😭😭
!d discord.Member.mentioned_in
mentioned_in(message)```
Checks if the member is mentioned in the specified message.
!d discord.Message.guild
The guild that the message belongs to, if applicable.
!d discord.Guild.owner
owner```
The member that owns the guild.
(:
here
i tried
Do u have intents?
no
@bot.command()
@commands.has_permissions(manage_roles = True)
async def mute(ctx, user : discord.Member,*,reason= "No reason provided idot", duration = 0, unit = None):
roleobject = discord.utils.get(ctx.message.guild.roles, id=870577969477857289)
await user.add_roles(roleobject)
if unit == "s":
wait = 1 * duration
time.sleep(wait)
elif unit == "m":
wait = 60 * duration
time.sleep(wait)
await user.send("You have been muted in **Aurora | Social • Icons • Anime** because:"+reason)
await ctx.send(f":white_check_mark: {user} was muted for {duration}")
lol ok i got no errors
!intents
Using intents in discord.py
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default, discord.py has all intents enabled, except for the Members and Presences intents, which are needed for events such as on_member and to get members' statuses.
To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.
Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:
from discord import Intents
from discord.ext import commands
intents = Intents.default()
intents.members = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.
Member intent, that's what u need
U r sleeping in an elif statement...
Indent lol
aaa
Well I have to go. I am sure kayle will tell u the problem (:
indents
i checxkt he indents
The guild name.
Ignoring exception in on_message
Traceback (most recent call last):
File "C:\Users\luffy\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "c:\Users\luffy\Desktop\All Things\Code File\Python\Discord.py\MineHardcore.py", line 169, in on_message
if Member.mention in message.content:
AttributeError: 'NoneType' object has no attribute 'mention'
@maiden fable noice
1*0 is 0 @broken turtle
because 60m is taken as the reason and duration not specified so its 0
o
Did u enable members intent?
Don't. Act. Innocent.
b-but... i am sad, cries
help. i turned on intent member
no u ain't 🤦
where proof
I know cz me yr friend
is there a way i can actively adjust to ratelimits to be able to add / delete something as fast as possible without triggering the ratelimit?
are you? 
No. They are dynamic
This was the reason the ratelimits ain't static
no, but there's some method that allows bulk delete/add
you cant bulk reset nicknames iirc
Indeed
For things like messages and reactions. Yeah there is
you just bullied me
some method
okay well is there a way i can actively adjust a asyncio.sleep()? Like, i dont just want preset values, i want it to be dynamic to the already dynamic dpy ratelimits
u too
When 
No way

Facts
can i use random integers for a sleep() then?
facts 2
so the time that sleeps is "random"
?
yeah you can do that
!d random.randint
random.randint(a, b)```
Return a random integer *N* such that `a <= N <= b`. Alias for `randrange(a, b+1)`.
just make sure you use asyncio sleep
Yea
asyncio.sleep(random.randint(1, 0.05))```
and not regular time.sleep so you don't run into blocking
time.sleep is blocking and can stop great whole bot
ye ofc
Send a raw request to the discord API, you can check the x-ratelimit-... keys in the response headers
Too less
Use that to decide how long to wait for
i want to be able to do it as fast as possible
?
1-5 seconds at least
Anyways its ot. We can sort it out in DMs afterwards 
you start

is there on_mention events ?
@client.command()
async def apply(ctx, user:discord.Member=None):
if ctx.author.id is 781583513815220235:
await ctx.send("Currently you are blacklisted from using this command")
else:
user = user or ctx.author
role = ctx.guild.get_role(822001928593997875)
await user.add_roles(role)
await ctx.send(f"{ctx.author.mention} is a Official now !!!")
``` i cant check the command right now... the original one works (the one without `if` and `else`) i have added these else and if so would it work ??
so when someone mentions my bot i can send something
Never said I was messaging now. I have to go out in about 5 min. Will start it when I get there
wtf
!d discord.ext.commands.when_mentioned
discord.ext.commands.when_mentioned(bot, msg)```
A callable that implements a command prefix equivalent to being mentioned.
These are meant to be passed into the [`Bot.command_prefix`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Bot.command_prefix "discord.ext.commands.Bot.command_prefix") attribute.
heyoo help
where am i supposed to put that
wht bruh
this is for commands
command_prefix=
class MyData:
def __init__(self, _id: int):
self.joined_at: datetime.datetime = self.select("joined_at")
so currently, self.joined_at selects a data in the db, but it wont be updating everytime I updated the db, how do i make so self.joined_at also updating everytime I update the db? I saw dpy uses _handle_something and flatten_handlers class decorator (but that would be quite long and i kinda dont like it), should I use that too?
like for ?ban you can do @bot_mention ban
me
yes i meant send the code sorry lmao
pos = ["s","m","h","d"]
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]
@client.command()
@commands.has_permissions()
async def giveaway(ctx):
await ctx.send("Let's start with this giveaway! Answer these questions within 15 seconds!")
questions = ["Which channel should it be hosted in?", "What should be the duration of the giveaway? (s|m|h|d)", "What is the prize of the giveaway?"]
answers = []
def check(m):
return m.author == ctx.author and m.channel == ctx.channel
for i in questions:
await ctx.send(i)
try:
msg = await client.wait_for('messsage', timeout=15.0, check=check)
except asyncio.TimeoutError:
await ctx.send('You didn\'t answer in time, please be quicker next time!')
return
else:
answers.append(msg.content)
try:
c_id = int(answers[0][2:-1])
except:
await ctx.send(f"You didn't mention a channel properly. Do it like this {ctx.channel.mention} next time.")
return
channel = client.get_channel(c_id)
time = convert(answers[1])
if time == -1:
await ctx.send(f"You didn't answer with a proper unit. Use (s|m|h|d) next time!")
return
elif time == -2:
await ctx.send(f"The time just be an integer. Please enter an integer next time.")
return
prize = answers[2]
await ctx.send(f"The giveaway will be in {channel.mention} and will last {answers[1]} seconds!")
embed = discord.embed(title = "Giveaway!", description = f"{prize}", color = ctx.author.color)
embed.add_field(name = "Hosted by:", value = ctx.author.mention)
embed.set_footer(text = f"Ends {answers[1]} from now!")
my_msg = await channel.send(embed = embed)
await my_msg.add_reaction("🎉")
await asyncio.sleep(time)
new_msg = await 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 channel.send(f"Congratulations! {winner.mention} won the prize: {prize}!")
@client.command()
@commands.has_permissions(kick_members=True)
async def reroll(ctx, channel : discord.TextChannel, id_ : int):
try:
new_msg = await channel.fetch_message(id_)
except:
await ctx.send("The ID that was entered was incorrect, make sure you have entered the correct giveaway message ID.")
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} for the giveaway rerolled!")```
nah fam
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pydis.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
don't just pastes so much code here
Your questions a bit too difficult to handle for my IQ
XD
someone teach me python lol
like https://github.com/Rapptz/discord.py/blob/master/discord/message.py#L794-L795 this thing for example
discord/message.py lines 794 to 795
def _handle_pinned(self, value: bool) -> None:
self.pinned = value```
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
Do u know... I don't know the internals of dpy
somebody help
ty
!paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pydis.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
please
ok
Hi snow. Only u can help Kylee
idk, who knew it then? 
ru copying code
I never knew dpy... I hardly know dpy
hmm
@client.command()
@commands.has_permissions()
async def giveaway(ctx):
await ctx.send("Let's start with this giveaway! Answer these questions within 15 seconds!")
questions = ["Which channel should it be hosted in?", "What should be the duration of the giveaway? (s|m|h|d)", "What is the prize of the giveaway?"]
answers = []
def check(m):
return m.author == ctx.author and m.channel == ctx.channel
for i in questions:
await ctx.send(i)
try:
msg = await client.wait_for('messsage', timeout=15.0, check=check)
except asyncio.TimeoutError:
await ctx.send('You didn\'t answer in time, please be quicker next time!')
return
else:
answers.append(msg.content)
try:
c_id = int(answers[0][2:-1])
except:
await ctx.send(f"You didn't mention a channel properly. Do it like this {ctx.channel.mention} next time.")
return
channel = client.get_channel(c_id)
time = convert(answers[1])
if time == -1:
await ctx.send(f"You didn't answer with a proper unit. Use (s|m|h|d) next time!")
return
elif time == -2:
await ctx.send(f"The time just be an integer. Please enter an integer next time.")
return
prize = answers[2]
await ctx.send(f"The giveaway will be in {channel.mention} and will last {answers[1]} seconds!")no yes from youtube
bruh
bro.
what no i've seen this code before
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pydis.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
it's @fading mica's code
okay, so blindly copypasting.
😂🤣
copying isnt learning
you'll learn from docs not YT
U pinged him...
copying and going "Okay this should work" isnt learning.
stop copying from vids, you don't really learn unless you actually understand the code.
Indeed
yeah, you didn't even made an ai bot with tons of guilds
Breh, it's hardly in 50 servers
ohk
hunter you probably know more discord.py than i do, shush it
me having a bot only in 1 guild: 
bro the yexplain in vids
I've been looking for AI bots
can u help me
Duck it. I don't know more than u
Chatbots?
Anything AI-related
hunter made his own API for his chatbot, i recommend you use it :)
they may explain, but do you understand what they explain????
The API isn't public @patent lark
make it public 
Indeed lol
Can I see it too? 👀
No thanks
why
Invite Link or Support Server?
yes bro litlle bit bro but wht u say i understand the most even wht @Arla says
!e py def foo(): print("Hunter make the API public") foo()
@patent lark :white_check_mark: Your eval job has completed with return code 0.
Hunter make the API public
I don't want to make a proper key and authentication stuff
Lmao
pls help in making giveaway commands
@client.command(aliases=['repeat', 'rep'])
async def loop(self, ctx: commands.Context):
if not ctx.voice_state.is_playing:
return await ctx.send('Nothing being played at the moment.')
ctx.voice_state.loop = not ctx.voice_state.loop
await ctx.send("*This track will now repeat*")
I've got ctx in the argument, but I'm still presented with the error : ctx is a required argument that is missing
I can give u the discord bot link, but not making the API public, thanks
which part do you need help with
y is there self
i've told you to !paste your code you haven't done that
remove self
the whole can u explain and i will write it down
self is for cogs, you don't seem to be using em
yes
this is also the whu helps
im not gonna spoonfeed you the code, but i'll rather tell you what parts do.
!pastes
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pydis.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
ohk but i can then add u in dev for bot
bruh?
you want me to give you code? no
and im not interested thanks
if you actually understood, you should know how to fix your code
If I want to see the nick name is it {user.display.name} orrrr {user.display_name} or am I wrong wrong
guys i wrote while True loop in on_ready. and after minutes bot got off .what is wrong?
memer
!d display_name
no not spoon feed explain and me someparts
member*
!d discord.Member.display_name
display_name```
Returns the user’s display name.
For regular users this is just their username, but if they have a guild specific nickname then that is returned instead.
ugh
Member
???
sorry lmfao
Thanks!
!d discord.Member.nick
The guild specific nickname of the user.
use displayname it is better
yes
{user.display_name}
Yes yes got that part, thank you @boreal ravine
👍
pls yelp
some body can help me ?
i don't know how many times ive told you, not sure if you understand, can you please !paste your code!!??
its saying way too big
so how
!paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pydis.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
can you send code for on ready
!p def convert(time):
pos = ["s","m","h","d"]
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]
@client.command()
@commands.has_permissions()
async def giveaway(ctx):
await ctx.send("Let's start with this giveaway! Answer these questions within 15 seconds!")
questions = ["Which channel should it be hosted in?", "What should be the duration of the giveaway? (s|m|h|d)", "What is the prize of the giveaway?"]
answers = []
def check(m):
return m.author == ctx.author and m.channel == ctx.channel
for i in questions:
await ctx.send(i)
try:
msg = await client.wait_for('messsage', timeout=15.0, check=check)
except asyncio.TimeoutError:
await ctx.send('You didn\'t answer in time, please be quicker next time!')
return
else:
answers.append(message.content)
try:
c_id = int(answers[0][2:-1])
except:
await ctx.send(f"You didn't mention a channel properly. Do it like this {ctx.channel.mention} next time.")
return
channel = client.get_channel(c_id)
time = convert(answers[1])
if time == -1:
await ctx.send(f"You didn't answer with a proper unit. Use (s|m|h|d) next time!")
return
elif time == -2:
await ctx.send(f"The time just be an integer. Please enter an integer next time.")
return
prize = answers[2]
await ctx.send(f"The giveaway will be in {channel.mention} and will last {answers[1]} seconds!")
embed = discord.embed(title = "Giveaway!", description = f"{prize}", color = ctx.author.color)
embed.add_field(name = "Hosted by:", value = ctx.author.mention)
embed.set_footer(text = f"Ends {answers[1]} from now!")
my_msg = await channel.send(embed = embed)
await my_msg.add_reaction("🎉")
await asyncio.sleep(time)
new_msg = await 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 channel.send(f"Congratulations! {winner.mention} won the prize: {prize}!")
@client.command()
@commands.has_permissions(kick_members=True)
async def reroll(ctx, channel : discord.TextChannel, id_ : int):
try:
new_msg = await channel.fetch_message(id_)
except:
await ctx.send("The ID that was entered was incorrect, make sure you have entered the correct giveaway message ID.")
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} for the giveaway rerolled!")
Converting to "int" failed for parameter "pep_number".
!pep <pep_number>
Can also use: get_pep, p
Fetches information about a PEP and sends it to the channel.
yes yes
but it is 1000 line
!paste def convert(time):
pos = ["s","m","h","d"]
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]
@client.command()
@commands.has_permissions()
async def giveaway(ctx):
await ctx.send("Let's start with this giveaway! Answer these questions within 15 seconds!")
questions = ["Which channel should it be hosted in?", "What should be the duration of the giveaway? (s|m|h|d)", "What is the prize of the giveaway?"]
answers = []
def check(m):
return m.author == ctx.author and m.channel == ctx.channel
for i in questions:
await ctx.send(i)
try:
msg = await client.wait_for('messsage', timeout=15.0, check=check)
except asyncio.TimeoutError:
await ctx.send('You didn\'t answer in time, please be quicker next time!')
return
else:
answers.append(message.content)
try:
c_id = int(answers[0][2:-1])
except:
await ctx.send(f"You didn't mention a channel properly. Do it like this {ctx.channel.mention} next time.")
return
channel = client.get_channel(c_id)
time = convert(answers[1])
if time == -1:
await ctx.send(f"You didn't answer with a proper unit. Use (s|m|h|d) next time!")
return
elif time == -2:
await ctx.send(f"The time just be an integer. Please enter an integer next time.")
return
prize = answers[2]
await ctx.send(f"The giveaway will be in {channel.mention} and will last {answers[1]} seconds!")
embed = discord.embed(title = "Giveaway!", description = f"{prize}", color = ctx.author.color)
embed.add_field(name = "Hosted by:", value = ctx.author.mention)
embed.set_footer(text = f"Ends {answers[1]} from now!")
my_msg = await channel.send(embed = embed)
await my_msg.add_reaction("🎉")
await asyncio.sleep(time)
new_msg = await 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 channel.send(f"Congratulations! {winner.mention} won the prize: {prize}!")
@client.command()
@commands.has_permissions(kick_members=True)
async def reroll(ctx, channel : discord.TextChannel, id_ : int):
try:
new_msg = await channel.fetch_message(id_)
except:
await ctx.send("The ID that was entered was incorrect, make sure you have entered the correct giveaway message ID.")
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} for the giveaway rerolled!")
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pydis.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
just in on_ready
why is ur on ready 1k lines
what can i do ?
uh commands..?
i want to creat while
o
https://paste.pythondiscord.com/zozubitofo.py @slate swan
@slate swan what error
yeah, what's the issue
please some body help me :(
bro its not taking in channel u wanna test
i can dm u server link
I didn't tell you to DM it did I?
ITS 100 LINE
!paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pydis.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
ok wait
firstly
what's @commands.has_permissions()
@slate swan
Delete it now!!!!
You put your token
what's nthing
no thats wrong
discord.ext.commands.has_permissions(**perms)```
A [`check()`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if the member has all of the permissions necessary.
Note that this check operates on the current channel permissions, not the guild wide permissions.
The permissions passed in must be exactly like the properties shown under [`discord.Permissions`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions "discord.Permissions").
This check raises a special exception, [`MissingPermissions`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.MissingPermissions "discord.ext.commands.MissingPermissions") that is inherited from [`CheckFailure`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
i will put admin
=true
okay..
see
There is a typo
see bcoz of u guys me is alo learning
stop it
no
It should be administrator
bruh what?
check how you wrote administrator
bro i dm u the link
can i send it again ?
NO
Which link?
its name is testing bot
server
no.
ohk
sorry
have you read discord ToS? don't just dm links without permission

Indeed
starts DMing everyone my bot link
bro can you help me ?
sure, but cut out the token
ohk
sorry i forgot to ask
okay. anyways
what's the error with the code
if it's nothing why is it in your code
you haven't said it yet
and want help
don't ask me to join your server, just say what's wrong
see it does not respond when i give #channel or even 880470977434247248 channel id
no error
you also put your db info
might wanna cut that out too
deleted
oh ok
how
Do you know why?
does it not say anything
await ctx.send("Let's start with this giveaway! Answer these questions within 15 seconds!")
not this?
just says this
it uses wait for
just test it out i will kick u as soon as u test it
do you even know what it means
bru sorry
answer my question please
yes
if we wont answer in 15 seconds the bot will not take in next command
okay last question
or proced to further next questions
did you do the coding while he was explaining or did you copy from github
or something else
well copy it and listen to it while explaining
@slate swan yr doggo cutie
hmm
even i like it
cute doggo
now
please read my code and help me :)
well i'm sorry i have to go for work to do..
you'll have to wait for someone else to help you sorry
ohk
um @maiden fable you have time to help?
and thanks btw 
What do u need help with?
my bot got off after some minutes
whit no error idk what is wrong ?
send code
Not a code problem
-> Discord Diconnected Your Bot
-> The Internet Went
-> The Machine Shut Down
why discord disconnect my bot ?
connecting it to discord requires an internet connection
if you don't have internet it won't connect
what
no i have
see
just use several wait_fors
and collect all the information
if you don't know how to do it put duration prize etc as positional command args
and use speechmarks for more than a word
don't use x, *, y
ohk
Hi, a newbie question: How can I add a method as a command? I have a class that subclass discord.ext.commands.Bot
whats the decorator to chedck for perms in a cog
anyone
bois I fixed my discord bot bug. It was literally a matter of me forgetting that the arg "check" exists in wait_for() ;-;
good bro
Images are really inconvenient to work with here

let me see your import statement(s)
unused imports
you see, when importing a module like that:
from datetime import datetime, time
ohk
the module name is the same as one of its descendants I'm assuming?
Yes
uh
so i think the program might be confusing the two
🎉
There's a way to insure that but I forgot how
pls tell me how @maiden fable
!d datetime.timedelta
class datetime.timedelta(days=0, seconds=0, microseconds=0, milliseconds=0, minutes=0, hours=0, weeks=0)```
All arguments are optional and default to `0`. Arguments may be integers or floats, and may be positive or negative.
Only *days*, *seconds* and *microseconds* are stored internally. Arguments are converted to those units...
Oh yeah that works too
Bruh I'm dumb smh
No wonder it took me 3 days to fix this damn bug
Please?
instead of timedata can i not use something else
ohk
see new error nut it send message now
me
i am getting this error, when i try to open my repl site, (i am trying to use uptimer bot)
Hmmmm.... We Couldn't Reach Your Repl Make sure your repl has a port open and is ready to receive HTTP traffic.
@slate swan Beluga?
uh no
Hi
I'm trying to make my bot recept messages and send them to a specific channel
that can be modified through a command
How can I make the bot only take the channel ID as an argument?
typehint
thx
channel: discord.Channel or discord.TextChannel
hi need anythin?
what?
My main file suddenly doesn't want to import discord nor discord.ext
It was working fine just a few hours ago, I didn't even touch the file
Replit or?
how can i track daily messages?
nop, vscode
I'm not even surprised at this point because God forbidden I have a smooth experience while coding
restart the IDE
why would you want that now lol?
!d discord.on_message
discord.on_message(message)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Message "discord.Message") is created and sent.
This requires [`Intents.messages`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Intents.messages "discord.Intents.messages") to be enabled.
Warning
Your bot’s own messages and private messages are sent through this event. This can lead cases of ‘recursion’ depending on how your bot was programmed. If you want the bot to not reply to itself, consider checking the user IDs. Note that [`Bot`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot") does not have this problem.
you mean on message events?
client.load.extension(f'CogHolder.{filename[:-3]}')
AttributeError: 'Bot' object has no attribute 'load'```
yes that counts daily messages
Ooooh, I see what's happening
load_extension()
Or not
giveaway command?
yes can u help me
Use bot or client
not load.extension
load_extension
Where did you get stuck?
see
okay?
pass in the arguement then
you made it positional
howpls just tell me
i did the whole thing by me
@slate swan
i can regenrate and it half
does anyone know how to steal emojis command?
steal emojis?
lolonline
online
I want it on dnd
send me this command i need this
dnd
remove idle and put dnd
did
check now
or else remove status
1 sec add it again and then put dnd
@client.event
async def on_ready():
await client.change_presence(activity=discord.Activity(name="in the space | Prefix is #", type=discord.ActivityType.playing), status=discord.Status.idle)
print("Ready!")```
thnx i needed it
I have this code```py
await c.execute(f"SELECT amount FROM warn WHERE userid={member.id} ")
user = await c.fetchone()
if user is None:
await c.execute(f"INSERT INTO warn VALUES ({member.id}, 0)")
await ctx.send("User added to db")
else:
await ctx.send(f"User exist, and amount is: {user}")
and get this error ```py
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 994, in invoke
await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 894, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 176, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: OperationalError: unrecognized token: "877835890574118932 "
how can i set the Listening to status?
and Watching status?
and Competing in status?
!d discord.ActivityType
class discord.ActivityType```
Specifies the type of [`Activity`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Activity "discord.Activity"). This is used to check how to interpret the activity itself.
!d discord.Activity
class discord.Activity(**kwargs)```
Represents an activity in Discord.
This could be an activity such as streaming, playing, listening or watching.
For memory optimisation purposes, some activities are offered in slimmed down versions:
• [`Game`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Game "discord.Game")
• [`Streaming`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Streaming "discord.Streaming")
thx @maiden fable
import discord
import os
import datetime
from dotenv import load_dotenv
from discord.ext import commands
load_dotenv()
#Global Variables
intents = discord.Intents()
intents.members = True
bot = commands.Bot(command_prefix=['n','N','n!','N!'], intents=intents)
bot.remove_command("help")
#Events
@bot.event
async def on_ready():
print("Logged in!")
await bot.change_presence(activity=discord.Game(name="nhelp"))
#Basic Commands
@bot.command()
async def help(ctx):
em = discord.Embed(color=discord.Color.red())
em.set_author(name="Ningo Command Section", icon_url=bot.user.avatar_url)
em.add_field(name="Basic Commands",value="help, serverinfo, si, memberinfo, mi, avatar, av, invite, inv, ping")
await ctx.send(embed=em)
@bot.command(aliases=['av'])
async def avatar(ctx, member:discord.Member=None):
if member is None:
member = ctx.author
em = discord.Embed(title=f"{member}'s avatar", color=discord.Color.red())
em.set_image(url=member.avatar_url)
await ctx.send(embed=em)
@bot.command(aliases=['mi'])
async def memberinfo(ctx, member:discord.Member=None):
if member is None:
member = ctx.author
accCreate = member.created_at.strftime("%d %b %y %H:%M:%S UTC")
joinDate = member.joined_at.strftime("%d %b %y %H:%M:%S UTC")
x = datetime.datetime.utcnow()
accAge = x - member.created_at
joinServerAge = x - member.joined_at
embed = discord.Embed(color=discord.Color.red(), title=f"{member.name}#{member.discriminator} (@{member.display_name})")
embed.add_field(name="ID", value=f"{member.id}")
if member.name != member.display_name:
embed.add_field(name="Actual membername", value=f"{member.name}")
embed.add_field(name="Avatar", value=f"[Link]({ctx.author.avatar_url})")
embed.add_field(name="Created Account On", value=f"{accCreate}")
embed.add_field(name="Created Account", value=f"{accAge} ago")
embed.add_field(name="Joined Server On", value=f"{joinDate}")
embed.add_field(name="Joined Server", value=f"{joinServerAge} ago")
embed.add_field(name="Member's Top Role", value={member.top_role.name})
embed.set_thumbnail(url=member.avatar_url)
await ctx.send(embed=embed)
@bot.command()
async def ping(ctx):
latency = round((bot.latency)*1000)
await ctx.send(f":ping_pong: My latency is {latency}ms")
@bot.command(aliases=['inv'])
async def invite(ctx):
await ctx.send("https://discord.com/api/oauth2/authorize?client_id=885040999066386452&permissions=8&scope=bot")
@bot.command(aliases=['si'])
async def serverinfo(ctx):
em = discord.Embed(description=f"**Owner:** :crown:{ctx.guild.owner}\n**Members:** :busts_in_silhouette:{ctx.guild.member_count}\n**Channels:** :hash:{len(ctx.guild.text_channels)} :loud_sound:{len(ctx.guild.voice_channels)}\n**Region:** :flag_white:{ctx.guild.region}\n**ID:** :id:{ctx.guild.id}", color=discord.Color.red())
em.set_author(name=ctx.guild.name, icon_url=ctx.guild.icon_url)
await ctx.send(embed=em)
bot.run(os.getenv("DISCORD_TOKEN"))
The commands are not being executed
help someone pls
Is ur bot ratelimited ?
wdym
Check the logs of ur bot
is that all your code
?
yes
no error?
do you know what that means?
pls tell me
nope
hello
answers is an empty list and ur trying to index it thats why ur getting that error
there's nothing in it.
this works fine
discord.ext.commands.errors.ExtensionFailed: Extension 'Cogs.MainCog' raised an error: TypeError: module() takes at most 2 arguments (3 given)```
Any idea on what this error might be?
Yes, cause ur appending it based in the answers of the queations
Hmm its a module error most likely somthgn is wrong in ur imports
what are ur imports in that cog ?
import os
import discord
from discord.ext import commands
from discord.ext.commands.errors import ExtensionNotFound
from dotenv import load_dotenv
Apparently it autoimported commands.errors??
help
I guess you're trying to load class instead of extension..?
What is MainCog
Yes vsc does it sometimes
The cog where all the other commands are supposed to be in
define prize
prize = answer 2
And your setup() method? did you ```py
def setup(bot):
bot.add_cog(Cogs.MainCog(bot))
I did, although I used client.add instead of bot.add
I'll give it a try with bot.add
Nah that's fine
bro to what
Don't need to do that, whatever you named is fine.. What did you called in your main file, like client/bot.load_extension(what??)
See, in that cmd ur provided an empty list then appended it based on the data provided, then indexed the prize, in the reroll cmd u did not do the same, to get the prize u must define it or access it thru the embed which would be confusing for u, so an alternative is to use db and store the info there too... but then u will have to keep removing the data once the giveaway has ended completed so just remove the prize part.
if filename.endswith('.py'):
client.load_extension(f'Cogs.{filename[:-3]}') # This One
print ('{} has been loaded!'.format('MainCog'))```
The prize is not an instance variable and localised to the method only, make it instance var or do something else to make it available in other func
Apparently, it's this especific line that's messing up according to the report
specific*
Can you share the whole cog file? It's hard to guess what's wrong 
!paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pydis.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
async def load(ctx, extension):
client.load_extension(f'Cogs.{extension}')
@client.command()
async def unload(ctx, extension):
client.unload_extension(f'Cogs.{extension}')
for filename in os.listdir('./Cogs'):
if filename.endswith('.py'):
client.load_extension(f'Cogs.{filename[:-3]}')
print ('{} has been loaded!'.format('MainCog'))
This is the entirety of the init process for the cogs
Is steal emoji in that?
I tried messing around with the names to see if it would load if I declared the name, but it still didn't work
Hmm u dont need to provide a fixed cog name just do extension or so
Whats the name of ur cogs folder ?
@lofty mulch ? https://paste.pydis.com/
just Cogs
ist Cogs or cogs
Cogs with capital C
Alr then can u code of the entire cog
i got it
lolthnx guys
oooo
Wdym by command ?
That's the whole cog
Ah that's wrong way to load cogs, you need to pass in the subclass of cog inside add_cog ```py
def setup(bot): # bot or client or whatever
bot.add_cog(Index(bot))
And not commands.bot
It's mostly wrong
ooh
Hoi
get the role first, then if role not in member.roles: then await ctx.send("you cannot used the cmd as you dont have the role for it")
Lemme try
https://vcokltfre.dev/tutorial/05-cogs/ Have a look at this for how to make cogs
Thanks
And of course, it's still giving the same error
You know what, might just call it a night and get some rest
role = discord.utils.get(ctx.guild.roles, name = "whatever")
if role not in ctx.author.roles:
await ctx.send()
there are 2 ways either by providing
@commands.has_role(roleid)
decorator
or get the role inside the command and do
role = discord.utils.get(ctx.guild.roles, id = roleid)
if not role in ctx.author.roles:
return await ctx.send("You need the {role.mention}, to use this command")
Because I already told you this is not the way cogs are made, you are subclassing a whole module 
Use database for it.
I did fix it
Just have a look at the shared link to see how to make one
In the filename part it should be load_extension
Well, lesson learned
and also yes its same, but it wont run unless u do !load test
like savefile? or dump? or just make a list in the file itself
I should start paying attention to what I write
hola
No 
no like make a empty list and then append with the command name or so and then upload the list to ur db and then fetch it accordingly to the guild id.
is it possible to make embed auto response?
time to ping Kylee and demand an explanation
Someone tell me how to typehint a snowflake which is a str and I need to name it ID 
I need to know discord permessions
!d discord.Permissions
class discord.Permissions(permissions=0, **kwargs)```
Wraps up the Discord permission value.
The properties provided are two way. You can set and retrieve individual bits using the properties as if they were regular bools. This allows you to edit permissions.
Changed in version 1.3: You can now use keyword arguments to initialize [`Permissions`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions "discord.Permissions") similar to [`update()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions.update "discord.Permissions.update").
wdym
luv u
(:
oh like when i said hello it's reply with "hello world" but in embed
this ^
sure
yes
how though i try it and i mess it up
!d discord.on_message
discord.on_message(message)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Message "discord.Message") is created and sent.
This requires [`Intents.messages`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Intents.messages "discord.Intents.messages") to be enabled.
Warning
Your bot’s own messages and private messages are sent through this event. This can lead cases of ‘recursion’ depending on how your bot was programmed. If you want the bot to not reply to itself, consider checking the user IDs. Note that [`Bot`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot") does not have this problem.
!d discord.Embed
class discord.Embed(**kwargs)```
Represents a Discord embed.
`len(x)` Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.
Certain properties return an `EmbedProxy`, a type that acts similar to a regular [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") except using dotted access, e.g. `embed.author.icon_url`. If the attribute is invalid or empty, then a special sentinel value is returned, [`Embed.Empty`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Embed.Empty "discord.Embed.Empty").
For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") for you.
Hey can someone help me , my bot is doing executing commands twice due to these lines of code
async def initialise(): await client.wait_until_ready() client.db = await aiosqlite.connect("expData.db") await client.db.execute("CREATE TABLE IF NOT EXISTS guildData (guild_id int, user_id int , exp int, PRIMARY KEY (guild_id, user_id))")
can someone tell me whats wrong ?
!d discord.Message.channel
The TextChannel that the message was sent from. Could be a DMChannel or GroupChannel if it’s a private message.
!d discord.TextChannel.send
await send(content=None, *, tts=False, embed=None, file=None, files=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message to the destination with the content given.
The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.
To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/stable/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`File`](https://discordpy.readthedocs.io/en/stable/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.
If the `embed` parameter is provided, it must be of type [`Embed`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Embed "discord.Embed") and it must be a rich embed type.
Dude, just name the methods instead of spamming python 
I like spamming those embeds 👀
Python has an automute
Sad
embed = discord.Embed(title="Title" color=0x[your_hex])
embed.add_field(
name="Name", value="Description", inline=False)
await ctx.send(embed=embed)```





