#Basic Pycord Help

1 messages ¡ Page 72 of 1

shell radish
#

If you want to use a custom emoji, send it with \ in front

#

such as \pycord

#

then it should output as

#

and that's the string you want to use

wild hill
#

/Moderation

shell radish
#

wrong slash

wild hill
deep night
#

when i use
await ctx.trigger_typing()

I get permission error, which permission need to be allowed?

#

these are my current

echo wraith
#

Also changing these won't update them once you added the bot to a server

echo wraith
#

np

buoyant eagle
#

somebody else have rate-limit or its only me?
if its only me how much time i should way for it to go away?

little cobalt
#

Channels got many rate limits

buoyant eagle
# little cobalt ?

[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"

little cobalt
#

How many commands do you have?

buoyant eagle
#

idk

#

there a max amount?

little cobalt
#

Yea

buoyant eagle
#

what is it?

little cobalt
#

100 normal slash commands

buoyant eagle
#

wdym whenm you say normal?

buoyant eagle
fresh sierra
#

.cmd-limits

sly karmaBOT
#

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

buoyant eagle
# fresh sierra You can use sub 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?

fresh sierra
#

This are group yes

buoyant eagle
#

it still giving me rate limits

fresh sierra
#

You cannot just have more than 100 /name

fresh sierra
buoyant eagle
#

what

errant trout
#

exactly when is the ratelimit occuring

buoyant eagle
#

2025-04-11 21:06:59?

errant trout
#

i mean

#

is it when you do something

#

such as restarting the bot

buoyant eagle
#

yes

#

i cant test my bot

errant trout
#

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)

buoyant eagle
#

now it doesnt give me the rate limit but it stills doesnt show my commands

errant trout
#

hmmm i guess you need to sync at least once

#

wait for the ratelimit to expire, then let your bot sync commands

buoyant eagle
#

but when i sync its giving rate limit so i cant sync

errant trout
#

yeah so you have to wait GuraShrug

echo wraith
buoyant eagle
errant trout
#

it tells you how long is left

#

on the ratelimit message

buoyant eagle
#

and then its giving rate limit again

little cobalt
#

Usually 24 hours for the reset for slash commands

errant trout
#

if it doesn't work then you might have to wait the full 24

#

because syncing is weird

buoyant eagle
errant trout
#

or just temporarily test on a new token if you can afford it

buoyant eagle
errant trout
#

new bot

buoyant eagle
errant trout
#

literally how

buoyant eagle
#

idk

errant trout
#

you sure you changed the token in your files...?

buoyant eagle
#

yes

#

the other bot is online

#

and its showing me only help command .

    for command in bot.commands:
        print(command)
errant trout
#

it's bot.application_commands

buoyant eagle
#

oops

#

bruh

errant trout
#

mmmm if you set auto_sync_commands=False and later manually run await bot.sync_commands() while the bot is running, does that work?

buoyant eagle
#

idk

#

its showing my commands

#

BUT

#

its saying user install when i set that to guild install

sage tendon
#

why do you have so many commands..

errant trout
#

if #1132206148309749830 message is everything then it's not really that many

buoyant eagle
sage tendon
#

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

errant trout
#

oh probably uhhhh

#

during big outages, whenever the bot reconnects it might try to sync again

fresh sierra
#

mb the chat didnt load

sage tendon
#

it was during testing nelo

cobalt bone
#

Is it possible to change the way requests are sent to discord?

cobalt bone
sage tendon
#

wdym the frequency

errant trout
sage tendon
#

i just feel like pycord either unnecessarily force syncs commands, or discord handles the ratelimit weirdly

cobalt bone
# sage tendon wdym the frequency

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.

fresh sierra
#

but it seems a bit hard so good luck with it

sage tendon
cobalt bone
sage tendon
#

sounds like you should switch hosts

#

what do you use

cobalt bone
cobalt bone
fresh sierra
#

since as you say if other bots send too much requests you will also get rate limit

sage tendon
#

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

cobalt bone
#

:/

fresh sierra
#

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

sage tendon
#

theres hosts for literally <1.50€ so Shrug_3 go for it if you can

fresh sierra
#

its like 3 panels like this at max

#

but everymonth the thing will be delete so you will need to do everything

cobalt bone
#

I can't pay...

fresh sierra
#

"my" thing is free

cobalt bone
#

thinkCat why not

fresh sierra
#

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)

cobalt bone
#

thanks !

cobalt bone
fresh sierra
#

and it will restart everything so

elfin inlet
#
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))
     ```
sage tendon
#

positional?

little cobalt
sage tendon
#

how do you

little cobalt
#
modal = TheModal()
await ctx.send_modal(modal)
sage tendon
#

but thats what they are doing? lol

little cobalt
sage tendon
#

i dont see the difference?

little cobalt
#

you mean its imported from a file location in any way?

sage tendon
#

clearly lol

elfin inlet
little cobalt
sage tendon
#

show your pip list

errant trout
elfin inlet
lethal loom
#

Hi, does anyone know why when I get self.bot.owner_id none in cog and not the id of the bot owner?

little cobalt
lethal loom
#

hm....

little cobalt
#

Or did you even set at owner of the bot?

sage tendon
#

yippie the docs are down
and back

lethal loom
little cobalt
sage tendon
lethal loom
#

Okay, how can i set me as owner?

torn barn
#

owner_id=… on the bot/client constructor

echo wraith
#

Tbh if there's a V3 that manual owner id thing should be removed.

lapis dock
#

^ and owner-id and owner_ids should be merged

echo wraith
#

Yess

errant trout
#

agree with deprecating owner_id, but manually being able to set owner_ids is still useful for internal owner checks

sage tendon
#

would simplify checks anyway
narrows it down to if user.id in bot.owner_ids

#

instead of needing to check both variables

errant trout
#

well you only need to check both if you set both

sage tendon
#

okay yea

#

but in-lib ones if there are any

errant trout
#

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)

little cobalt
#

Can I have 2 of the same events?

sage tendon
#

if you use listeners

little cobalt
#

It would be in a cog so yea, listeners

sage tendon
#

not two of the same in the same cog but that'd be pointless anyway

echo wraith
errant trout
sage tendon
#

oh, hm

errant trout
#

in the listener decorator, you can pass the name of any event instead of using the function name

echo wraith
#

Like pycord is not a framework

sage tendon
#

its very common to make owner only commands

echo wraith
#

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

sage tendon
#

why tho?

#

its literally perfect
its the owners of the bot
why should it not be in the bot class

echo wraith
#

The fact that you can set it manually feels weird to me

#

But whatever

sage tendon
#

if you have multiple people owning a bot

#

or a managed bot

echo wraith
#

Yeah but in that case it's not "core" to me

#

Idk how to explain

brazen flower
#

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

sage tendon
#

that is not a thing in pycord

brazen flower
sage tendon
#

You have to pick one

brazen flower
#

ok, thanks

lapis dock
#

You dont need to use both either, each have approximately the same features

brazen flower
lapis dock
#

DM with other users or DM with the bot itself?

brazen flower
#

dm between 2 users

#

like this

lapis dock
#

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

rugged lodgeBOT
#

Here's the slash users example.

brazen flower
#

thanks you

buoyant eagle
#

how could i add in discord.Option the the type is the bot application commands?

sage tendon
#

Not possible directly

#

what do you even need that for tho

halcyon dagger
#

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

sage tendon
#

Only via the integrations menu in the server settings

halcyon dagger
#

Okay, so if the bot is ran in direct msgs it is not possible?

sage tendon
#

Not to hide them, no
You can only do checks then

halcyon dagger
#

Ah okay thank you ❤️

sage tendon
#

of course you can also exclude the command from being used in DMs entirely but i think thats not what you want

halcyon dagger
#

no, the bot wouldnt really be used in servers, prolly just DMs

nocturne jewel
#

there's any API limit or i can update channel status every ~1 second?

sage tendon
#

if its counted under the channel editing bucket its once every 10 minutes i think
try it out and see how far you get

lapis dock
#

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

sage tendon
#

yea agree
its probably for a clock or counter

sage tendon
#

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

errant trout
sage tendon
#

huh
you sure?
if i inspect element it, the url is .webp

errant trout
#

the lib uses png, but it seems to be interchangable...? lol

lapis dock
#

Doesn't discord convert things to webp after you upload them?

sage tendon
#

i checked with a file type checker and the stuff i get from discord sure are PNGs

errant trout
#

ah right, for assets you can use any allowed extension and discord will return it in that format

autumn gust
#

about how many things are wrong here

#

oh it just can't find the file lmao nvm

silk spire
#

Missing await?

autumn gust
#

that's a good point too

frail basin
#

and you misspelled ephemeral

autumn gust
frail basin
#

in the function parameters

#

ctx should be type hinted as discord.ApplicationContext

autumn gust
#

oh shit good point, damn you tab

#

welp, what's wrong here

little cobalt
autumn gust
#

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

lapis dock
#

You do you, its your code after all. But I am going to leave this here for reference

sly karmaBOT
#

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!
little cobalt
autumn gust
fresh sierra
autumn gust
#

also it's something I'm familiar with lmao

autumn gust
#

is it a library and then just as aiofile

fresh sierra
silk spire
#

Aiofiles isn't really necessary unless your file is like is really big (GBs)

fresh sierra
#

always better to not have blocking code when using a bot discord

silk spire
#

Anything non async is blocking then

fresh sierra
#

but using a database might be better

silk spire
#

print too

#

Definitely

fresh sierra
#

while print will always take the same amount of time

autumn gust
#

why global? because idfk how to toss data up the chain

fresh sierra
#

learn database will always be a plus

autumn gust
#

all I know is how to toss it down the chain lmao

fresh sierra
#

and its really easy

autumn gust
#

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

sage tendon
#

just use sqlite

fresh sierra
autumn gust
#

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

sage tendon
#

youll regret that

echo wraith
sly karmaBOT
# autumn gust about how many things are wrong here

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

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

# bad
time.sleep(10)

# good
await asyncio.sleep(10)

Read more

echo wraith
#

.tag rie

sly karmaBOT
#

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.

autumn gust
#

then let me regret it and be forced to rewrite the code pls

fresh sierra
#

believe me

#

i did first json

#

then sqlite

#

then aiosqlite

echo wraith
sly karmaBOT
# autumn gust about how many things are wrong here

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!
fresh sierra
#

and rewrite 10times the database of all ur code is horrible

lapis dock
sage tendon
#

json is not a data storage format

fresh sierra
#

but i never used sqlite so

echo wraith
#

tortouaise o r emme

#

is da best

autumn gust
#

I'm only upstuck on it being json because I know I can always just resort to using txt files

sage tendon
#

...wtf

autumn gust
#

no joke, was the first idea

sage tendon
#

why are people so allergic to databases

autumn gust
#

"literally what's stopping me from just using txt files to print this text"

#

sounds like more effort than it is probably

echo wraith
autumn gust
#

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:?

echo wraith
#

Not at all

rugged lodgeBOT
#

Here's the confirm example.

autumn gust
#

oh SifHollow

#

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?

sage tendon
#

its the view.

autumn gust
#

ah got it, thanks

sage tendon
#

look into OOP in python, the entire library is based on it

autumn gust
#

trying to confirm because I still have no idea how to navigate it😭

sage tendon
#

i just look up whatever class i need and go from there

autumn gust
#

buttons don't appear? what have I missed, does it need the interaction?

sage tendon
#

yes

autumn gust
#

ah, got it

#

does it have to respond with a message or can I just ignore it or do anything else?

sage tendon
#

a button has to respond with something when pressed

#

either a modal or a message

autumn gust
#

modal?

#

so can it do something stupid and useless like react to the ephemeral message?

#

(if you can even do that)

sage tendon
#

no

autumn gust
#

welp, rip

#

well, I added the interaction but it still doesn't seem to add the buttons?

#

no traceback in console

sage tendon
#

are you sure you're importing the right thing

#

and show the command code again

autumn gust
autumn gust
#

watch the issue be me accidentally capitalizing something again

autumn gust
#

wait, can ephemeral messages even have buttons?

sage tendon
#

yes

autumn gust
#

alright so that's not an issue

#

I'm pretty sure I'm importing the right thing?

#

everything seems to check out

sage tendon
#

ctrl+click follow your Confirm() and see if its the right class

#

and make sure you restarted your bot

autumn gust
#

ok funny part is, it still times out lmao

autumn gust
sage tendon
#

what times out?

autumn gust
sage tendon
#

also really dont use globals unless absolutely unavoidable..

autumn gust
#

as if buttons were there but I didn't click them

sage tendon
autumn gust
sage tendon
#

show

autumn gust
#

stupid idea

sage tendon
#

can you do view=Confirm() directly in the response

#

yea

autumn gust
#

lmao

#

nope, didn't work

#

so it's an issue somewhere here

sage tendon
#

are you actually restarting your bot

autumn gust
#

yeah

#

ctrl+pause break in the terminal and relaunching it

sage tendon
#

wtf is ctrl pause break

autumn gust
#

terminates whatever is currently running

sage tendon
#

tf

#

i always use ctrl+c

autumn gust
#

oh that's a thing?

#

lmao

#

I hit ctrl+pause break

sage tendon
#

where is your view class

autumn gust
#

view class?

sage tendon
#

yea

autumn gust
#

that's a thing?

sage tendon
#

...your confirm view class

autumn gust
#

oh wait

#

you mean view=Confirm() or?

sage tendon
#

where is your Confirm class located

autumn gust
#

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

sage tendon
#

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

autumn gust
#

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
sage tendon
#

bruh
idk man
you have only one file right

autumn gust
#

yes

#

hmmm... question: so intents, right

sage tendon
#

just send it here

autumn gust
#

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

autumn gust
#

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?

autumn gust
little cobalt
autumn gust
#

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?

sage tendon
#

the decorator handles that

autumn gust
#

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

sage tendon
#

... you weren't tho?

autumn gust
#

look at the indents

sage tendon
#

bruhh

autumn gust
#

is the correct way

#

1 hour only to find out it was my indents 😭

little cobalt
autumn gust
flat wind
#

is a thread delete raised by an on_raw_thread_update event ?

rugged lodgeBOT
silk spire
#

I don't see why it would fire an update event

flat wind
#

I know there is this event too, but a delete is an update technically 🤷
that's why I ask

silk spire
#

Not really. Update means something has changed regarding the thread like the archive status. Delete means.. it's gone.

flat wind
#

okay, thanks

silk spire
#

Tias I guess

flat wind
#

I will check. To make sure, I have added a if thread is None in my code (after trying to get / fetch it)

opal swan
#

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)
echo wraith
fresh sierra
#

Also take in account defer

opal swan
#

forgot how to remove an attachments in this case

fresh sierra
#

For message in message, if not message.contrnt continue

#

If you only want to send the text

opal swan
#

ty

#

ty again it work correctly !

round heart
#

I don't use JSON as a storage format, I use YAML. Much better.
(Apparently that was a conversation from yesterday; I'm late)

echo wraith
#

How can one manually get a message from the message cache

#

I found it

nocturne jewel
#

how can i send a message like every sunday at 16:00

lofty parcel
#

tasks.loop

#

You can set specific datetimes

errant trout
#

well you can set a specific datetime.time, you'd still have to check the current day

nocturne jewel
#

i'll see it, thanks!

lofty parcel
#

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

round heart
quartz umbra
rugged lodgeBOT
sly karmaBOT
#

Tag not found.

Did you mean...
vc-autosave

sly karmaBOT
quartz umbra
#

what does that have to do?

echo wraith
#

Make sure you save your file

#

Also

echo wraith
quartz umbra
#

I'm 99% certain its saved as there's no white dot next to the filename xD

echo wraith
#

.tag logging

sly karmaBOT
quartz umbra
echo wraith
#

And set it to logging.DEBUG instead of INFO

quartz umbra
echo wraith
quartz umbra
echo wraith
quartz umbra
quartz umbra
#

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

quartz umbra
#

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)

echo wraith
#

Ok are you sure the bot isn't running twice?

quartz umbra
#

this always happens...

#

thanks

#

xD

echo wraith
#

Nw

quartz umbra
#

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?
sly karmaBOT
# quartz umbra hi! does anyone know why `guild.get_role` might be None? I'm 99% certain I'm usi...

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.

sage tendon
#

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

fresh sierra
sage tendon
#

doesnt work

torn barn
#

Use yarl.URL and extract the clean url

sage tendon
#

I already said just removing the query params doesnt work

#

nevermind it, i found another problem first lol

echo wraith
#

#discord-api-updates message

sage tendon
#

yes, as i just said
twice

fresh sierra
sage tendon
#

no nvm it for now the issue is bigger than the url anyway lol

fresh sierra
#

does @tasks.loop overlap or wait until finish to go to the next itinaration ?

fiery fable
#

once i do guild.fetch_member() its going to be cached or not?

echo wraith
torn barn
#

No, fetch_ calls don’t cache anything

torn barn
fiery fable
torn barn
#

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

fresh sierra
silk spire
#

Someone should document that tbh

little cobalt
#

Usually fetch_ is an API call to Discord

torn barn
#

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

fresh sierra
#

why does fetch doesnt cache after ?

fresh sierra
#

what do you think about that ?

silk spire
#

Sounds good to me

sage tendon
#

you have to fetch in certain situations to get certain info

fresh sierra
sage tendon
#

what not

fresh sierra
sage tendon
#

hm

#

well makes sense ig

torn barn
errant trout
#

Strictly speaking that isn't true either, but yeah close enough

frail basin
#

If a button has a custom_id set, how come button.is_persistent() returns false?

little cobalt
frail basin
#

yes and yes

little cobalt
#

with timeout=None?

frail basin
#

I added the button to the view and its timeout is set to None

little cobalt
frail basin
#

f string

little cobalt
#

?

frail basin
#

if you add = to the end of an f-string variable it will print like this

#

thats just the logging statement anyways

fresh sierra
#

checked the code and it seems fine

#

did you use discord.ui.Button for the button ? or select ?

frail basin
#

I used the correct button class

fresh sierra
#

self._provided_custom_id = custom_id is not None
that's how it is setup

#

yeah really strange

#

are you on master ?

frail basin
#

2.6.1

fresh sierra
frail basin
#

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

fresh sierra
#

but pycord should handle that, you might want to open a pr to add this change

fresh sierra
frail basin
#

ill make an issue

fresh sierra
little cobalt
frail basin
little cobalt
#

no, I mean the view

#

Where did you add the view to a persistent view

#

Did you add it at the on_ready event?

frail basin
lofty parcel
#

Views are persistent, not the button itself

frail basin
#

discord.ui.Button classes have an .is_persistent() function

frail basin
frail basin
fresh sierra
#

Im in the train so I have no connection rn, ill do it when I can

fresh sierra
#

if yes i'll do a pr

frail basin
#

Is there even an ETA for v2?

#

I didnt see any official announcement yet

errant trout
#

i'll just include it in the v2 pr

fresh sierra
lapis dock
errant trout
#

the unofficial ETA is today

sage tendon
#

you mean from discord or

echo wraith
#

From discord

errant trout
#

experiment gate is being lifted like right now lol

echo wraith
#

OMFG YAAAY

sage tendon
#

wdym experiment gate

lapis dock
#

Probably the experiment that allows it on the test guilds

flat wind
#

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.

flat wind
#

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 ?

lofty parcel
#

That'd be the only way yeah

flat wind
#

okay thanks

sage tendon
#

save that info next time

errant trout
sage tendon
#

will 2.7 have components v2?

errant trout
#

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

sage tendon
#

so, days?

errant trout
#

should be yeah

sage tendon
#

yippie

#

please dont tell me anything's breaking

errant trout
#

no but we will fully break it in v3

#

(mainly forcing users to create ActionRow for v1 components)

sage tendon
#

will views be easier or just different

#

or harder

errant trout
#

probably more verbose? but it will hopefully make more sense

sage tendon
#

even more verbose?

errant trout
#

right now the entire row system is too simple which made v2 compatability a pain

#

it's very basic right now lol

sage tendon
#

well as long as 2.7 comes out soon..

errant trout
#

(i mean too simple for the user, internally it's hell because it's doing stuff like automatically calculating item positions)

sage tendon
#

is it like grid views in websites?

errant trout
#

i guesssss? only buttons can be grids though

lofty parcel
#

Didn't know components were that complicated

#

Why does it need to calculate item positions

errant trout
#

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

fresh sierra
#

Hope 2.7 will be released with pr ;)

#

Does all valid pr will be merge or only some of them ?

quartz umbra
#

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?

torn barn
#

Make sure you pass the ids as integers and not strings

quartz umbra
#

thanks that was it

little cobalt
lapis dock
#

My guess is CONFIG is intended to be a constant in this context.

flat wind
#

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

lapis dock
#

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

flat wind
# lapis dock 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

lapis dock
#

that would only work for threads with no messages tho, wouldent it?

flat wind
#

yeah, but that's for the event on_thread_create, so it is always a new thread

lapis dock
#

ah ok

flat wind
#

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

errant trout
#

you can get the oldest message of any channel with await channel.history(after=discord.Object(1), limit=1).flatten()[0]

lapis dock
#

For threads my option would be a bit simpler

errant trout
#

yeah but that assumes the thread starting message exists

#

and starting_message only applies to public threads

round heart
errant trout
#

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

round heart
#

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.

errant trout
#

i guess for the most part it's to avoid having separate parsing for integers in the many functions that accept Snowflakes

lapis dock
#

I have always wondered why it is not discord.Snowflake

errant trout
#

Snowflake is the lower level protocol, Object implements it

lapis dock
#

oh, so it is a think 😅

frail basin
#
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

errant trout
#

(even below the hard limits they set)

sage tendon
frail basin
sage tendon
#

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

frail basin
#

Thats just named that way cause I reused the same file as one of my issue MRC-s

lapis dock
# frail basin ```python import discord from discord.ui import View, Container bot = discord.Bo...

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

frail basin
errant trout
#

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)

lapis dock
#

Ah ok

round heart
#

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?

lapis dock
#

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

lofty parcel
#

I assume non-v2 messages will be deprecated at some point?

fresh sierra
#

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 ?

lapis dock
#

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?"

lapis dock
lofty parcel
#

My bet is, they will make us switch

#

Because they've always said embeds were not really meant for bots

lapis dock
#

The big thing right now is pages does not work without some major changes

lofty parcel
#

Guh

#

Someone's gotta rewrite that thing

#

It is scary

lapis dock
#

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

fresh sierra
#

so containers are the new embeds ?

toxic saffron
#

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

toxic saffron
little cobalt
#

So you dont need help I guess

toxic saffron
#

i added it

fresh sierra
toxic saffron
#

I cant see the commands

fresh sierra
#

you want to add it to ur account but you added it to the guild ?

toxic saffron
#

only in the server

fresh sierra
toxic saffron
toxic saffron
fresh sierra
#

can you show us how you define a command with the user app ?

lapis dock
edgy nest
toxic saffron
toxic saffron
edgy nest
#

what's ltc

toxic saffron
#

slashcommandgroup

edgy nest
#

let's see that

toxic saffron
#

ltc = SlashCommandGroup("ltc")

edgy nest
#

is it added to the bot

lapis dock
#

wont integration_types and contexts only work on the top level command as well? not subcommands

edgy nest
#

yeah

toxic saffron
#

means?

edgy nest
#

do you have an add_command or an add_application_command somewhere

#

or is it in a cog

toxic saffron
#

COG

lapis dock
# toxic saffron means?

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

toxic saffron
#

now thanks guys

toxic saffron
#
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?
lapis dock
#

when you send the message
embed=..., file=file

toxic saffron
#

hmm, i getting missing accsess now when i try to make a oauth2 link with accsess I getting a scope error

lapis dock
#

what are you trying to do with oauth?

#

could you post the full error

toxic saffron
#

User installed, guild installed its working fine

toxic saffron
#

my slashcommand in a dm

#

but in a guild its working

sage tendon
#

which line throws the error

lapis dock
#

-# I got to go study, toothy gots you covered :)

toxic saffron
sage tendon
#

that's.. your error handler

toxic saffron
#

ye

sage tendon
#

I mean which line of the command errors

toxic saffron
#

await ctx.send(embed=embed, file=file)

#

file = discord.File(fp=ltc_qr, filename="ltc_qr.png")

sage tendon
#

yea you can't send messages lol

#

you can only do .respond with user installed bots

toxic saffron
#

thanks, working now

flat wind
#

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 ?

sage tendon
#

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

fresh sierra
sage tendon
#

that only changes anything for notifications

#

it won't affect this

fresh sierra
fresh sierra
#

neither whats under

#

do you have an code so i can try to see the effects ?

sage tendon
#

a message edit cannot cause a ping

#

that's it

torn barn
#

its just how interactions work

sage tendon
#

the only thing it does is highlight the message if you add a mention

torn barn
#

lol

#

the first response will not ping anyone

#

the followups will

sage tendon
#

huh

#

that's wrong and not related to what we're talking about

torn barn
#

oh shit

#

there were more messages

#

i was replying to another person's message 😭

wide jasper
#

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

lapis dock
#

Are the interaction IDs the same? (Move the print below the line where you add to the set)

wide jasper
lapis dock
#

nice, glad you found the fix :)

wide jasper
outer trout
#

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?

sage tendon
#

how many servers is your bot in

#

And no, cache isn't static, it should update with every event sent by discord

outer trout
# sage tendon how many servers is your bot in

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

?

sage tendon
#

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

fresh sierra
#

But you can get or fetch, if get is None then you fetch all role and check if its inside

outer trout
# sage tendon you really should never need to do that

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

outer trout
sage tendon
#

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

fresh sierra
#

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

outer trout
# sage tendon do you delete roles at all? else a 404 wouldnt make sense for roles

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..

sage tendon
#

role limit? what

#

i have like 150 roles in my server lol

outer trout
sage tendon
#

wtf

#

honestly no clue
you are on 2.6.1 right

outer trout
# sage tendon wtf

😄
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

sage tendon
lapis dock
#

What intents do you have? And did you change them recently?

fresh sierra
#

are they some example of component v2 code usage ?

lapis dock
#

Not yet

sage tendon
#

with autocomplete

fiery fable
#

is there an easy way to get all guilds the bot and the user are sharing?

rugged lodgeBOT
fiery fable
#

oh my god i overlooked it reading the docs... thanks

lean garnet
#

Hello, how can I implement this ?

#

or at least how it is named so I can look in the documentation

rugged lodgeBOT
#

Here's the context menus example.

lean garnet
#

Thanks !

echo wraith
#

Did app emojis get merged already or not yet ?

round heart
#

2.7 2.7 2.7 2.7 2.7

echo wraith
#

haha

lapis dock
#

You need to say it backwards 7 times for it to come true

round heart
#

Wen pycord 7.2, with ai

lethal loom
#

Hi, is pycord support this in the latest git?

sage tendon
#

the latest git is 2.49.0

lofty parcel
#

Lmfao

wide jasper
#

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?

sage tendon
#

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

wide jasper
#

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?

sage tendon
#

well read my message first lol

wide jasper
#

i i am using pycord: 2.6.1

sage tendon
#

no use diagnosing an issue when another issue exists

wide jasper
wide jasper
#

any docs about the new way to do it

sage tendon
#

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

wide jasper
sage tendon
#

no

#

read what i said

#

(contexts apply to slashcommandgroups as well)

wide jasper
#

i have to set nothing just guild_ids=[123] in my slashcommandgroup

sage tendon
#

thatll also allow it for DMs

#

wait nvm im dumb

#

you are right

wide jasper
#

then how to deny it for dms think_FF

#

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

lofty parcel
#

Or... set the actual contexts...

wide jasper
lofty parcel
#

You don't make it a guild command and set contexts.

lapis dock
sage tendon
#

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

wide jasper
#
cogs_group = SlashCommandGroup(
        name="fv", 
        description="Commands",
        guild_ids=[1234545],
        checks=[
            has_any_role(ung_role_ids)
        ]
    )

is this now wrong or right?

sage tendon
#

yea
but uh, why guild_ids at all

wide jasper
wide jasper
sage tendon
#

because thats not how you use that

#

unless has_any_role returns such a predicate

wide jasper
#
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

sage tendon
#

because it doesnt satisfy the requirements for a check function

wide jasper
wide jasper
sage tendon
#

thats what they say

wide jasper
#
    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

sage tendon
#

doesnt matter

lapis dock
maiden bloom
#

Does bot.emojis not include emojis added in the developer portal?

errant trout
maiden bloom
#

Got it. I really need to just switch to master this is ridiculous

round heart
errant trout
#

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

round heart
#

oh yucky. Does the API let you add them?

errant trout
#

Yeah there's a couple methods for them

#

Just no events, but not the end of the world

lapis dock
#

you should probably know when your emojis are updated

round heart
#

That's the advice my momma always told me, growing up

lethal loom
#

Hi, when i uuse a command i can use cctx.defer() but how can i use it in a interaction callback

frail basin
#

if thats what you mean

fresh sierra
#

but the interaction callback is just the command function

frail basin
lethal loom
lapis dock
# lethal loom THX

Just so you are aware ctx.defer is just a shortcut for ctx.interaction.response.defer

fresh sierra
#

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

sage tendon
#

is the channel you are running that in sbd ticket

fresh sierra
#

thats the whole point

sage tendon
#

is it a thread?

fresh sierra
fresh sierra
#

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

lofty parcel
#

Have you tried printing channel for both commands

#

And see if there's any difference

#

Which would be weird

fresh sierra
#

like that doesnt make any sens to me

fresh sierra
sage tendon
#

print the channel objects.

lofty parcel
#

^

fresh sierra
#

sbd-ticket sbd-ticket True

#

for

#

print(channel, ctx.channel, channel == ctx.channel)

sage tendon
#

did you print that as the first line in your command

#

if not, do it

fresh sierra
#

ok

fresh sierra
#
    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)
sage tendon
#

i said first

#

not second

#

because of that exact line that changes the channel var which makes that whole test worthless

fresh sierra
#

when i dont specify the agr channel

sage tendon
#

specify it, print it

fresh sierra
#

and its none

#

and when i specify its both the same

sage tendon
#

did you try with the master branch

fresh sierra
#

so
None sbd-ticket False -> no arg
sbd-ticket sbd-ticket True -> arg

fresh sierra
sage tendon
#

they are though, didnt you just prove that

fresh sierra
sage tendon
#

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

fresh sierra
#

but however there are not really since the permission are different

sage tendon
#

i wouldn't distrust obj == obj tests

fresh sierra
#

== might be true but is might be false

#

but i forgot what == means and is is

sage tendon
#

actually yea retry with is

fresh sierra
#

yep its good on master

raw beacon
#

== value
is memory address

#

iirc

sage tendon
#

are you also gonna become a 2.7 yapper

fresh sierra
#

just hope they first push the pr before merging

#

i dont want to have the same issue than in 2.6...

sage tendon
#

hardly matters most of the time

fresh sierra
#

since ctx.channel return a function

sage tendon
#

No

fresh sierra
#

maybe it cannot really check if those part are the same in both case

sage tendon
#

its a property

fresh sierra
#

yep true

#

idk which one but some return a funct to retrieve it

sage tendon
#

properties use functions under the hood

fresh sierra
#

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 ?

sage tendon
#

who knows

fresh sierra
#

let me check that

sage tendon
#

might deep check all values

fresh sierra
#
    @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

echo wraith
#

cause python memory management does bs

#

don't use is

sage tendon
#

is yielded the only correct result

echo wraith
#

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

sage tendon
#

is returned false no?

echo wraith
#

yeah I thought the opposite at first

fresh sierra
fiery fable
#

is there a recommended order of command decorators?

silk spire
#

No, the order shouldn't matter in most cases.

sage tendon
#

The order absolutely matters

#

First decorator has to be the slash command decorator

#

apart from that tho, no I think

echo wraith
#

yeah

silk spire
#

Ah, I assumed everything followed same design as ext.commands

sage tendon
#

wdym

silk spire
#

The decorator on prefix commands doesn't matter, if pycord hasn't changed it. Like checks and the command decorator can be anywhere.

sage tendon
#

the command decorator always has to be on top for all i know

silk spire
#

Nah

#

Builtin checks can handle the func being a Command or not by setting an attribute

humble turtle
#

how can i use components v2

#

?

fresh sierra
#

but you can still use the pr

humble turtle
#

but how do I install it

ivory beacon
humble turtle
#

thx

nocturne jewel
#

how to get a slash command id directly from the code?

nocturne jewel
#

like /help => it mention all commands

fresh sierra
#

and you can you bot.application_commands to get all commands

rugged lodgeBOT
nocturne jewel
#

what's the event name when someone boost the server?