#Basic Pycord Help

1 messages · Page 70 of 1

fresh sierra
#

You should check the helper fonction

raw beacon
#

Can userapps fetch a users server specific banner? If the userapp isnt added to the server

sage tendon
#

pretty sure no

raw beacon
errant trout
#

but not server specific, no

#

(for user apps, you should assume that your bot is not a member and has no access to member-specific info apart from some of the command user's)

raw beacon
#

yea but it can fetch the server avatar for some reason

#

but not the server banner

#

which is.. confusing

sage tendon
#

banners are not part of the member object, you need to fetch it seperately
but the server avatar is part of the member object

raw beacon
#

ah

buoyant eagle
#

why i cant see the slash command?

sage tendon
#

many reasons

#

try restarting discord

lapis dock
#

what do you mean? It is not showing in discord when you type slash?

buoyant eagle
#

yes

sly karmaBOT
#

Application Commands Not Showing Up?

  • Refresh Discord by restarting or pressing Ctrl+R (or Command ⌘ + R)
  • Uninstall libraries that conflict with the discord namespace (e.g. discord.py).
  • Invite your bot with the application.commands scope.
  • Load cogs before bot.run() (e.g. not in on_ready).
  • Do not override on_connect.
  • Update to the newest version of py-cord (see ?tag install).
  • Turn off User Settings > Accessibility > Chat Input > Use legacy chat input.
  • Share your code and errors.
buoyant eagle
# lapis dock what do you mean? It is not showing in discord when you type slash?
@commands.slash_command(name = "access", description = "command to grand access to a user")
@option("user", discord.User,description = "Select User")
@option( "duration",choices = ["5 Days", "10 Days", "15 Days", "30 Days", "Perm",] ,description = "Select The Duration of the access" )
@discord.default_permissions(manage_channels = True)
async def access(ctx):

i did something wrong?

sage tendon
#

and below that?

#

is that in a cog?

buoyant eagle
#

nope

sage tendon
#

then you need to use @bot.slash_command

lapis dock
#

Where are your option arguments O.o

sage tendon
#

that too lol

#

also you should use discord.Member as option type and as typehint for the argument

buoyant eagle
#

now i see the command but i dont have the options

sage tendon
#

you dont have any arguments in your function definition

buoyant eagle
#

how i add them?

sage tendon
#

like any other function argument

#

lol

lapis dock
#

Have you taken a look at the guide yet?

buoyant eagle
#

yes

sly karmaBOT
sage tendon
#

the guide explains everything you're trying to do

lapis dock
buoyant eagle
echo wraith
#

Give the full traceback

#

Bruh

buoyant eagle
#

oh wait a sec

sage tendon
#

I mean the error is very clear

#

something you are trying to do, you lack permissions for

#

the bot, in that case

buoyant eagle
#

sorry
just got back to dev bots after a long time

cedar sandal
#

I’m having difficulty loading cog extensions into my main script. It never calls the function to import the cogs. I added print statements to debug but it never prints so the function never happens. Can someone give me a working example because I’m an idiot?

#

ChatGPT and Gemini don’t understand pycord super well

lapis dock
#

Could you show what you have instead and we can help correct your mistake

cedar sandal
#

Yeah. Will post back later when I have time to focus on jt

lapis dock
cedar sandal
#

That is very helpful

#

I will use this to practice and then try to expand it with my own ideas in a new cog

#

Thank you

nocturne jewel
#

how to put this hidden online status?

silk spire
cedar sandal
#

in the guide for cog's the math commands do not contain the ctx paramater... is this normal? my IDE is complaining about it

shell radish
#

@errant trout can you fix it

cedar sandal
#

also the greet is broken

#
    async def greet(self, ctx, member: discord.Member):
        await ctx.respond(f'{ctx.author.mention} says hello to {member.mention}!')```

```discord.ext.commands.errors.CommandNotFound: Command "greet" is not found```
#

fix: (not sure if this is how you'd want it)

    async def greet(self, ctx, member: discord.Member):
        await ctx.send(f'{ctx.author.mention} says hello to {member.mention}!')```
fresh sierra
fierce seal
#

is there a way to get reactions to a message interaction points to, from inside a view class?

sage tendon
#

what

noble flax
#

Am I imagining seeing something, but is there a way for an autocomplete to use the list of the discord members? So that you can select the discord name from a list?

silk spire
#

Set the type to discord.Member

noble flax
cedar sandal
cedar sandal
lapis dock
quartz umbra
#

can somebody give me the docs for integration types? I forget the bot command

raw beacon
#

.rtfm integration

quartz umbra
# raw beacon .rtfm integration

no not like that, there's a page on the docs i think that shows you how to make a command accessible in DMs etc if you add the bot to your profile

sage tendon
#

that's a user app

quartz umbra
#

yh you gave me an example the other day i can't find the message

rugged lodgeBOT
#

Here's the slash users example.

quartz umbra
raw beacon
#

ah

cedar sandal
#

I guess this is a basic general-rule question:

what is the best practice way to store API keys/tokens such that they’re not included in the project repo, but it’s sensible to the user where they should be

#

Environment variable vs dummy apikeys.py… That kind of thing

lapis dock
#

I use a .env but if you are distributing the code and expecting users to fill in the data private.py might be better. Not sure if there are sequrity benefits to having it as a text file or not..

sage tendon
#

I personally have a git-excluded config.py, makes it very straightforward to access and im just used to it
and then i have example.config.py as, well, example file for anyone else wanting to use it

livid nymph
#
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction
``` anyone getting this error all of sudden? I didn't change my code or anything but it suddenly stopped working
lofty parcel
livid nymph
#

code looking like that so it should respond instantly

#

I didn't even have ctx.defer() before

#

is it possible its because of a slow internet connection?

lapis dock
#

Yes the 3 seconds start when discord sends the interaction. The time it takes for the internet to deliver that request to you and the time it takes for your response to be delivered to discord will be included in the given 3 seconds

sage tendon
#

does it work if you defer?

#

if you have close to or over 3000ms of latency to discord, even temporarily, thats really bad lol

lapis dock
#

discord response times have been acting up a bit lately as well. Not sure how that you affect the timing

sage tendon
#

fairly stable at least today tho

cedar sandal
#

what's wrong with line 11?

#

Option isn't a thing, I get that... how would I achieve the same concept properly

shell radish
#

from discord import Option or use discord.Option

cedar sandal
#

still barking

shell radish
#

yeah, that's a different thing

#

you can ignore it or use @option instead

tidal vessel
valid panther
#

Hello! I would like to know what you think of the two options of healthcheck that I had thought. The first option was to make a https server that every x time makes a call returning info that everything is ok. And the second one is to make a .py script that makes the call. It is because I have the discord bot in a docker service and I would like to know the status without needing to see the logs.

echo wraith
echo wraith
river oriole
#

Slash command sub Groups are just Slash command groups right? So I should be able to call .command() on them?

river oriole
#

I think I'm doing something wrong then. I get this Error everytime I try to use a sub command group

Traceback (most recent call last):
  File "/Users/dominik/Development/D-20/.venv/lib/python3.9/site-packages/discord/cog.py", line 784, in _load_from_module_spec
    spec.loader.exec_module(lib)  # type: ignore
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/Users/dominik/Development/D-20/modules/Tickets/index.py", line 20, in <module>
    class Tickets(commands.Cog):
  File "/Users/dominik/Development/D-20/modules/Tickets/index.py", line 41, in Tickets
    @intro_group.command(name="send", description="Sends the Introduction message")
AttributeError: 'function' object has no attribute 'command'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/dominik/Development/D-20/bot.py", line 37, in <module>
    bot.load_extension(f"modules.{module_name}.index")
  File "/Users/dominik/Development/D-20/.venv/lib/python3.9/site-packages/discord/cog.py", line 918, in load_extension
    self._load_from_module_spec(spec, name)
  File "/Users/dominik/Development/D-20/.venv/lib/python3.9/site-packages/discord/cog.py", line 787, in _load_from_module_spec
    raise errors.ExtensionFailed(key, e) from e
discord.errors.ExtensionFailed: Extension 'modules.Tickets.index' raised an error: AttributeError: 'function' object has no attribute 'command'
#

With this code:

group = SlashCommandGroup(
    name="ticket",
    description="Commands related to Tickets",
    contexts=InteractionContextType.guild,
)
# intro_group = group
intro_group = group.subgroup(
    name="introduction", description="Commands related to the introduction message"
)
@intro_group.command(name="message", description="Sets the Introduction message")
@isStaff()
async def message(self, ctx: ApplicationContext):
    await ctx.send_modal(
        SetIntroductionMessage(title="Set the Introduction Message")
    )
#

It works fine when I use intro_group = group or @group.command()

errant trout
#

(why do we have a @subgroup decorator????)

river oriole
gusty ibex
#

Why does the "import discord" come out gray? Nothing else happens in that file, in everyone else if I can import it. I tried to fix it by reinstalling py-cord, but not even that.

gusty ibex
#

I already fixed it, apparently the code editor did not detect a use of "discord" and marked it in gray.

marble hull
#

hey guys, basic question - how do cooldowns work?

#

like is the data stored in cache or something?

sage tendon
#

probably saved in the slash command object

little cobalt
fresh sierra
#

same in vsc, it gonna be dark green

buoyant eagle
#

how i can remove the help command?

lapis dock
#

help_command=None in the bot constructor

buoyant eagle
#

ok thanks

cobalt bone
#

require_tag is deprecated ?

sage tendon
#

thats for ForumChannel.edit

echo wraith
#
Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/discord/client.py", line 614, in connect
self.ws = await asyncio.wait_for(coro, timeout=60.0)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/asyncio/tasks.py", line 520, in wait_for
return await fut
^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/discord/gateway.py", line 339, in from_client
socket = await client.http.ws_connect(gateway)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/discord/http.py", line 216, in ws_connect
return await self.__session.ws_connect(url, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 1021, in _ws_connect
raise WSServerHandshakeError(
aiohttp.client_exceptions.WSServerHandshakeError: 520, message='Invalid response status', url='wss://gateway.discord.gg/?encoding=json&v=10&compress=zlib-stream'

Any1 has an idea ? Just got it once.

#

Ok I can't read guys goodnight

lapis dock
#

Did some ddevs digging, seems like you should just ignore an retry (with a maximum number of retries ofc)

fresh sierra
#

im doing a backup system, and i was wondering should i save the icon like guild, profil or member as bytes or just using the url will work forever ?

echo wraith
# fresh sierra im doing a backup system, and i was wondering should i save the icon like guild,...

The url will not work forever afaik if it's the same as message attachements because th eurl is signed. HOWEVER, you should NEVER store files like that in a database. Instead, if it is not possible to do with theurl which i'm not sure it is, take some storage space (either local storage or something like s3 etc...) and download the file there under a given name, then store the name in your database.

fresh sierra
#

never change store how ? as bit or as url

echo wraith
#

you store a filename

fresh sierra
#

and i cannot download, it would be way to expensive

echo wraith
#

then you store the actual file somewhere else

echo wraith
#

It's in any case not more expensive in storage space than storing it in the db as bytes

fresh sierra
#

its like thousand and thousand of image

#

so i might stick with the url, i feel like it will still works since in from discord

echo wraith
#

Idk the only thing that could happen is the url expires and it doesn't work anymore

fresh sierra
#

i think there is like 14d outside of discord but infite on discord

echo wraith
#

I'm not sure

#

Try asking in ddevs maybe

fresh sierra
#

from what i heard about it i should be scare

lapis dock
#

Asking for help on ddevs is fine, dealing with some of the people asking for help on ddevs is not fine

fresh sierra
#

ok, i'll go there to ask and i'll tell you about the time

sly karmaBOT
fresh sierra
#

well there is a limit but no i still dont know how im gonna fix it

stray cape
#

can anyone give an example of the use of SlashCommandGroup.checks?

sage tendon
stray cape
#

yeah I lowkey don't understand how to use it does it have to do something with

bot: commands.Bot
@bot.check
async def some_check(ctx: discord.ApplicationContext) -> bool:
   return True or False
```?
sage tendon
#

the link i sent has examples

stray cape
#

where

#

nevermind thank you kidney

sage tendon
#

click it and read

stray cape
#

what if I want to add a check for a group itself?

#

that it only is accessible for a specific group of people

sage tendon
sage tendon
#

?

#

why would i just randomly make up stuff

stray cape
#

mb I didnt mean it like that

#

just suprised that i can actually configure something via discord

fresh sierra
stray cape
#

it's role-based anyways

fresh sierra
#
    slash_group = discord.SlashCommandGroup(
        name="debug",
        checks=[Lumabot.is_owner().predicate],
        contexts=[
            discord.InteractionContextType.guild,
        ],
    )

stray cape
#

but thanks for bearing with me

fresh sierra
#

then yeah if its by role it will, remember however that this can be overwrite

stray cape
stray cape
#

as in it'll convert the \🔥 to 🔥

fresh sierra
#

but you should just pass them as unicode emoji ig

sage tendon
#

footer wont render any special text formatting i think

#

so yea if anything only as unicode emoji

stray cape
#

because this is lowkey not useful or is it that my terminal it rendering it like that

sage tendon
#

i mean thats on your IDE font

fresh sierra
#

stray cape
#

alrighty 👍

fresh sierra
#

i think its the emoji u used

sage tendon
#

VSC continues to amaze

stray cape
#

catched that

#

neovim 🔥

fresh sierra
#

🔥

sage tendon
fresh sierra
fresh sierra
#

which mean the first emoji he sent was not a unicode one

stray cape
#

alright ily yall thx ❤️

fresh sierra
#

🔥

#

this is

stray cape
#

okay one last question: how do I send a Paginator object..?

rugged lodgeBOT
#

Here's the paginator example.

stray cape
#

aha respond

echo wraith
#

\🔥

stray cape
#

\🔥

#

thank god sqlalchemy exists

tidal vessel
#

When a member leaves the server, are they automatically removed from the bot's cache, or are they still retained?

sage tendon
#

I'd think they're removed, Pycord handles cache pretty well

frosty dust
#

Is it possible to change the domain the requests py-cord makes go to?
Like if I wanted to use xyz.com/api instead of discord.com/api for testing purposes

sage tendon
#

Gotta say I don't see the point lol

lapis dock
frosty dust
errant trout
#

uhhh there was a pr for that

#

let's see

sage tendon
#

yea but unless you recreated Discord's entire backend it's kinda pointless imo

frosty dust
#

The entire backend is pretty much done lol

errant trout
frosty dust
#

It has most needed endpoints

errant trout
#

if you're on master then have fun

sage tendon
#

what are you using that for tho

frosty dust
sage tendon
#

I thought it was for testing

frosty dust
#

Both are valid uses no?

stray cape
frosty dust
#

Im testing it now, supporting the dev of the projects, and gonna decentralize my communication

lapis dock
#

What does decentralize mean? I hear it thrown around sometimes

errant trout
#

just lookup spacebar on github, probably easier to explain that way

frosty dust
#

None reliant on big companies

lapis dock
#

So who does host it? Random people that self host?

sage tendon
#

bold of you to assume Microsoft didn't make a copy to train language models on yet :>

frosty dust
sage tendon
lapis dock
#

😬

frosty dust
#

Their ai on the other hand shows off tons of closed source code when jailbroken

#

Not mine

#

Considering news too, discord is planning their IPO to sell

#

So

errant trout
#

i wouldn't be surprised if discord sold but people have been saying that since like 2020

sage tendon
#

yea I mean discord is selling data left and right already 100% idc what they say

frosty dust
#

Self hostable replacements are the key to safety. FOSS is the way to go

#

Ssl certs can be gotten for free and encryption is at your fingertips

#

Between 2 domains, 2 vps's, my home pcs, etc, I can host anything I will ever need

raw beacon
#

got this is in my console

Unclosed connection
client_connection: Connection<ConnectionKey(host='gateway.discord.gg', port=443, is_ssl=True, ssl=True, proxy=None, proxy_auth=None, proxy_headers_hash=None)>``` 
am i doing something wrong?
#

im never calling that connection myself

sage tendon
#

are you exiting the bot

raw beacon
#

nop

#

unless the internet was unstable or something, which is unlikely

sage tendon
#

can always happen

#

never saw that myself tho

raw beacon
#

weird

#

never seen it either before this

fresh sierra
#

so i got a function that save some message to backup them, what do you think its better, saving all messsage author and pdp in local at that time or just save the id and then fetch them ?

#

i mean performance wize

#

because for the fetch i know i can fetch all people from the guild, but if there is a banall not one will be in the guild so i will have to fetch a lottttttttttt of author i think and im afraid if i touch a limit

lapis dock
lapis dock
fresh sierra
#

but i get i'll only save the member_name and member_pdp instead of id and fetching user

cobalt bone
#

Why default_reaction_emoji parameter in ForumChannel(...).edit(default_reaction_emoji=...) cannot accept None ? How remove default reaction emoji ?

echo wraith
#

Hmm interesting

sage tendon
#

because it cant be not set?

#

oh no it can be unset

#

hm

cobalt bone
#

Optional allow the None value alright ?

lapis dock
#

yeah

#

wait maybe?

cobalt bone
#

I have tested discord.MISSING but I get an error

errant trout
#

None is correct

#

MISSING generally shouldn't be used by users

rugged lodgeBOT
lapis dock
#

why does optional exists if you can just do | None in less charecters?

errant trout
#

| for typing is the newer syntax from 3.10 onwards

cobalt bone
#

I have the error and default_reaction_emoji_ is None...

errant trout
#

or 3.9 wtv

#

ah

echo wraith
#

no yeah

#

you're right nelo it's starting 3.10

#

I meant because 3.9 doesnt support it

errant trout
#

icic

lapis dock
#

but why in the docs that line uses | syntax

echo wraith
errant trout
#

someone wrote that one poorly

#

in that context it should be commas

cobalt bone
#

it's more short than Union[...]

echo wraith
#

Anyways, please ping me if this emoji upvote thing is an issue with the lib so I can take a look gtg now

errant trout
#

yeah the generic _edit function doesn't accept none well

cobalt bone
#

AH

echo wraith
#

-remindme 5d this shit

lofty vaultBOT
#

Set a reminder in 5 days from now (<t:1742760922:f>)
View reminders with the reminders command

errant trout
#

probably in some attempt to avoid using missing

#

but as jank as it is, it's useful

echo wraith
#

I mean if that was the goal one could have done smth like try kwargs.pop() except but that would be even weirder than MISSING imo

errant trout
#

actually eh in this instance it's unrelated to missing, you just have to add a single clause

#

try/except on kwargs is everywhere in the lib lol

cobalt bone
#

so actually, I'm stuck ? :')

errant trout
#

are you trying to remove the default emoji?

cobalt bone
#

yes

echo wraith
errant trout
#

if you want you could just edit the file to allow none

#

but eh

cobalt bone
#

but ?

errant trout
#

strictly speaking you could do a raw edit but it looks like you're doing a larger function py await bot.http.edit_channel(channel.id, default_reaction_emoji=None)

cobalt bone
#

damn

echo wraith
#

untested tho so lmk if anything doesn't work

errant trout
#

yeah that'd fix it

echo wraith
#

Gonna test tomorrow now gn

#

pip install git+https://github.com/Paillat-dev/pycord.git@fix/forum-edit-no-default-emojis

#

I think

cobalt bone
#

gn

#

It must be great to work on the maintenance of a project as big as Py-cord.

rugged wing
#

I think this would constitute as basic help, so I have my bot off the ground and running, pretty basic with a self hosted mysql server for working with some data.

I currently have it joined in a main server, and also my own personal test server.

My Q:
Is there a best practice for how to handle GUILD_IDS when a bot is in multiple servers?

Like say I have guild_ids set in my slash commands for development purposes. What's the standard practice of handling that with multiple servers?

Should I just save what Guilds it joins in a table and pull those when I initiate the bot?

echo wraith
#

You can use environment variables maybe ?

sage tendon
#

You dont have to pass guild ids if you want the commands available in all servers

lapis dock
#

^^

echo wraith
#

Oh that was the question

rugged wing
#

I was under the impression you pass guild ids if you want them to update immedately, otherwise it could take 2-3 hours?

#

Did I misunderstand that

lapis dock
#

That is old information, now both are quick

sage tendon
#

Thats not the case anymore

#

was like that in the first few weeks of slash commands or so

rugged wing
#

Oh fantastic, that's useful to know

#

Thank you, and a follow up question.

So then lets say I want my bot to send an "Online" message to a specified channel in each of the servers it's in, it would probably make sense to store some guild_id/channel_id information in a database to handle that?

I considered environment variables, but it doesn't feel quite right.

sage tendon
#

sqlite

rugged wing
#

I am using a self hosted mysql server, but generally that seems like a resonable approach?

sage tendon
#

if you plan to have your bot added to many servers, yes
if its only ever gonna be in 2 or so servers, hardcode it, not worth the effort

rugged wing
#

Reasonable, thank you very much!

lofty parcel
#

It'd be spammy and just unnecessary.

#

Users can look at the members list to see if the bot is online or just use a command.

rugged wing
#

Yeah, I decided to go with an environment variable, it's only posting that to my personal server that I'm using to develop it

#

Totally agree!

lofty parcel
#

Ah, thought you meant every server the bot was in.

#

Not just your dev server.

rugged wing
#

Well I did state it like that you're not wrong, but realistically this is being developed for my own personal community. So in practice it really will only ever see my main server, and my test server

#

I was just sort of feeling out generally how that might be approached if a bot may be in more than one server, but I understand now.

#

The biggest benefit was being able to get away from passing guild_ids into the command decorators

lofty parcel
#

You can always hardcode it

#

If its just 2 servers

rugged wing
#

Yeah, I do plan to chuck it on github though, so in hindsight an environment variable was always the answer 🙂

sage tendon
#

my bot on github has several hardcoded channel IDs, 10+ hardcoded roles etc lmfao

rugged wing
#

Sounds like from what I'm gathering there's nothing wrong with it

lofty parcel
#

There's nothing wrong about hardcoding IDs

#

Specially if its a private bot lol

rugged wing
#

I just end up overthinking things, and like to keep things clean when possible lol, plenty of over engineering for my relatively simple bot

lapis dock
#

It is still ideal to not hardcode IDs if you are trying to be super professional

rugged wing
#

Thanks for the validation Wolfy 😆

lofty parcel
#

If you wanna be super professional, encrypt and store the IDs in a database, create an API with auth, request the IDs everytime you need then, the auth changes every 2 hours. /j

rugged wing
#

I randomize all the values in my database daily to make sure no one can understand whats going on in there

#

Unhackable Unusable

rugged wing
#

If I am calling to a regular function that interacts with the database, say:
def add_user(user_id)

It's correct to call that function like so to prevent locking up the code, correct?
await asyncio.to_thread(add_user, user_id)

#

(I realize this is not a pycord library question, sorry)

lofty parcel
rugged wing
#

I am using pymysql, which I don't believe has that

#

I'll take a look though, thanks!

lofty parcel
#

aiomysql is the async one iirc?

#

Google could probably give you a better answer than me, sorry, I use mongo lol

rugged wing
#

Oh I understand

#

No worries, yeah I do see aiomysql

#

Do you think it's worth the hassle of switching over versus calling my functions with asyncio.to_thread()?

#

I have such little experience with asynchronous code lol

lofty parcel
#

Yeah dw

#

You will realize it ends up being just having to add 2 words to your current code

rugged wing
#

Which might eventually bug me enough to make the switch knowing there's an alternative

#

haha, appreciate the knowledge!

little cobalt
lofty parcel
#

Yes

round heart
fresh sierra
#

can we manage the post using pycord ? like edit them close them delete them etc ?

#

because i see we can do that with threads

lapis dock
#

Forum channel posts are threads, you should be able to manage them in the same way

fresh sierra
#

ok perfect then thanks

echo wraith
#

discord.PartialMessageable doesnt need a guild_id if working with a channel ?

rugged lodgeBOT
somber crystal
#

TypeError: View.__init__() got an unexpected keyword argument 'disable_on_timeout'

    def __init__(self, user_id, interaction_user_id):
        super().__init__(timeout=5, disable_on_timeout=True)```

hi, im kinda new,  i was wondering why im getting an error here :/
fresh sierra
echo wraith
#

kk

echo wraith
#

.tag install

sly karmaBOT
#

1. Uninstall discord.py or any other forks of discord.py you might have with the namespace discord.
python -m pip uninstall discord.py discord -y

2a. Install py-cord
python -m pip install py-cord

2b. Update py-cord
python pip install -U py-cord

Installing other builds:
Note: You need to have git installed. Use ?tag git to find out how to install git.

Updating the module to master branch (unstable):
pip install -U git+https://github.com/Pycord-Development/pycord

somber crystal
somber crystal
#

pycord doesnt have app_commands yea

echo wraith
#

it doens't

somber crystal
#

rt shi

echo wraith
#

What are you trying to do ?

somber crystal
#

making a slash cmd rn

#

i js got pycord today

#

made it in dpy

little cobalt
#

Here is it for py-cord

slow gazelle
#

Does anyone why this doesn't deploy slash commands correctly?

for root, _, files in os.walk("commands"):
    for file in files:
        if file.endswith(".py") and file != "__init__.py":
            cog_path = os.path.join(root, file)
            cog_path = cog_path.replace("\\", "/").replace("/", ".").replace(".py", "")
            try:
                bot.load_extension(cog_path)
                loaded_commands += 1
            except Exception as e:
                failed_commands += 1
                logger.error(f"Error al cargar el comando {cog_path}: {str(e)}")```
#

it's loading commands and not throwing errors, but i can only see them showing up in my main acc, not in my alt

#

nor my other devs

sly karmaBOT
#

Tag not found.

Did you mean...
slashnoshow
slashcmdnoshow
slash no show

sly karmaBOT
# slow gazelle it's loading commands and not throwing errors, but i can only see them showing u...

Application Commands Not Showing Up?

  • Refresh Discord by restarting or pressing Ctrl+R (or Command ⌘ + R)
  • Uninstall libraries that conflict with the discord namespace (e.g. discord.py).
  • Invite your bot with the application.commands scope.
  • Load cogs before bot.run() (e.g. not in on_ready).
  • Do not override on_connect.
  • Update to the newest version of py-cord (see ?tag install).
  • Turn off User Settings > Accessibility > Chat Input > Use legacy chat input.
  • Share your code and errors.
sage tendon
#

also, I recommend against only putting one command into each cog, that'll create a big amount of cogs that might be hard to manage

well unless your commands are really, really long

cobalt bone
#

does exist an Enum class to get archive duration possibilities for Threads ?

errant trout
#

(60, 1440, 4320, 10080)

cobalt bone
#

damn xD thanks

marble compass
#

TypeError: expected Interaction or BridgeContext, not <class 'discord.commands.context.ApplicationContext'>

frosty ocean
#

Hi, how can I allow multiple lines in a modal form?

sage tendon
#
frosty ocean
#

So with style=TextStyle.paragraph?

sage tendon
#

InputTextStyle, yes

frosty ocean
#

I will try it out, thank you

frosty ocean
#

I get the error NameError: name 'TextStyle' is not defined

#

The same also with InputTextStyle

#

With style=discord.InputTextStyle.paragraph, it works

fresh sierra
#

(look to the pip list)

sage tendon
#

do you know basic python

frosty ocean
#

I thought I could do that with a separate import of TextStyle as well

frosty ocean
sage tendon
#

because, still, its called InputTextStyle

fresh sierra
marble compass
#

Do I need to explicitly add a slash command group?
My regular application commands were registered automatically, but the group command wasn’t.

little cobalt
#

than you just load the cog

marble compass
#

nah, the main file

little cobalt
#

looks fine for me

#

mhm

#

but you could try it by adding it to the bot

marble compass
#

umm sure

#

It gets registered only after being explicitly added.

sage tendon
#

did yo urestart discord after adding the group

errant trout
#

(for cogs, it is automatically added when the cog is loaded; there is no equivalent mechanism for that outside of cogs)

marble compass
quartz umbra
#

hi! anybody know why this command isn't registering? Are you not able to use integrationtypes with slash command groups or am I doing it wrong?

    embed_group = discord.SlashCommandGroup("embed", "Embed commands")
    @embed_group.command(
        integration_types={
            discord.IntegrationType.guild_install,
            discord.IntegrationType.user_install
        },
        description="Create a simple embed!"
    )
    async def simple(self, ctx, description: str, title: str = None, color: discord.Color = discord.Color.blue(), thumbnail_url: str = None):   
errant trout
#

...we really should remove several kwargs from subcommand decorator

lapis dock
#

^ subcommands cant have different "settings" then the base command because... discord

quartz umbra
#

it works thanks!

sage tendon
#

This is embed.type
but the discord docs dont say anything lol (the link is broken btw)

lapis dock
#

pretty sure discord bots only use rich, I think the other types are for discords autogeneration from links and such

rugged lodgeBOT
#

Here's the slash users example.

lapis dock
#

@void schooner ^

#

Just note that some information is missing when a command is invoked in a user install context, specifically a bunch of information about the guild

void schooner
#

oh, that is very simple. thanks a lot for the direct example 🙂
and i will keep the limitation in mind. Thanks for the info

#

Yep, now i can use it everywhere. Thanks 😊

lapis dock
#

🎉

sonic onyx
#

I haven't messed with discord bots in over a year. Can anyone tell me what this does? It's part of my initialization function.

await bot.change_presence(activity=discord.Activity(name="The Terminal.", type=discord.ActivityType.watching))

I imagine it changes the state of the bot so that it reads messages in the named channel, but I'm not sure.

shell radish
sonic onyx
#

OH. Like on the discord profile itself. Got it.

shell radish
#

yup, it's purely "cosmetic"

sonic onyx
#

don't need that lol

sonic onyx
#

In this program, what is ctx?

#

(yes I wrote this at some point.)

eternal kite
#

how can i set a button's value its label?

#

currently the self in the callback refers to the view but i have no idea how to obtain the label of the button

fresh sierra
eternal kite
somber crystal
#

um does anyone know how to edit original message using applicationcontext? i went thru the docs but i didnt rly get it :(

rugged lodgeBOT
echo wraith
#

This I think @somber crystal

#

You do ctx.interaction

#

to get the interaction object

somber crystal
#

i didnt know ctx.interaction is possible

#

i dont remember seeing it in the docs either, but lemme try

#

discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'ApplicationContext' object has no attribute 'edit_original_response' 😭🙏 @echo wraith

echo wraith
somber crystal
#

ye thas what i did

echo wraith
#

.tag paste

sly karmaBOT
#

Please copy and paste your code here. This makes it easier for everyone helping you.

somber crystal
#
 await ctx.interaction.edit_original_response(embed=embed, view=QuizGame(ctx))```
echo wraith
#

also

somber crystal
#

oh wai

echo wraith
#

.tag autosave

sly karmaBOT
#

Tag not found.

Did you mean...
vc-autosave

somber crystal
#

response

#

mb

echo wraith
#

.tag vc-autosave

sly karmaBOT
#

Look at this StackOverflow post to learn how to setup auto-saving in VS Code.

echo wraith
# somber crystal mb

It should be the same between response or message. The message one is an alias to response

somber crystal
#

i have no idea why its giving an error then

echo wraith
#

can you

#

.tag paste

sly karmaBOT
#

Please copy and paste your code here. This makes it easier for everyone helping you.

echo wraith
#

I'll take a look

somber crystal
#

oh uh wai

#

await ctx.interaction.edit_original_message(embed=embed, view=QuizGame(ctx))

#

like thas it>

#

?

#

.tag paste await ctx.interaction.edit_original_message(embed=embed, view=QuizGame(ctx))

sly karmaBOT
#
Error

Flag 'delete' is required and missing

echo wraith
#

No

#

click on the link

#

in

somber crystal
#

oh

echo wraith
#

.tag paste

sly karmaBOT
#

Please copy and paste your code here. This makes it easier for everyone helping you.

echo wraith
#

and paste your entire file

somber crystal
#

oh ok

somber crystal
echo wraith
#

to the paste

sage tendon
#

line 56

echo wraith
somber crystal
echo wraith
#

simply use await ctx.respond

somber crystal
#

i call this in another file

#

want me to paste that?

echo wraith
sage tendon
#

line 56

echo wraith
#

no actually

somber crystal
sage tendon
#

you don't need followup.send

#

you can always use .respond

echo wraith
#

yeah

#

use .respond

somber crystal
#

oh

#

i thought we had to use followup after defer

echo wraith
#

it will handle everything for you

somber crystal
#

i see

sage tendon
#

and the error is STILL on line 56 in the first paste

somber crystal
#

and this stays the same i believe ?

await ctx.interaction.edit_original_message(embed=embed, view=QuizGame(ctx))

sage tendon
#

just use the interaction you get from the button

echo wraith
somber crystal
sage tendon
#

right

#

don't name your variable ctx if it's not applicationcontext

echo wraith
#

also @somber crystal

    with open('cards/jobs.json', 'r') as f:
            jobs_data = json.load(f)
#

.tag blocking

sly karmaBOT
#

In asynchronous programming a blocking call is essentially all the parts of the function that are not await. Do not despair however, because not all forms of blocking are bad! Using blocking calls is inevitable, but you must work to make sure that you don’t excessively block functions. Remember, if you block for too long then your bot will freeze since it has not stopped the function’s execution at that point to do other things.

A common source of blocking for too long is something like time.sleep(). Don’t do that. Use asyncio.sleep() instead. Similar to this example:

# bad
time.sleep(10)

# good
await asyncio.sleep(10)

Read more

echo wraith
#

You should use something like aiofiles

somber crystal
#

oh

echo wraith
#

and do async with open

#

await f.read

somber crystal
echo wraith
#

pip install aiofiles

sage tendon
#

but yea don't name the variable ctx if it's an interaction
it'll confuse people trying to help, and it'll confuse you sooner or later

#

even more ideally you also typehint it as the correct thing so you get warnings if you use an attribute that doesn't exist

somber crystal
#

alr, im not using ctx

#

but uh await interaction.edit_original_message(embed=embed, view=QuizGame(interaction)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'ApplicationContext' object has no attribute 'edit_original_message'

#

i am using application context in work file tho

echo wraith
#

tf

sage tendon
#

and calling it interaction

#

why

echo wraith
#

@somber crystal if you're using it in a slash command, call it ctx and type it as discord.ApplicationContext, if using it with buttons or other ui components, name it interaction and type it as discord.Interaction

#

that will help make more sense of what's going on

somber crystal
#

oh 😭😭

somber crystal
#

helpp okayy

echo wraith
somber crystal
#

@echo wraith @sage tendon sry for the ping
it worked ^^
tysm! 🤍

echo wraith
lapis dock
marble compass
#

can a command option be Union[discord.Member, str] type?

sage tendon
#

No

#

and there's no point for that

#

like what do you need that for

marble compass
#

for a clash royale bot, either mention or player_tag

sage tendon
#

then just make 2 options, one for the clash royale ign and one for the discord mention ig

marble compass
#

yeah that is the only option now

errant trout
#

i'd personally opt for autocomplete but yeah that works

#

or prompt them to mention inside the string option and parse through discord.utils.raw_mentions

marble compass
void schooner
errant trout
lofty vaultBOT
#

Reminder for @echo wraith

Reminder from YAGPDB

this shit

echo wraith
#

already fixed

void schooner
sonic onyx
#

How do I get the discord ID of the person using the slash command?

sage tendon
#

check the docs

sonic onyx
#

alr got it. i was using .id on the wrong thing

#

Well, making the balance command wasn't that difficult

void schooner
#
async def resumake(ctx, file: discord.Attachment, filename: str = "resume"):
    await ctx.defer()
    await file.save(f"{filename}.yaml")
    await generate_resume(filename)
    await ctx.respond(file=discord.File(f"{filename}.pdf"))

this already works, so didn't think of separately posting in #969574202413838426 . just wondering if the series of await function calls is bad practice, or normal?

sage tendon
#

its fine

void schooner
#

Marvelous. Thanks

sonic onyx
#

Is this good practice?

lapis dock
#

No, you are right, with open would be better

void schooner
#

yeah but i wasn't sure where 😅 like, maybe not inside try. some parts of the except block feel like they should be done a bit differently

lapis dock
#
with open(...) as file:
  file.read()
  file.write(...)

No need for close as the context manager does that for you

sage tendon
#

your database is text files? lmao

#

why dont you just use sqlite or something

#

then you dont have to deal with manually wrangling text files

void schooner
lapis dock
sage tendon
#

This is like really bad practice

lapis dock
sage tendon
#

there is no reason to do that

#

none

#

and as a helper i feel obligated to be a bit harsher and say they will absolutely regret doing it like this later, its way too error-prone and complicated, and also slow!

sonic onyx
#

It's very low traffic.

lapis dock
sage tendon
#

sqlite would still be miles easier than manually wrangling text files

#

it's literally easier

void schooner
#

on second thought, even JSON/CSV may be better than this

sonic onyx
void schooner
lapis dock
#

You can specify what kind of error type the except will catch ^

sonic onyx
#

Ohh I see

lapis dock
#

Otherwise it eats all error, even ones that you did not intend to catch

sage tendon
#

and why while 1:

void schooner
#

C habits ig. but yeah, use while True

sonic onyx
#

I do a majority of everything with C followed by C++

sonic onyx
void schooner
#

well... welcome to python ig 🙂

sonic onyx
sage tendon
#

wait.. when is that else clause even being entered?? else after a try-except?

sonic onyx
#

else is not entered until open(file, r) runs without error

lapis dock
#
with open(...) as file:
  read file
if file is empty:
  balance = 0
else:
  balance = int(file contents)
print(balance)

This approach would avoid the try/except and the while loop

sage tendon
#

why are so many people so against even just sqlite

lapis dock
sage tendon
#

tf
and when is that entered?

nocturne jewel
#

is anyone getting random Shard ID None heartbeat blocked for more than 830 seconds? I didn't get any issue for the past year and now i am getting this (the bot is in just one server)

well, there's a blocking code but it still the same code in the past year

lapis dock
sage tendon
sonic onyx
lapis dock
#

That is pseudocode btw, not valid python
When you open a file with rw as the mode, I think it creates the file if it does not exists

sonic onyx
#

is rw read/write mode in one?

lapis dock
#

yeah

sage tendon
#

you could / should use mode x when creating the file

#

if you really wanna keep doing text files lol

sonic onyx
#

alr imma try rewriting it a bit to be less convoluted

nocturne jewel
sage tendon
#

i mean you said yourself you have blocking code

sonic onyx
#

Otherwise the file would instead be blank

sage tendon
#

no idea if you can do it while creating the file with x, but if not, just do it right after

sonic onyx
#

and cause errors if I try to do operations with its read values

lapis dock
#

A new file will just by an empty string, you should check if it is blank and then defualt it to 0 if it is

nocturne jewel
sage tendon
#

restart the bot and see if it still happens

sonic onyx
#

Why is if-except-else considered bad?

little cobalt
sage tendon
#

Honestly what I find a bit weird about it is that you're trying to make a self-fixing loop
Like if it fails it fixes it and then on the next loop its (hopefully) in working order

sonic onyx
#

There is a big problem with the except in my case where the exception isn’t specified.

sage tendon
#

then make another one as a catch-all that aborts it

sonic onyx
#

But it seemed like people were saying the concept of using if-except to catch the file read error is bad idea

sonic onyx
sage tendon
#
try:
    ...
except specific-exception:
    ....
except:
    <abort, clearly bigger error happening>
#

oh wait you have that already

#

yea

errant trout
#

while it isn't inherently wrong to use try-except, it is generally better to avoid the error in the first place

#

i.e. check if the file exists with a more appropriate method

sonic onyx
#

Is it not one of the fastest methods to check though?

sage tendon
#

why wait for an error if you can avoid it altogether

errant trout
#

i'm just speaking in a general sense, if you prefer to use try-except then it's not like we can stop you

sonic onyx
errant trout
#

if you want to scope your exception down, it's FileNotFoundError

#

otherwise, os.path.isfile(path) will return a bool for whether the file exists

sonic onyx
sonic onyx
#

how do you declare a command that ends up looking like this?

little cobalt
#

you mean with the space at it?

sonic onyx
#

mostly the specific argument

#

I want my next command to only take another user then an integer as its arguments, but I'm not sure how to do that with the neat discord integration as shown

little cobalt
#

name: int

sonic onyx
#

wouldn't that then require people to enter the discord ID of the user?

#

most of the documentation I can find refers to prefixed commands

#

I tried CheckBalance(ctx, target: discord.Member) but it doesn't run

sonic onyx
#

I got it to work.

#

Unrelated issue was breaking it. I had the name string start with a capital letter, which broke my program lol

little cobalt
#

oh you want a user, so yea, it would be user: discord.Member

sonic onyx
#

where can I find the list of other member functions like .id?

little cobalt
#

go the docs and search for discord.Member

lofty parcel
#

.rtfm discord.Member

little cobalt
#

or like that, the first one

sonic onyx
#

Found it in the docs. Is global name the username#1111?

#

I see that there's name, global name, and local name

little cobalt
#

That got removed at discord or can you still get that?

#

the # stuff

sonic onyx
#

oh, right

#

I thought I saw local name, but i guess its just name and global name

#

so I'm guessing global is the username

lofty parcel
#

.name is the username

#

.global_name is the name

eternal kite
#

how can i check if a user can view a channel?

sonic onyx
lofty parcel
sonic onyx
#

alr thanks

lofty parcel
#

discord.Member.global_name would give you Dark

lofty parcel
#

Then check for read_messages attr which is a bool

nimble matrixBOT
eternal kite
#

alr thx

sonic onyx
#

I'm guessing its more efficient to use ctx.author.id once and store it in a local variable than it is to call ctx.author.id every time I need it in command. Would that be true?

lofty parcel
#

Whatever works

#

You'd be using another variable for nothing really

sonic onyx
#

Both work, I'm just wondering what is more efficient.

#

even if the effect is miniscule

lapis dock
#

Both are just looking at a value. That level of efficiency is generally not worth looking into.

sonic onyx
#

So once discord.Member is passed as an argument, its already a stored structure variable?

lapis dock
#

Not sure what that means but the efficency is so small I am not even sure if it is reliable

#

I did a quick test and you are on the scale of 7 nano second difference between the 2. That is 7 billionths of a second.

sonic onyx
#

Ok so there's essentially no difference.

sonic onyx
#

The fact that the difference is so small means that .id only accesses a variable that already exists within that structure and nothing else

lapis dock
#

Not sure what a structure is, but the terminology I am familiar with is that you are getting an instance of the Member class.

sonic onyx
#

sorry, structs are at least what they're called in C++

#

Python likely names them differently

lapis dock
#

Because you are learning python I would recommend the python discord. They have a bunch of people who are way more experienced than me and can answer those specific, non-discord related, questions better.

sly karmaBOT
#

The Python Discord is an un-official server for anything Python related. For general Python help please use this server. Note: There is no official Python Discord server.

https://discord.gg/python

sonic onyx
#

How do I make my bot actually ping people by name? I can only seem to get this

errant trout
#

otherwise, format it as <@user_id>

sage tendon
sage tendon
#

And in compiled languages, the compiler will take your code apart to optimise it to hell and back anyway

somber crystal
#
        result.save(buffer, format='PNG')
        buffer.seek(0)
        RC_file = discord.File(buffer, filename='rosebot_huntRC.png')
        await interaction.message.edit(
            content=f"{interaction.user.mention} Hunted **{card_name}** | {card_series} - {ctier}",
            view=self,
            attachments=[RC_file] 
        )```

`AttributeError: 'File' object has no attribute 'to_dict'`
any idea why im getting this error?
im p sure RC_file is valid discord.file
sage tendon
#

file=RC_file

somber crystal
#

oh, but arent we supposed to use attachments when editing message

#

lemme try

sage tendon
#

this is only if you want to remove some or all attachments

somber crystal
#

omg im stupid, tysm i got it 😭🙏

somber crystal
echo wraith
#

I think

#

to clear the files

somber crystal
#

i see

echo wraith
#

when editing

somber crystal
#

alrighty lemme try

somber crystal
echo wraith
#

npp

sage tendon
#

please read

sage tendon
#

yea but.... meh

sonic onyx
#

And the fundamental behavior in question does turn out to be almost identical

#

C on the other hand does not have objects

void schooner
#

modern C++ has proper classes and objects tho, not just structs. In Python you can also have dataclasses and namedtuples that can be used for dot-notation accessing, if you don't want to write a bunch of code to make full classes (i highly recommend dataclasses; very similar to structs, and very flexible)

void schooner
echo wraith
sonic onyx
#

I don’t think so, based on my reading. Since author.id is already a member of an existing object that has been copied, it’s essentially being defined twice if you also assign it a second variable

#

I only do so for code readability if anything

void schooner
sonic onyx
#

It’s really interesting how everything is so certain things are setup in Python vs C/C++, like for loops

void schooner
#

wait till you see for loops in Go :3

sage tendon
#

they're like at the complete opposite ends of the spectrum in terms of high and low levelness

sonic onyx
#

for x in A:
as compared to
for (int i = 0, i < MAX, i++) {}

#

Java is actually the first language I learned a bit of years ago and this feels like going back to a better form of that

void schooner
sage tendon
#

in range(5) works too

sonic onyx
#

Hm, though it’s not really necessary in as many cases as in C. Trying to brute force C into python isn’t gonna make me a good python programmer

void schooner
echo wraith
#

Didn't know about CircuitPython

void schooner
sonic onyx
#

Performance is always important to consider. Maybe not for something as low impact as what I was talking about

sage tendon
#

its python

sonic onyx
#

But if it were the case that author.id needed to be retrieved from somewhere across a network and I was calling it multiple times, that would be a significant waste of resources

#

And time

void schooner
#

Premature optimization is the bane of good software

sage tendon
#

thats also a bad mindset lol

sonic onyx
#

Understanding what methods are faster than another method helps to avoid performance issues in the future. Sure, if you don’t know how to do it anymore efficiently, then it is what it is.

#

One of the reasons so many programs that we use are so unoptimized is because no one bothers and assumes the hardware will surpass the needs, and it’s quite bothersome.

#

Because that’s a huge issue I run into with newer applications on slightly older devices. Efficiency has gone out the window for a lot of applications now.

void schooner
void schooner
sage tendon
#

"small efficiencies"

#

doesnt mean to never consider performance

void schooner
void schooner
sonic onyx
void schooner
#

ah. the term for that is attribute of an object/instance, in OOP languages like Java/Python

sonic onyx
#

Now that I realize it’s just grabbing an attribute, I can understand why it makes almost no difference

void schooner
#

makes sense

sonic onyx
#

But in most projects, not all inefficiencies are the same. I can already see that that slowest part of my program is likely opening text files.

#

The rest is basically inconsequential when it comes to efficiency right now

#

Also, does anyone know how I’d make a command that works only once a day for that user?

void schooner
#

I wonder if SQLite would fare better 🤔

sonic onyx
#

SQLite installs itself to your device, right?

void schooner
#

SQLite is just reading from a DB file. unlike other SQL variants, SQLite doesn't need a server or anything too "involved". and Python stdlib comes with an SQLite interface built-in. all you have to do is just import it and use it

sonic onyx
#

I’m not opposed to using it, I just want to come up with my own system as practice, even if I lose efficiency. If I do anything larger, I’ll definitely consider a better solution

lofty parcel
void schooner
#

i was mistaken. edited. you do need to install the SQLite C libs (if they don't already come preinstalled on your system; at least on macOS/Linux it likely does). but Python comes with the interface built-in: https://docs.python.org/3/library/sqlite3.html

sonic onyx
#

I’m finding it difficult to come up with a daily and weekly command that doesn’t rely on that program to run continuously during the cooldown

lofty parcel
#

Then you need a database

sonic onyx
#

Surely I could save the time and day it would be done to my machine and run a comparison, but is that the best way of doing it?

void schooner
#

half of the replies to Mr. Klunk are either "don't worry about this in Python" and "Use a database" XD

sonic onyx
#

grrr I’ll make my own database

lofty parcel
#

I mean it's a db or a json file if you want it for the laugh

void schooner
sonic onyx
#

Genuinely though, making databases is likely something im going to do quite a bit so its good to get some practice on a problem that I don’t have a time restriction for

void schooner
#

Python has very good support for SQLite, JSON, and CSV. would be really good to use any of those (but especially SQLite, in this case)

void schooner
#

also just so you know, SQLite is used in embedded systems quite a bit, since it's written in C (thus fast), lightweight (small memory/storage footprint), and serverless (thus easy to work with)

sonic onyx
#

The only thing that bothers me is the question of organization. So I already have an organized folder of text files with the balances of people who use my bot. That’s simple enough.

#

But to create a cooldown for a command that will be different for each person depending on when they use the command, I need a similarly large assortment of storage.

void schooner
void schooner
fresh sierra
sonic onyx
#

You use the command at 11 am. It does it’s effect. You cannot use it again until 11am tomorrow. It will not give its effect again until that time

fresh sierra
void schooner
fresh sierra
sonic onyx
#

oh thanks

void schooner
sonic onyx
#

And there we get our max efficiency lol

sage tendon
#

What's with everyone avoiding sqlite or in memory storage like it's lava

echo wraith
#

Lmao

sage tendon
#

there's a thin line between that and reinventing the wheel

fresh sierra
#

i mean if he wants to that's on him, considering that in his futur where memory and libs will be tight that's normal

eternal kite
#

wait why am i getting rate limited out of a sudden

#

is it because my users are spamming commands or smth?

frail basin
eternal kite
sage tendon
#

usually Pycord handles rate limits
what are you doing, clearly you're doing something way more than usual

eternal kite
#

wth

#

nah

#

my bot is running fine since 2021

#

it's just that my bot users has increased by a lot lately

sage tendon
#

do you edit channels or stuff a lot

sage tendon
sage tendon
#

could be it if the hoster uses the same IP for multiple servers

eternal kite
errant trout
#

is that the full error

eternal kite
sage tendon
#

show them all

errant trout
#

it would help to see anything related, it's pretty hard to get that message specifically because the library tries to handle ratelimits so you managed to do something very wrong

sage tendon
eternal kite
errant trout
#

yeah

sage tendon
#

sidenote consider updating your python, 3.9 becomes EOL this year iirc

errant trout
#

oh that one is assuming you may have been temp banned by cloudflare, not discord

#

because typically 429s are handled differently

eternal kite
sage tendon
#

no clue what happened to 3.10

sage tendon
#

im always on latest lol

errant trout
#

how many users/guilds is it in?

eternal kite
#

400 guilds?

#

400+

#

maybe

errant trout
#

hmmm

#

realistically you should be fine until the mid thousands

eternal kite
#

but it's an economy bot so players are spamming different commands every second

errant trout
#

that'd do it

#

is it over prefix commands?

eternal kite
#

uh

#

wdym

#

slash commands obviously

errant trout
#

does your bot use slash commands mainly

sage tendon
#

shouldn't be an issue if it's all regular slash commands though

errant trout
#

ok that's fine

edgy nest
#

since that looks like error logs i would suggest fixing the errors

errant trout
#

yeah

edgy nest
#

that would likely mitigate your issue

errant trout
#

it seems like you have errors being spammed?

eternal kite
errant trout
#

i mean the messages themselves aren't necessarily a problem

eternal kite
edgy nest
#

you may also just be performing some action repeatedly very often

eternal kite
#

and so it can't send messages to the channel due to being ratelimited

sage tendon
edgy nest
#

any member roles or anything?

eternal kite
#

and it raises the error again

edgy nest
#

dms?

errant trout
#

the thing is that interactions have a significantly higher ratelimit, in normal usage you would never get ratelimited

eternal kite
sage tendon
#

yea maybe just abort the error handler when it's a 429 so it doesn't loop on itself lol

eternal kite
sage tendon
#

I think you constantly spam the API trying to log an error, get another error, etc

eternal kite
#

weird

sage tendon
#

of course that can't be the root issue but yea

eternal kite
sage tendon
#

yea but it's still constantly trying to send it no?

errant trout
#

not quite

#

any api action -> 429 unique case where it stops

eternal kite
#

yes but no

sage tendon
#

hm
well either way it can't be the root cause so maybe fix that later lol

eternal kite
#

i mean it's just a part of the whole error log

errant trout
#

did you ever set up the logging module

eternal kite
#

wdym abt that

#

oh

errant trout
eternal kite
#

nope but is it mandatory?

errant trout
#

no, but that gives details on ratelimits

edgy nest
#

the only way to really fix your problem is guess at what you're doing thats getting you ratelimited

errant trout
#

from the sounds of it, you've been exceeding ratelimits the entire time and only now discord's being harsher on you

eternal kite
#

right

edgy nest
#

anything in your bot that does a lot of fetch actions?

eternal kite
eternal kite
#

get_channel?

edgy nest
#

or perhaps something where your bot is lacking permissions but tries anyways?

edgy nest
eternal kite
edgy nest
#

or just any other discord actions

eternal kite
#

my bot is lacking permissions in some server and it's trying to send messages and editing nickname repeatedly whenever they use a command

errant trout
#

at the very least if you set the loglevel to WARNING it'll become very obvious what you're doing wrong, but yeah if you're aware of anything that might be spamming the api then deal with it

eternal kite
sage tendon
#

do any of you know if editing the bots nickname is particularly strictly limited

errant trout
#

they probably mean user nickname?

edgy nest
#

i would suggest checking permissions before trying to do anything, otherwise look for anything that might happen extremely often and try to downsize that

sage tendon
#

not always easily possible tho, permission checking sucks

edgy nest
#

especially stuff like sending a channel message every command, if they're being used that often

edgy nest
sage tendon
eternal kite
edgy nest
#

i myself have been ratelimited for sending way too many messages

eternal kite
sage tendon
#

what

eternal kite
#

i have no idea too

edgy nest
eternal kite
eternal kite
edgy nest
#

do you have member intents enabled?

eternal kite
#

yes

sage tendon
#

you need member intents to get your own member object? hm

errant trout
#

nah

eternal kite
#

guild.me only returns None in certain guilds

#

works fine in my official server and most servers

#

i ignored that tho

edgy nest
#

probably check Interaction.app_permissions then, i think it includes guild level permissions

errant trout
#

please stop ignoring your errors 😅

edgy nest
#

guild.me being none is weird though

eternal kite
eternal kite
errant trout
#

and look where you are now !!

edgy nest
#

anyways best thing you can do right now is try and change something and then wait it out

eternal kite
edgy nest
#

(turn your bot off so it doesn't keep sending requests!)

errant trout
#

yeah too late to unratelimit yourself lol

eternal kite
errant trout
sage tendon
#

honestly what I'd do right now is make a new bot, run it with the new token, and debug from there

rate limits are kinda random

eternal kite
#

and now it's back up

errant trout
#

well

sage tendon
errant trout
#

they can kill your token

#

it absolutely happens

sage tendon
#

yes but the process

errant trout
#

most bots will shutdown after a fatal error like that

edgy nest
eternal kite
errant trout
edgy nest
#

mm

sage tendon
eternal kite
edgy nest
#

so you should stop it

eternal kite
#

i think it's something to do with my hosting service

edgy nest
#

could be

sage tendon
edgy nest
#

what service do you use?

eternal kite
#

if it's getting too much error it will crash the process

errant trout
#

eh

eternal kite
errant trout
#

oh

edgy nest
#

that

errant trout
#

well

#

ok

edgy nest