#Basic Pycord Help

1 messages · Page 77 of 1

wheat tiger
#

it feels bad without typehints 💀 and more bad after learning typescript, where types are ur friends

sage tendon
#

then use typescript

torn barn
#

also, view.get_item returns a discord.ui.Button, not a discord.Button

sage tendon
#

the whole point of python is huge flexibility and no need to type

wheat tiger
sage tendon
#

if you just type everything use java or ts

wheat tiger
fresh sierra
torn barn
#

there is no such thing as discord.Item

sage tendon
#

this really is nitpicking now

wheat tiger
#

🙃

fresh sierra
#

in wavelink i have a nicething that make me handle all of those music

fresh sierra
#

by using the on_track_start and on_track_stop or smth like that you could directly here edit the message each time

#

according to what you set

#

in case you're not already doing that

torn barn
#

oh and luma, i'd recommend not using cast, but just do the typehint

wheat tiger
wheat tiger
torn barn
sage tendon
#

incredible

torn barn
#

but in the background it does some shit that makes it consume more memory than neccessary

sage tendon
#

didnt even know that works, dont you need to use a typevar for that?

silk spire
#

It's negligible though

torn barn
#

so just do val: typ = sumth # type: ignore

lapis dock
#

How are you creating your button?

fresh sierra
wheat tiger
torn barn
wheat tiger
#

and adding that on to the response

fresh sierra
#

im fine with cast in those situation

wheat tiger
fresh sierra
#

but thanks for the advice

sage tendon
#

whats the gain

torn barn
#

you could also just have assert or if checks

lapis dock
wheat tiger
torn barn
#

if they are typed as none it is because they can be at any point a None

silk spire
wheat tiger
silk spire
#

cast is supposed to be used inline

torn barn
sage tendon
#

luma just showed the warning the typehint way creates vs cast

lapis dock
#

The you might be able to do
view.button_callback.emoji = ...
Not sure if that is better for typing

torn barn
#

sheep aint braining

sage tendon
#

the ultimate solution is to not type it BECAUSE THE RETURN VALUE IS TYPED ALREADY

silk spire
#

Nah the player cannot be None there

#

It should have a special type for that but lol

silk spire
#

Oh wait it does have its own type

sage tendon
fresh sierra
sage tendon
#

says so in your IDE tho

fresh sierra
#

this is usually what im using:

player = cast(wavelink.Player, member.guild.voice_client)
valid panther
#

Has anyone managed to create an I18n system for SlashCommandGroup? cat

valid panther
#

Can I see it?

#

I just managed to work without subcommands

fresh sierra
#

But there is also an implementation made by dorûymk

#

Which is pretty easy, I did implement smth a bit more complex to suit my needs

#

But if you only need basic one, you should take a look at the repo pycord i18n

valid panther
errant trout
#

e.g. "group subcommand" is a valid key

echo wraith
#

How do you use an emoji in slash option ?

#
@bot.slash_command()
async def emoji(ctx: discord.ApplicationContext, emoji: discord.PartialEmoji):
    await ctx.respond(emoji.name)

gives

Traceback (most recent call last):
  File "/home/paillat/Documents/pycord/pycord/discord/commands/options.py", line 255, in __init__
    raise exc
  File "/home/paillat/Documents/pycord/pycord/discord/commands/options.py", line 250, in __init__
    self.input_type = SlashCommandOptionType.from_datatype(input_type)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/paillat/Documents/pycord/pycord/discord/enums.py", line 804, in from_datatype
    datatypes = [cls.from_datatype(op) for op in datatype]
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/paillat/Documents/pycord/pycord/discord/enums.py", line 804, in <listcomp>
    datatypes = [cls.from_datatype(op) for op in datatype]
                 ^^^^^^^^^^^^^^^^^^^^^
  File "/home/paillat/Documents/pycord/pycord/discord/enums.py", line 862, in from_datatype
    raise TypeError(
TypeError: Invalid class <class 'discord.emoji.GuildEmoji'> used as an input type for an Option
little cobalt
echo wraith
#

wait I cant read

#

Yeah

#

the dude that made the pr is wrong

little cobalt
#

yea

fresh sierra
echo wraith
#

No

#

ts is all broken

#

@fresh sierra Your pr did not fiy that btw

#

discord.ext.commands.errors.EmojiNotFound: Emoji "😄" not found.

fresh sierra
#

but in discord.Option

echo wraith
#

It is not in slash cmd

#

And in any case it did not fix the issue you marked it fixed

fresh sierra
#

which is maybe my issue

echo wraith
#

Ok whatever

fresh sierra
#

not an unicode emoji

echo wraith
#

Yeah I get that

#

but the issue is about unicode emoji

fresh sierra
echo wraith
#

it's about something else

fresh sierra
echo wraith
#

wdym

#

the github issue is something else

#

whatever

fresh sierra
#

guildemoji should not include unicode emoji

#

i do have a custom converter for emoji, maybe someone could pr that to include partial emoji as a valid converter

echo wraith
echo wraith
fresh sierra
#

this was the point of my pr

echo wraith
#
class DebugView(discord.ui.View):
    def __init__(self, bot):
        super().__init__(timeout=30)
        self.bot: Lumabot = bot
        button = discord.ui.Button(
emoji=str(discord.PartialEmoji.from_str(":person_medium_dark_skin
_tone_bald:")), style=discord.ButtonStyle.green
    )
    self.add_item(button)
await ctx.respond(view=DebugView(bot))
fresh sierra
echo wraith
#

Uh ok so it has nothing to di with command ?!

fresh sierra
echo wraith
#

ok

fresh sierra
#

and not unicode

#

i might do a pr to handle all kind of custom emoji

echo wraith
fresh sierra
#

or i dont understand regex

fresh sierra
# fresh sierra

we could add to this only a

if argument:
            return discord.PartialEmoji(name=argument)
#

but it will not really check if its a real partial emoji

#

but at the same time i dont think partial never check for valid data

fresh sierra
echo wraith
#

My idea would be to just add a strict = True to PartialEmoji.from_str and that's it

fresh sierra
#

so it would mean also add inside the partial emoji the real emoji (or its already the case, im not sure)

#

and so inside the converter just do a partialemoji = discord.PartialEmoji.from_str(argument) ?

errant trout
#

should work as long as it matches <(a?):(\w{1,32}):([0-9]{15,20})>$

#

EmojiConverter only works if the bot has the input emote cached

deft kestrel
#

¿its possible to use selects in modals?

sage tendon
#

no

lapis dock
#

Soon™ maybe™

deft kestrel
#

damn. another question, in the same view, can you show differents options in select2, depending what you choose in select1?

or when a view is rendered you cant change the options from a select?

shell radish
#

you can edit select2 to reflect the changes

deft kestrel
#

so its possible to change select2 options dinamically depending of what you choose in the first one right?

sage tendon
#

yes

deft kestrel
#

okay good stuff, thank you so much! ✨

lapis dock
#

When the first select is submitted you can edit the second select values and then editing the message with the updated view

deft kestrel
#

im trying to do that, but i not being able to have 2 selects in the same view, having them both in differents rows

sage tendon
#

why not?

deft kestrel
#

i not sure, to be honest, i trying to just use the "choose a flavor" select twice in the same view, and no luck, actually, having them both, are making none of them appearing

#

okay, what gemini suggested worked, ussing self.add_item(self.first_select) and the same with the second one

sage tendon
#

i mean how else did you do it lol

deft kestrel
#

in the example in the documents you dont need to do that with only one select i guess, only when you have multiples?

sage tendon
#

you shouldnt need to do that at all afaik

deft kestrel
#

what you mean?

livid nymph
#

whats the best way to move a task that runs regularly into a thread (not a discord thread)?

sage tendon
#

do what you do in the task in an asyncio runner

sage tendon
#

you just cant call the functions the same

livid nymph
#

would I be able to just have the tasks as normal and use the asyncio.to_thread?

sage tendon
#

yea

#

in the task

deft kestrel
sage tendon
#

were the functions called the same

deft kestrel
#

can i share pictures?

#

i dont know if there is a name attribute

sage tendon
#

the FUNCTION names

#

yes, show

deft kestrel
#

this is the example one, and just next to that one, i added the other

sage tendon
#

are the functions called the same

deft kestrel
#

im sorry not being able to reply you with the info you need, but, there is no function here, not at least at my knowledge of pycord, i just added 2 selects with the decorator with that info inside in the same view. ¿i guess they are anonimous functions?

sage tendon
#

you put the select decorator ontop of a function

#

that function name needs to be unique.

deft kestrel
#

so if you want to add 2 selects, you need 2 init functions with different names? and my bad, true, there was a function there. i kinda new to pycord yet and i dont undestand some stuff x3

sage tendon
#

no..

#

@discord.ui.select(...)
async def FUNCTIONNAME():

@discord.ui.select(...)
async def FUNCTIONNAME2():

#

the function names cannot be the same

deft kestrel
#

to be honest, i never did that way 😬 . damn, i am really lost with this stuff. so, each of them would have they own select_callback. i guess?

sage tendon
#

that is literally exactly what you showed..

#

send the whole file please

deft kestrel
sage tendon
#

please dont use AI, use the guide

fresh sierra
errant trout
#

advaith confirmed he'd be working on modals on his internship, give it a few months

fresh sierra
#

are you sure its the modal for bot ?

#

if its the case that would be really nice !

echo wraith
#

that was smth different

echo wraith
#

if saying "stay tuned" means confirmed yeah sire

errant trout
echo wraith
#

fair

errant trout
#

but yeah i guess nothing "confirmed" until he actually starts on it

errant trout
echo wraith
ancient timber
#

does pycord have a specific way to check a users presence? casue anytime i run an eval to pull it i get none even though intents is setup and on in the main file and dev portal

fresh sierra
#

im also pretty sure that users dont have presence and that only members have

ancient timber
#

I was using. The away fetch_user() function

fresh sierra
#

i'll check about it, but you should check for a member to see

ancient timber
#

Intents for presence is on for both the dev portal and in my bot.py it's marked as true

#

It returns offline for the things I tried to pull it for

fresh sierra
#

you should check for member and not user

#

looking at the doc, it seems that its for member only

ancient timber
#

Oh so how would u check to see if they are online ?

#

That's all I'm trying to do lol

fresh sierra
#

using this and by checking the after.status

ancient timber
#

Ahh I remember reading that somewhere, would basically make your bot listen to the update event and apparently it's hard to catch

fresh sierra
#

this is what you want, so you dont have to fetch userr each time

ancient timber
#

Thank u 🙏

reef lake
#

is there a way to use put multiple commands of different cogs into one single SlashCommandGroup?

reef lake
hexed herald
reef lake
#

becuae i just tried and it did not work i thought i may have mad some mistake

hexed herald
#

what exactly do you mean? like
/command subcommand

#

I use it to group commands like this and have each in it's own cog

reef lake
#

mb i wanted to say subgroup not subcommand like this
/music queue add [params]

hexed herald
#

hmm, I haven't actually tried that yet but I have my commands organized in subordners like
/extensions/module_a
and in the /extensions folder I've got a file where I create the discord.SlashCommandGroup where you can create subgroups already so I guess it should work
(This layout is comfortable for me because I use the load_extensions functions for my bot with the recursive argument)

fresh sierra
#

Instead of just « group »

reef lake
#

okay

#

i ll try next coding sess

steady nymph
#

hi. how can I edit a message by channel ID and message ID? just switched to pycord from discord.py and so far I did it like this:

channel = bot.get_channel(CHANNELID)
msg = await channel.fetch_message(MSGID)
await msg.edit(content=content)
echo wraith
#

that should work too ?

sage tendon
#

yea

steady nymph
#

mh. I'll check permissions then. the fetch_message being red underline in vscode confused me

sage tendon
#

show what it shows

sage tendon
#

no.. what vscode shows

steady nymph
#

oh

sage tendon
#

yea either wrong IDs or permissions

#

or you don't have message intent but I think that'd look different

sage tendon
steady nymph
#

oki, I'll double check the perms. just came to my mind once I posted my initial question

#

thank you, will let you know if it worked after lunch break

sly karmaBOT
# steady nymph hi. how can I edit a message by channel ID and message ID? just switched to pyco...

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
#

not the issue here but worth keeping in mind

little cobalt
#

I only saw get_channel so

fresh sierra
# steady nymph

Its because the channel you using fetch message form is a discord.abc.Guildchannel, this include some channel without the fetch message

#

And it also can be None

#

Si to resolve that you should make sure it’s not None / checking it’s a text channel for exemple

lethal loom
#

Hi, i will set a url but it dont work
Error:

In components.0.components.0.custom_id: A custom id and url cannot both be specified
In components.0.components.0.url: A custom id and url cannot both be specified```

code:
```py
# Create a View for the Payment Button and a cancel button
class PaymentView(discord.ui.View):
    def __init__(self, payment_url):
        super().__init__()
        print(f"Payment URL: {payment_url}")
        self.payment_button.url = payment_url
        
    # URL Button for Payment
    @discord.ui.button(label="Jetzt bezahlen", style=discord.ButtonStyle.link, emoji=":credit_card:")
    async def payment_button(self, button: discord.ui.Button, interaction: discord.Interaction):
        await interaction.response.send_message("Zahlung.", ephemeral=True)```
little cobalt
#

Die haben auch kein Timeout

silk spire
#

Sie können nur URL-Schaltflächen deaktivieren

lethal loom
#

mach sinn 😭

lethal loom
# little cobalt Ein Link Button hat kein Callback

Ich hab das jetzt so geamcht, aber jetzt ist der abbrechen button links neben dem bezahlen button, abe rich will das erst der bezahlen button nund dann der abbrechen button kommt kannst du mir sagen wie ichd as amchen kanN`?

    def __init__(self, payment_url):
        super().__init__()
        print(f"Payment URL: {payment_url}")
        self.payment_button = discord.ui.Button(
            label="Jetzt bezahlen",
            style=discord.ButtonStyle.link,
            url=payment_url
        )
        self.payment_button.url = payment_url
        self.add_item(self.payment_button)

        
    @discord.ui.button(label="Abbrechen", style=discord.ButtonStyle.red)
    async def cancel_button(self, button: discord.ui.Button, interaction: discord.Interaction):
        ...```
little cobalt
fresh sierra
#

ish libe dish

silk spire
#

could also do something like self._children.insert(0, ...) but idk

echo wraith
#

Personally I like doing sellf.button = Button and self.button.callback = something

#

because I often have reactive stuff where state of other components changes depending on one

lapis dock
#

Oop, ping :/

shell radish
#

it’s UC Berkeley no?

lapis dock
#

Santa Cruz

#

Unless he transferred this year

shell radish
#

oh I could’ve went there

#

they accepted me but I didn’t go

rigid parcel
#

https://guide.pycord.dev/extensions/commands/help-command

This page doesn't help me at all on how to safely disable the "help" command, it only tells me the wrong ways to do so. In addition, the UI examples aren't working either goddammit

Can someone please tell me the correct way of disabling the built-in help command?
-# I've done way too much work for my dictionary stuff, and I really don't want to redo 300+ lines of code just because of this.

errant trout
#

help_command=None will work

#

(the wording is pretty awkward regardless)

rigid parcel
#

For the features and customizability that I want in a %help command, working with constrictions is very frustrating goddammit

Plus I don't want cogs to be treated the same as categories, otherwise I would need to reorganize 1k+ lines of code.

rigid parcel
errant trout
#

i mean, the entire section says it's talking about creating; this is correct

#

because when creating a custom help command you pass help_command=YourHelpCommandClass() instead of trying to set None

deft kestrel
#

In myView have 2 selects added to the view with the self.add_item both of them with a few options, but i having the next error
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In data.components.0.components.0.options: Must be between 1 and 25 in length.
In data.components.1.components.0.options: Must be between 1 and 25 in length.

what i am missing? 😅

sage tendon
#

no more than 25 options

deft kestrel
#

the first select have 5, and the second have 1 (becuase the first one will add dinamically the rest)

sage tendon
#

you have more than 25 somewhere

deft kestrel
#

there is any doc explaining how to do this with 2 selects with the self.add_item()? i feel i having some trouble with that, because it all worked with decorators, but i need to also modify dynamically the first one select (to add the default option to the selected one, so when i edit the message dont get deleted) also, not been able to trigger selects callbacks with the custom_id

sage tendon
#

nothing special about it

#

show your view code

#

why do you use both the decorator and the self.add_item variant

#

thatsn ot how that works lol

deft kestrel
sage tendon
#

whatever you call the callback will end up being the select object

#

afaik

deft kestrel
#

so the decorator is not needed?

sage tendon
#

its one way to do it

#

what i said is if you use the decorator, the function name of the callback should be the select object so you can access it via that

deft kestrel
#

but that would fix the options error?

sage tendon
#

what would

deft kestrel
#

okay, makes sense, because the code thinks the decorators are the selects, and both of them are empty

sage tendon
#

if you dont wanna use the decorator you just need to remove it and set the select callback manually

deft kestrel
#

how you set the callback manually?

sage tendon
#

select.callback

#

check the docs

deft kestrel
# sage tendon check the docs

could you share where i can find that? i really checked the select Menus, and i dont find anyway to do that without the decorators, the examples are only with the decorators, sorry for bothering you so much 😅

sage tendon
deft kestrel
#

after reading it, i not really sure how to use it to be honest 😅 , self.category_select.callback(interaction)... what interaction should i pass it? self.my_method_name?

sage tendon
#

self.category_select.callback = your_function

deft kestrel
#

in select Menu callback examples have it to access to the selected item... i will remove it like i guess is not needed in this case 😅

#

how you access to the data then? with self.values[]?

sage tendon
#

uhh

#

try it

#

if not then just use the decorator honestly

deft kestrel
silk spire
#

You can

silk spire
#

So it would be self.select_callback.options = [] in that case

#

Same for all the other attrs

sage tendon
#

yea

deft kestrel
sage tendon
#

same thing is true for commands btw

#

which is how you can dynamically create slash commands

deft kestrel
sage tendon
#

it's literally super easy lol
it's one or two extra lines

loud kayak
#

how do i put a button in an embed?

fresh sierra
#

.tag cv2

sly karmaBOT
#

Components V2 are under development in pycord and aren't yet included in the official releases on PyPI or the master GitHub branch. However, you can access the features now by installing directly from the pull request #2707. To do this, use the following command: pip install git+https://github.com/Pycord-Development/pycord.git@refs/pull/2707/head Please be aware that this is a development version and may contain bugs, feel free to report them by adding a comment to the pull request.

loud kayak
#

ohh ok

hexed herald
#

hey, do I correctly use ctx.invoke() ?
Especially, how do I pass the command in? Do I just use the function name?

                await ctx.invoke(command=self.warn, member=member, reason=reason)

This is how I currently use it (self.warn is the command function)

#

but it fails with this exception ApplicationContext.invoke() missing 1 required positional argument: 'command'

silk spire
#

Dont do command=

#

You could also call the command await self.warn(ctx, member=..., ...)

hexed herald
#

alright, thank you!

lapis dock
#

Will calling it directly trigger error handling properly?

hexed herald
#

I don't know if it does currently, in the note is written

This does not handle converters, checks, cooldowns, pre-invoke, or after-invoke hooks in any matter. It calls the internal callback directly as-if it was a regular function. You must take care in passing the proper arguments when using this function.

fresh sierra
#

because you are just invoking a function and nothing else

#

if you use Client.invoke_application_command() however it should handle everything

real glacier
#

hello! do i have to rewrite some codes to support the user install?

#

or it works for both user & guild ?

sage tendon
#

i think as long as you make it user installable every command should by default work everywhere

real glacier
#

alr thanks i will try that!

lapis dock
#

If that does not work you can set the default installation contexts and contexts in the bot constructor

real glacier
real glacier
#

in every commands?

lapis dock
#

default_command_contexts
The default context types that the bot will use for commands. Defaults to a set containing InteractionContextType.guild, InteractionContextType.bot_dm, and InteractionContextType.private_channel.

New in version 2.6.

Type:
Collection[InteractionContextType]

default_command_integration_types
The default integration types that the bot will use for commands. Defaults to a set containing IntegrationType.guild_install.

New in version 2.6.

Type:
Collection[IntegrationType]]

real glacier
#

wait nvm

#

its working now! thanks!

lapis dock
real glacier
#

all good! i thought it needed any intents. prob my research is mistaken

#

dont know if it's a bug, but the emoji stop working after the interaction message has been edited. such as paginator editing to the new embed

#

issues from group chat

#

and (emojis) it's working in any guilds

real glacier
#

container

errant trout
#

likely a discord issue, they have some strange logic when bots use custom emojis

lapis dock
#

Are those server emojis or app emojis?

real glacier
lapis dock
#

Try with app emojis, you might have less issues

round heart
#

Are app emojis on master?

lapis dock
lofty parcel
#

Is there a way to get the raw member payload without needing to do another api call

#

For example on on_member_update event

errant trout
fresh sierra
#

could a on_raw_member_update be implemented ?

lofty parcel
#

It wouldn't be very cool to do an api call there right

errant trout
#

there's no point in raw_member_update

#

because any member update you'd get would be cached

fresh sierra
#

dark has one ;), (except if its for the tag (which are currently not in the lib)

errant trout
#

(the only point of raw events in the lib is circumventing cache)

#

probably in v3 we'll have _data as an attribute in all discord models or something

#

you could also propose it for v2 if you care enough but eh

fresh sierra
#

i might do that around the 20 of july when im finally home

#

let me do my paillat rn

#

-reminder 15d #1132206148309749830 message

lofty vaultBOT
#

Set a reminder in 2 weeks and 1 day from now (<t:1752690359:f>)
View reminders with the reminders command

fresh sierra
#

(i said 20 and i put 15...)

lofty vaultBOT
#
Remindme <Time:Duration> <Message:Text>

[-channel channel:Channel]

Invalid arguments provided: Not enough arguments passed
lofty parcel
#

Hm

#

I guess forking the lib and editing it is the best way

#

Since it'd be for someone else

fresh sierra
lofty parcel
#

There's no point if it's still subject to change

fresh sierra
#

(we could have that for every obj maybe in v3)

lofty parcel
#

I dont even know how the lib does the attributes shit either way

#

I have to look into the files

uncut quartz
#

how do i install the dev version so i can use components v2?

sly karmaBOT
# uncut quartz how do i install the dev version so i can use components v2?

Components V2 are under development in pycord and aren't yet included in the official releases on PyPI or the master GitHub branch. However, you can access the features now by installing directly from the pull request #2707. To do this, use the following command: pip install git+https://github.com/Pycord-Development/pycord.git@refs/pull/2707/head Please be aware that this is a development version and may contain bugs, feel free to report them by adding a comment to the pull request.

uncut quartz
#

thank you bot

lofty parcel
#

or nour

fresh sierra
#

it should

errant trout
#

But idk

errant trout
#

Fixed, reinstall

uncut quartz
#

ty

torn barn
#

why is the accessory an iterable in the first place?

errant trout
steady glade
fresh sierra
#

how should i do for the inline here:

#

i would like to have the default name and default user limit on the same row, but only those 2 and same for the channel and category

#

im not even sure this is possible tbh

#

this is the closest i have been but it looks awful with those big padding

errant trout
#

empty fields is the only way to do 2 column inline consecutively

fresh sierra
#

By using the \u200b

errant trout
#

no

#

empty string, no character

fresh sierra
#

Ok phone the padding doesn’t appear

fresh sierra
#

I thought it was the same

wheat tiger
#

Isn't this the correct of using local files as image/thumbnail in embed?

fresh sierra
#

.tag localfile

sly karmaBOT
#

Tag not found.

Did you mean...
local-file

fresh sierra
#

.tag local-file

sly karmaBOT
#
f = discord.File("some_file_path", filename="image.png")
e = discord.Embed()
e.set_image(url="attachment://image.png")
await messagable.send(file=f, embed=e)```
wheat tiger
#

.tag local-file

sly karmaBOT
#
f = discord.File("some_file_path", filename="image.png")
e = discord.Embed()
e.set_image(url="attachment://image.png")
await messagable.send(file=f, embed=e)```
wheat tiger
fresh sierra
wheat tiger
#

No error is shown

fresh sierra
fresh sierra
wheat tiger
fresh sierra
wheat tiger
#

if I send as normal message using file=discord.File() it sends

fresh sierra
#

f = discord.File(f"media/{result}.gif", filename="image.png")
e = discord.Embed()
e.set_image(url="attachment://image.png")
await messagable.send(file=f, embed=e)

wheat tiger
#

yeye ig I get what u mean

#

lemme test

wheat tiger
#

man

fresh sierra
sage tendon
quartz umbra
#

silly question but can you make (discord) polls with py-cord or is this not even supported by the Discord API?

lapis dock
echo wraith
#

.tag master

sly karmaBOT
#

pip install -U git+https://github.com/Pycord-Development/pycord
-# Note: The Master Branch May Have The Newest Features But It May Also Have More Bugs
The docs for the master branch: https://docs.pycord.dev/en/master/

quartz umbra
#

ah I found it. Thanks and sorry for the hassle!

lapis dock
#

poll=... in all the contexts you can send a poll

quartz umbra
#

tysm!

uncut quartz
#

if theres a better place to discuss this lmk

#

oh wait

#

this might be me being dumb

silk spire
#

looks like you're trying to add something other than a TextDisplay to a Section?

echo wraith
#

error messages could be improved but yeah

#

calling it section is a lil misleading for newcomers

silk spire
#

iirc discord said not to hardcode the types for now so Shrug

echo wraith
#

hm true

uncut quartz
#

yeah i was passing a discord.ui.Section into add_section, i didnt realise that was different

#

is it possible to use a persistent button with components v2? i subclassed the Button class, and i use it as the accessory in a section in a container in a view with no timeout, but it isn't persistent

little cobalt
#

Did you also add the view to the bot?

uncut quartz
#

wdym

#

oh

#

i see

uncut quartz
#

how can i get a before and after with the on_raw_thread_update event?

#

i just need to check whether any thread has been closed or reopened

#

but on_thread_update cant check if it's been reopened

lapis dock
#

Why cant on_thread_update work?

#

IE what are you seeing in the raw event that is not present in the normal event?

uncut quartz
lapis dock
#

Ah, yeah ok.

uncut quartz
#

and i check for something like before.archived == False and after.archived == True or vice versa to check whether they were closed or reopened

lapis dock
#

So the problem is you cant really get before in the raw events because discord does not send that data.

uncut quartz
#

hmm

#

i do give closed threads a tag

#

so i might be able to check if it is opened and has that tag

#

ill try this

#

ty

lapis dock
#

Yeah that might be a good way to do it. Otherwise you might be able to just say that any thread that is not in the cache was archived but there may be some edge cases where that wont work. It might also show up in audit log (which also can be inconsistent)

agile sentinel
#

cna nayone help me with my code

#

im making an ticket tool but wehn i press the panel button to make one the bot creates multple ticket and channles

echo wraith
#

.tag paste

sly karmaBOT
#

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

echo wraith
#

.tag idw

sly karmaBOT
#

Saying it doesn't work or asking what's wrong with this code is not helpful for yourself or others.
Describe what you expect and/or tried (with your code), and what isn't going right.
Please provide any errors you get for optimal assistance.

sage tendon
#

me when I run my bot multiple times

echo wraith
#

Is there a tag for that ?

lapis dock
#

dont think so

fresh sierra
#

if its a member, why is it typehint as User ?

sage tendon
#

probably if the user left

fresh sierra
sage tendon
#

no idea

errant trout
#

strictly speaking it should be Role | User | Member | Object because all are valid in overwrites_for

#

Object if you don't have the real object, User if for some reason you have User instead of Member

#

(effectively you could just reduce the typehint to Snowflake - the type used for any object that has an id)

fresh sierra
#

so in fact it should always be also a member ?

#

except if its not cached or for weird reason ?

lapis dock
errant trout
#

it would but we already use Snowflake like that elsewhere in the library

#

if a function accepts Object for any reason, it can be typed as Snowflake

#

(i.e. it only relies on id and nothing else)

slim prawn
#

I am trying to migrate from dpy to pycord
cannot import name 'AppCommandOptionType'

shell radish
#

.rtfm optiontype

wheat tiger
#

@fresh sierra How du save channel ids in JSONField?

#

I have this issue, see if I use supabase to manually set that channel_id field in json then the value gets rounded-off but when set using bot it sets correctly but shows wrong value. Ig js is the culprit here which is used by supabase.

#

So should I save them as Text?

#

@fresh sierra

fresh sierra
wheat tiger
fresh sierra
#

but when i was using mysql only i was just using a text field with the list of int, and then for orm i just have a json fields list and i append the int inside

#

but when i used to only use the raw sql, i faced an issue with too big int, that were rounded into e^10, so i just convert then to int then str and then i used to added them inside my db

errant trout
#

if you need to save json as string, use json.dumps when saving and json.loads when loading it back to python

fresh sierra
#

(in case i meant save the int as str, but i was saving it alone and not inside a json)

ivory beacon
#

Whenever I react to a message using a bot with add_reaction("❌"), the emoji appears invisible. The same thing happens with . Is this a Discord bug?

#
await message.add_reaction("✅")
await message.add_reaction("❌")
lapis dock
#

Most likely, I don't think it could possibly be a py-cord bug

sage tendon
#

restart discord

echo wraith
#

I have had that bug for like a month on some emojis

#

it's discord

ivory beacon
echo wraith
#

Idk it comes an goes

uncut quartz
#

if ive got a loop (ext.tasks.loop) in another file, which i import and start from my main file, does it need to be in a cog? if not, how can I reference the bot from that loop?

#

nvm

sage tendon
#

you shouldnt do that

uncut quartz
sage tendon
#

there is no need to import a ready-defined task

#

just define it where its supposed to run

errant trout
# uncut quartz if ive got a loop (ext.tasks.loop) in another file, which i import and start fro...

while it's not required, ideally you design your tasks to be inside a cog like the docs show https://docs.pycord.dev/en/stable/ext/tasks/index.html#recipes ```py
from discord.ext import tasks, commands

class MyCog(commands.Cog):
def init(self):
self.index = 0
self.printer.start()

def cog_unload(self):
    self.printer.cancel()

@tasks.loop(seconds=5.0)
async def printer(self):
    print(self.index)
    self.index += 1

...```

#

however, it's not a requirement - you could import if you wanted py from discord.ext import tasks @tasks.loop(seconds=5.0) async def printer(): print(self.index) self.index += 1

from some_file import printer
... # Main bot code
printer.start()```
#

if you do the cog style and want to start it from a different file (like your main bot file), you should NOT import the cog; instead, use bot.get_cog(cog_class_name) and start it through that after the client is ready

#

so e.g. in your main bot file, you could have something like py @bot.event async def on_ready(): tasks = bot.get_cog("MyCog") tasks.printer.start()

rocky arch
#

is there any good way a ui component can access the view associated with it in a type safe manner? i keep having to put #type: ignore to shut mypy up but im sure there's a better way to do this. the underlying problem is that it recognizes self.view is a discord.ui.View but self.view is actually a class that inherits from discord.ui.View with extra properties

torn barn
#

You can type Button

#

discord.ui.Button[MyViewSubclass]

#

Doing that you’ll type the view attr to MyViewSubclass | None

#

You’ll still need to do an assertion to check it is not None

rocky arch
loud kayak
#

how do i get the lines in embeds?

#

like the separators

torn barn
#

those are components v2

#

the separator component

eternal kite
#

hi, the server members intent is kinda buggy recently for my bot, get guild returns none sometimes but works normally sometimes, get member too, sometimes it just returns none, and sometimes it works fine

lofty parcel
#

get_memeber returning None means the user isnt cached

eternal kite
# lofty parcel Any get_ relies on cache

nope but previously i use guild.chunk() in bot.check but i removed it and added the code into on_application_command after to decrease the command execution time

#

so am i supposed to chunk the user? with what method?

#

or guild.chunk() is enough?

#

the problem is that the command just doesn't load at all, and also not raising any errors

#

it just stucks at thinking

errant trout
#

uh

#

why would you use guild chunk on command execution...?

lofty parcel
#

And doesnt chunking already happen by default

errant trout
#

yeah

errant trout
eternal kite
errant trout
#

congrats, that's why your member cache isn't filled

eternal kite
#

so thats why i do guild.chunk

errant trout
#

chunking blocks the websocket

eternal kite
#

but if i dont, it's going to take 10 years for the bot to get ready

lapis dock
#

I thought discord fixed that

errant trout
#

how many guilds are you in

errant trout
eternal kite
#

1.2k

errant trout
#

then either you have to accept the long startup time or try build your commands without using member cache

eternal kite
#

also, the guild.chunk code has been there for over 2 years, and i havent tocuhed anything

eternal kite
#

it started to happen recently

errant trout
#

unless you updated im guessing discord changed something with chunking, but it's pretty standard for you to have long startup times with more members

eternal kite
errant trout
#

sounds about right

#

hm

eternal kite
#

yea im not waiting 2 hours to chunk 1.2k guilds

errant trout
#

you could probably just chunk in another thread

lapis dock
#

What features of yours require members to be cached?

eternal kite
#

wait, i think it's not the issue here

#

because the bot commands are not responding at all

errant trout
eternal kite
#

it just stucks at thinking, the on_application_command is just an error happened alongside the main cause

errant trout
#

does that still happen if you remove the chunk code

eternal kite
#

no idea, i never touched it

#

the bot stucks at thinking for some players, but not for the others

#

and it will be back to normal after a couple minutes 10-20 or an hour

errant trout
#

ok, so try removing the chunk code

eternal kite
#

especially it's not working for new users

eternal kite
errant trout
#

it sounds to me like chunking on command is the problem

#

if you haven't touched anything (neither have we), to our understanding chunking takes up most of your websocket traffic which ends up blocking other events

eternal kite
errant trout
#

doing it in a bot check would still do it in on every command though

eternal kite
#

so right now when i kick the bot and reinvite it, it stucks at thinking when i use a command

eternal kite
errant trout
#

i mean yeah but that's not quite what my point is

#

you were saying that chunking at startup takes 2 hours; not chunking at startup means that 2 hours would still happen, just split across the runtime of your bot

eternal kite
#

yea

errant trout
#

so if someone runs a command in a large guild and it needs to be chunked, it's still gonna block the entire bot for, idk, a few minutes

#

(or to be more accurate, floods websocket -> other events like command execution get delayed)

#

that's what I'm assuming you're dealing with, and the unfortunate part here is that using another thread wouldn't actually work because it's still coming down the same websocket

#

you could try switching to Sharding since you meet the minimum of 1k guilds, which should split your websocket connection, but not sure how effective it'll be

#

part of the reason why huge bots like dyno have insanely long downtimes for their maintenance is because across their thousands of shards they have millions of servers and hundreds of millions of members to cache - that's the largest bottleneck if you want to track them

errant trout
lapis dock
loud kayak
#

what is the attribute to get a user's username (mine for example is nziie3) in the discord.User class? documentation was kinda vague on that part

#

.global_name?

#

nvm its just .name

lofty parcel
#

.name is username which according to the docs isnt unique

#

Oh well

#

Its the other way around

#

Tf

edgy nest
#

.name has been and always will be their unique username

#

.global_name is their global display name

#

and the reason its like that is because changing .name would've been breaking

#

thanks for coming to my ted talk

loud kayak
#

w ted talk

mighty otter
#

is it possible to make 2 commands without getting the unique name error?

like these:
/report
/report directly

i want the second one to sue the slash command groups so it can be classified and has the space in between the words intead of a dash or an underscore

little cobalt
#

You can do this with slash command groups

rugged lodgeBOT
#

Here's the slash cog groups example.

mighty otter
sage tendon
#

show your code

mighty otter
sage tendon
sage tendon
#

just follow the guide

#

you just need to call the other command smth too
like /report directly and report <idk>

echo wraith
#

You can't have a command name be both a command and a subcommand parent

fresh sierra
echo wraith
mighty otter
echo wraith
lapis dock
#

I do something like
/Tag
/Tag-manage xyz
Would that work for you?

echo wraith
#

Actually I never tried but you could maybe do something to work around it with localisations

#

But I'm not saying it'd work

fresh sierra
torn barn
#

You can do that with guild-specific commands. But you won't be syncing per each guild everytime, would you?

#

So you can have /report directly as a global command and /report as a guild command

lapis dock
#

Is directly the only subcommand?
If so just have "report" and "report-directly"

cobalt bone
#

Hello ! How to see forward content message ?
message.content return an empty string (or None I don't remember)

sly karmaBOT
round heart
#

Remind me, cv2 has unlimited containers (things that can have an accent color) now? Or does that still have some sort of restriction

#

Oh. 40 - <#discord-api-updates message>

#

Wait, no. Top-level says unlimited. (But wouldn't that be 40? lol)

#

Yeah, dv8 confirmed it's really 40, in line with the per-message limit.

errant trout
#

previously, top level and container were 10 each

#

now those don't exist, you just have one constraint to consider

round heart
#

So accessories would reduce that number, then

errant trout
#

a section will always be considered 3 components

#

(at minimum, 5 at max)

round heart
#

Wait, what? Why 3?

errant trout
#

the section itself counts, and sections must have both an accessory and at least 1 item

round heart
#

I thought the accessory was the item. woof.
So a section is different from a Container, right? Which one gets the accent colors?

We need a visual nomenclature guide.

errant trout
#

container is with colours

#

a section should only be used if you want text with an accessory (thumbnail or button) to the right

round heart
#

So is that 4, then?
Container + Section + Accessory Definition + Button/Thumbnail?

errant trout
#

4 yes, but button/thumbnail is the accessory

round heart
errant trout
#

no, Section must have 1-3 items - currently, it only supports TextDisplay

round heart
#

I see. I think

Container
\ Section
  \ TextDisplay
  \ Accessory

(Assuming accessory is a child of section, not textdisplay)

errant trout
#

correct

mighty otter
#

guys my bot's music stutters when i add more music to the queue, idk if its anything to do with the processing power but the cpu usage isnt at 100% when that happens so i know the cpu can handle more than that, so maybe it's because the code was singlethreaded but idk how i can fix it, anyone have any ideas?

little cobalt
#

Is that a youtube music bot?

mighty otter
#

Yes

#

yt-dlp and ffmpeg

lofty parcel
#

You won't receive help here.

mighty otter
#

its a personal bot thats used only by me, plus, i use adblock in youtube anyway

echo wraith
mighty otter
lapis dock
#

I think Spotify has something for streaming music for personal use only but I'm not 100% sure, I don't use Spotify

round heart
#

Hm. Is there a way to have the 'author' stuff from Embeds (which had a nice image icon on the left) in cv2? Outside of galleries, all images seem to be pushed to the right

errant trout
#

there's been concepts of alternatives but no guarantees (e.g. updating <@id> to support icon modes)

errant trout
#

oh god

tidal pecan
echo wraith
#

This is from a time I never knew I think

round heart
#

Yeah I’m lost, as well

sage tendon
#

doesn't exist I believe

torn light
#

How hard is it to switch from disnake to pycord?

echo wraith
torn light
echo wraith
#

Non slash stuff should be pretty easy because their base is the same. If your use slash is shouldn't be too hard but you'll have to play around. I think some implementations were copy pasted between the two but I'm not 100% certain

#

@torn light

torn light
#

ok

tender python
#

Can i make a slash command not show in DMs?

pliant shell
#

So I just made a simple autocomplete, but am getting the weirdest error that i don't understand.

Ignoring exception in on_application_command_auto_complete

RuntimeError: Task <Task pending name='pycord: on_application_command_auto_complete' coro=<Client._run_event() running at E:\VS Code\Omega\New\.venv\Lib\site-packages\discord\client.py:412> cb=[set.discard()]> got Future <Future pending> attached to a different loop

The whole autocomplete is just returning a list:

async def get_cogs(ctx: discord.AutocompleteContext):
    return list(loaded_cogs)

Can i be pointed in the right direction to fixing it, please? I can provide the full traceback if needed, but it's not much...

lapis dock
lapis dock
pliant shell
# lapis dock are you starting your bot is a "complex" way? Other then `bot.run(...)`? A full ...

Kind of? I have a run file that uses a subprocess.run for the main.py which then has asyncio.create_task(bot.start()).
This was the traceback i got at first:

Ignoring exception in on_application_command_auto_complete
Traceback (most recent call last):
  File "E:\VS Code\Omega\New\.venv\Lib\site-packages\discord\client.py", line 412, in _run_event
    await coro(*args, **kwargs)
  File "E:\VS Code\Omega\New\.venv\Lib\site-packages\discord\bot.py", line 883, in on_application_command_auto_complete
    await self._bot.wait_for(
  File "C:\Users\Kaspars\AppData\Local\Programs\Python\Python312\Lib\asyncio\tasks.py", line 520, in wait_for
    return await fut
           ^^^^^^^^^
RuntimeError: Task <Task pending name='pycord: on_application_command_auto_complete' coro=<Client._run_event() running at E:\VS Code\Omega\New\.venv\Lib\site-packages\discord\client.py:412> cb=[set.discard()]> got Future <Future pending> attached to a different loop
#

now that i think about it i might not need the asyncio.create_task

lapis dock
#

If i had to guess that is par t of the problem, unfortunetly I do not understand asyncio enough to know how to fix it

pliant shell
#

Alright. Well i'll try to remove the asyncio part, i don't remember why i had put it in, in the first place

lapis dock
#

you might be able to fix it by passing the event loop into the bot constructor

pliant shell
#

Hehe not smart enough for that, will be finding ways around

tender python
#

Is there a way to get the content of a forwarded message? I keep getting blank messages in logs.

lapis dock
#

It is under Message.snapshots
But only on master branch

rugged lodgeBOT
errant trout
#

message.system_content is also a shorter way to get it (on master)

#

otherwise message.snapshots[0].message.content

sharp pawn
#

Guys a quick question
I was wondering what is the best use case when you need to get the list of members of large servers (target 1000+ members)
I noticed that the Guild.fetch_members method does not have a chunk limit parameter, so does pycord care about the API rate limit? and how many members it fetches per request when the limit is set to None?

errant trout
#

per docs ```py
Usage ::

async for member in guild.fetch_members(limit=150):
    print(member.name)

Flattening into a list ::

members = await guild.fetch_members(limit=150).flatten()
#

generally speaking, you probably don't want to overuse this with limit=None for large servers

#

but i guess that's up to you to decide

sharp pawn
#

Thank you for the answer

#

Well idk is a one time thing an abuse? xD
I will use to get the members when the bot joines a server then it will never use it again

errant trout
#

do you not have the members intent?

sharp pawn
#

Yes i have them

errant trout
#

did you disable member caching

sharp pawn
#

Probably not

errant trout
#

then you don't need to fetch

#

all members will be in guild.members when your bot joins the server

silk spire
#

There is also Guild.chunk to get all members and cache them from the gateway

#

But do you really need them

sharp pawn
#

You sure? i remember that it contains the members that are cached. I never truly understood when a member is removed from a cache actually

errant trout
silk spire
#

Via the events

#

on_member_remove for example will remove it internally too

errant trout
sharp pawn
# silk spire But do you really need them

This bot will be used inside Rematch communities, and i want it to automatically link their rank and stats for the members of the server
Ofc there will be some commands to do so but since i want to focus on the tournament management i want this part to be like a secondary thing that u should not worry about for the most part

sharp pawn
errant trout
#

all good

errant trout
#

if the numbers are close enough, then it is caching members - they may not be exactly the same though

sharp pawn
#

Yeah if a small part is missing i can run over on that actually

round heart
echo wraith
echo wraith
#

😭

#

you got what I mean

pliant shell
#

Rewrote my code that had a view with 3 buttons, now am getting an error that i don't think i've even seen in this channel:

discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In components.0.components.1.sku_id: A sku_id is required
sage tendon
#

show your code

pliant shell
#

Which part? It is about 300 lines long...

sage tendon
#

the view

pliant shell
#
hit_button = Button(label="Hit!", style=ButtonStyle.primary)
        stand_button = Button(label="Stand.", style=ButtonStyle.premium)
        double_button = Button(label="Double Down!!!", style=ButtonStyle.danger)

        view = View()
        view.add_item(hit_button)
        view.add_item(stand_button)
        view.add_item(double_button)

and

hit_button.callback = hit_callback
        stand_button.callback = stand_callback
        double_button.callback = doubledown_callback
#

Seems the indentation messed up a bit when pasting, but it's indented as needed

sage tendon
#

well, if you have a premium button you need to pass the sku id of a premium product

pliant shell
#

ah, i thought it was a color xd

#

Will change and test.

#

Ok that worked, thanks a lot!

sage tendon
#

np

undone shale
#

👋

I've got a bot that creates a message+view on command, and edits the message each time a button is clicked.

The message is correctly edited, but then it also says "This interaction failed" in red? Can anyone explain why please?

Code below:

class SociocracyBot(discord.Bot, abc.ABC):

    def __init__(self, *args, **options):
        super().__init__(*args, **options)

        self.votes: Dict[uuid.UUID, discord.InteractionMessage] = {}
        self.logger = get_logger()

    async def consent_added(self, user, view_uuid: uuid.UUID):
        message = self.votes[view_uuid]

        await message.edit(content=message.content + f'\n* {user.mention}')

    async def consent_withdrawn(self, user, view_uuid: uuid.UUID):
        message = self.votes[view_uuid]

        await message.edit(content=message.content.replace(f'\n* {user.mention}', ''))```
#

class ConsentView(discord.ui.View):
    """
    A view which allows the user to consent or withdraw consent via buttons.
    """

    def __init__(self, * args, ** kwargs):
        super().__init__(* args, ** kwargs)

        self.uuid = uuid.uuid4()

        self.consents: dict[int, str] = {}

        consent_button = discord.ui.Button(label='Consent', style=discord.ButtonStyle.green)
        consent_button.callback = self.add_consent
        self.add_item(consent_button)

        withdraw_consent_button = discord.ui.Button(label='Withdraw Consent', style=discord.ButtonStyle.red)
        withdraw_consent_button.callback = self.withdraw_consent
        self.add_item(withdraw_consent_button)

    async def add_consent(self, interaction: discord.Interaction):
        if interaction.user.id in self.consents:
            await interaction.response.send_message("You have already consented", ephemeral=True)
        else:
            self.consents[interaction.user.id] = interaction.user.mention
            await sociocracy.consent_added(interaction.user, self.uuid)

    async def withdraw_consent(self, interaction: discord.Interaction):
        if interaction.user.id in self.consents:
            await sociocracy.consent_withdrawn(interaction.user, self.uuid)
        else:
            await interaction.response.send_message("You have not consented so cannot withdraw", ephemeral=True)
#
@sociocracy.slash_command(name='ask_for_consent', description='Creates a view where you can ask for consent.')
@command_logging_decorator
@error_responder_decorator
async def ask_for_consent_command(
    ctx: discord.ApplicationContext,
    topic: discord.Option(str, description='What are we consenting to?', required=True),
):

    view = ConsentView()

    interaction = await ctx.respond(f'{ctx.user.mention} is looking for consent on:\n{topic}\n\n{underline("Consenting Users:")}\n\n', view=view)

    message = await interaction.original_response()

    sociocracy.votes[view.uuid] = message```
#

The button is clicked, does the "Processing" animation, edits the message, and continues said animation until it stops with the error message.

silk spire
#

You aren't responding to the interaction

#

You can edit the message with the button using interaction.response.edit_message

undone shale
#

I see, thanks!

Is there a way to get the current message content from the interaction?

#

interaction.response.content doesn't seem to exist.

sage tendon
#

why do you need that, you are building that yourself, you know what it is

undone shale
#

It'd be handy to be able to just be able to pull it

sage tendon
#

i mean interaction.original_response() but you could just save it in a var

undone shale
#

Mm, yeah, I probably will to avoid yet more async messing around. Cheers.

silk spire
#

interaction.message is the message with the button

#

original_response is the response that you're supposed to send

undone shale
#

interaction.message seems to be None for some reason

silk spire
#

It's typed as Message | None but it can never be None for a component interaction

undone shale
#
    print(interaction.message.content)
AttributeError: 'NoneType' object has no attribute 'content'```
silk spire
#

Oh you didn't say it was for a component

#

Yeah there is no message in a slash command since you're the one sending it after receiving the interaction

undone shale
#

Hmm fair, thanks

#

Okay, going back to the start:

I send a message with a view.

view = ConsentView()

interaction = await ctx.respond(f'{ctx.user.mention} is looking for consent on:\n{topic}\n\n{underline("Consenting Users:")}\n\n', view=view)```

What is the best way to get a Message object from this that corresponds to the message created by `ctx.respond`?
#

Because interaction.message is None and interaction.original_response() gives me an InteractionResponse but I can't seem to get a Message from that.

#

(I tried ctx.send but that gives me 403 permission issues)

sage tendon
#

wait, why do you want that message

#

you are just there sending it, whats the point of regrabbing it

undone shale
#

I want that message so I can edit it when someone clicks a button.

#

When someone clicks the green button, their name should be edited into the list.
When someone clicks the red button, their name should be removed from the list (if present).

#

Specifically, I want to store a reference to it for later use.

lofty parcel
undone shale
#

I mean... I can, but I still need to fundamentally edit the message?

lofty parcel
#

Then you just do

f"{self.author.mention} is looking for consent on: {self.topic}

Consenting users:
{"\n".join(self.users)}
undone shale
#

What's self here, the View?

lofty parcel
#

Yes

undone shale
#

I didn't know views could contain text tbh - I didn't see anything on the docs about it.

lofty parcel
#

You're subclassing a view...

#

It's a class after all... you can give it attributes

undone shale
#

Okay yes, but I don't know how I would add text that renders to it.

#

Because that seems like it'd require a lot of interacting with the Discord API itself.

#

(Like adding attributes is trivial, sure. But making Discord read them seems less so)

lofty parcel
#

No?

undone shale
#

Can you provide an example in that case?

lofty parcel
#

Broad example cause im on mobile but sure

#
class MyView(discord.ui.View):
     def __init__(self, author: discord.Member, topic: str, *args, **kwargs):
             super().__init__(*args,**kwargs)
    self.author = author 
    self.topic = topic
    self.consents = [] 

  async def your_some_callback(...):
          add_consent(...) # this is your own function already defined
          await interaction.response.edit_message(f"{self.author.mention} is looking for consent on: {self.topic}. Consenting users: {"\n".join(self.consents)}") # it is assumed self.consents is something iterable that will spit out mentions or the __str__ discord.Member is thats what youre storing (idk)
#

@undone shale

undone shale
#

Oh right, adding them to the interaction - I thought you meant directly making the view render text like it renders buttons.

That's a good idea, thank you.

undone shale
left crane
#

Hello, I'm a bit confused which slash_command decorator to use. I've got a simple bot that does not have prefix commands and I'm using cogs, I noticed theres discord.Cog as well as discord.ext.commands.Cog, but not sure which one would be best suited, as well as the tons of slash_command decorators. Can anyone guide me about the difference?

#

using v2.6.1 (latest)

fresh sierra
#

mostly the same for the slash commands, its just depends if you use discord.Bot, commands.Bot etc

fresh sierra
#

then @discord.command should be fine or @slashcommand etc etc

left crane
#

also I noticed in the guide it's commands.Cog but not @commands.slash_command instead @discord.slash_command

#

i think its just different decorators that work better with commands.Bot?

fresh sierra
#

let me take a look

left crane
left crane
fresh sierra
#

discord.slash_command is a shortcut of discord.command.slash_commands

left crane
errant trout
#

if you want "correct", just use discord.slash_command

#

they're all shortcuts of each other

left crane
#

also what about discord.Cog is that different to commands.Cog

#

or again just a shortcut?

errant trout
#

commands.Cog has some minor adjustments to work with prefix stuff

fresh sierra
#

bit weird to have command.ext.slash_commands tho imo

errant trout
#

ext doesn't have a slash decorator

left crane
fresh sierra
left crane
#

ok so this is just an alias then

left crane
#

alright well thanks

sinful juniper
#

hi, why does discord.Color.embed_background() not work?

embed = discord.Embed(
            title=f"Vysion Help",
            description=f"Hi, for help with various commands, we recommend that you check out our **bot documentation** or join our Discord **support server**.\n\n- Just use the buttons below.",
            color=discord.Color.embed_background()
        )
        embed.set_footer(text=footer_text, icon_url=avatar)
        await ctx.respond(embed=embed, view=Buttons())
errant trout
#

(even without nitro, users can still pick between 3 dark themes)

sinful juniper
errant trout
#

maybe? but i think it might not match any lol

sinful juniper
errant trout
#

on components V2 in the next release, Container by default doesn't show any bar so it's a better alternative

errant trout
#

it just sets the colour code to the same as the dark theme

sinful juniper
errant trout
#

no like

sinful juniper
errant trout
#

because 1) you have a different dark theme and 2) the code is outdated

sinful juniper
errant trout
#

that's not Embed :)

sinful juniper
#

V2?

errant trout
#

yep

#

in cv2, Container is a new object that works similar to Embed. colour is optional in that

sinful juniper
#

okay, lemme install the PR for test purpose

silk spire
#

@fresh sierra curious, how does pycord do command translations and is there a guide

fresh sierra
#

there is just name_localization which you can pass as a dict but that's pretty much all

silk spire
#

Aha

#

So only dpy and disnake has a whole class around it

fresh sierra
#
name_localizations={'en-GB': 'member', "fr": "membre"}
echo wraith
#

tbf I prefer the dict version

#

it's easier when I load them from a json blob

silk spire
#

Loading a file for each command in each file sounds meh

echo wraith
#

wdym

fresh sierra
silk spire
#

We can lol

#

Else they would've closed it already

silk spire
# echo wraith wdym

I assume you do with open("name", ...) as rp: json.load(rp) etc and then use the kwarg

silk spire
#

Ah you set the attrs

echo wraith
#

I don't define any metadata when creating the command

#

Yeah

silk spire
#

So basically what dpy and disnake do but then at library level

echo wraith
#

Idk I prefer having more control over my setup

#

Like for extensions

#

I just don't like the lib doing that for me

fresh sierra
#

having a native thing could be nice too

echo wraith
#

meh

fresh sierra
#

for people which dont really have time to do it by themselve

echo wraith
#

depends what you mean by native thing

#

like how deep you wanna go

fresh sierra
#

nothing deep

#

mainly like pycord-i18n, really basic

silk spire
#

Dpy literally does what you do

fresh sierra
echo wraith
#

I cant find it in the docs

fresh sierra
#

does it support chain like this ?

#

or it is a 1 depths localization so each string must be unique

fresh sierra
#

i have to say that the local_str is a pretty good idea

echo wraith
#

I see

silk spire
fresh sierra
#

because you can get lost really fast between name, parameter name, name localization

silk spire
#

Damn

fresh sierra
#

but i dont know if it would be a good idea to have that inside an internal lib

silk spire
#

But dpy does have Interaction.translate

Basically calls your translator

fresh sierra
#

so you could use that to translate even in content / emebd ?

silk spire
#

You'll need to call it yourself for each field but yeah

#

Easy helper function

fresh sierra
#

but why does make also a HybridBot class to have access to listener, list of commands get_hybrid command etcs ?

echo wraith
silk spire
#

Hybrid commands are basically prefix commands but with some handling for slash

#

Basically an implementation detail

fresh sierra
#

(even tho pycord dont have it too)

#

(but we cant even say pycord support bridge currently...)

silk spire
echo wraith
#

Bridge/hyprid/whatnot code should not implement anything slash related it should reuse the implementation

silk spire
#

I don't see why we need to bloat the lib and potentially confused with HybridBot etc

echo wraith
#

oops I wasn't looking at the keyboard

silk spire
#

lol

fresh sierra
echo wraith
#

I'm also tired i'm re-re-re-reading the cv2 pr rn

silk spire
#

At least yours is not that big of a change iirc

fresh sierra
silk spire
#

Holy shit nvm 245 commits

echo wraith
#

yeah ws about to say

fresh sierra
#

if i get it danny gonna make his own implementation ? even tho anonymous maked one ?

echo wraith
#

I mean that's average size of any v3 pr but yeah

silk spire
silk spire
#

But it'll probably have many requested changes from him

silk spire
echo wraith
#

there we go

#

Now on the emojis pr

torn barn
#

How simple and that things

echo wraith
#

hmm

#

finished reviewing the emojis pr

#

yee

silk spire
#

Ggwp nc fr

torn barn
#

I understand why

#

Also, as I said I am not an expert on that complex things on Views, but I tried

#

Meh

#

Will see if Danny supersedes it with a commit or merges the pr

silk spire
#

That would be so cheeky

#

But I doubt it

#

He doesn't have that kind of time

torn barn
#

When we creating discord.py-but-worse-but-fast-released-features-because-we-do-poor-impls-but-we-fast-and-we-want-money-like-djs

silk spire
#

Also one for pycord while we at it

torn barn
#

One for all forks

silk spire
#

or do a discord.py-plus-nextcord-plus-pycord

torn barn
#

discord.py-hikari

#

pycord.js

silk spire
#

💀

fresh sierra
#

is there any other lib that do use support hybrid command ?

silk spire
#

pycord.js but it's py

torn barn
silk spire
#

Does disnake not have an extension for it

#

Between all those other 100 extensions

torn barn
#

disnake steals impls from all possible forks

silk spire
#

Oh bruh

torn barn
#

Where did you mention me for a pr involving voice

#

On GitHub

#

Was it nextcord or disnake

fresh sierra
#

nextcord dont support hybrid too

#

curretnly only dpy support it ig

silk spire
fresh sierra
#

does the hybrid command actually work ? supporting group, subgroup etc ?

silk spire
#

Yes

#

As I said, it's basically a prefix command with a slash command

fresh sierra
#

yeah i did that too, but its not what currently in pycord

#

no i was like maybe its also a weird thing in dpy

torn barn
#

on dpy the only change you do to support hybrids is change from commands.command to commands.hybrid_command

#

plus make sure you have valid unions and valid subgroups and etc etc

silk spire
#

Pycord shouldn't have made it a separate extension lol

torn barn
#

It makes sense for it to be separate

silk spire
#

All messed up with separate options and decorators

torn barn
#

Indeed

silk spire
fresh sierra
#

im curretnly looking at it

#

either im stupid

#

either it does not make any sense

silk spire
fresh sierra
#

why do we skip attachment here ? ( only in bridge command ext context), while we dont do that for actual prefix command

    async def transform(self, ctx: Context, param: inspect.Parameter) -> Any:
        if param.annotation is Attachment:
            # skip the parameter checks for bridge attachments
            return await run_converters(ctx, AttachmentConverter, None, param)
        else:
            return await super().transform(ctx, param)
silk spire
#

Lmao

#

That's because attachments need to get from the message

#

But it should always do that for prefix commands

fresh sierra
#

like what makes the prefix commands from a bridge different from the normal one for the converter

#

because there is also a Bridge converter mapping

#

its because Option is for slash command and so if we want to use it for both we need to also be able to support it by using the decorator

echo wraith
#

Bridge should just be separateeee

fresh sierra
#

which show us a lack of support for other thing like choices, options name / descriptions etc

fresh sierra
#

that's why it is completly fucked up

fresh sierra
#

for me they should just be an addition of the ext.commands