#Basic Pycord Help
1 messages · Page 70 of 1
Can userapps fetch a users server specific banner? If the userapp isnt added to the server
pretty sure no

banner is included in bot.fetch_user
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)
yea but it can fetch the server avatar for some reason
but not the server banner
which is.. confusing
banners are not part of the member object, you need to fetch it seperately
but the server avatar is part of the member object
ah
why i cant see the slash command?
what do you mean? It is not showing in discord when you type slash?
yes
Application Commands Not Showing Up?
- Refresh Discord by restarting or pressing
Ctrl+R(orCommand ⌘ + R) - Uninstall libraries that conflict with the
discordnamespace (e.g.discord.py). - Invite your bot with the
application.commandsscope. - Load cogs before
bot.run()(e.g. not inon_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.
@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?
nope
then you need to use @bot.slash_command
Where are your option arguments O.o
that too lol
also you should use discord.Member as option type and as typehint for the argument
now i see the command but i dont have the options
hence wolfy said this
you dont have any arguments in your function definition
how i add them?
Have you taken a look at the guide yet?
yes
Official Pycord Guide: https://guide.pycord.dev/
the guide explains everything you're trying to do
https://guide.pycord.dev/interactions/application-commands/slash-commands#options--option-types
This section explains it well
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: Forbidden: 403 Forbidden (error code: 50013): Missing Permissions
help....
What code
Give the full traceback
Bruh
oh wait a sec
I mean the error is very clear
something you are trying to do, you lack permissions for
the bot, in that case
sorry
just got back to dev bots after a long time
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
Could you show what you have instead and we can help correct your mistake
Yeah. Will post back later when I have time to focus on jt
This page might also be helpful
https://guide.pycord.dev/popular-topics/cogs
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
how to put this hidden online status?
It's a http only bot aka only handles interactions
https://discord.com/developers/docs/interactions/overview#preparing-for-interactions
gotcha, thx
in the guide for cog's the math commands do not contain the ctx paramater... is this normal? my IDE is complaining about it
Cogs, often known as modules or extensions, are used to organize commands into groups. This is useful
it's an error on the guide
@errant trout can you fix it
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}!')```
a user command is not a command but an app command
is there a way to get reactions to a message interaction points to, from inside a view class?
what
uh... no
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?
Set the type to discord.Member
Thank you good sir, I vaguely remember it from a while ago but couldn't find where
I was seeing that the CTX in the respond wasn’t tieing to the CTX in the definition. But I am noob so idk if I’m trying to understand it backwards
You can do this for several other fields as well. I just did one where you pick a voice channel from a list. Pretty neat
You are trying to use it as a prefix command when in reality it is a user command that shows up when you right click a user and hover over "apps"
Ohhhhh
can somebody give me the docs for integration types? I forget the bot command
.rtfm integration
discord.Integration
discord.Integration.account
discord.Integration.delete
discord.Integration.enabled
discord.Integration.guild
discord.Integration.id
discord.Integration.name
discord.Integration.type
discord.Integration.user
discord.BotIntegration
discord.BotIntegration.account
discord.BotIntegration.application
discord.BotIntegration.delete
discord.BotIntegration.enabled
discord.BotIntegration.guild
discord.BotIntegration.id
discord.BotIntegration.name
discord.BotIntegration.type
discord.BotIntegration.user
discord.StreamIntegration
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
that's a user app
thiS?
yh you gave me an example the other day i can't find the message
Here's the slash users example.
this thx!
ah
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
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..
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
There we go
Thanks toothy
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
Most of the times means you're not replying under 3 seconds.
async def upload(self, ctx, attachment:discord.Attachment):
if attachment:
# Responding with the file URL
await ctx.defer()
await ctx.respond(f"Received your file: {attachment.url}")
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?
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
does it work if you defer?
if you have close to or over 3000ms of latency to discord, even temporarily, thats really bad lol
discord response times have been acting up a bit lately as well. Not sure how that you affect the timing
fairly stable at least today tho
what's wrong with line 11?
Option isn't a thing, I get that... how would I achieve the same concept properly
from discord import Option or use discord.Option
Why is the setup() function asynchronous? In py-cord, it's synchronous.
I fixed
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.
What I have personally is a task in my bots that requests uptime Kuma every tot seconds
With a post or a get?
Post
Slash command sub Groups are just Slash command groups right? So I should be able to call .command() on them?
Yes
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()
it should be .create_subgroup, not .subgroup
(why do we have a @subgroup decorator????)
Ohh my bad. Thank you very much
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.
I already fixed it, apparently the code editor did not detect a use of "discord" and marked it in gray.
hey guys, basic question - how do cooldowns work?
like is the data stored in cache or something?
probably saved in the slash command object
It looks like you use PyCharm. If you import stuff but you havent used it yet in the code its gonna be a gray colour
same in vsc, it gonna be dark green
how i can remove the help command?
help_command=None in the bot constructor
ok thanks
require_tag is deprecated ?
thats for ForumChannel.edit
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
Did some ddevs digging, seems like you should just ignore an retry (with a maximum number of retries ofc)
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 ?
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.
but i dont know if the url expired outside of discord
never change store how ? as bit or as url
and i cannot download, it would be way to expensive
then you store the actual file somewhere else
why would it be ?
It's in any case not more expensive in storage space than storing it in the db as bytes
if i need to save all of the profile of all members
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
Idk the only thing that could happen is the url expires and it doesn't work anymore
yeah but i dont think it will expires if i use it on discord context
i think there is like 14d outside of discord but infite on discord
from what i heard about it i should be scare
Asking for help on ddevs is fine, dealing with some of the people asking for help on ddevs is not fine
ok, i'll go there to ask and i'll tell you about the time
well there is a limit but no i still dont know how im gonna fix it
can anyone give an example of the use of SlashCommandGroup.checks?
The following section outlines the API of Pycord’s prefixed command extension module. Bots: Bot: Attributes activity, allowed_mentions, application_flags, application_id, cached_messages, case_inse...
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
```?
the link i sent has examples
click it and read
what if I want to add a check for a group itself?
that it only is accessible for a specific group of people
If its role based you should do that in the integration settings in your server settings
If its permission based used https://docs.pycord.dev/en/stable/api/application_commands.html#discord.commands.default_permissions
Is that for real a thing?
mb I didnt mean it like that
just suprised that i can actually configure something via discord
pass in the group the check
I think this should work
it's role-based anyways
slash_group = discord.SlashCommandGroup(
name="debug",
checks=[Lumabot.is_owner().predicate],
contexts=[
discord.InteractionContextType.guild,
],
)
but thanks for bearing with me
then yeah if its by role it will, remember however that this can be overwrite
alrighty
got it
\🔥
by the way will emoji's like :fire: work if I set it in a footer?
as in it'll convert the \🔥 to 🔥
but you should just pass them as unicode emoji ig
footer wont render any special text formatting i think
so yea if anything only as unicode emoji
because this is lowkey not useful or is it that my terminal it rendering it like that
i mean thats on your IDE font
�
alrighty 👍
i think its the emoji u used
VSC continues to amaze
🔥
Luma, that icon is for characters that the font doesnt have a character for
yep this one is not a real one
i copy past that from discord
which mean the first emoji he sent was not a unicode one
alright ily yall thx ❤️
okay one last question: how do I send a Paginator object..?
Here's the paginator example.
aha respond
\🔥
When a member leaves the server, are they automatically removed from the bot's cache, or are they still retained?
I'd think they're removed, Pycord handles cache pretty well
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
Gotta say I don't see the point lol
Discord broke copy pasting some Unicode emojis, you might have to right click the message and copy text
yea but unless you recreated Discord's entire backend it's kinda pointless imo
probably
The entire backend is pretty much done lol
It has most needed endpoints
if you're on master then have fun
what are you using that for tho
Decentralization
I thought it was for testing
Both are valid uses no?
it doesn't really affect me right now but it's an interesting fact to hear
Im testing it now, supporting the dev of the projects, and gonna decentralize my communication
What does decentralize mean? I hear it thrown around sometimes
just lookup spacebar on github, probably easier to explain that way
It means that your data isnt stored by big companies
I host a gitea instance, that way microsoft doesnt store my code
Or people host next cloud instead of google drive
None reliant on big companies
So who does host it? Random people that self host?
bold of you to assume Microsoft didn't make a copy to train language models on yet :>
They cant access my private repos on my site
anyone who wants
😬
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
i wouldn't be surprised if discord sold but people have been saying that since like 2020
yea I mean discord is selling data left and right already 100% idc what they say
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
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
are you exiting the bot
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
This should just reconnect to discord right after
trying to fetch a large list will lead to ratelimits, it is better to store those things as you receive them through events
i will not really be able to store them through event, it will be when i want to load the backup
but i get i'll only save the member_name and member_pdp instead of id and fetching user
Why default_reaction_emoji parameter in ForumChannel(...).edit(default_reaction_emoji=...) cannot accept None ? How remove default reaction emoji ?
Hmm interesting
Optional allow the None value alright ?
I have tested discord.MISSING but I get an error
why does optional exists if you can just do | None in less charecters?
| for typing is the newer syntax from 3.10 onwards
Cause python 3.9
I have the error and default_reaction_emoji_ is None...
no yeah
you're right nelo it's starting 3.10
I meant because 3.9 doesnt support it
icic
but why in the docs that line uses | syntax
Cause it's a mess
it's more short than Union[...]
Anyways, please ping me if this emoji upvote thing is an issue with the lib so I can take a look gtg now
yeah the generic _edit function doesn't accept none well
AH
-remindme 5d this shit
Set a reminder in 5 days from now (<t:1742760922:f>)
View reminders with the reminders command
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
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
so actually, I'm stuck ? :')
are you trying to remove the default emoji?
yes
but ?
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)
damn
cc @cobalt bone https://github.com/Pycord-Development/pycord/pull/2739
untested tho so lmk if anything doesn't work
yeah that'd fix it
Gonna test tomorrow now gn
pip install git+https://github.com/Paillat-dev/pycord.git@fix/forum-edit-no-default-emojis
I think
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?
You can use environment variables maybe ?
You dont have to pass guild ids if you want the commands available in all servers
^^
Oh that was the question
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
That is old information, now both are quick
Thats not the case anymore
was like that in the first few weeks of slash commands or so
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.
sqlite
I am using a self hosted mysql server, but generally that seems like a resonable approach?
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
Reasonable, thank you very much!
UX wise, I wouldn't.
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.
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!
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
Yeah, I do plan to chuck it on github though, so in hindsight an environment variable was always the answer 🙂
my bot on github has several hardcoded channel IDs, 10+ hardcoded roles etc lmfao
Sounds like from what I'm gathering there's nothing wrong with it
I just end up overthinking things, and like to keep things clean when possible lol, plenty of over engineering for my relatively simple bot
It is still ideal to not hardcode IDs if you are trying to be super professional
Thanks for the validation Wolfy 😆
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
I randomize all the values in my database daily to make sure no one can understand whats going on in there
Unhackable Unusable
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)
Most database motors have an async version that you can use
aiomysql is the async one iirc?
Google could probably give you a better answer than me, sorry, I use mongo lol
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
Yeah dw
You will realize it ends up being just having to add 2 words to your current code
Which might eventually bug me enough to make the switch knowing there's an alternative
haha, appreciate the knowledge!
oh, you also use mongodb?
Yes
Cc @lofty parcel
Q&A discussion discussing the merits of No SQL and relational databases.
can we manage the post using pycord ? like edit them close them delete them etc ?
because i see we can do that with threads
Forum channel posts are threads, you should be able to manage them in the same way
ok perfect then thanks
discord.PartialMessageable doesnt need a guild_id if working with a channel ?
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 :/
nope, message are link to the channel and not the guild
kk
discord.ui.View
discord.ui.View.add_item
discord.ui.View.children
discord.ui.View.clear_items
discord.ui.View.disable_all_items
discord.ui.View.disable_on_timeout
discord.ui.View.enable_all_items
discord.ui.View.from_message
discord.ui.View.get_item
discord.ui.View.interaction_check
discord.ui.View.is_dispatching
discord.ui.View.is_finished
discord.ui.View.is_persistent
discord.ui.View.message
discord.ui.View.on_check_failure
hm that's weird. Can you check this ?
.tag install
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
alrighty
wait im insanely new to pycord sry, i use app_commands
discord.py
pycord doesnt have app_commands yea
rt shi
What are you trying to do ?
Learn all about Slash Commands and how to implement them into your Discord Bot with Pycord!
Here is it for py-cord
oh omg tysm
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
Tag not found.
Did you mean...
slashnoshow
slashcmdnoshow
slash no show
.tag slashnoshow
Application Commands Not Showing Up?
- Refresh Discord by restarting or pressing
Ctrl+R(orCommand ⌘ + R) - Uninstall libraries that conflict with the
discordnamespace (e.g.discord.py). - Invite your bot with the
application.commandsscope. - Load cogs before
bot.run()(e.g. not inon_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.
why such a complicated loading procedure? just do bot.load_extensions("commands"), you can replace your entire code with just that
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
does exist an Enum class to get archive duration possibilities for Threads ?
no, but docs list it under TextChannel.edit
(60, 1440, 4320, 10080)
damn xD thanks
TypeError: expected Interaction or BridgeContext, not <class 'discord.commands.context.ApplicationContext'>
Pass in ctx.interaction
Hi, how can I allow multiple lines in a modal form?
https://docs.pycord.dev/en/stable/api/ui_kit.html#discord.ui.InputText.style
https://docs.pycord.dev/en/stable/api/enums.html#discord.InputTextStyle
The library has helpers to help create component-based UIs. Shortcut decorators: Objects: Attributes children, disable_on_timeout, message, parent, timeout. Methods cls View.from_message, def add_i...
The API provides some enumerations for certain types of strings to avoid the API from being stringly typed in case the strings change in the future. All enumerations are subclasses of an internal c...
So with style=TextStyle.paragraph?
InputTextStyle, yes
I will try it out, thank you
I get the error NameError: name 'TextStyle' is not defined
The same also with InputTextStyle
With style=discord.InputTextStyle.paragraph, it works
are you sure you are using pycord ?
(look to the pip list)
well... thats how you need to do it lol
do you know basic python
I thought I could do that with a separate import of TextStyle as well
Yes, but it works now
yea, but you imported it wrong if it doesnt
because, still, its called InputTextStyle
oups the chat didnt fully load mb, perfect then
Do I need to explicitly add a slash command group?
My regular application commands were registered automatically, but the group command wasn’t.
Was is in a cog?
than you just load the cog
did yo urestart discord after adding the group
yes in main file, no in cogs
(for cogs, it is automatically added when the cog is loaded; there is no equivalent mechanism for that outside of cogs)
yup
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):
you have to set it on the group, not subcommand
...we really should remove several kwargs from subcommand decorator
^ subcommands cant have different "settings" then the base command because... discord
alr that makes sense tho i knew i was messing smth up xD
it works thanks!
This is embed.type
but the discord docs dont say anything lol (the link is broken btw)
pretty sure discord bots only use rich, I think the other types are for discords autogeneration from links and such
Here's the slash users example.
@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
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 😊
🎉
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.
It sets the bot's activity (like "Listening to Spotify") to "Watching the The Terminal"
OH. Like on the discord profile itself. Got it.
yup, it's purely "cosmetic"
don't need that lol
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
interaction.data["values"] will give you the button value
oh i solved it with custom_id thx anyway
um does anyone know how to edit original message using applicationcontext? i went thru the docs but i didnt rly get it :(
ohh
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
You should do ctx.interaction.edit_original_message
ye thas what i did
.tag paste
await ctx.interaction.edit_original_response(embed=embed, view=QuizGame(ctx))```
also
oh wai
.tag autosave
Tag not found.
Did you mean...
vc-autosave
.tag vc-autosave
Look at this StackOverflow post to learn how to setup auto-saving in VS Code.
It should be the same between response or message. The message one is an alias to response
oh
i have no idea why its giving an error then
I'll take a look
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))
Flag 'delete' is required and missing
oh
.tag paste
and paste your entire file
oh ok
yep done
line 56
You can't edit the response if you never responded in the first palce
i did in another file
simply use await ctx.respond
yeah
line 56
it will handle everything for you
i see
and the error is STILL on line 56 in the first paste
and this stays the same i believe ?
await ctx.interaction.edit_original_message(embed=embed, view=QuizGame(ctx))
alr
yea, but I don't get why you pass ctx at all
just use the interaction you get from the button
you sure ? It's an Interacton object named ctx
oh, alr
also @somber crystal
with open('cards/jobs.json', 'r') as f:
jobs_data = json.load(f)
.tag blocking
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)
yea?
You should use something like aiofiles
oh
alrr
pip install aiofiles
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
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
tf
@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
oh 😭😭
here it should be ctx
helpp okayy
and you should be using ctx.edit
@echo wraith @sage tendon sry for the ping
it worked ^^
tysm! 🤍
npp lmk if there's anything, happy to help
Context, for slash commands this is
discord.ApplicationContext
discord.ApplicationContext.author
discord.ApplicationContext.bot
discord.ApplicationContext.channel
discord.ApplicationContext.channel_id
discord.ApplicationContext.cog
discord.ApplicationContext.command
discord.ApplicationContext.defer
discord.ApplicationContext.delete
discord.ApplicationContext.edit
discord.ApplicationContext.followup
discord.ApplicationContext.guild
discord.ApplicationContext.guild_id
discord.ApplicationContext.guild_locale
discord.ApplicationContext.interaction
can a command option be Union[discord.Member, str] type?
for a clash royale bot, either mention or player_tag
then just make 2 options, one for the clash royale ign and one for the discord mention ig
yeah that is the only option now
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
That should work better, thanks!
Edit: can't get members in autocomplete, tried using discord.ext.commands.Converter too
I will just use the 2 options
discord.ApplicationContext.respond has the same params as discord.ApplicationContext.send_response?
doesn't seem to have anything here: https://docs.pycord.dev/en/stable/api/application_commands.html#discord.ApplicationContext.respond
Also if I am just sending back a string or a file attachment, is it better practice to use send_response?
just use respond, it handles all cases
Reminder for @echo wraith
this shit
already fixed
Marvelous. Thanks
How do I get the discord ID of the person using the slash command?
with .id
alr got it. i was using .id on the wrong thing
Well, making the balance command wasn't that difficult
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?
its fine
Marvelous. Thanks
Is this good practice?
No, you are right, with open would be better
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
with open(...) as file:
file.read()
file.write(...)
No need for close as the context manager does that for you
hardcoded file path....
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
we actually discussed that #general message
Bare except is very bad, please dont do that 🙏
This is like really bad practice
Yeah, we talked about that yesterday, they had their reasons and had thought about the alternatives already
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!
It's very low traffic.
I would personally change the flow to open the file as rw and check if it is empty rather than a try/except
sqlite would still be miles easier than manually wrangling text files
it's literally easier
on second thought, even JSON/CSV may be better than this
Wdym by this
except: should be like except FileNotFoundError as e: and then you have the error context in e
You can specify what kind of error type the except will catch ^
Ohh I see
Otherwise it eats all error, even ones that you did not intend to catch
and why while 1:
C habits ig. but yeah, use while True
I do a majority of everything with C followed by C++
oh lol. True isn't even a term in C
well... welcome to python ig 🙂
It seems like i'm trying to catch IOError?
wait.. when is that else clause even being entered?? else after a try-except?
else is not entered until open(file, r) runs without error
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
why are so many people so against even just sqlite
You can put else on a few different things in python, for loops for example
tf
and when is that entered?
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
When the for loop exits cleanly without using break iirc
your bot has been stuck for over 10 minutes lol
"File is empty" will be true if the file doesn't exist?
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
No
is rw read/write mode in one?
yeah
you could / should use mode x when creating the file
if you really wanna keep doing text files lol
alr imma try rewriting it a bit to be less convoluted
wtf how is that possible
i mean you said yourself you have blocking code
I need to initialize it with a zero though, don't I?
Otherwise the file would instead be blank
no idea if you can do it while creating the file with x, but if not, just do it right after
and cause errors if I try to do operations with its read values
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
yeah but i didn't get any issue in the past year so it's really really strange
restart the bot and see if it still happens
Why is if-except-else considered bad?
At the bot?
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
There is a big problem with the except in my case where the exception isn’t specified.
then make another one as a catch-all that aborts it
But it seemed like people were saying the concept of using if-except to catch the file read error is bad idea
Yeah. Have the except [specific] catch file read error, then except [unspecified] print an error and exit the loop
try:
...
except specific-exception:
....
except:
<abort, clearly bigger error happening>
oh wait you have that already
yea
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
Is it not one of the fastest methods to check though?
why wait for an error if you can avoid it altogether
i'm just speaking in a general sense, if you prefer to use try-except then it's not like we can stop you
That’s a good point.
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
Thank you for this.
how do you declare a command that ends up looking like this?
you mean with the space at it?
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
name: int
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
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
oh you want a user, so yea, it would be user: discord.Member
where can I find the list of other member functions like .id?
go the docs and search for discord.Member
.rtfm discord.Member
discord.Member
discord.Member.accent_color
discord.Member.accent_colour
discord.Member.activities
discord.Member.activity
discord.Member.add_roles
discord.Member.avatar
discord.Member.ban
discord.Member.banner
discord.Member.bot
discord.Member.can_send
discord.Member.color
discord.Member.colour
discord.Member.communication_disabled_until
discord.Member.create_dm
discord.Member.created_at
discord.Member.default_avatar
discord.Member.desktop_status
discord.Member.discriminator
discord.Member.display_avatar
or like that, the first one
Found it in the docs. Is global name the username#1111?
I see that there's name, global name, and local name
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
how can i check if a user can view a channel?
If I wanted your name, for example, which would give me dark.py
discord.Member.name would give you dark.py
alr thanks
discord.Member.global_name would give you Dark
Use the permissions_for method
Then check for read_messages attr which is a bool
alr thx
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?
Both work, I'm just wondering what is more efficient.
even if the effect is miniscule
Both are just looking at a value. That level of efficiency is generally not worth looking into.
So once discord.Member is passed as an argument, its already a stored structure variable?
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.
Ok so there's essentially no difference.
discord.Member is likely a structure. I'm guessing when its passed as an argument, a copy of the whole Member structure is being passed. Therefore, Member.id is actually a variable already.
Member:
id: ....
name: ....
....
The fact that the difference is so small means that .id only accesses a variable that already exists within that structure and nothing else
Not sure what a structure is, but the terminology I am familiar with is that you are getting an instance of the Member class.
sorry, structs are at least what they're called in C++
Python likely names them differently
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.
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.
How do I make my bot actually ping people by name? I can only seem to get this
if you have the user object, user.mention
otherwise, format it as <@user_id>
it's classes / objects like in every language beside C lol, and they're very different
if you never worked with proper classes and objects before please look into it
You really don't need to worry about stuff like this, especially in python lol
and I mean what's the difference, you're accessible a variable either way, the only difference is that you need like 32 bit more RAM to store the id in another variable
And in compiled languages, the compiler will take your code apart to optimise it to hell and back anyway
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
file=RC_file
sorry for the ping, do you know how we can remove the file?
file=None doesnt work
how do i clear the file
attachments=[]
I think
to clear the files
i see
when editing
alrighty lemme try
oh yess it worked tymsms 💗
npp
Models are classes that are received from Discord and are not meant to be created by the user of the library. Attributes key, url. Methods def is_animated, async read, def replace, async save, def ...
please read
Structs in C++ are objects
yea but.... meh
And the fundamental behavior in question does turn out to be almost identical
C on the other hand does not have objects
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)
as for this, one takes up more time, another takes up more space, i'm guessing? so pick your 🐟 ||(wordplay: poison/poisson (fish))||
Guys we're talking about python lol
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
the guy's into embedded dev (maybe wants to do MicroPython/CircuitPython later), so good to keep these in mind ig. but ye, i wouldn't bother with performance this much :v
It’s really interesting how everything is so certain things are setup in Python vs C/C++, like for loops
wait till you see for loops in Go :3
they're like at the complete opposite ends of the spectrum in terms of high and low levelness
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
In Python we could also do: for i in range(0, max_i, 1): if we want to :3 (but no one wants to)
in range(5) works too
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
Ye, but it’s good to know the existence of the step argument
Yeah ofc
Didn't know about CircuitPython
Neither is performance thinking, if I’m being honest… not at this stage
Performance is always important to consider. Maybe not for something as low impact as what I was talking about
its python
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
Performance is never important to consider unless it’s obviously bad practice (like quadruple-nested loops), or if it’s something that is actually impacting the program’s ability to do its work
Premature optimization is the bane of good software
thats also a bad mindset lol
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.
"We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. Yet we should not pass up our opportunities in that critical 3%"
— Donald Knuth
from: https://en.wikipedia.org/wiki/Program_optimization#When_to_optimize
certainly i agree. just not about trivial matters like this
correct
as i mentioned here as well (if one reads beyond the first 6 words...)
Oh yea, obviously. My question about whether to use a variable or just call .id each time came from the fact that I didn’t know what .id was.
ah. the term for that is attribute of an object/instance, in OOP languages like Java/Python
Now that I realize it’s just grabbing an attribute, I can understand why it makes almost no difference
makes sense
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?
File I/O and Networking are almost always the bottlenecks
I wonder if SQLite would fare better 🤔
SQLite installs itself to your device, right?
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
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
I didn't know sqlite was in the standard python
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
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
Then you need a database
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?
half of the replies to Mr. Klunk are either "don't worry about this in Python" and "Use a database" XD
grrr I’ll make my own database
I mean it's a db or a json file if you want it for the laugh
the code is trivial. you can literally just read it and understand what's going on... source of Python stdlib SQLite module: https://github.com/python/cpython/tree/3.13/Lib/sqlite3
or CSV 😏
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
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)
that's fair too
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)
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.
similarly large assortment of storage
... we... have a word for that... XD
can explain the cooldown mechanic a bit? i think i'm not quite getting it
there is a build it method about those cooldown in case you dont know
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
I did NOT know
there is dynamic cooldown you should take a look
Ah, just store last invoked time alongside the value. Use the CSV module
The following section outlines the API of Pycord’s prefixed command extension module. Bots: Bot: Attributes activity, allowed_mentions, application_flags, application_id, cached_messages, case_inse...
how do I find it?
oh thanks
Oh nice. That’s even better
And there we get our max efficiency lol
tf
What's with everyone avoiding sqlite or in memory storage like it's lava
Lmao
.
there's a thin line between that and reinventing the wheel
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
wait why am i getting rate limited out of a sudden
is it because my users are spamming commands or smth?
Are you using a shared hosting service?
nope
never seen that before lol
usually Pycord handles rate limits
what are you doing, clearly you're doing something way more than usual
wth
nah
my bot is running fine since 2021
it's just that my bot users has increased by a lot lately
do you edit channels or stuff a lot
so you're running it on your own server or something
vps
could be it if the hoster uses the same IP for multiple servers
so far from what i can see in the error logs, it's just sending messages to a logging channel, and updating the bot's nickname
is that the full error
there are multiple errors
show them all
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
btw does it do that even if you send raw requests?
yeah
sidenote consider updating your python, 3.9 becomes EOL this year iirc
oh that one is assuming you may have been temp banned by cloudflare, not discord
because typically 429s are handled differently
any syntax or major changes from the new version?
no clue what happened to 3.10
huh what caused it
im always on latest lol
idk that's between you and them lol, it'll probably go away after some time
how many users/guilds is it in?
but it's an economy bot so players are spamming different commands every second
does your bot use slash commands mainly
shouldn't be an issue if it's all regular slash commands though
ok that's fine
since that looks like error logs i would suggest fixing the errors
yeah
that would likely mitigate your issue
it seems like you have errors being spammed?
yup but it sends messages occasionally
i mean the messages themselves aren't necessarily a problem
the error is raised by 429
you may also just be performing some action repeatedly very often
and so it can't send messages to the channel due to being ratelimited
so you have an infinite error loop?
any member roles or anything?
and it raises the error again
dms?
the thing is that interactions have a significantly higher ratelimit, in normal usage you would never get ratelimited
yeah kinda but im not seeing any error messages in the log channel
yea maybe just abort the error handler when it's a 429 so it doesn't loop on itself lol
nope
I think you constantly spam the API trying to log an error, get another error, etc
weird
yeah good idea i'll do that
of course that can't be the root issue but yea
but the channel isn't sending any message
yea but it's still constantly trying to send it no?
yes but no
hm
well either way it can't be the root cause so maybe fix that later lol
did you ever set up the logging module
Pycord logs errors and debug information via the logging python module. It is strongly recommended that the logging module is configured, as no errors or warnings will be output if it is not set up...
nope but is it mandatory?
no, but that gives details on ratelimits
the only way to really fix your problem is guess at what you're doing thats getting you ratelimited
from the sounds of it, you've been exceeding ratelimits the entire time and only now discord's being harsher on you
right
anything in your bot that does a lot of fetch actions?
so far it's just the sending message and nick editing requests
like what kind?
get_channel?
or perhaps something where your bot is lacking permissions but tries anyways?
fetch_member would be a main culprit usually
yes i think that's the reason
or just any other discord actions
my bot is lacking permissions in some server and it's trying to send messages and editing nickname repeatedly whenever they use a command
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
nope
do any of you know if editing the bots nickname is particularly strictly limited
they probably mean user nickname?
i would suggest checking permissions before trying to do anything, otherwise look for anything that might happen extremely often and try to downsize that
not always easily possible tho, permission checking sucks
especially stuff like sending a channel message every command, if they're being used that often
guild.me.permissions.change_nickname?
hm okay yea I was more thinking like send message permissions
like even .can_send sucks
yeah but attempting to send message to a channel shouldn't be ratelimited right? unless it's different if it's trying to send a message but it fails?
i myself have been ratelimited for sending way too many messages
oh i remember before this happens the error logs is showing guild.me is None
what
i have no idea too
is your bot a user-installable app?
no
do you have member intents enabled?
yes
you need member intents to get your own member object? hm
nah
guild.me only returns None in certain guilds
works fine in my official server and most servers
i ignored that tho
probably check Interaction.app_permissions then, i think it includes guild level permissions
please stop ignoring your errors 😅
guild.me being none is weird though

they wasn't fatal and i was lazy
and look where you are now !!
anyways best thing you can do right now is try and change something and then wait it out

(turn your bot off so it doesn't keep sending requests!)
yeah too late to unratelimit yourself lol
discord shut it down two hours ago
set up logging as outlined here, it'll help
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
and now it's back up
well
discord can't turn off your bot lol
yes but the process
most bots will shutdown after a fatal error like that
they only do that for gateway login stuff i think
idk it's suddenly down and my discord are full of pings
nah ik because it's happened to me before
mm
the bot account or the actual process
the bot is off
if its still running it will try and send requests to discord even if its ratelimited
so you should stop it
i think it's something to do with my hosting service
could be
that's on you then lol
nothing from Discord's side can kill your process
what service do you use?
if it's getting too much error it will crash the process
eh
railway.app
oh
that
