#Basic Pycord Help
1 messages ¡ Page 72 of 1
/
wrong slash
when i use
await ctx.trigger_typing()
I get permission error, which permission need to be allowed?
these are my current
You need to make sure the permissions are correct for the channel too
Also changing these won't update them once you added the bot to a server
now it works ty
np
somebody else have rate-limit or its only me?
if its only me how much time i should way for it to go away?
?
Channels got many rate limits
[2025-04-11 20:30:59] [WARNING ] discord.http: We are being rate limited. Retrying in 431.55 seconds. Handled under the bucket "None:None:/applications/{application_id}/commands"
How many commands do you have?
Yea
what is it?
100 normal slash commands
wdym whenm you say normal?
removed some and now i have 90
You can have 100 commands, and each command can have up to 25 sub-command groups. Each sub-command group can have up to 25 sub-commands.
100 x 25 x 25 = 62.5k
Of course, "slash commands can have a maximum of 4000 characters for combined name, description, and value properties for each command and its subcommands and groups", so you're not likely to hit that 62.5k command limit
This can be doubled again with guild commands
# ---===Antilinks-commands===---
antilinks_group = discord.SlashCommandGroup(name = "antilinks")
# ---===Drop-commands===---
drop_group = discord.SlashCommandGroup(name = "drop")
# ---===Fun-commands===---
fun_group = discord.SlashCommandGroup(name = "fun")
# ---===Feedback-commands===---
feedback_group = discord.SlashCommandGroup(name = "feedback")
# ---===GiveAway-commands===---
giveaway_group = discord.SlashCommandGroup(name = "giveaway")
# ---===Logs-commands===---
messages_group = discord.SlashCommandGroup(name = "message", description = "Log messages")
roles_group = discord.SlashCommandGroup(name = "role", description = "Log roles")
members_group = discord.SlashCommandGroup(name = "member", description = "Log member")
channels_group = discord.SlashCommandGroup(name = "channel", description = "Log channels")
# ---===Moderation-commands===---
moderation_group = discord.SlashCommandGroup(name = "staff")
# ---===Multi-Cogs-commands===---
setup_group = discord.SlashCommandGroup(name = "setup", description="Setup")
# ---===Tickets-commands===---
tickets_group = discord.SlashCommandGroup(name = "ticket")
# ---===Utillity-commands===---
utillity_group = discord.SlashCommandGroup(name = "utillity")
this?
This are group yes
it still giving me rate limits
You cannot just have more than 100 /name
Because you will need to rate limit to be done before not having it again
what
exactly when is the ratelimit occuring
2025-04-11 21:06:59?
could you try set auto_sync_commands=False in your bot constructor
(if you ever need to update command metadata or add/remove commands, set it back to True)
now it doesnt give me the rate limit but it stills doesnt show my commands
hmmm i guess you need to sync at least once
wait for the ratelimit to expire, then let your bot sync commands
but when i sync its giving rate limit so i cant sync
yeah so you have to wait 
You'll need to wait
i waited a hour or so i think
and then its giving rate limit again
Usually 24 hours for the reset for slash commands
if it doesn't work then you might have to wait the full 24
because syncing is weird
damn
hate this
or just temporarily test on a new token if you can afford it
you mean reset the bot token or make a new bot?
new bot
made new one and still the same đ
literally how
idk
you sure you changed the token in your files...?
yes
the other bot is online
and its showing me only help command .
for command in bot.commands:
print(command)
it's bot.application_commands
mmmm if you set auto_sync_commands=False and later manually run await bot.sync_commands() while the bot is running, does that work?
idk
its showing my commands
BUT
its saying user install when i set that to guild install
why do you have so many commands..
if #1132206148309749830 message is everything then it's not really that many
good question
i've actually experienced something similar recently
My bot has like 20 commands, and i didnt touch any of the data that would trigger a proper resync of any command, and i still got ratelimited under the commands bucket after restarting a bunch of times
im not sure if discord changed something or if its an issue with pycord where commands are force synced needlessly
oh probably uhhhh
during big outages, whenever the bot reconnects it might try to sync again
how many commands do you have ?
mb the chat didnt load
it was during testing nelo
Is it possible to change the way requests are sent to discord?
like?
I'd like to manage the frequency of requests sent to discord
wdym the frequency
idk then but there's no code to randomly sync commands
i just feel like pycord either unnecessarily force syncs commands, or discord handles the ratelimit weirdly
You can send requests to discord like sending a message, creating a channel... I'd like to control this sending to put a personal rate limit.
fork the library ig
but it seems a bit hard so good luck with it
pycord manages ratelimits if you mean that, you dont have to worry
For Discord, possible. The problem is that I'm on a free host and the bot sends too many simultaneous requests for certain commands and the host's proxy blocks me (sometimes it's discord too but I think it just blocks the server's IP).
katabump
I'd love to, but I can't afford one right now.
you will not be able to do anything about that
since as you say if other bots send too much requests you will also get rate limit
yea these free hosts are often just overcrowded and just reach the IP ratelimit, you literally cannot affect it
i assume its free if it has those issues
:/
if you want there is a french host with a free version for a month (but you can renew forever) with up to 3 panels pterodactyl
ping will be around 80 but else its can be good
theres hosts for literally <1.50⏠so
go for it if you can
its like 3 panels like this at max
but everymonth the thing will be delete so you will need to do everything
I can't pay...
"my" thing is free
why not
i didnt use it for years so idk how its working etc but if this can help you
but again its not magic, you might get rate limit also (even if there is less chance cos its a small business)
thanks !
Are there any modules that can be used to start several bots at the same time on the same server?
if there are all on the same panel you can just restart the panel
and it will restart everything so
ctx.send_modal(Views.Feeder.FeederPopup())
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "F:\downloads!!\Coding\HSC_bot\src\cmds\setup.py", line 98, in __init__
self.add_item(discord.InputText(
^^^^^^^^^^^^^^^^^^
TypeError: InputText.__init__() got an unexpected keyword argument 'label'
the docs say label is a required peram
am I stupid
class FeederPopup(ui.Modal):
def __init__(self):
super().__init__(title="Feeder URL")
self.add_item(discord.InputText(
label="Feeder URL",
placeholder="https://meow.camera/#5422485483170589671",
style=discord.InputTextStyle.short,
required=True))
```
positional?
That is not how you send a modal
how do you
modal = TheModal()
await ctx.send_modal(modal)
but thats what they are doing? lol
i dont see the difference?
you mean its imported from a file location in any way?
clearly lol
Like toothy said, the only difference is I defined the modal class elsewhere and instantiated it inside of my send command. If it would help, I can send the modal definition too...
Do you have anything else installed that causes this issue?
show your pip list
discord.ui.InputText
omg ty im an idiot
Hi, does anyone know why when I get self.bot.owner_id none in cog and not the id of the bot owner?
Did you set the Owner ID at the bot?
hm....
Or did you even set at owner of the bot?
yippie the docs are down
and back
im not automaticly the owner i set it manu right?
Bots: Attributes activity, allowed_mentions, app_emojis, application_flags, application_id, auto_sync_commands, cached_messages, cogs, debug_guilds, default_command_contexts, default_command_integr...
Okay, how can i set me as owner?
owner_id=⌠on the bot/client constructor
Tbh if there's a V3 that manual owner id thing should be removed.
^ and owner-id and owner_ids should be merged
Yess
agree with deprecating owner_id, but manually being able to set owner_ids is still useful for internal owner checks
would simplify checks anyway
narrows it down to if user.id in bot.owner_ids
instead of needing to check both variables
well you only need to check both if you set both
the builtin bot.is_owner(user) will check both, if neither are set it will fetch application info and only set the latter
actually
it sets owner_ids if it's a team, otherwise it sets owner_id
(either way just use the builtin)
Can I have 2 of the same events?
if you use listeners
It would be in a cog so yea, listeners
not two of the same in the same cog but that'd be pointless anyway
I'm not saying it's not useful but imo it is too specific of a use case to be part of the core library, but whatever idrc
idk how manually setting the bot owner is too specific
you can
oh, hm
in the listener decorator, you can pass the name of any event instead of using the function name
Not too specific but doesn't feel like it should be a core feature
Like pycord is not a framework
its very common to make owner only commands
Yes it is but it should be up to the user to handle how they check that / use something from discord.utils
Imo
It should not be part of the bot class
why tho?
its literally perfect
its the owners of the bot
why should it not be in the bot class
Hi, i want to use this with py-cord AppCommandContext
class discord.app_commands.AppCommandContext(*, guild=None, dm_channel=None, private_channel=None) can you help me please
that is not a thing in pycord
i can't use pycord and discord.py in same script
You have to pick one
that is discord.py code, so either you keep using discord.py or you switch to pycord
ok, thanks
You dont need to use both either, each have approximately the same features
do you know how to use py-cord to use commands in dm?
DM with other users or DM with the bot itself?
You need to make a user app for that, and then make sure you set the correct contexts and integration types for the command. Here is an example
Here's the slash users example.
thanks you
how could i add in discord.Option the the type is the bot application commands?
possible that only certain discord UIDs can see slash commands?
Otherwise I would check if the UID is whitelisted to run the command and if not displays to the user "not authorized" or smth similar
Only via the integrations menu in the server settings
Okay, so if the bot is ran in direct msgs it is not possible?
Not to hide them, no
You can only do checks then
Ah okay thank you â¤ď¸
of course you can also exclude the command from being used in DMs entirely but i think thats not what you want
no, the bot wouldnt really be used in servers, prolly just DMs
there's any API limit or i can update channel status every ~1 second?
if its counted under the channel editing bucket its once every 10 minutes i think
try it out and see how far you get
I don't think it is, but it still has not been documented by discord, so it is still experimental
Updating anything once per second seems way too often though
yea agree
its probably for a clock or counter
Is there any way to find out which file extension a role icon needs?
I tried copying the exact code from my emoji saver which tries to get it from the URL, but it just ends up with no extension
I feel like that's kind of hacky anyway
role icons are saved as png
huh
you sure?
if i inspect element it, the url is .webp
the lib uses png, but it seems to be interchangable...? lol
Doesn't discord convert things to webp after you upload them?
i checked with a file type checker and the stuff i get from discord sure are PNGs
ah right, for assets you can use any allowed extension and discord will return it in that format
Missing await?
that's a good point too
ctx typehint is wrong
and you misspelled ephemeral
typehint?
Can you show the json?
oh
I think I hit shift by accident
I really should pay attention to small errors like this huh
would you look at that, now that the json is actually written properly it can read it
welp that's half of the progress, thanks gang
You do you, its your code after all. But I am going to leave this here for reference
JSON is a convenient and easy-to-read data storage protocol that's widely accepted by most programming languages. However, we caution against its use for storing and retrieving data in an asynchronous environment like a Discord bot. Donât use json!
- It's a file-based data storage, which makes it vulnerable to race conditions
- You'll need to implement your own synchronization primitives to avoid corrupting data
- If you're not careful, you could accidentally wipe your entire JSON file.
Solution? Use a database. Recommended schema are SQLite, PostgreSQL, and MongoDB.
- Async libraries exist on pypi for each of these
sqlite --aiosqlite(or Danny's wrapper: asqlite)
postgresql --asyncpg
mongodb --motor - Databases organize your data into tables, and are fast at inserting, retrieving, and removing records
- You can impose uniqueness constraints to ensure against duplication
- The Python libraries enforce synchronization for you
- The query language is intuitive, you can get running with simple queries in just a few hours!
If you use VS Code, you could install for the errors the extension "Error Lens" from Alexander
I'm only using it for private use, so idm using json
dont use file as its blocking, you should use aiofiles
also it's something I'm familiar with lmao
so what do I do exactly then
is it a library and then just as aiofile
pip install aiofiles, and then async with ... and await file.read()
Aiofiles isn't really necessary unless your file is like is really big (GBs)
always better to not have blocking code when using a bot discord
Anything non async is blocking then
but using a database might be better
ofc but you can imagine that he could use in his code with ... : and then a long code
while print will always take the same amount of time
(all I use it is to get out data I actually need and then process it outside of that, kinda the reason I just globalled people instead of doing it inside with)
why global? because idfk how to toss data up the chain
learn database will always be a plus
all I know is how to toss it down the chain lmao
and its really easy
I've tried in the past and I couldn't even figure out how to download it lmao
probably because I couldn't figure out where the actual download button was on sqlite
just use sqlite
pip install asqlite
A simple async wrapper for sqlite3. Contribute to Rapptz/asqlite development by creating an account on GitHub.
I will probably get it if I need it for something else and/or I run into issues, for now I think json will do
youll regret that
.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)
.tag rie
You can run blocking code (such as PIL/Pillow) in an executor to run it in a separate thread: ```py
def my_blocking_func(*args):
...
@bot.command()
async def test_command(ctx):
ret = await bot.loop.run_in_executor(None, my_blocking_func, 'put', 'args', 'here')``` See the python documentation for more info.
then let me regret it and be forced to rewrite the code pls
when you will have to change that will be a nightmare
believe me
i did first json
then sqlite
then aiosqlite
.tag nojson
JSON is a convenient and easy-to-read data storage protocol that's widely accepted by most programming languages. However, we caution against its use for storing and retrieving data in an asynchronous environment like a Discord bot. Donât use json!
- It's a file-based data storage, which makes it vulnerable to race conditions
- You'll need to implement your own synchronization primitives to avoid corrupting data
- If you're not careful, you could accidentally wipe your entire JSON file.
Solution? Use a database. Recommended schema are SQLite, PostgreSQL, and MongoDB.
- Async libraries exist on pypi for each of these
sqlite --aiosqlite(or Danny's wrapper: asqlite)
postgresql --asyncpg
mongodb --motor - Databases organize your data into tables, and are fast at inserting, retrieving, and removing records
- You can impose uniqueness constraints to ensure against duplication
- The Python libraries enforce synchronization for you
- The query language is intuitive, you can get running with simple queries in just a few hours!
and rewrite 10times the database of all ur code is horrible
I think that aiosqlite is more common
json is not a data storage format
idk, i just edit the message according to the tag
but i never used sqlite so
I'm only upstuck on it being json because I know I can always just resort to using txt files
...wtf
no joke, was the first idea
why are people so allergic to databases
"literally what's stopping me from just using txt files to print this text"
sounds like more effort than it is probably
it's an object notation
am I understanding buttons correctly?
await ctx.respond("Are You Sure?", discord.Button(custom_id="y", label="Yes", style="success"), discord.Button(custom_id="n", label="No", style="danger")
(this is just me trying to mentally explain buttons to myself, and I have no idea if I'm correct or not lmao)
and I presume then it's just if y: if n:?
Here's the confirm example.
oh 
only question I have is: is there a way to avoid the entire self thing?
like, using return or something?
or is the self thingy referring to just the button
because my bot has no __init__ stuff in it, so idk if that's an issue or not?
its the view.
ah got it, thanks
look into OOP in python, the entire library is based on it
ty, also for interactions like await interaction.response.send_message I look here in the docs, right? https://docs.pycord.dev/en/stable/api/models.html#interactions
trying to confirm because I still have no idea how to navigate itđ
i just look up whatever class i need and go from there
buttons don't appear? what have I missed, does it need the interaction?
yes
ah, got it
does it have to respond with a message or can I just ignore it or do anything else?
modal?
so can it do something stupid and useless like react to the ephemeral message?
(if you can even do that)
no
welp, rip
well, I added the interaction but it still doesn't seem to add the buttons?
no traceback in console
entire command is like this (ignore the questionable code)
am I ever sure of anything (sarcasm, not really?)
watch the issue be me accidentally capitalizing something again
check
wait, can ephemeral messages even have buttons?
yes
alright so that's not an issue
I'm pretty sure I'm importing the right thing?
everything seems to check out
ctrl+click follow your Confirm() and see if its the right class
and make sure you restarted your bot
ok funny part is, it still times out lmao
yeah it brings me back to my class
what times out?
the interaction
also really dont use globals unless absolutely unavoidable..
as if buttons were there but I didn't click them
show
like it just does the timed out message
show
are you actually restarting your bot
wtf is ctrl pause break
terminates whatever is currently running
where is your view class
view class?
yea
that's a thing?
...your confirm view class
where is your Confirm class located
uuuh... in the same file if that's what you're asking?
it's outside any command
at the top below bot = discord.Bot()
...wait
nope that wasn't it
tried moving it above it, but nope
no idea tbfh
can you send your pip list
wait, since you are using vsc... are you actually saving the file before restarting the bot
yes
aiohappyeyeballs 2.4.4
aiohttp 3.11.11
aiosignal 1.3.2
attrs 25.1.0
audioop-lts 0.2.1
frozenlist 1.5.0
GPUtil 1.4.0
idna 3.10
multidict 6.1.0
pip 25.0
propcache 0.2.1
psutil 7.0.0
py-cord 2.6.1
yarl 1.18.3
bruh
idk man
you have only one file right
just send it here
do buttons need it
like, do you need to define intents
I believe that was a thing I had to do a while back, and didn't do here
let me try to tinker with some things, then I will when I'm out of ideas because I think I might've found the issue?
I just realized, the example for the buttons is like 3 years old isn't it?
interesting...
???? it suddenly has an issue with this
????????????
I'm so confused?
oh alright reinstalling pycord fixed it lmao?
alright, I've spent a while trying to tinker, do you mind if I send you the file in dms?
Can you show the pip list?
I fixed it alr
reinstalling py-cord solved it
still fighting buttons tho
something I just realized is that I don't think I'm even adding the buttons to the view?
the decorator handles that
ah
I'm actually so lost
OH MY FUCKING GOD
I THINK I FOUND IT???
I WAS DEFINING THE FUCKING BUTTONS INSIDE INIT
DESPERATE CHAT GPT ATTEMPT TO THE FUCKING RESCUE I SWEAR TO GOD
AND IT WORKS PERFECTLY
... you weren't tho?
bruhh
yea
yep, and I had it like this
is a thread delete raised by an on_raw_thread_update event ?
I don't see why it would fire an update event
I know there is this event too, but a delete is an update technically đ¤ˇ
that's why I ask
Not really. Update means something has changed regarding the thread like the archive status. Delete means.. it's gone.
okay, thanks
Tias I guess
I will check. To make sure, I have added a if thread is None in my code (after trying to get / fetch it)
hi i have this error in the console : discord.errors.HTTPException: 400 Bad Request (error code: 50006): Cannot send an empty message
messages = await text_channel.history(limit=10).flatten()
for message in messages:
async with aiohttp.ClientSession() as session:
webhook = discord.Webhook.from_url(webhook.url, session=session)
await webhook.send(message.content)
probably the original message contains just an attachment so its content is empty
Also take in account defer
forgot how to remove an attachments in this case
For message in message, if not message.contrnt continue
If you only want to send the text
I don't use JSON as a storage format, I use YAML. Much better.
(Apparently that was a conversation from yesterday; I'm late)
how can i send a message like every sunday at 16:00
well you can set a specific datetime.time, you'd still have to check the current day
i'll see it, thanks!
Iirc a cron lib also exists?
But dunno if it works with pycord
Last time I tried it didn't, or maybe i was dumb
aiocron. It works with pycord if you set it via aiocron.crontab(...) (the decorator does not work within classes (e.g. cogs))
I am so confused. How can this command: https://pastebin.com/St7eMNYC
have this output? (See screenshot). It's not the 2nd embed as the 1st line differs and the debug log isn't printed. I'm baffled.
Kits == 1 btw
Where is the embed even coming from xD
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
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.
what does that have to do?
That your logging level is debug or lower
I'm 99% certain its saved as there's no white dot next to the filename xD
.tag logging
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...
What do you mean by this?
Read this
And set it to logging.DEBUG instead of INFO
okay... what do i do with that? I'm a bit stuck
Did you set up logging somewhere in your code ?
I mean, Py-cord's debug logging is now showing, but idk what to do with that
Well now your own debug logging will show too
no no, I am using a different library called loguru and my logs (including debug logs) are already showing
Uh ok alright
This is what's outputted to console:```py
2025-04-17 09:47:02.414 | INFO | main:<module>:14 - Loading cogs...
2025-04-17 09:47:02.422 | INFO | main:<module>:19 - Loaded queue_cog.py
2025-04-17 09:47:05.404 | INFO | main:on_ready:11 - Logged in as EzTiers - 1336048103999930419
2025-04-17 09:47:15.078 | DEBUG | cogs.queue_cog:sendwaitlistembed:13 - Called /sendwaitlistembed
What line differs even
From the embed? This:
From the dropdown menu, please select the kit you wish to test in.
That's written in the embed, but not displayed. I had this embed previously, but not anymore (aka i deleted it for debugging)
Ok are you sure the bot isn't running twice?
Nw
hi! does anyone know why guild.get_role might be None? I'm 99% certain I'm using the correct role IDs, yet it doesn't work. This is the code in question:
tester_role = guild.get_role(tester_id)
sr_tester_role = guild.get_role(sr_tester_id)
if tester_role is None or sr_tester_role is None:
log.error(f"Tester or Sr. Tester role not found. IDs: {tester_id}, {sr_tester_id}")
await interaction.respond("An error occurred while processing your request.", ephemeral=True)
return
This is the console log: ```py
2025-04-17 13:55:02.795 | ERROR | views.queue:create_high_ticket:125 - Tester or Sr. Tester role not found. IDs: 1362395334302498848, 13623953998847714792025-04-17 13:55:02.795 | ERROR | views.queue:create_high_ticket:125 - Tester or Sr. Tester role not found. IDs: 1362395334302498848, 1362395399884771479
Why is this happening? Is it an intent / permission issue?
.tag get_x
Any function that starts with get_ in Py-cord is retrieving the related object from your bots cache. If the object is not in the bots cache the get_ method will return None. Because of this behavior you should check if the get_x method is None and if it is use the fetch_x method.
Why Is Using fetch_ Without Using get_ First Bad?
The fetch_ method makes a call to the discord API. This API call is unneeded if you already have the information. It will also make your command take longer because it will have to send and than wait for a response from the discord API. It will also contribute to the discord APIs global rate limit of 50 requests per second.
What Is Cache?
The cache is a temporary storage inside your bot. It holds many objects from members to messages. When you restart your bot the cache will be empty. When the cache is full it will delete older objects to make space for the new objects.
Is there any way to get a "clean" attachment url without the whole ex= nonsense at the end? For an API I use i need a clean one without any query params
Maybe just remove everything after the .png or whatever it is
doesnt work
Use yarl.URL and extract the clean url
I already said just removing the query params doesnt work
nevermind it, i found another problem first lol
It's not nonsense and I'm pretty sure the attachment won't load if you remove them
#discord-api-updates message
yes, as i just said
twice
Can you give an example of url ?
no nvm it for now the issue is bigger than the url anyway lol
does @tasks.loop overlap or wait until finish to go to the next itinaration ?
once i do guild.fetch_member() its going to be cached or not?
I don't think so but am not đŻ sure
No, fetch_ calls donât cache anything
I think it overlaps it, but try it and see
but wouldnt that be good because if you have chunk_guilds_at_startup enabled you dont have anything cahced at the beginning and could slowly cache everything
fetch_ calls have incomplete information
Only things cached are the ones received via gateway, which have all the information you need
chunk_guilds_at_startup doesnât make the bot call fetch_members on every guild, it uses the gateway to request all members of each guild
Pretty sure it waits
after test it does not
Someone should document that tbh
Do you have an example for that?
Usually fetch_ is an API call to Discord
Yes, I know
Example is on members, the user object can (and is usually) missing fields that are received via gateway only
This can include, for example, guild_banner, or user fields
Canât reproduce rn but when I can I will
why does fetch doesnt cache after ?
yeah, and maybe have an arg for it can overlap if needed
what do you think about that ?
Sounds good to me
ehm, no I don't think
you have to fetch in certain situations to get certain info
Fetch guild doesnât return everything
what not
no, actually, everything available on the fetch_ calls is received via gateway, but not everything received via gateway is available on fetch_ calls
Strictly speaking that isn't true either, but yeah close enough
Did you add the button to a view and set the view persistent?
yes and yes
with timeout=None?
I added the button to the view and its timeout is set to None
why is there a =?
f string
?
if you add = to the end of an f-string variable it will print like this
thats just the logging statement anyways
checked the code and it seems fine
did you use discord.ui.Button for the button ? or select ?
I used the correct button class
self._provided_custom_id = custom_id is not None
that's how it is setup
yeah really strange
are you on master ?
2.6.1
can you try on master to see if this still occurs ,
I am not setting the custom id during the initial button creation actually
a bit after, but still before adding it to the view.
Might be that
yep
but pycord should handle that, you might want to open a pr to add this change
this is only during the init
The custom_id's setter doesnt
ill make an issue
i'll take a look in 5min
where did you add the view to a persistent view?
you mean the button?
no, I mean the view
Where did you add the view to a persistent view
Did you add it at the on_ready event?
I dont quite understand how thats relevant. Adding the view to the bot shouldn't have any effect on whether the button itself is persistent.
Views are persistent, not the button itself
discord.ui.Button classes have an .is_persistent() function
fixing this, fixes the whole issue
but yes.
Im in the train so I have no connection rn, ill do it when I can
@errant trout since the component v2 are coming, is there a point of fixing this now ?
if yes i'll do a pr
i'll just include it in the v2 pr
no idea but ig it will be before 2.7
I think the unofficial ETA is within the next week or 2. But we know how all the other ETAs went XD
the unofficial ETA is today
you mean from discord or
It was Monday then Tuesday then soon â˘
From discord
experiment gate is being lifted like right now lol
OMFG YAAAY
wdym experiment gate
Probably the experiment that allows it on the test guilds
is it possible to fetch a message object of a message ID without knowing the channel associated ?
I know the guild but not the channel.
Nope
You need a channel
okay, because I have multiple channels (like a list of it) but I don't know exactly in which channel the message have been sent.
So I should do a for loop until I find it ?
That'd be the only way yeah
okay thanks
save that info next time
merged and queued for release
will 2.7 have components v2?
the entire reason 2.7 hasn't released is because we thought v2 would release a month ago lol
the pr is more or less done
so, days?
should be yeah
no but we will fully break it in v3
(mainly forcing users to create ActionRow for v1 components)
probably more verbose? but it will hopefully make more sense
even more verbose?
right now the entire row system is too simple which made v2 compatability a pain
it's very basic right now lol
well as long as 2.7 comes out soon..
(i mean too simple for the user, internally it's hell because it's doing stuff like automatically calculating item positions)
is it like grid views in websites?
i guesssss? only buttons can be grids though
Didn't know components were that complicated
Why does it need to calculate item positions
the current design of Views is that you just do add_item
but this ignores the existence of the ActionRow component; they can have up to 5 buttons or 1 select, and also exist in the V2 space
because ActionRow can exist with other V2 components, we have to work around the existing system that uses weights and has various library-sided checks for full compatability
in v3, we'll likely force users to add ActionRow to the view and then add Select/Button to the row, instead of just having a row kwarg
that strategy is also more in-line with how Container and Section are used in v2 components
Hope 2.7 will be released with pr ;)
Does all valid pr will be merge or only some of them ?
hi! can someone help me figure out why @commands.has_any_role() isn't working as I intended? This is my code: ```py
@commands.slash_command(name="start", description="Start the queue for a kit in a region.")
@commands.has_any_role(*get_tester_role_ids())
async def start(self, ctx, kit: discord.Option(str, choices=CONFIG.get('kits')) = None, region: discord.Option(str, choices=CONFIG.get('regions')) = None):
await ctx.respond("Hello world")
This is the `get_tester_role-ids()` method (not in a class): ```py
def get_tester_role_ids():
"""
Get the tester role IDs from the configuration.
"""
sr_tester_id = CONFIG.get('roles', {}).get('sr_tester')
tester_id = CONFIG.get('roles', {}).get('tester')
if sr_tester_id is None or tester_id is None:
log.warning("Tester role IDs not found in configuration.")
return None
return sr_tester_id, tester_id
I know that the get_tester_role_ids() method is working as intended since I have set up global error handling, which displays the required roles (MissingAnyRoles.missing_roles) correctly. I use the command with both of the roles yet I'm told I don't have permission. Why might this be happening?
Make sure you pass the ids as integers and not strings
second time i made this mistake in this project 0-0
thanks that was it
Keep in mind, if you use choices, that you have to restart the whole bot if you add new stuff to the list
My guess is CONFIG is intended to be a constant in this context.
is there a way to get the thread.starting_message if we don't have the message in cache ?
Like a way to fetch it in the on_thread_create event
The thread ID id the message ID when created from a message. You can get the channel from the thread.parent or thread.parent_id if not cached
Then you can fetch the message
I found an other way, using the thread.last_message and make sure the MessageType is default. If there was no starting_message, then the last_message is the MessageType.thread_created
that would only work for threads with no messages tho, wouldent it?
yeah, but that's for the event on_thread_create, so it is always a new thread
ah ok
if the thread was created using the /thread command, then the last_message is MessageType.thread_created, and if we made the thread using the right click on a message, it is a MessageType.default
you can get the oldest message of any channel with await channel.history(after=discord.Object(1), limit=1).flatten()[0]
For threads my option would be a bit simpler
yeah but that assumes the thread starting message exists
and starting_message only applies to public threads
What is discord.Object(1); def the first time I've ever seen that class referenced
Object is a placeholder for any snowflake
if you ever see Snowflake in docs, it means you can pass any object that has a discord ID
e.g. in something like history you might find it useful to pass a Message to before or after; if you don't have an actual message object but you have the ID, you can just stuff it into Object
Ahhh, okay; I was just going to ask why it couldn't take a literal 1 since Snowflakes are (more or less) integers, but I do see that Snowflake is defined as a Protocol class.
i guess for the most part it's to avoid having separate parsing for integers in the many functions that accept Snowflakes
I have always wondered why it is not discord.Snowflake
Snowflake is the lower level protocol, Object implements it
oh, so it is a think đ
import discord
from discord.ui import View, Container
bot = discord.Bot(intents=discord.Intents.all())
import logging
logging.basicConfig(level=logging.DEBUG)
second_container = 2
class TestView(View):
def __init__(self):
super().__init__(timeout=None)
c1 = Container(color=discord.Color.red())
count = 0
for i in range(10):
s = discord.ui.Select(placeholder=f"{i*25+1} - {(i+1)*25}")
for _ in range(25):
count += 1
s.add_option(label=f"Option-{count}")
c1.add_item(s)
self.add_item(c1)
c2 = Container(color=discord.Color.red())
for i in range(second_container):
s = discord.ui.Select(placeholder=f"{i*25+1} - {(i+1)*25}")
for _ in range(25):
count += 1
s.add_option(label=f"Option-{count}")
c2.add_item(s)
self.add_item(c2)
@bot.event
async def on_ready():
print(f"Logged in as {bot.user} (ID: {bot.user.id})") # type: ignore
print("------")
@bot.slash_command(name="test")
async def test_modal(ctx: discord.ApplicationContext):
await ctx.defer()
await ctx.respond(view=TestView())
import os
# from dotenv import load_dotenv
# load_dotenv()
bot.run(os.getenv("TOKEN"))
Setting second_container to 1 / 2 works as expected, 3 / 4 silently fails, 5 throws a HTTPException
And if I dont defer the interaction then 3 / 4 results in an Unkown interaction / This interaction failed
I assume this would be something to do with discord and not the lib? Just based off of the HTTP status codes
yes, if you try to stuff too much into components discord won't bother trying to work with it
(even below the hard limits they set)
in your test_modal command, why do you defer then instantly respond anyway?
I was testing to see if that would show different results (and it did).
My production bot does heavy querying for most commands anyways so I might aswell defer in the test bot too.
Yea just jumped into my eye because the function is called test_modal, and you cannot defer an interaction if you want to send an actual modal
Thats just named that way cause I reused the same file as one of my issue MRC-s
5 is expected to fail because you would have 32 components when the maximum if 30.
You have 2 containers, then you have 15 total select menus. Each select menu needs to be in an action row (which pycord does for you) but this counts as 2 components, so it is 15*2. Also according to lala's docs you cant have more then 5 actions rows per message so I am surprised that the first container works at all
5 per message is the none-v2 limit
message.components.max_length = 10
message.components.total_nested_components_in_tree = 30
section.components.max_length = 3
media_gallery.items.max_length = 10
container.components.max_length = 10
(MediaGallery items are not considered components)
Ah ok
Are Containers the only entities that can have a color? Is it Containers that are limited to 5?
Or is it more like Embeds where it's 10?
Yeah, containers are the only thing with color. The 5 limit is for action rows in non-v2 messages.
Hopefully I answered the second part of your question
I assume non-v2 messages will be deprecated at some point?
waouw 250 options that a lot
and is this inside an embed ?
i'll have to rewrite everything to make it works with the new thing
is it easy to do the migration or its completly different ?
ÂŻ_(ă)_/ÂŻ
That is going to be my first question in the API updates thread for it
"Is this supposed to be an alternative for embeds or are embeds going to be phased out over time and all bots using embeds should switch over?"
It is inside a container. I would say that the transfer is not too difficult but it is not a drop in replacement either
My bet is, they will make us switch
Because they've always said embeds were not really meant for bots
The big thing right now is pages does not work without some major changes
Yeah I think pages needs a complete redesign. Personally I would prefer if it was a view you could subclass rather then its own send/edit thing. That would reduce some of the complexity and allow for more custimization without making a mess
so containers are the new embeds ?
hello
integration_types = {IntegrationType.guild_install, IntegrationType.user_install}, contexts={InteractionContextType.guild, InteractionContextType.bot_dm, InteractionContextType.private_channel}
anyone see a error?
my import py from discord import slash_command, SlashCommandGroup, InteractionContextType, IntegrationType
Do you even get an error?
nope
So you dont need help I guess
what is the issue ?
I cant see the commands
you want to add it to ur account but you added it to the guild ?
only in the server
this is for ur account right ?
I added it in a guild and to my account, but the commands are only showing in the guild
yeah
can you show us how you define a command with the user app ?
in some ways yes
slap ctrl+r and come back if that doesn't work
did
@ltc.command(description="Generate a Payment.", integration_types = {IntegrationType.guild_install, IntegrationType.user_install}, contexts={InteractionContextType.guild, InteractionContextType.bot_dm, InteractionContextType.private_channel})```
what's ltc
slashcommandgroup
let's see that
ltc = SlashCommandGroup("ltc")
is it added to the bot
wont integration_types and contexts only work on the top level command as well? not subcommands
yeah
means?
COG
You need to move the integration_types and contexts into the group definition not the command decorator
Discord does not allow /ltc view to be only a guild command and /ltc pay to only be a user command for example
now thanks guys
file = discord.File(fp=ltc_qr, filename="ltc_qr.png")
embed = discord.Embed(description=f"### LTC Payment\nAddress: `{ltc_address}`\n**Amount: `{amount}` $(USD) `{amount}`âŹ(EUR) `{ltc_amount}` Litecoin**")
embed.set_image(url="attachment://ltc_qr.png")```
where do I need to add the file and how?
when you send the message
embed=..., file=file
hmm, i getting missing accsess now when i try to make a oauth2 link with accsess I getting a scope error
Application Command raised an exception: Forbidden: 403 Forbidden (error code: 50001): Missing Access
User installed, guild installed its working fine
when doing what
which line throws the error
-# I got to go study, toothy gots you covered :)
@commands.Cog.listener()
async def on_application_command_error(self, ctx, error):
await ctx.respond(f"{error}", ephemeral=True)
raise error
that's.. your error handler
ye
I mean which line of the command errors
await ctx.send(embed=embed, file=file)
file = discord.File(fp=ltc_qr, filename="ltc_qr.png")
thanks, working now
weird but...
When the bot replies without mentioning author, and then edit the message, it becomes a message that mention the author.
Any way to change that ?
testy
hm
so the @ before the username of who the bot replies to is suddenly there?
I mean it doesn't really affect anything, message edits cannot cause notifications or red 1s
maybe by using allowed mention
its not what he means by mentionning ?
.
i didnt really get that
neither whats under
do you have an code so i can try to see the effects ?
its just how interactions work
the only thing it does is highlight the message if you add a mention
im very confused, since yesterday many of my commands/interactions are executed twice. for e.g. i have a user_command where i added this code now:
print(self.processed_interactions)
if ctx.interaction.id in self.processed_interactions:
return # Skip already processed interactions
self.processed_interactions.add(ctx.interaction.id)
now its only getting executed one time because of the return but my log still say:
2025-04-21T02:41:57: set()
2025-04-21T02:41:57: {1363676098251980900}
so it still tries to execute it twice. i also added a print in the cog setup, the cog is only loaded one time and bot is also only running one time
Are the interaction IDs the same? (Move the print below the line where you add to the set)
figured out where the problem is, i've rewritten my cog loading logic yesterday and accidentally enabled an old error handling cog where i had the line await self.bot.process_application_commands(interaction) 
nice, glad you found the fix :)
yes, but thank you for your fast response đ
I often have the problem that the attributes of the Guild instance like guild.members or guild.roles or out of sync, so the cache contains objects which results in 404 error in the API.
How to re-sync the cache, so I dont have to use fetch every time but force a re-sync if I detect a mismatch?
Is there an automatic syncing logic, or is it really static from the bootup?
how many servers is your bot in
And no, cache isn't static, it should update with every event sent by discord
one single guild/server. Mhhm thats weird.
Does the ``fetch` method updates the cache then also? So for example
await guild.fetch_roles() #sync roles
....
roles = guild.roles() # uses cache synced before
?
you really should never need to do that
Unless you messed with how the caching works or your bot is in a LOT of servers, cache should be 100% reliable
And dont fetch every time, thatll cost time and eventually ratelimit you if you do it often enough
I donât think it does
But you can get or fetch, if get is None then you fetch all role and check if its inside
Well I understand - but right now I have this issue. With the whole cache. Member, roles, etc. - getting regulary 404 errors if I try to use the cached objects
The weird thing is - this is a problem occured since a few days. Was never an issue before and I didnt changed my code
Its not none - its more an out-of-sync issue. So guild.members still contains members who left the server for example
do you delete roles at all? else a 404 wouldnt make sense for roles
and make sure you are always actually using the cache and not saving it to some variable and reusing that later or something
Its more probable that a member is not in that itâs in when it should not
But this is out of my knowledge so I cannot really help you with out of sync stuff
However when you get a answer pls ping me
yes I do - I have a lot of channels and since discord have a role limit the bot manages the roles I use for a ping dynamically. So my bot deletes and creates roles for some channels depended how popular a current channel is. Maybe this is some kind of race condition - one thread just deleted it but the other still uses the old cache. Will investigate.
That would explain the role thing - but I get the same with members recently. Weird..
Yes but without the bot managing my roles I would need more than 250 (which is the limit as far as I know)
đ
In short: I have gaming server where each game have its own channel - and each channel have one role for it. The bot dynamicalle moves and sortes the channels and uses the role for ping if a event (mapped to that channel) is created. Since I have 400+ channels I cannot create a role for each channel, so I only create the role if the channel is "active" and the role is needed. I save the members of the role in my own database - so if the role is deleted it still exists in my database and If I need it the bot recreates it and adds all members from my database

What intents do you have? And did you change them recently?
are they some example of component v2 code usage ?
Not yet
with autocomplete
is there an easy way to get all guilds the bot and the user are sharing?
;
oh my god i overlooked it reading the docs... thanks
Hello, how can I implement this ?
or at least how it is named so I can look in the documentation
Here's the context menus example.
Thanks !
2.7 2.7 2.7 2.7 2.7
haha
You need to say it backwards 7 times for it to come true
Wen pycord 7.2, with ai
Hi, is pycord support this in the latest git?
soon, can be tested if you install https://github.com/Pycord-Development/pycord/pull/2707
Summary
Soon
Edit by Lala:
Temporary reference: https://github.com/Lulalaby/discord-api-docs/blob/comp_v2/docs/interactions/Message_Components.md#v2-components
Yet another edit by Lala:
Offici...
the latest git..
the latest git is 2.49.0
Lmfao
when i have
@cogs_group.command(
guild_ids=[12345],
name="random",
description="aikdjnaiwhfiabnwi"
)
@commands.guild_only()
@has_any_role(role_ids)
why is the has_any_role check executed before checking if its a guild?
guild_only is deprecated
the new way is using contexts
Also uh, neither guild ids nor contexts or guild_only applies to subcommands
subcommands are not standalone commands in discord's model
because i tried executing my slash cmd in dms for fun and then got AttributeError: 'User' object has no attribute 'roles', but with guild_only() it shouldnt do anything?
well read my message first lol
i i am using pycord: 2.6.1
no use diagnosing an issue when another issue exists
sorry, started writing before you sent your message lol
okay, so what should i exaclty do
any docs about the new way to do it
make whatever command you want to be guild only its own group or just base command
look in the SlashCommand docs, you'll find the contexts attribute
cogs_group = SlashCommandGroup(
name="fv",
description="Commands",
guild_only=True,
guild_ids=[12345677],
checks=[
has_any_role(ids)
]
)
``` so like this?
so if i understood it right
i have to set nothing just guild_ids=[123] in my slashcommandgroup
then how to deny it for dms 
okay
so i can also now remove my
@has_any_role
@commands.guilds_only
and guild_ids
in my commands because i defined it in my slashgroup
Or... set the actual contexts...
what you mean my that? i thoughjt its unapplicable for guild commands?
You don't make it a guild command and set contexts.
It's a guild command tho so it's only available in guilds
I think what dark is on about is that they should rather set context than put in the guild IDs of the one or few servers their bot is in unless its specifically a command locked to a specific guild
im confused now
cogs_group = SlashCommandGroup(
name="fv",
description="Commands",
guild_ids=[1234545],
checks=[
has_any_role(ung_role_ids)
]
)
is this now wrong or right?
yea
but uh, why guild_ids at all
because i want that only the commands can be executed on one guild
but also now my checks isnt working anymore
because thats not how you use that
Command Permission Decorators: Commands: Shortcut Decorators: Objects: Attributes full_parent_name, qualified_id, qualified_name. Methods@ after_invoke,@ before_invoke,@ error, def get_cooldown_ret...
unless has_any_role returns such a predicate
sorry im very confused now
def has_any_role(role_ids):
print(f"Checking roles: {role_ids}")
async def predicate(ctx):
if not isinstance(ctx.author, discord.Member):
return False
return any(role.id in role_ids for role in ctx.author.roles)
return commands.check(predicate)
# Slash Command Group
cogs_group = SlashCommandGroup(
name="fv",
description="Commands",
guild_ids=[12551236],
checks=[
has_any_role(role_ids)
]
)
thiss is what i have now
i tried it out and my has_any_role func is not called when i execute my slash commadn
because it doesnt satisfy the requirements for a check function
is the problem that it returns commands.check(predicate) instead of true/false?
read. the. docs.
List[Callable[[ApplicationContext], bool]]
thats what they say
async def check_has_any_role(ctx: discord.ApplicationContext) -> bool:
print(f"Checking roles: {role_ids}")
role_ids = config().fw_role_ids
return any(role.id in role_ids for role in ctx.author.roles)
# Slash Command Group
cogs_group = SlashCommandGroup(
name="fv",
description="Commands",
guild_ids=[1234],
checks=[
check_has_any_role
]
)
i think like that?
it works.. but is it the 100% right way
and should the task be sync or async
doesnt matter
The difference is you are not using it as a decorator anymore, the whole nested function thing is for decorators
Does bot.emojis not include emojis added in the developer portal?
in the next version (will require you to specify cache_app_emojis=True)
Got it. I really need to just switch to master this is ridiculous
Wait, where do you define that kwarg?
In Bot/Client
It just fetches the emojis on startup
There's no events related to app emojis, so if they change while the bot's running you have to fetch them again
oh yucky. Does the API let you add them?
Yeah there's a couple methods for them
Just no events, but not the end of the world
you should probably know when your emojis are updated
That's the advice my momma always told me, growing up
Hi, when i uuse a command i can use cctx.defer() but how can i use it in a interaction callback
interaction.response.defer()
if thats what you mean
but the interaction callback is just the command function
I think they mean view items
THX
Just so you are aware ctx.defer is just a shortcut for ctx.interaction.response.defer
can someone explain me this ?
knowing that at the begining of my command i have :
async def add(
self,
ctx: LumabotContext,
member: discord.Member,
channel: discord.TextChannel = None,
):
channel = channel or ctx.channel
if (
channel.permissions_for(member).view_channel
and channel.permissions_for(member).send_messages
):
return await ctx.respond(
ctx.translator.ticket.add.error.already.format(user=member)
)
await channel.set_permissions(member, view_channel=True, send_messages=True)
await ctx.respond(
ctx.translator.ticket.add.success.format(channel=channel, member=member)
)
how can specify a channel or not change
is the channel you are running that in sbd ticket
yeah
thats the whole point
is it a thread?
nope
so its saying that both have the perm to view channel
i guess 2.6.1 moment
let me try on master
but why from ctx.channel it will be different than channel -> thats a mystery ig
Have you tried printing channel for both commands
And see if there's any difference
Which would be weird
like that doesnt make any sens to me
and again both channel are the same
print the channel objects.
^
sbd-ticket sbd-ticket True
for
print(channel, ctx.channel, channel == ctx.channel)
ok
same result
async def add(
self,
ctx: LumabotContext,
member: discord.Member,
channel: discord.TextChannel = None,
):
channel = channel or ctx.channel
print(channel, ctx.channel, channel == ctx.channel)
i said first
not second
because of that exact line that changes the channel var which makes that whole test worthless
specify it, print it
did it
and its none
and when i specify its both the same
did you try with the master branch
so
None sbd-ticket False -> no arg
sbd-ticket sbd-ticket True -> arg
im gonna test that on my test bot but how come ctx.channel and channel are not the same
they are though, didnt you just prove that
seems that there are equal
I think Paillat mentioned a weird issue with permissions_for, but im not sure if it was on 2.6.1 or master
either way try the git version
but however there are not really since the permission are different
i wouldn't distrust obj == obj tests
actually yea retry with is
yep its good on master
are you also gonna become a 2.7 yapper
im already one
just hope they first push the pr before merging
i dont want to have the same issue than in 2.6...
hardly matters most of the time
i knew that part but if the variable are equal might be a bit tricky
since ctx.channel return a function
No
maybe it cannot really check if those part are the same in both case
its a property
properties use functions under the hood
idk how the == will evaluate them
will it check all different thing
like a before.channel == after.channel even tho they will have different name ?
who knows
let me check that
might deep check all values
yeah it does not
@commands.Cog.listener()
async def on_guild_channel_update(self, before, after):
print(before.name, after.name, before == after)
test1 test True
but is does
is yielded the only correct result
tf
what was the problem ?
that before == after ?
that's expected
and the fact that is returns true is beecause it ain't the same object but that's normal
is returned false no?
yeah I thought the opposite at first
does return false
is there a recommended order of command decorators?
No, the order shouldn't matter in most cases.
The order absolutely matters
First decorator has to be the slash command decorator
apart from that tho, no I think
First you mean top to bottom ?
yeah
Ah, I assumed everything followed same design as ext.commands
wdym
The decorator on prefix commands doesn't matter, if pycord hasn't changed it. Like checks and the command decorator can be anywhere.
the command decorator always has to be on top for all i know
Nah
Builtin checks can handle the func being a Command or not by setting an attribute
not on master rn
but you can still use the pr
but how do I install it
pip install git+https://github.com/Pycord-Development/pycord.git@refs/pull/2707/head
Summary
Soon
Edit by Lala:
Temporary reference: https://github.com/Lulalaby/discord-api-docs/blob/comp_v2/docs/interactions/Message_Components.md#v2-components
Yet another edit by Lala:
Offici...
thx
how to get a slash command id directly from the code?
i mean this, i need it for mentioning a command from the code
like /help => it mention all commands
using command.id then
and you can you bot.application_commands to get all commands
thx
what's the event name when someone boost the server?
