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-bots
1 messages · Page 840 of 1
Hec
yes it was
How u know
Disabled?
i ask coder and youtubers coder of bot they tell me
disabled disables it prolly
Who told u
so many yt

😑
sure
Tell his name who tells js is hard
guild = await bot.get_guild(915357451484790916)
TypeError: object NoneType can't be used in 'await' expression```
anyone got as solution
your guild is returning None
no idea
It doesn't need to be awaited
Yes
No
Because its never worked for me. It's just broke all the time when I tried to implement it there
It say nonetype
But it’s a coroutine?
await guild.unban(member_real)
AttributeError: 'NoneType' object has no attribute 'unban'```
NEZHA 69
Code pls
It shows the error for trying to await it
!d discord.ext.commands.Bot.get_guild
get_guild(id, /)```
Returns a guild with the given ID.
@tasks.loop(seconds=5.0)
async def tempbancheck(self):
for i in range (0, len(Scammer_Items)):
for x in Scammer_Items[i]:
if Scammer_Items[i][x]['Expired'] == True:
pass
else:
unban_date = Scammer_Items[i][x]['Date Expiration']
formatted_time = datetime.datetime.fromisoformat(unban_date)
if formatted_time < datetime.datetime.now():
member_real = await bot.fetch_user(x)
guild = bot.get_guild(915357451484790916)
await guild.unban(member_real)
print("unbanned")
Scammer_Items[i][x]['Expired'] = True
json.dump(Scammer_Items, open("./Cosmic overground/punishments.json", "w"), indent=1)```
the no profile people take over
!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.
USE CTX ARG
!course
thanks but
The issue is with that you can’t use await syntax with something returning None
!course python
self , ctx
!resources
Resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
Exactly, yet it still doesn't need to be awaited
No it's not
But try removing the await and see if it works I guess
Ye I saw from the command
@nimble plume
It'll probably return None if the guild wasn't found in cache
If you don't know how to help, don't
Alright.
🗿
get_channel also isn't a coro

!d discord.Guild.get_channel
get_channel(channel_id, /)```
Returns a channel with the given ID.
Note
This does *not* search for threads.
See
guys i try add emoji to button and
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: Object of type Emoji is not JSON serializable```
Code?
await client.get_channel(int(channel_id)).send(embed=embed, components=[[Button(style=ButtonStyle.grey, emoji=pipa, label=f"Done {reportemoji}", custom_id="button_r_d")]])
await member.send(embed=embed2)
the fuck
Wha
oh
Lol
What is this

Lolll
that’s what I’m saying
I know what it is @final iron lmao, it doesn't wait for on_ready so the guild doesn't load before it checks the first time
It's cursed
what
Belongs in #esoteric-python
actually such a annoying error
Ye
Rip
so its this the code and discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: Object of type Emoji is not JSON serializable
Not using variables can really ruin the readability of code. This is a prime example of that
^

looks like a fucking CST or something

It's unreadable
Is it possible to mention a user in an embed?
Yes
if u dont use emoji in the code its this:
ok
!d discord.Member.mention
property mention: str```
Returns a string that allows you to mention the member.

@hardy venture

@nimble plume i search video of code with harry but so many video coming of python which video this
not in title/field name, and it won't actually ping them
1o
And in footer
Never tryed
i dont think so
await send(f"{member.mention}", embed=embed)
what

just say member.mention
In embed*
it is but thats what the bot is sending
then only in description i think u can use mention @nimble plume
@nimble plume give me video in dm
Yes
99% of my embed they only use description xD
^ anyway it's irrelevant because it won't ping them
Mine uses title for some reason
Ohk..
in description it works
send
whats the best way to deal with the problem of dming users with dms turned off?
description = f""
description += f"more data text {var}"
em = Embed(description=description, colour=dh.color["blurple"])
await ctx.send(embed=em, delete_after=20)
``` 99% of my embeds looks like this
Claim a help channel
Woah blurple
anyone dealt with this
i prefer color from rgb
🟦 + 🟪 = 💥
i used to do websites so hex is in my head xD
You can't DM them
Im thinking of adding delete after
You can't do anything about it
well you can use a try except, if bot can't dm raises exception, otherwise you can't dm someone with dms closed
yeah but how do I bypass the error in the best way so it just runs the other code
oh god
try except block
is there no like global way I can deal with it? cause I really dont wanna go edit every command
😭
and i have this in a file that i import
# Colors for embeds
color = {"blurple" : 0x7289DA, "green" : 0x33ff57, "yellow" : 0xFFD300, "red" : 0xB22222}
def embed(title="", description="", url="", colour=None):
em = disnake.Embed(title=title, description=description, url=url, colour=colour)
return em
Use ctrl + f2
!d discord.ext.commands.Bot.on_command_error
await on_command_error(context, exception)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
The default command error handler provided by the bot.
By default this prints to [`sys.stderr`](https://docs.python.org/3/library/sys.html#sys.stderr "(in Python v3.9)") however it could be overridden to have a different implementation.
This only fires if you do not specify any listeners for command error.
why your bot dms the user on every command
¯_(ツ)_/¯

Huh
channel = client.fetch_channel(944270496659279882)
msg = await channel.fetch_message(944461110717841448)
thats my code, and this is the error messsage
Unhandled exception in internal background task 'updateMessage'.
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/tasks/__init__.py", line 168, in _loop
await self.coro(*args, **kwargs)
File "main.py", line 33, in updateMessage
msg = await channel.fetch_message(944461110717841448)
AttributeError: 'coroutine' object has no attribute 'fetch_message'
won't this still just like messahe up the code
like it wont run the part after
You missed an await
fetch_channel() returns a coroutine object, you need to await it
@nimble plume which i watch 1 year or 6 months
ty
1
@frank tartanwhen u get AttributeError: 'coroutine' its you forgot use await
what
1 year
Ya
ok
!ot @slate swan @nimble plume
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
You're just clogging up the channel
Im not he is pinging me
why u ping me
Move to the off topic channel
why
You're clogging up the channel
Ok ill ignore him
ok
how to make on_member_join only work on one server.
what?
ctx.guild? on_member_join doesnt take ctx
yeah i just figured
check if member.guild = your guild variable
Check the guild ids
you can do
if member.guild.id != 1234:
return
or that, yeah
What is 1234?
the guild id 
1234 aint a guild id, its just an integer
the guild id is an integer
but thats not a guildid just integer
bro
def function(self,arg1,arg2,arg3,arg4,arg5,arg6) --> None:
@client.command()
async def hallo(ctx):
await ctx.send("hello", components = [Button(label="Hi", style="3", emoji="✅", custom_id="button1")])
interaction = await client.wait_for("button_click", check=lambda i:i.custom_id=="button1")
await interaction.send(content = "Button clicked", ephemeral=True)```
Emoji ERROR:
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In components.0.components.0.emoji: Only dictionaries may be used in a ModelType```
they probably meant that it isn't a valid guild ID

!function hi i a m n o t h i n g
@nimble plume #bot-commands
Yes ik lol
well, it wasn't meant to be lmao since it was just an example
yeah
@honest vessel i know 😑
anybody?
In components.0.components.0.emoji: Only dictionaries may be used in a ModelType
pass a dict?
when i get the reactions of a message with ```py
msg.reactions.users
any chance that someone could help me with a bot I'm creating? I want it to change people's nicknames if they are connected to the voice channel if that is possible. I already have a way of getting the user IDs of everyone connected, just can't figure out how to mass change the nicknames
for loop them
or edit their nicks when they join vc
@radiant rampartthis how u change a nick tho,
await user.edit(nick="new nick")```
this how i do for my afk function
await user.edit(nick=str(user.display_name)+str(" (afk)"))
so I just put this under my for member in users: line?
users is channel.members
yeah, py for member in users: await member.edit()
if you want to change them all sametime sure, but if you want it to automaticly change their name when join a vc, or leave it n change it back you will need use an event that runs when a user joins a vc
await member.ban()
i can use that to change the nick of all my members in the server
and just wait ur bot getting kicked XD
? kicked by who
if it's my server
administrator
lol
sure can
its gonna be api-blocked
just 2,4k members
well put a sleep n it will work
how long are the api bans
iirc 15-20 mins, might be wrong
I doubt more than 30 people will be in my voice chats anyway
u can asyncio.sleep()
why u wanna change their names tho?
fun
i mean for his vc stuff
yeah honestly
i change their nicks adds (afk) to it and removes it when they use afk command again, only reason i see change name is usefull
why doesn't case_insenstive=True, work in prefixes?
cause u spell wrong
the only utility i see is to check if the user has unpingable name so the bot change it
case_insensitive=True
super odd, bot is saying that it’s missing permissions but it has manage nicknames
💀
maybe you are missing permissions 
lol
it cant change your name if you have higher role than bot
ah
why i made bot owner of server so afk command works on me 😄
it still doesn't work oof
bot = Bot(command_prefix="e!",
case_insensitive=True,
intents=Intents.all(),
test_guilds=[821619777419739147],
help_command=None)```
you're right( i haven't made a use for it yet) but still can't get case insensitive to work duh
i imported Bot from disnake.ext.commands
You can explicitly import it
it worked some days ago... couldn't figure out why it doesnt work now
it should work tho
ima ask in disnake server
you sure your bot disconnects when u closes it
so you dont run an old instance of it in background
cause you can run multiply bots
@honest vessel odd, I just tried testing it on my alt account and it just does nothing now? not even an error
I made sure the bot’s role was higher than the ones on my alt account
can u post ur code of whole command?
sure I’ll dm it to yoy
ok
@scarlet rune how are you typing out the command?
are you typing E! command_name or E!command_name?
what is disnake?
its a lib
!pypi disnake | fork of dpy
E!command
the same as e!command
ok try e!COMMAND
uh it worked, i suppose i should make E! as prefix?
🙂 yes
aight then oof
you can add e! and E! in a tuple and set that as ur command prefix
wtf font does discord use
i tried whitney and one other to try and get character widths
using pillow and measuring size
did not work
what are you tryna do
jwK'FIp@x'
'NvWh^s=-e
RNs@V=j||Q
C]S^'%:Q%!
these strings should all be equal length for example
i'm trying to add dashes to some strings so they're equal i.e.
text here - - - - - - - - - - - - - something here
something here dif size - - - another thing here
i may just go through and do everything manually this is dumb
https://stackabuse.com/formatting-strings-with-python/ formatting strings perhaps?
with my rpg bot im making i got this error and i have no idea what it means. i added this command and it all stopped working, but it's fine without it:
how strange
me?
me?
yes
kk
can you use text alignment in an embed? that would save a lot of hastle
you overwrote the built in function open with your open command
@bot.remove_function("open")
?
What
or just change the name
change the name
kk
_open if you want to keep it named that
here
paste me the first few lines of that command including the decorators
Use the name kwarg in the decorator
^^!
im just doing chest_open
you can keep it as name if you want
Guys how can i make this command send a normal not in "only u see this"?
@client.command()
async def hallo(ctx):
await ctx.send("hello", components = [Button(label="Hi", style="3", custom_id="button1")])
interaction = await client.wait_for("button_click", check=lambda i:i.custom_id=="button1")
await interaction.send(content = "Button clicked", ephemeral=True)```
but the func name can't be that
ephemeral=False
Remove the ephemeral=True
ty so much
!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/master/api.html#discord.Game "discord.Game")
• [`Streaming`](https://discordpy.readthedocs.io/en/master/api.html#discord.Streaming "discord.Streaming")
@full lily thx so much that thing was rly breaking everything
ah 👍
this button why so slow? and not work in 5/10 time
How do i make a soccer command in discord.py
ill recommend usingndpy 2.0 or a fork
ok, im using keep_alive and uptime robot, but im getting this error:
it works on my other bot but not this one
any idea why this is?
install flask
as a package?
yes
ok
package manager > install
^^
imagine if all python packages(modules) was already installed
pl0x dont fill my HDD
it stil wont import flask tho cause u havnt installed it 😄
i did
python downloading pip modules if module not found 😎
is this the full traceback?
str(role.mention)
the mention is already a string...
I'll shorten it for you
roles = []
for role in member.roles:
roles.append(str(role.mention))```
to
```py
role_mentions = [role.mention for role in member.roles]```
That is irrelevant to the error
The error is from passing an invalid formatter to strftime
true and not shown in the given error
What do you mean it's not shown
the traceback doesn't contain the line
Their f-strings are fine, that rules them out. What is left is the stftime
The error specifically mentions invalid format string
I'd suggest the discord built-in timestamp
My discord bot is sending a huge message by getting info from end point how do I sent as txt file without creating txt file
So it sends the txt file straight to channel without saving to pc to save storage
BytesIO is what you're probably looking for
Does it save file to pc
See it’s getting all info from an api but message is too big
nope, saves as buffer
doesn't have to be saved locally
from io import BytesIO
# if you have an image or anything that saves to a stream
buffer = BytesIO()
im.save(buffer, "png") # 'save' function for PIL, adapt as necessary
buffer.seek(0)
# if you have some bytes
buffer = BytesIO(my_bytes)
# if you have some text
my_text = "Don't do drugs kids"
buffer = BytesIO(my_text.encode("utf8")) # change encoding as necessary
await ctx.send(file=discord.File(fp=buffer, filename="whatever.png"))```
example with image ^^
Ok
can tell me why this code make other commands be executed twice?
@commands.Cog.listener()
async def on_message(self, message):
if message.author == bot.user:
return
if message.author.id == owner_id:
emiliasalute = ["Hey Emilia, you there?", "Hey emilia, you there?", "You there emilia?"]
answers = ["Hey, I'm here!", "I'm here!",
f"I'm here {message.author.name}!",
f"{message.author.name}, I'm here!",
f"Hey {message.author.name}, I'm here!"]
if message.content in emiliasalute:
emiliasalute = "https://cdn.discordapp.com/attachments/944600993788731432/944601384500723762/emilia_salute.gif"
ownerreact1 = disnake.Embed(color=ecolor)
ownerreact1.set_image(url=emiliasalute)
await message.reply(random.choice(answers), embed=ownerreact1)
elif message.content == 'ping':
await message.reply(f':ping_pong: pong! ({round(bot.latency * 1000)} ms)')
print("bot pinged;")
elif message.content == 'peng':
await message.reply(f':ping_pong: pang! ({round(bot.latency * 1000)} ms)')
print("bot pinged;")
await bot.process_commands(message)```
remove await bot.process_commands(...)
cogs handle that for you
its not making an event, just a listener
ah i see, i thought it's the same as event
no
you can only have one event, but multiple listeners
event = bad | listener = good
aye, okay okay thanks i didn't know that!
I highly suggest you to start using discord timestamps
He shouldn’t be using that
Example:
<t:1420070609>
Isn’t that a bit nicer?
<t:your_timestamp>
So your_timestamp should be the created_at timestamp
well, it is, but, strftime isn;t wrong either it's about style ig 
Pastebin
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
He just ‘skips’ the error by implementing timestamp I’d say
There is all time stamps for discord
Discord docs exist
He only wants time stamps it makes his life 10x easier
i have this when someone joins my server and it looks fine to me
, though i need to rewrite the code because the second bot still runs on dpy 1.6.0 lmao so probably i will also switch to timestamp instead of strf
Na it looks clean
I made one for TikTok
yeah, that's the only advantage, looks more clean which is fair
Ye
@hoary cargo well I need to use it bc TikTok api uses it
They use unix
understandable
No. The timestamps also update depending on your region
<t:1645119398>
I’m using: from discord.commands import option but I’m not sure on module
This will not show 12:36pm for everyone
5:36pm
Only one problem it doesn’t work with code block
what's the format tho ddmmyy ? or
@final iron yk from discord.commands import option
Do you know module
I can’t find it
option?
No
What's discord.commands
I used it for / command but I don’t know module
Just use disnake
Traceback (most recent call last):
File "main.py", line 216, in <module>
bot.run(os.getenv("token"))
File "/home/runner/GDBot/venv/lib/python3.8/site-packages/discord/client.py", line 723, in run
return future.result()
File "/home/runner/GDBot/venv/lib/python3.8/site-packages/discord/client.py", line 702, in runner
await self.start(*args, **kwargs)
File "/home/runner/GDBot/venv/lib/python3.8/site-packages/discord/client.py", line 665, in start
await self.login(*args, bot=bot)
File "/home/runner/GDBot/venv/lib/python3.8/site-packages/discord/client.py", line 511, in login
await self.http.static_login(token.strip(), bot=bot)
File "/home/runner/GDBot/venv/lib/python3.8/site-packages/discord/http.py", line 300, in static_login
data = await self.request(Route('GET', '/users/@me'))
File "/home/runner/GDBot/venv/lib/python3.8/site-packages/discord/http.py", line 216, in request
raise HTTPException(r, data)
discord.errors.HTTPException: 429 Too Many Requests (error code: 0): You are being blocked from accessing our API temporarily due to exceeding our rate limits frequently. Please read our docs at https://discord.com/developers/docs/topics/rate-limits to prevent this moving forward.
172.18.0.1 - - [19/Feb/2022 18:36:24] "GET / HTTP/1.1" 200 -
im getting this what does this mean?
you spammed the API and now u blocked
i spammed what API?
Discord api
whats that?
That's requests for you
How discord works is off api
You sent too many requests (messages ect)
ok
You spammed the command or something ?
Your ip is black listed for a bit
ok
@fallow mauve what are you hosting on ?
i didnt even know what that is until now 😢
O
Understandable
You didn’t spam api
?
Someone else spammed api
It's irrelevant anyway since y'all suffer
No replit shares same ip so when someone spams api on repl everyone suffers
ok so someone out there killed my bot and everyone's that has its code hosted on repl.it
Imagine you go on replit just to troll and get everyone rate limited
😐
replit?
i hate them even though i dont know their name

i just got an answer
Someone hosted a bot on repl and spammed api they didn’t specify to just do your repl
replit shares ips so the whole ip got ratelimited lol
just make a new replit
most people make a new one and it fixes the issue
maybe it changes the ip im not quite sure
@fallow mauve
That should change ip
Yes
i just type kill 1?
theres a command to change your ip in replit?
Think so
or are you just trolling
Works for me
I’m not sure it works every time I get rate limited
🙂
ive never gotten ratelimited by the discord api lol
I have a lot
only the praw api
I use repl a lot
Sometimes I use vs code
why tho
Idk it’s just easy to use ide
Access from anywhere
bro what
vsc isnt quite hard
It’s not
I just prefer Replit layout
you have to be joking
- sometimes I like to code on phone
nah youre just trolling at this point
I’m not lmao
dont belive you at all
Hey, I was wondering if I could get the members banned by someone specific (from audit logs) and unban them
Let me guess you got nuked
!d discord.Guild.bans
await bans()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Retrieves all the users that are banned from the guild as a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`BanEntry`](https://discordpy.readthedocs.io/en/master/api.html#discord.BanEntry "discord.BanEntry").
You must have the [`ban_members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.ban_members "discord.Permissions.ban_members") permission to get this information.
Yup, exactly that
I don't want to unban everyone so I was wondering if I could somehow get only the people which got banned from nuking
Yes it’s possible
it returns a user obj just compare ids or names i recommend the snowflake
@jade bay await bans()
But what am I supposed to compare it to?
a snowflake?
I'm not entirely sure what a snowflake is
the id of the user is unique so its called a snowflake
hence a snowflake always being unique
oh, but how would I get the IDS of the people which got banned by the nuker?
no just iterate through the list and check the ids and if the id is correct as the nukers just use the pass statement
member = guild.get_member(member_real)```
anyone know why that returns none type?
member_real is prolly none
what is memeber_real
member_real = await bot.fetch_user(x)
There is a propriety which returns the user which banned the other user?
which prints as mictony#9857
!d discord.Message.author
get_member accepts only a snowflake
and not a user obj
It's not a message..,
it probably has that attr
The person that bans is who invoked the command, aka the message author
its not used by the bot
not sure what a snowflake is
but as soon as i sent that message I realised it gotta be a member_real.id
!d discord.abc.Snowflake
class discord.abc.Snowflake```
An ABC that details the common operations on a Discord model.
Almost all [Discord models](https://discordpy.readthedocs.io/en/master/api.html#discord-api-models) meet this abstract base class.
If you want to create a snowflake on your own, consider using [`Object`](https://discordpy.readthedocs.io/en/master/api.html#discord.Object "discord.Object").
needs to be an id 😭
@kindred drum
yes
ah
it accepts an int lol
snowflake = unique
yes
in this case the id is a snowflake
everyone has a snowflake
youll never see a user with the same ids
but @everyone has the same id as the guild
😔
why? cause? hash?
maybe like
ID=hash(email, ip)
something that way
maybe just email hashed
at first
nah i think discord just bounds them to the guild
Well, discord directly says they use twitters snowflake package
i dont know what better channel to ask in this server, its relevant to discord. so if u del account u can make new one on that email or need new email no matter?
That's how they generate unique IDs
if its on discord ill say that you already have an account on it iirc and that if you loging you enable it since discord deactivates the account first and then continues to delete it
if the account is deleted yes you can iirc
yes
good
i see no reason why you cant
now for sake sakes, i can tell u can put up ur own mailsever with domain and do like mymail1@mydomain.com -> acc mymail2@mydomain.com -> acc but u only have 1 legit email
redirect emails
im not sure if you can
i think so
You can just setup a gmail account and use dots
so they only allow certain email domains?
E.g one@gmail.com -> on.e@gmail.com all point to the same email
gmail hotmail etcyahooo
no no no u missing it
lets say u have one@gmail.com
thats ur gmail
but u buy a domain n put up a mailserv er that directs ur emails
u can create accounts n say acc1@mydomain.com
as email
but ur server only redirect it to ur one@gmail.com
they cant check that up
so you want a domain that redirects to another so spoof it?
so u can have 100000 emails on 1 domain
You don't even need to do all that though, is just fine
but all ur discord accounts has 1 email
These are counted as two different emails, but they point to the same email
Yea, which is what you just explained
or technical 1 and 1000
A redirection
out
i figured this out cause my idea was how u share email
witth one if u dont trust em
do a temp email
but u cant send em
but u can recive
if u send u gonna show its layers
so you want several accounts tied to one email but make allor of emails that get redirected to a domain and one password?
which one
better to return and keep things flatter but add an extra line or no 🤔
trying to make a lil more readable
Is this json
😤 look im self taught okay
oh i can't be using a database for the player saves
aren't we all
i experimented with that and it wouldn't work.
i could seperate the player save into a db and a dict but
half and half
Json is not a database, its a data format or a javascript object :/
That's why I said to not use it
Well you have jsonic dbs
So they are json too
Use json files instead to target what youre saying
Wat
umm lemme give you an example of the saves for map objects in the player dict
so if you can put that in a db good luck
Don't see why it would be a issue, just use something like mongo

yeah but why would you do it
Roflll
*dbs which work with dictionaries
Don't relate anything to json pls 💀
Uhh, whatever
Mongo uses JSON files /s
This is easy, you just create an array of types ```sql
CREATE TYPE foo AS (
bar varchar,
baz INT,
qux NUMBER(1),
)
CREATE TABLE foos (
data foo[]
)
If you were to use postgres you could also just add a JSON codec
And store it as JSON
isn't that just adding extra unnecessary steps
Which part
just, why would i move everything to a db, makes no sense with my data structure
Because there are some perks you get from using an actual DBMS than just a .json file
Don’t think all flavors of SQL RDBMS support list types
but I haven’t used all of them so idk
I’ve gone through docs of some and haven’t seen list types listed in the data typed
Almost all of them should, it's like a very basic necessity
I can say it does for postgres at the very least
i doubt it would be faster. I currently using a caching for 5 minutes whenever someone interacts so only the most recent are in the player dictionary.
yeah Postgres has them
Actually, most of the time databases are faster in querying then just your json file. But you also need to account for all the other things the a DBMS does that a .json file does not
You can also cache your queries
redis 😩
it wouldnt be though. if i have 10 players loaded into my dict vs searching through 1 million in a db
You must be under some kind of misconception clearly
^
imagine saying 1 million and having only 7 users
😆
Plus, for an example redis queries are usually O(1)
Nothing funny, json files are generally resource wasting too, it first of all reads all of the file, then writes all of it back when you dump stuff
That's constant time for getitem
My understanding of databases is very limited but i received opposite advice when explaining what i was doing to someone else, they basically said they see no compelling reason to use a db

Isnt that single person outvoted to 5 rn
I got a question, so i am developing a discord bot with discord.py, and now i wanna know in how many servers my bot is? Any suggestions
as many servers as it’s invited or added to
i think it's len(client.guilds) if i remember correctly
Use the len method on Bot.guilds or Client.guilds because it returns a list of the guilds it is in
thank you
Why do you waste braincells going so deep
if you have any specific reasons i'd want to use a db for my structure
Oh God, I'm not wasting my energy, so, use whatever you want
🗿
how could i make a command like 'search' so that whatever i search the bot will search in google and send the top result? im pretty new so yeah
Use a lib or webscrape?
!pypi google

bot.user.name how i set newnick for bot
not serverside
the username
maybe cant?
await edit(*, username=..., avatar=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the current profile of the client.
Note
To upload an avatar, a [bytes-like object](https://docs.python.org/3/glossary.html#term-bytes-like-object "(in Python v3.9)") must be passed in that represents the image being uploaded. If this is done through a file then the file must be opened via `open('some_filename', 'rb')` and the [bytes-like object](https://docs.python.org/3/glossary.html#term-bytes-like-object "(in Python v3.9)") is given through the use of `fp.read()`.
The only image formats supported for uploading is JPEG and PNG.
Changed in version 2.0: The edit is no longer in-place, instead the newly edited client user is returned.
trying to educate myself on databases 😤 if anyone knows any good videos/resources lemme know
dunno what any of thoes are ..
sqlbolt to learn sql and then use aiosqlite for sqlite but the async instance
you can use the module that the person sent which get used to scrape data from websites etc
@bot.command()
@commands.has_any_role(692760082085183519, 940008547993927691, 863878825376743475)
async def очистить(ctx, amount : int):
if amount == None:
emb=discord.Embed(title="❌ Error", description="Введите число!", color=discord.Color.from_rgb(0, 255, 0))
await ctx.reply(embed=emb)
else:
await ctx.channel.purge(limit=amount)
await ctx.reply(f"{ctx.author.name} удалил {amount} сообщений")
if not working, why?
you can use is or not and amount will never be None and if you are gonna set a defualt value make it 1 and you cant purge allot because youll get ratelimited
A okay
How can I deduce that the bot does not have enough rights when pressing the button?
More precisely, how to make a condition
Dude
💀
It would be a lot better with buttons
You can have a 25 button area field
As 5 action rows, 5 buttons per row
yeah but you cant have a 10x10 grid
Then you wouldn't have to do all this coord specifying stuff
and how would you flag
Press the button, ask in an ephemeral message if you want to flag or dig
but then thats 2 steps
click button; flag or dig
rn its only coords
and im not sure how this would scale with 10x10
I feel like that sacrifice is a lot better then specifying the coordinates
Press & click, not read type and send
If you want to do 10x10 just make that the regular one, keep the others in buttons?
Not sure
remember, easier for users means harder to code for the programmer, harder for user to use, easier to code 
Except when your users are coders
The easier an implementation it is, the easier it is to hack it
That's why all my homies like low-level functions
why not make a cursor with buttons?
what?
with buttons youll have 4+ for x and y and it would just be 7 buttons
oh i see what you mean
cursor with buttons would be horrific
imagine you're at 0, 0 and you want to get to 10, 10
the ratelimits would be psycho
sounds like a you problem
or just do a plus 5 movement or sm lol
better than specifying cords
-_-
do interactions even have ratelimits, I'll have to test that rq
yes?
Probably
it says slow down, you're clicking too fas
who clicks a button so quickly you get ratelimited
you dont have to click it quickly
ik
even if you click it pretty slow, after 5 times you get ratelimited
dynamic ratelimits lol
I remember somewhere someone saying it doesn't or whatever
I'll look at the headers of the request anyhow
it does
just check the headers lol
That's what I Just said
that is so
is there any like discord phising link list? so i can put that on a filter
kinda triggers me how it says it on the row where the button is and not on bottom
I'm not getting this when spamming my buttons
guess youre slow
spamming
lolll
how many times did you spam them
i can assure you i didnt hack discord 😳
;|
discord is confusing
did you just find a way to bypass the ratelimits? o.O
just check the id of the guild
If the member is not in the server it will throw an error iirc
if ctx.guild.id == 1234567890:
...
and you can use or so no need for that if statement when you can just do
member = member or ctx.author
guys, how can i make a command the command enable & disable command (perserver)
youll have to do a blacklist afaik
your about me isnt correct lol
a bot token is 52 chars
so make your name 52chars or else
thats not the only reason it isnt correct, do you know what the other reason is?

its not a bot token lol
I can't fit a whole ass code in the about me
he isnt using pycord?
bro
im joking lol
nobody uses pycord
^

let me know when you figure it out
thats the punchline
@cold sonnet make your about me follow pep8
he didnt subclass the Bot class?
Why
I have to fit it in just a few lines
nope
You're missing spaces around the equal sign when you're defining the bot variable
you wont figure it out
he probably doesnt even follow pep8 LOL
Can you not add those in?
ok?
ok
ok
nice
the quotes?
thou shall say it
they look off but i think its my font lol
@pliant gulch tell them the error with his about me
i better not be wrong about this error
why ping andy
zilo mate you're off the mark
...
mean you when_mentioned()?
yes
seems right to me
in the command_prefix you dont call the function
What
only on the or one iirc
do you call when_mentioned_or?
no
bro
just like you dont call get_prefix
you do tho
you dont
doesnt get prefix call it?
Yea, the first one is correct
im so confused
when_mentioned_or("!")
how so?
!d discord.ext.commands.when_mentioned_or | take a look
discord.ext.commands.when_mentioned_or(*prefixes)```
A callable that implements when mentioned or other prefixes provided.
These are meant to be passed into the [`Bot.command_prefix`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.command_prefix "discord.ext.commands.Bot.command_prefix") attribute.
Example
```py
bot = commands.Bot(command_prefix=commands.when_mentioned_or('!'))
```...
actually thats right
Kek
😖
!d discord.ext.commands.when_mentioned
no
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/master/ext/commands/api.html#discord.ext.commands.Bot.command_prefix "discord.ext.commands.Bot.command_prefix") attribute.
you dont call it in the command_prefix
proof
yeah get_prefix does iirc
you can split the arg
1:d and split it on the colon and if the unit is a day just use math
If you called when_mentioned inside of command_prefix= you'd get an error anyways
You need the message and the bot
why don't the docs explicitly mention anything
command_prefi interesting
the edittt
Well, anyone reading the docs could clearly see the arguments it takes right?
🙃
Plus it quite literally says so what to do! "These are meant to be passed into the Bot.command_prefix attribute."
!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/master/ext/commands/api.html#discord.ext.commands.Bot.command_prefix "discord.ext.commands.Bot.command_prefix") attribute.
yeah says the same for the or one
but that returns itself when called so
meh
couldn't the string it returns be the prefix
so you could call it if it were made like that
Do you have the discord.Message instance right when you construct the bot???
why you need that
The function takes it
where else would it check for a mention
when_mentioned doesn't even need the message
It only returns a list of the mentions the bot can have
if when_mentioned just returned "<@numbers>"
though
where would it get the id from
your bot gets its own id on startup
i don't understand what i've done wrong. Could someone explain pls?
ahh okay thanks, also the command doesn't work either. How do i fix that?
How would you make a command to show all the guilds the bot is in? Additionally, how would you make the bot leave a guild it is in without the person who ran the command being in the guild.
cause i literally copied it from a video and it does nothing and gives no errors in the terminal.
for guild in bot.guilds:
...
how would I go about making a 'createrole' command, and making sure it clears all permissions so its just a blank role with a name?
ty
ive started but I don't know if it's correct
send the code
@commands.has_permissions(manage_roles=True)
async def createrole(ctx, member:discord.Member, *, role:discord.Role = None):```
discord.errors.ClientException: Callback for serverinfo command is missing "ctx" parameter.
you would do something like
guild = ctx.guild
perms = discord.Permissions(permissions=0)
await guild.create_role(name=role, permissions=perms)
whats the simple fix for this
thanks
add ctx param 🗿
is this in a cog?
how do i make an on_ready where it says
Bot_Name#0000 is now online
yes
self, ctx
i did try that
just do print(client/bot.mention is online) in the on_ready
2 sec i will do it again
print(f"{bot.mention} is online") ?
that works ye
ok ty
ii forgot the "
@client.command(aliases=['cr'])
@commands.has_permissions(manage_roles=True)
async def createrole(ctx, member:discord.Member, *, role:discord.Role = None):
guild = ctx.guild
perms = discord.Permissions(permissions=0)
await guild.create_role(name=role, permissions=perms)
await ctx.send(f'`{role}` was created')```
I think I've done it all wrong @slim ibex
wait i dont need member
Traceback (most recent call last):
File "C:\Users\jackr\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "taken.py", line 83, in on_command_error
await ctx.reply(embed=ErrorEmbed)
File "C:\Users\jackr\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\context.py", line 340, in reply
return await self.message.reply(content, **kwargs)
File "C:\Users\jackr\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\message.py", line 1358, in reply return await self.channel.send(content, reference=self, **kwargs)
File "C:\Users\jackr\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\abc.py", line 1065, in send
data = await state.http.send_message(channel.id, content, tts=tts, embed=embed,
File "C:\Users\jackr\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\http.py", line 254, in request
raise HTTPException(r, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In message_reference: Unknown message
when i add it
you don't need member param if you aren't modifying a member or using the member in some way
removed it but it still doesnt work
im just trying to create a role
errors?
that means something in your code has errored further along the line
discord.ext.commands.errors.RoleNotFound: Role "test" not found.
Hey @cerulean olive!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
!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.pythondiscord.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.
Hey @cerulean olive!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
bru was py
replace discord.Role with 'str'?
ye
k
@manic wing
clean, works. thankyou
you deleted the message and are trying to do things to it after you deleted it
np
delete it add the end
Best way to make Embed python for help command
Is it possible to host a web server and a discord bot @ the same time ?
I have a discord bot that uses coinbase commerce's api and I have a webhook that receives events.
!d message.edit
No way, José.
No documentation found for the requested symbol.
.
Idk
for embed in embeds:
edit_embed() etc.
camelCase smh
await message.edit(content="newcontent")
thats what im saying
Not even that, first two words are all lowercase (serverinfo) and then it switches to camel case 😂
I thought camelCase was written like that when there are more than 2 words
Or is it written like serverInfoEmbed
Yes, thats how it would be named in camel case ig
It’ s a mixture
How to create private channel on command?
!d discord.Guild.create_text_channel
await create_text_channel(name, *, reason=None, category=None, position=..., topic=..., slowmode_delay=..., nsfw=..., overwrites=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Creates a [`TextChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.TextChannel "discord.TextChannel") for the guild.
Note that you need the [`manage_channels`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to create the channel.
The `overwrites` parameter can be used to create a ‘secret’ channel upon creation. This parameter expects a [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") of overwrites with the target (either a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") or a [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")) as the key and a [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/master/api.html#discord.PermissionOverwrite "discord.PermissionOverwrite") as the value.
Note
Creating a channel of a specified position will not update the position of other channels to follow suit. A follow-up call to [`edit()`](https://discordpy.readthedocs.io/en/master/api.html#discord.TextChannel.edit "discord.TextChannel.edit") will be required to update the position of the channel in the channel list...
How do you make secret channel tho
overwrites param
Ok
did you read this?
@bot.command()
async def start(ctx):
guild = 944633510013075497
await guild.create_text_channel('test')
int can’t create text channels
^
You need discord.Guild instance
hence ctx.guild
Ok
!d discord.Guild
class discord.Guild```
Represents a Discord guild.
This is referred to as a “server” in the official Discord UI.
x == y Checks if two guilds are equal.
x != y Checks if two guilds are not equal.
hash(x) Returns the guild’s hash.
str(x) Returns the guild’s name.
^
but an id can't do shit
hi
but 524 doesn't have send attribute\
hi
hi
and no variables can't start with numbers in python
duh, that's an error
yah
hi
how can i create a discord.Member with an id?
read
what
whats interaction

bru