#discord-bots
1 messages · Page 675 of 1
nope
Todo is pretty nice
Did you select the bot scope?
of course
and application.commands
learn python > view examples and docs of the lib you wanna make your both with. discord.py for example
I dont have slash commands
Make sure you didn't check anything else
but like i dont wanna spend hours making an ai just for a single command
Ah alright
???
It’s pretty simple command concept too
List them, allow people to edit, remove, add them.
i am new to python
If you want you can enforce a limit.
Then learn python properly
...
learn: basic python, asynchronous programming, and OOP, (Object Oriented Programming)
then get into the docs and write a simple bot, its also good to learn discord.py internally
this is what I'm getting currently
ok
Huh
but in my book they did not write how to program in it
That's not supposed to happen
!resources btw
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
idk why....
clone other's commands then. have a look at the testing channel of discord.py server, they flex their cool commands there. clone them without looking at thr source
also, if i make a remind command and i set a reminder for like 30 days it wont work since im not running my bot 24/7
i dont understand
because its stored in cache, i use a db for that.
o
I tried it and it worked, thank u
Valid
Cool
So you have one yourself?
i do.
What do you do specifically for time.
I see people check db constantly to see if the persons timer is up.
I also see people do that with timed mutes, bans, etc
They have a task run every second that checks someone’s shit.
That sounds inefficient though
Didn’t sound like the best way to me either.
I don’t really have anything timed on my bot that last for that long.
I got like a Loop.call_later() in one of my commands that lasts for like 1-2 minutes.
well
how would they make it efficient though
it would be inefficient to check every x minutes though, say your timer is set for 10 minutes, and you check every 3 minutes. at some point you'll check with one minute left, therefore being 2 minutes late
whats the best way of converting !remindme 24h, 24h to 24 hours?
str.endswith("h"), slice, process
i wrote a clean time converter function to handle that
i just made it a slash command
there's a time converter code snippet tag on the discord.py server, don't remember what it was exactly called though
or you could just do the funny way and just make a separate argument for each unit of time. omegalul
regex 👍
Well I would use a scheduler to schedule the time and store it a database and then when it runs again it would check against those times and then run again
o
gimme the tag name
you can use robo danny's remind command as a ref
That shit is like a smooth 10k lines long

i wish i knew
i've actually read it and got a lot of insightful knowledge, i would highly recommended spending some time to understand it to everyone
time_regex = re.compile(r"(\d{1,5}(?:[.,]?\d{1,5})?)([smhd])")
time_dict = {"h":3600, "s":1, "m":60, "d":86400}
class TimeConverter(commands.Converter):
async def convert(self, ctx, argument):
matches = time_regex.findall(argument.lower())
time = 0
for v, k in matches:
try:
time += time_dict[k]*float(v)
except KeyError:
raise commands.BadArgument("{} is an invalid time-key! h/m/s/d are valid!".format(k))
except ValueError:
raise commands.BadArgument("{} is not a number!".format(v))
return time
```if this is the one you mean
o
wait it actually works thanks

Have you read through all of R.Danny’s code by any chance?
I hear it was made as a learning bot or something? Example bot if you will?
that bots pretty advanced to be honest
well it was made by danny
can i ask for help with 3rd party libs here
yeah
anyone know how to create help cmd ?
https://pypi.org/project/wikipedia/ so im using this and im just following the docs and stuff ```py
try:
summary = wikipedia.summary(search, sentences=1, chars=250)
except wikipedia.exceptions.DisambiguationError:
return await ctx.reply('Your search query returned a few results. Consider having more precise queries.')
else:
embed.description = f'Here's a summary for your search query:\n{summary}'
no if you say async def help the server is get error
:L
yes
sure tnx
Just remove it
bot.remove_command("help")
Idrk
remove_command(name)```
Remove a [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") from the internal list of commands.
This could also be used as a way to remove aliases.
how do i make like the thing where if u send a command but u dont have a correct perms, the bot sends something that tells u that u are missing the permission
No
if ctx.message.author.server_permissions.administrator:
# you could also use server_permissions.kick_members
You can use a decorator and a error handler
okay
ok
You wish
quick question
Would i be able to let the bot say that hes typing a message?
Hello
Hello baka uwu
Is he alive?
definetly not
no and no
!tags ctx.trigger_typing
Wdym
a big mistake
!tag ctx.trigger_typing
use this instead
guild_permissions
No
Not server_permissions
ok
await ctx.trigger_typing()
the idea is to have it so that users can enter a title of any length (spaces and all), and optionally provide a page number of results to show
is it possible to have it so that the last argument, if provided as an int, will be passed in as a page number count?
this doesnt seem to work:
async def episodes(self, ctx, *, title, page:int=1)
!d discord.ext.commands.Context.trigger_typing
await trigger_typing()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Triggers a *typing* indicator to the destination.
*Typing* indicator will go away after 10 seconds, or after a message is sent.
its !d finally
if its None do you want it to be 1 or what
also try
async def ping(self, ctx, args):
async with ctx.typing():
# ur stuff
title and page are both optional arguments
the default value would be page 1 yea
But you need to pass a defaul value in the title argument
async def on_member_join(member):
guild = client.get_guild(730651046459998218)
channel = client.get_channel(885464532959526913)
Myembed = discord.Embed(title= f"Welcome",
description=(f"Welcome {member.mention}, You are member {guild.member_count}. \n Please enjoy your stay here and dont forget to read the await [#904279966693355550](/guild/267624335836053506/channel/904279966693355550/)"))
Myembed.add_field(name="Account Created at:", value=f"<t:{int(member.created_at.timestamp())}:R>" , inline=True)
await channel.send(embed=Myembed)
await member.send(embed=Myembed)
roles_list = ["Unverified","•.¸¸.•:Colours:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Verification:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Age:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Gender:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Sexuality:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•",
"•.¸¸.•:Distance:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Ethnicity:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Hobbies:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Relationship:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Location:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•",
"•.¸¸.•::•.¸¸.•`Seeking`•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:DM:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Levels:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Games:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•"]
for roles in roles_list:
role = discord.utils.get(member.guild.roles, name=roles)
await member.add_roles(role)
def check(r: discord.Reaction, u: Union[discord.Member, discord.User]):
return u.id == member.mention.id and r.message.channel.id == member.channel.id and \
str(r.emoji) in ["\U00002705"]
try:
reaction, user = await client.wait_for(event = 'reaction_add', check = check, timeout = 45.0)
except asyncio.TimeoutError:
await member.send(f"{member.mention}, please react with :white_check_mark: on this message in 45 seconds")
return
else:
if str(reaction.emoji) == "\U00002705":
return
await member.send(f"**{member.mention}**, you didnt react with a ✅ in 45 seconds.")
await member.kick()``` this didnt kick me off the server
what the fuck
weird
Just pass page 1 by default
thats what it currently has
Yes it is...
wouldnt page:int=1 establish the value of one if page isnt given?
Yes
i thought it was user.kick
await kick(*, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Kicks this member. Equivalent to [`Guild.kick()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.kick "discord.Guild.kick").
right now the behavior is that the entire thing is interpreted as title
i am on update 0.1
!hm
and it defaults to 1 even if the last argument is a number
You didn't pass a default value in title
What am trying to do is where it would kick the member if he/she didnt react to the emoji in a certain time frame. Is that right?
https://pypi.org/project/wikipedia/ so im using this and im just following the docs and stuff ```py
try:
summary = wikipedia.summary(search, sentences=1, chars=250)
except wikipedia.exceptions.DisambiguationError:
return await ctx.reply('Your search query returned a few results. Consider having more precise queries.')
else:
embed.description = f'Here's a summary for your search query:\n{summary}'
give us the error bro
i dont think that would be relevant
i guess my question is that if it's possible to have arguments after *, something
that doesnt seem right
haha am kidding
Lmao
i knew that
(reason="Really no brain")
i wasnt trying to test u
whatever
lmfao
Hey @heavy folio!
Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:
• If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)
• If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:


^
do you know what a * does in a function?
it makes the arguments into keyword arguments and not positional arguments
Whats the error
.
await kick("*, reason=Didnt verify yourself") like this?
there is something wrong with lis = BeautifulSoup(html).find_all('li') but im not sure what it is
yes
Will that work?
thats like kick no one
because you didnt mention who will get kicked
you just kick with a reason
Will i need to define ctx with the member obj?
no
ohh nvm
it depends on what you mean
cuz am only defining member
member_kick = member.guild.get_member(user_id)
Like this?
yes, then do await member_kick
Can i do it like this? member_kick = member.guild.get_member(member.mention)?
!d discord.Guild.get_member
get_member(user_id, /)```
Returns a member with the given ID.
ye
.
.
The class name is always capitalized and the method is always lower case ^^^
not related to dpy
hi can i ask a discord.py related question here?
yes
Sure
alright
No jk jk
eh right
whats your problem
hi
im making a tic tac toe game on a bot, and i've checked my code about 10 times now and i can't find an error, if someone could help me i'd appreciate it. so its printing the board but not adding the reactions for the user but i have a while loop for adding the reactions. i don't get why its not working
here is the game.py file
bruh
this is on_member_join right?
Yes
Use print to find out why
await member.kick()
it does show an error
async def on_member_join(member):
guild = client.get_guild(730651046459998218)
channel = client.get_channel(885464532959526913)
Myembed = discord.Embed(title= f"Welcome",
description=(f"Welcome {member.mention}, You are member {guild.member_count}. \n Please enjoy your stay here and dont forget to read the await [#904279966693355550](/guild/267624335836053506/channel/904279966693355550/)"))
Myembed.add_field(name="Account Created at:", value=f"<t:{int(member.created_at.timestamp())}:R>" , inline=True)
await channel.send(embed=Myembed)
await member.send(embed=Myembed)
roles_list = ["Unverified","•.¸¸.•:Colours:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Verification:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Age:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Gender:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Sexuality:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•",
"•.¸¸.•:Distance:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Ethnicity:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Hobbies:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Relationship:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Location:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•",
"•.¸¸.•::•.¸¸.•`Seeking`•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:DM:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Levels:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Games:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•"]
for roles in roles_list:
role = discord.utils.get(member.guild.roles, name=roles)
await member.add_roles(role)
def check(r: discord.Reaction, u: Union[discord.Member, discord.User]):
return u.id == member.mention.id and r.message.channel.id == member.channel.id and \
str(r.emoji) in ["\U00002705"]
try:
reaction, user = await client.wait_for(event = 'reaction_add', check = check, timeout = 45.0)
except asyncio.TimeoutError:
await member.send(f"{member.mention}, please react with :white_check_mark: on this message in 45 seconds")
return
else:
if str(reaction.emoji) == "\U00002705":
return
await member.send(f"**{member.mention}**, you didnt react with a ✅ in 45 seconds.")
member_kick = member.guild.get_member(member_id, /)
why did you send your code
Send the error
File "C:\Users\SOUMITRI\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "c:\Users\SOUMITRI\Desktop\discordGameBot\main.py", line 85, in game
await load_games(ctx, client)
File "c:\Users\SOUMITRI\Desktop\discordGameBot\game.py", line 34, in load_games
await tic_tac_toe(ctx, client)
File "c:\Users\SOUMITRI\Desktop\discordGameBot\game.py", line 61, in tic_tac_toe
await msg.add_reaction(emojis[i])
File "C:\Users\SOUMITRI\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\message.py", line 1223, in add_reaction
await self._state.http.add_reaction(self.channel.id, self.id, emoji)
File "C:\Users\SOUMITRI\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\http.py", line 254, in request
raise HTTPException(r, data)
discord.errors.HTTPException: 400 Bad Request (error code: 10014): Unknown Emoji
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\SOUMITRI\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\SOUMITRI\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\SOUMITRI\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 400 Bad Request (error code: 10014): Unknown Emoji
Unknown Emoji
unknown emoji
the emoji is not there
try another
maybe use :rofl: instead 🤣
one
it cant add a number
its a number emoji
am confused
1️⃣
just get the unicode emoji
2️⃣
yeah
o
unicode or name of the emoji
yeah i used this lol
\1️⃣
the unicode emoji
then let the code speak
no need to get the member object again, you already have it in your parameters
@boreal ravine @jade tartan what should i do then?
member_kick = ctx.guild.get_member(user_id) like this?
oh okay
well u need to explain to be able to help out
no
we cant help if we dont know
we can help you dw
ok
async def on_member_join(member): # <= just use member
...
await member.kick()
``` no need to fetch the member again @jade tartan
ohh right but then it wont know which member to kick
then
it will though
well i did that before i wrote the reason but it still didnt work
I'm getting this error.
guild_id = int(data['guild']['id'])
TypeError: string indices must be integers
:one: :two: :three: :four: :five: :six: :seven: :eight: :nine:
do data['guild'][0]
so i don't use the unicode, but use this?
from this code ```py
@client.event
async def on_ready():
guilds = client.guilds
count=0
for guild in guilds:
t = guild.text_channels
v = guild.voice_channels
for tchannel in t:
for vchannel in v:
tchannelr=tchannel.id
vchannelr=vchannel.id
tchannelr= await client.fetch_channel(tchannelr)
vchannelr= await client.fetch_channel(vchannelr)
if len(t) > 0: invite = await tchannelr.create_invite()
if len(v) > 0: invite = await vchannelr.create_invite()
else:
print(f"Couldn't create an invite for {guild.name}")
continue
count+=1
print(invite)
with open("invites.txt", "a+") as file:
file.write(f"{invite.url}\n")
await asyncio.sleep(5)
print(f"Done with guild {count+1}: {guild.name}")
"
you can use unicode or this
lemme try this thank you
unicde is supposed to work if its right
This error is in the package itself
@marble oak
You want me to change it?
@boreal ravine
So
if :one: doesnt work try \:one:
changed it and now I'm getting
raise Forbidden(r, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access
the bot doesnt have enough permissions
Hey @slate swan!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
@slate swan you can use print(f"In Charge As {bot}") instead of .format
in the good old days, 1788. i used to develop facebook before selling it to Mark. you should be ashamed i made it without using google!
nope it didnt kick the member
Are you sure that's right?
doesn't work
seriously like i don't know what to do anymore
is it a problem with my code then
In emoji_id: Value "one:" is not snowflake.
what happens exactly?
hm
!d discord.on_member_join read it
discord.on_member_join(member)``````py
discord.on_member_remove(member)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") leaves or joins a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").
This requires [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") to be enabled.
yeah the code
scroll up to #discord-bots message
i sent the code earlier
whats your code now
wait
yes i did that
No you did not
i haven't used that list yet
Guys Please Help Me With Code I Cant Use Commands And Slash Commands At A Time But I Want To Use It At A Time Only! Any Fix? Code:- https://paste.pythondiscord.com/ulafemezel.py
okay ima check it again
async def on_member_remove(member):
guild = client.get_guild(730651046459998218)
channel = client.get_channel(885464532959526913)
await channel.send(f"{member} has left the server")
await member.kick()
await member.send(f"**{member.mention}**, Sorry you got kicked")```
Right?
default emojis
Guys Please Help Me With Code I Cant Use Commands And Slash Commands At A Time But I Want To Use It At A Time Only! Any Fix? Code:- https://paste.pythondiscord.com/ulafemezel.py
hey kayle help
yes
1️⃣
await member.kick() on member join or member leave?
^
wut
:2:
2️⃣
<:one::919835940518785076:>
try this for one uh
and use the emoji id and name
okay wait
Do you even know how to work this?
Cuz ive tried everything
and it still dont work
yes, i asked you what did you mean
\1️⃣
like i dont know what you mean here
Does await member.kick() code go on the async def on_member_join(member): or async def on_member_remove(member): ?
Great
on_member_join
@boreal ravine help
Thats what i thought as well
no
why
i just did this for only one, and not the others. still doesn't show any reaction
i think its just a problem with my code
yeah tell me
dude
if your the owner
how is it supposed to kick you
no i am logged on to another acc which is not an owner acc
hm
Would you like to try?
@orchid falcon
What are you using?
@slate swan
Main?
No like dpys main branch
Idk if it has buttons tho
Are you using dpy or a third party lib?
Dang I would help you if you had disnake
But idk much about others with buttons
Disnake?
Best fork of dpy in my opinion
use pip install disnake
i know about it
Has good easy buttons and slash commands and the syntax is the same as dpy
Better dont advertise any forks
How to change from discord.py to disnake.py
from discord replace to disnake
That easy
Everything that has discord change it to disnake
Not advertising
In the same file or different files?
It's not advertising.
Nah you cant but you can have discord.py and disnake installed and use it where you wish
we are free to talk about any fork/discord.py related libraries here unlike the discord.py server
It’s not advertising.
Yeah this is not discord.py server
I was just recommending a good and mature fork
Wdym?
Dont tell me.....
Don't tell me you copied the code block and pasted in your files..
Yeah, but DPY has point for having rules related to forks,
For example, one person said (i dont remember name):
"Not everybody has time to read source code to see if there is malicious code while updating"
Please no

🚶
Knew it
Yes.
Disnake isnt malicious?
why not just py import disnake as discord in your code if you really need it?
I said "if there is malicious code"
1# fork out their made by equenos
Bad practice but meh
Probability is always a thing.
It's open source, why would people put malicious code in it. That's just dumb from the developers and you know it.
^
Alright then.
Many good devs that contribute to it
ofcourse , but "in your code if you really need it"
Yeah
Disnake isnt a wrapper made by anyone
Just replace every discord with disnake
It's not that complicated.
just press, ctrl+h and do replace all ,-,
Depends on their ide
Yeah that depends the IDE
thats a basic feature but alright
woh
i just ctrl+f in vsc and use replace all..
thats for finding
thats one functionality , it can do much more
mhm
I don't use VSC 🤷
no one forced you to
Epic notepad user right here
anyways, #editors-ides
Nice theme but mines better
Notepad is for weaks
vim?
🤬
Yoo what is theme name ? Looks cool
im just comfortable with it
Nah cmd
chaseadamsio.vscode-theme-neon-night
👍
My theme is really good the only downside is that str are kinda grey but comments are grey so epic
Y'all inferior

anyways, #editors-ides again
Anybody got any command ideas so when i wake up tomorrow i can do something🕴️
Music commands ?
Ah yes
Using youtube_dl of course

a command which kicks all such users who didnt vote your bot
Yes. 
a levelling system
Make something original
Why am i asking for commands when tomorrow i need to learn sql🕴️
In that case...
Notes command would be ok aswell
No🚶
I think im going to make a notepad/bm command
why am i getting a keyerror but the item exists in the dict
my bot is way too dependent on database
how do u know it exists ?
Because it doesn't exist
it does
maybe ur using wrong dict
im not
what key does it give keyerror on
level
Im still crying because i dont have a eval command🚶
just use jsk
jishaku
A discord.py extension including useful tools for bot development and debugging.
well try restarting bot
Thank you guys now i will cry more🚶
or cog
When you use .find(), doesn't it return an array back?
it does
only if there is 2+ items as far as i remember code
hm
same error but its 0 now
how about you print the data you have ?
by data i mean object ur using to get those level from
Nope, always does return an array
okay
oh okay
Ignoring exception in on_message
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/disnake/client.py", line 505, in _run_event
await coro(*args, **kwargs)
File "/home/runner/bonbons-1/cogs/levels.py", line 36, in on_message
next_rank = data['level'] + 1
KeyError: 'level'
{'_id': 656073353215344650, 'level': 0, 'xp': 7}
data looks fine to me
😭
@slate swan GOT IT TO WORK THANK YOU SO MUCH
Used find_one or find
?
Print it?
i am using find_one, im just using find in eval
ok
Guys Please Help Me With Code I Cant Use Commands And Slash Commands At A Time But I Want To Use It At A Time Only! Any Fix? Code:- https://paste.pythondiscord.com/ulafemezel.py
same issue
how about you send the whole code around it so we can see what is wrong better ?
data = await self.db.find_one({'_id': message.author.id})
base_xp = randint(1, 5)
if not data:
await self.db.insert_one({
'_id': message.author.id,
'level': 0,
'xp': base_xp,
})
if data:
new_data = await self.db.find_one({'_id': message.author.id})
next_rank = new_data['level'] + 1
new_xp = data['xp'] + base_xp
if new_xp >= self.levels[str(next_rank)]:
await self.db.update_one(
{'_id': message.author.id}, {"$set": {"level": next_rank, "xp": 0}}
)
``` okay ig
damn codeblock in phone is pain to read
shrug
Question in jsk what happens when you run a given code were does it run your shell right and what happens if you get given a malicious code will jsk limit it or smth?
i dont think it will
sudo rm -rf / would delete all if sudo password was cached
malicious code will not be filtered
thats why jsk is owner_only
Is that default?
rip
yes
yes
Only i can use it?
and whoever you registered as owner, either in code or app
Thank you guys
Wdym exactly?
🚶
!d discord.ext.commands.Bot read this 🙏
class discord.ext.commands.Bot(command_prefix, help_command=<default-help-command>, description=None, **options)```
Represents a discord bot.
This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") you can do with this bot.
This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality to manage commands.
Oh you ment bot class🕴️
rip
I thought he ment something else but thx
we are the same
how can i get the guild avatar on on_member_join(member) event?
guild.avatar
!d discord.Guild.icon
property icon: Optional[discord.asset.Asset]```
Returns the guild’s icon asset, if available.
!d discord.Member.guild <=
The guild that the member belongs to.
thanks
i get TypeError: string indices must be integers. Why does it happen?
@client.command()
async def reroll(ctx, msg_id: int = None):
if not ctx.author == client.gw_trigger:
await ctx.send("Only the person hosting the giveaway can reroll it!")
else:
msg_to_reroll = await ctx.channel.fetch_message(msg_id)
msg_to_reroll.embeds[0].description["Hosted"]
if msg_to_reroll.embeds[0].title == "Giveaway ended!" or msg_to_reroll.embeds[0].title == "No one reacted and the giveaway ended!":
await ctx.send("Can't reroll as the giveaway mentioned has ended")
else:
if msg_to_reroll.embeds[0].description.startswith("Hosted by"):
user_list = [
user for user in await msg_to_reroll.reactions[0].users().flatten()
if user != client.user
]
if len(user_list) == 0:
await ctx.send("Can't reroll as no one joined!")
else:
prize = msg_to_reroll.embeds[0].title
winner = random.choice(user_list)
win_embed = discord.Embed(
title='Giveaway rerolled!',
description=
f'Hosted by - {ctx.author.mention}\nWinner - {winner.mention}\nPrize - {prize}',
colour=ctx.author.color)
await msg_to_reroll.edit(embed = win_embed)
else:
await ctx.send("Please provide the message ID of a valid giveaway")
this is my code
msg_to_reroll.embeds[0].description["Hosted"]
what are you trying to do here?
!d discord.Embed.description || its an str
The description of the embed. This can be set during initialisation.
how to get discord presence in pycharm
Install the plugin
Here you can find the link to the plugin https://plugins.jetbrains.com/plugin/10233-discord-integration
ok
no problem
Very cool plugin
why
class MyNewHelp(commands.MinimalHelpCommand):
async def send_bot_help(self, mapping):
destination = self.get_destination()
print(mapping)
embeds = []
print(embeds)
for page in self.paginator.pages:
emby = disnake.Embed(description=page)
print(emby)
print(embeds)
print("Is this even ran?")
embeds.append(emby)
print(embeds)
await destination.send('test', view=EmbedPaginator(self.context, embeds, timeout=180))
``` this is what I currently have, but it does not print anything/paginate the embed, why?
Its a plugin for pycharm for discord integration, its very good
i only came here to see what you all are up to with discord bots, i need ideas :c
command ideas?
what does emby print
nothing
💀
there is nothing being print, even the text is not printed
embeds list is empty???
nothing is printed
what
nah he has a debug print statement for his new subclassed help command
I mean, even this is not printed ```py
print("Is this even ran?")
try debugging the code
guys how do you think this code should be improved:
@bot.command()
async def eliminate(ctx, member: discord.Member):
guild = member.guild
SSCompetitor_Role = guild.get_role(919570782185750578)
if ctx.channel.id == 919563757204693103:
if guild.get_role(919571300467474543) in ctx.author.roles:
if guild.get_role(919570782185750578) in member.roles:
await member.remove_roles(SSCompetitor_Role)
await ctx.send("{0} was eliminated! R.I.P".format(member.name))
else:
await ctx.message.delete()
with bunch of print statements?
what's the error
there is no tracebacks
ig
💀
did u try the help command?
it sends the embed, yes but no pagination
useless var
which 💀
maybe you should take your own advice
read your own code, there isnt any other variable in there except guild
what advice
try debugging the code
why would I need to debug that? it already has an error
no
@boreal ravine super sorry to bother you but could you please help, my friend said he couldnt find any issue
@manic wing super sorry to bother you but could you please help, my friend (kayle) said to ask you
does it error? do you have emoji intents?
try print(bot.get_emoji(id))
- No
- I don't think I gave my bot emoji intents cause I didn't know it was a thing

give it emoji intents :troll:
do intents=discord.Intents.all()
do i do
from discord import intents first?
no
its unnecessary to do that
still no errors but still no emojis
i put the intent thing under
token =
you sure it's the right emoji I'd?
since you told earlier you just got the code from a GitHub repo

man i said that like yesterday or this morning how do u still remember

Idk , avg IQ maybe
its ID, I'd stands for "I would"
https://cdn.discordapp.com/emojis/919622543877501008.png?size=160
919622543877501008
is the id. , In the code too?
I'm aware , my phone's autocorrect changes it
lol
@slate swan 919622543877501008 this is the id for the emoji , use it
You just provided a wrong id
weird
for me when i copied id
it's 919859281661141015
how did you copy it?
@slate swan still no emojis 
restarted the bot?
Emoji is in int form?
Bot is in the server emoji is from?
You didn't update the emoji Id yet
lmao isn't that still the wrong I'd...?
Id*
good luck
yes.
making a help embed paginator is confusing af
Traceback (most recent call last):
File "c:\Users\phoen\OneDrive\Desktop\screenshot expiremtnt\screenshot.py", line 5, in <module>
driver = webdriver.Chrome()
File "C:\Users\phoen\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 70, in __init__
super(WebDriver, self).__init__(DesiredCapabilities.CHROME['browserName'], "goog",
File "C:\Users\phoen\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 93, in __init__
RemoteWebDriver.__init__(
File "C:\Users\phoen\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 268, in __init__
self.start_session(capabilities, browser_profile)
File "C:\Users\phoen\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 359, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "C:\Users\phoen\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 424, in execute
self.error_handler.check_response(response)
File "C:\Users\phoen\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 247, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary```
How to solve thiss
Damn my bot is in 90 servers now
Not related to a discord wrapper but seems like the module can't find the chrome exe
still flagged?
class MyNewHelp(commands.MinimalHelpCommand):
print("Is this ran?")
async def send_bot_help(self, mapping):
print("Is the function called?")
destination = self.get_destination()
print(mapping)
embeds = []
print(embeds)
for page in self.paginator.pages:
print("Is the loop ran?")
emby = disnake.Embed(description=page)
print(emby)
print(embeds)
print("Is this even ran?")
embeds.append(emby)
print(embeds)
await destination.send(embed=emby)
a = EmbedPaginator(self.Context, embeds=emby, timeout=180)
await a.start()
``` I had a print statement for every other line and nothing was printed
I made it look like this, and this still sends the embed```py
class MyNewHelp(commands.MinimalHelpCommand):
print("Is this ran?")
async def send_bot_help(self, mapping):
print("Is the function called?")
;-; this is way too confusing
does anyone have a bot with a button i could test because i wanna know if buttons work more than once, cause right now it seems like it only works once..
Hmm
I have a bot command that has buttons
can u dm me a server it's in along with the command
oh you wanted to test it..?
i just wanna know if the button works more than once because for me it only works once..
well they do for me, and I can't invite you to that server

wdym by "well they do for me"
wtf
uhh? They told that their buttons works only once and wanted to tets it on my bot, but I'm unable to invite them to my testing server and just said that for me the buttons works for more than 1 time
can i invite the bot?
it can be built from source but that part of code is not open sourced as it's just a test command
wait one second let me see if this exists
how to make @bot.command() function only i can use

add a if statement to see if ctx.author id is your id or make a decorator
give yourself a special role nobody can get and then do
@commands.has_role("role_name")
can i do with my user id ?
are you the owner of the server you're testing in
ya
@discord.ext.commands.is_owner()```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that checks if the person invoking this command is the owner of the bot.
This is powered by [`Bot.is_owner()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.is_owner "discord.ext.commands.Bot.is_owner").
This check raises a special exception, [`NotOwner`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NotOwner "discord.ext.commands.NotOwner") that is derived from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
do @commands.is_owner() 🚎
ok
await ctx.send(embed=embed, components=[
[Button(style=ButtonStyle.grey, label="Refresh", emoji=bot.get_emoji(919862920551219200))]])
interaction = await bot.wait_for("button_click", check=lambda i: i.component.label.startswith("Refresh"))
await interaction.send(content=value=f"```py\n{round(bot.latency * 1000)} ms```")
@is_owner.error
async def is_owner_error(ctx, error):
if isinstance(error, commands.MissingPermissions):
await ctx.send("u cant use that") ```
why this not working
Can’t*
why'd you think it was is_owner at first, is_owner is a decorator, not a command 💀
;-;
Please help
your code is too dirty to read, sorry ,-,
Idrk if it's flag tbh. If I don't get a response till Wednesday, then imma assume it's flagged
which library you using
U need to pass those buttons to a kwarg, like u do with embeds
Wait, that's discord.py?
That's totally not the way how u do it
view = View(...)
view.add_item(Button(...))
await ctx.send("Button Incomming!!!", view=view)
!d discord.ui.View
class discord.ui.View(*, timeout=180.0)```
Represents a UI view.
This object must be inherited to create a UI within Discord.
New in version 2.0.
!d discord.ui.Button
class discord.ui.Button(*, style=<ButtonStyle.secondary: 2>, label=None, disabled=False, custom_id=None, url=None, emoji=None, row=None)```
Represents a UI button.
New in version 2.0.
discord.ui is a part of discord.py, not an external lib
discord.ui is part of dpy 2.0
pip install -U git+https://github.com/Rapptz/discord.py
discord.ui is for buttons only
What are you trying to do?
you also have dropdowns
discord.ui.button(*, label=None, custom_id=None, disabled=False, style=<ButtonStyle.secondary: 2>, emoji=None, row=None)```
A decorator that attaches a button to a component.
The function being decorated should have three parameters, `self` representing the [`discord.ui.View`](https://discordpy.readthedocs.io/en/master/api.html#discord.ui.View "discord.ui.View"), the [`discord.ui.Button`](https://discordpy.readthedocs.io/en/master/api.html#discord.ui.Button "discord.ui.Button") being pressed and the [`discord.Interaction`](https://discordpy.readthedocs.io/en/master/api.html#discord.Interaction "discord.Interaction") you receive.
Note
Buttons with a URL cannot be created with this function. Consider creating a [`Button`](https://discordpy.readthedocs.io/en/master/api.html#discord.ui.Button "discord.ui.Button") manually instead. This is because buttons with a URL do not have a callback associated with them since Discord does not do any processing with it.
Error please
Install git
No
If it's a linux terminal
You can
Not possible in windows cmd
If it's a debian based disro
sudo apt install git-all```
Basically helps you with everything related to github
noo
This IG
pip install -U git+https://github.com/Rapptz/discord.py
What's the error
You have discord.ui that's an invalid syntax error
what's time.sleep for discordpy?
await asyncio.sleep(-) ?
Yeah
Because it’s blocking, asynchronous code won’t act properly with it since time.sleep stops everything rather than freeing up the event loop
Cz it blocks the whole bot
!blocking for more information (:
Why do we need asynchronous programming?
Imagine that you're coding a Discord bot and every time somebody uses a command, you need to get some information from a database. But there's a catch: the database servers are acting up today and take a whole 10 seconds to respond. If you do not use asynchronous methods, your whole bot will stop running until it gets a response from the database. How do you fix this? Asynchronous programming.
What is asynchronous programming?
An asynchronous program utilises the async and await keywords. An asynchronous program pauses what it's doing and does something else whilst it waits for some third-party service to complete whatever it's supposed to do. Any code within an async context manager or function marked with the await keyword indicates to Python, that whilst this operation is being completed, it can do something else. For example:
import discord
# Bunch of bot code
async def ping(ctx):
await ctx.send("Pong!")
What does the term "blocking" mean?
A blocking operation is wherever you do something without awaiting it. This tells Python that this step must be completed before it can do anything else. Common examples of blocking operations, as simple as they may seem, include: outputting text, adding two numbers and appending an item onto a list. Most common Python libraries have an asynchronous version available to use in asynchronous contexts.
async libraries
The standard async library - asyncio
Asynchronous web requests - aiohttp
Talking to PostgreSQL asynchronously - asyncpg
MongoDB interactions asynchronously - motor
Check out this list for even more!
how do we get tht "this message can only seen by you"
ephermal
NVM didn't find any
Just add ephemeral = True kwarg
While responding to interaction
like await ctx.send("blablablalbla", ephemeral=True)?
You can't use it with ctx.send
ephemeral messages can only be used on interactions
oh..
buttons and reactions?
Yup
Something like this
await interaction.response.send_message('Example', ephemeral=True)```
ahh makes sense...thenks a lot
:)
dumb question, how do i create a channel under a specific category
for member in members:
try:
await member.add_roles(role, reason=reason)
except discord.HTTPException:
failed += 1
m = member
await ctx.success(f'Muted {m} members.\n')
```this does not send all the members but it only send 1 member whyy?
await ctx.success?
because you do it for a single time , the await ctx....... is not inside the loop
!d discord.CategoryChannel.create_text_channel
await create_text_channel(name, **options)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
A shortcut method to [`Guild.create_text_channel()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.create_text_channel "discord.Guild.create_text_channel") to create a [`TextChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.TextChannel "discord.TextChannel") in the category.
also i dont know what .success is , you use some fork with that method?
I fcking hate flask
that will send 10 messages if i mentioned 10 ppl lol
this does not send all the members but it only send 1 member whyy? , what did you mean here then?
you want to send all members in a single message?
ya
use .join on member.name for all items in member list
if i wanted to create a voice channel under the category 'x', what do i type after the comma in await ctx.guild.create_voice_channel("name", )
category = CategoryChannel
thanks
wait would that be the category name as a str or its id
it would be CategoryChannel object
you can get it using bot.get_channel(id)
example : py await _ctx.guild.create_text_channel(name='m', category = _bot.get_channel(919888933880487976))
awesome, but what if i had the bot create a category and then under the same command, create a text channel under that category, how would i get the id of it
category = # create category channel here
await _ctx.guild.create_text_channel(name='m', category = category)```
easier
wonderful, thanks so much :D
yw

in the link @tawdry perch

You have opened [ but never closed it?
Why would I even use others token smh
Uh?
idk which part im supposed to close it in
wdym?
NTG
If you open [ close it as well, I have no idea where are you supposed to close it because I have no time to read it completely
i left that server 2 minutes ago BECAUSE I F"U"CKING ASKED THEM FOR HELP THEN THEY'RE LIKE: Rule 11, figure out the error urself
LMFAO why even use discord-components when you got views in dpy 2.0

wots that
discord.py 2.0
noooo 27% battery remaining and i dont have a charger
It allows you to create buttons
can u tell me a way to check my dpy version?
Just install the lib
It will show you the version
You need to install 2.0 from github
Yup
No
pip install -U git+https://github.com/Rapptz/discord.py```
i did pip install discord.py
This @slate swan
if i was to do category perms, would it be better to do set_permissions() or use overwrites
C:\Users\ADMIN>pip install -U git+https://github.com/Rapptz/discord.py
Collecting git+https://github.com/Rapptz/discord.py
Cloning https://github.com/Rapptz/discord.py to c:\users\admin\appdata\local\temp\pip-req-build-xp6o41bk
Running command git clone -q https://github.com/Rapptz/discord.py 'C:\Users\ADMIN\AppData\Local\Temp\pip-req-build-xp6o41bk'
Resolved https://github.com/Rapptz/discord.py to commit 45d498c1b76deaf3b394d17ccf56112fa691d160
ERROR: Error [WinError 2] The system cannot find the file specified while executing command python setup.py egg_info
ERROR: Could not install packages due to an OSError: [WinError 2] The system cannot find the file specified
WARNING: You are using pip version 21.2.4; however, version 21.3.1 is available.
You should consider upgrading via the 'C:\Users\ADMIN\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\python.exe -m pip install --upgrade pip' command.
C:\Users\ADMIN>
C:\Users\ADMIN>
!d discord.ext.commands.guild_only
@discord.ext.commands.guild_only()```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that indicates this command must only be used in a guild context only. Basically, no private messages are allowed when using the command.
This check raises a special exception, [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") that is inherited from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
oh cool this exists
WTF
!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.
if you use overwrite , you can do that right while making the channel , if you use set_permissions , you'll be making another api request
It's code shit
does any1 know how to modify this code to make it so that the bot responds to the command passed AFTER pinging it?(ignore the mongodb stuff at the start)
@client.event
async def on_message(message):
pcol = mdb["prefix"]
if client.user.mentioned_in(message) and message.mention_everyone is False:
result = pcol.find_one({"guild_id": message.guild.id})
result = result.get("prefix")
await message.channel.send(f"My prefix is ``{result[0]}``")
elif client.user.mentioned_in(message) and message.mention_everyone is False:
await message.channel.send(f"My prefix is ``!``")
await client.process_commands(message)
First pip uninstall discord
Then try reinstalling the git version
You can still use that format for output like that..
Could someone vouch for him cause something tells me that’s a command to uninstall discord app
dies
bruh are you that dumb?
yea!
pip is a package manager for python
BWAHHAHA I am sceming you it's a command to uninstall discord you are right
so it will delete discord.py(which is the module that you import at the start of your file)
oo my discord py is 1.7.3
not the discord app
bro what
Exactly
ok
Imagine pip uninstalling discord(app)😂🤣
igs he's confused between the sudo apt thing(sorry i dont know the command, i dont use linux)
C:\Users\ADMIN>pip install -U git+https://github.com/Rapptz/discord.py
Collecting git+https://github.com/Rapptz/discord.py
Cloning https://github.com/Rapptz/discord.py to c:\users\admin\appdata\local\temp\pip-req-build-gzkez5fi
Running command git clone -q https://github.com/Rapptz/discord.py 'C:\Users\ADMIN\AppData\Local\Temp\pip-req-build-gzkez5fi'
Resolved https://github.com/Rapptz/discord.py to commit 45d498c1b76deaf3b394d17ccf56112fa691d160
ERROR: Error [WinError 2] The system cannot find the file specified while executing command python setup.py egg_info
ERROR: Could not install packages due to an OSError: [WinError 2] The system cannot find the file specified
WARNING: You are using pip version 21.2.4; however, version 21.3.1 is available.
You should consider upgrading via the 'C:\Users\ADMIN\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\python.exe -m pip install --upgrade pip' command.
C:\Users\ADMIN>
As a matter of fact you can't use apt(Automatic Package Transfer (Linux Advanced Package Manager)) to install discord(app)
yes, i did uninstall first
You uninstalled first?
- py -m pip uninstall discord
- install from the repo
or just use a fork, idk why you wanna use the og one, its not gonna be updated too
(same steps to install a fork)
or don't
They just want buttons
Why convert to fork?
py-cord is a pretty good fork ngl
Whose slash commands are still unstable lmao
because they are being updated with the latest features
He doesn't want those feature so don't suggest things he doesn't want
never encountered probs with that, but other features are pretty cool tho
It still suffers with user and message interaction commands
lol
their support is better compared to other forks tho
but before it was the opposite
They are famous just due to youtube nothing else
YouTube made PyCord famous
i remember once when i went to the nextcord server to get help for py-cord and it actually worked lmao
is there a way to check if i have the file ( just wanna make sure if i downloaded it correctly )
I asked help for disnake in dpy and it works too lol
and then a few weeks later i admitted to that in the py-cord server, then turns out there was a nextcord mod lurking in the chat, and 2 secs later i got banned frm nextcord
i asked help for dpy in py and it works too lol
lmfao rubbish logic of his
yeah because its a fork
.
They all are connected with dpy 2

<:emoji_name:emoji_id>
whats the official way of creating discord bot without using any library?
Using API IG
why would you not use lib?
but how?
you will need to use modules
botghost or someth
Just pull request from discord API
You can use the api.


yeah
Very shit idea
i ll make my own api wrapper?
if you use API you will still use request modules etc?
Make it ATB
making a bot without using a lib is already a shit idea, might as well make it worst
Never do that
what?
i ll use aiohttp
Use socket and create everything from scratch
C:\Users\ADMIN\PycharmProjects\Fluxo>python main.py
File "C:\Users\ADMIN\PycharmProjects\Fluxo\main.py", line 28
[Button(style=ButtonStyle.blue, label="Refresh", emoji=bot.get_emoji(919862920551219200)), Button(style=ButtonStyle.red, label="Delete", emoji=bot.get_emoji(919862920551219200)))]]
^
SyntaxError: closing parenthesis ')' does not match opening parenthesis '['
takes just few minutes
It's not I use raw API requests for everything instead of handling events
well, but how?
Just read the docs IG
take a look at the API docs
pls i've been stuck here for about 2 hours i just wanna get this over with
isnt aiohttp for web scraping?
WTF
what?




you didnt start yet?

read the bottom for issue

