#Basic Pycord Help

1 messages · Page 73 of 1

nocturne jewel
#

on_guild_boost?

fresh sierra
#

and check for the number of boost

nocturne jewel
wide jasper
#

is it possible to get guild data from a autocomplete func discord.AutocompleteContext?

so i can return like [role for role in ???GUILD??? if role.id in allowed_roles and role.name.startswith(ctx.value.lower())]

sage tendon
wide jasper
sage tendon
#

"didn't work" means what?

lapis dock
#

is this a guild install command or a user install command?

wide jasper
#

i got list index out of range first

#

i dont know how and why

sage tendon
#

show and we can help

wide jasper
#

print(f"[DEBUG] guild: {ctx.interaction.guild}") this is what i did now and it gives me the guild object ✅

but before i asked here i tried it already and it gave me the "list index out of range" error

#

very weird

lapis dock
#

If you can reproduce the error it might be useful for a bug report because nothing in the snipets you provided would lead to that error

wide jasper
#

i have no idea how this error is supposed to have come about... the guild attribute is not a list

wide jasper
wide jasper
sage tendon
#

make it string optionchoices and let the values be their IDs

#

that's the only real workaround

lapis dock
#

^ this would also allow users to copy paste the ID if they want

wide jasper
sage tendon
#

fix what

#

that's not an error that's a feature

#

you have to validate the input anyway, autocomplete doesn't validate anything

grizzled loom
fresh sierra
#

And not let the user add new things

grizzled loom
#

alright

sudden star
#

hello, im having problem with SlashCommandGroup. when i used the "commands.Context" on ctx im having a problem.

errant trout
lapis dock
sly karmaBOT
#

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

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

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

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

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

lapis dock
#

Master branch install ^

teal vine
#

Hi,
I have started programming again after a long time and wanted to rewrite my discord.py bots to pycord. In doing so, I have already encountered some errors that I don't know how to fix.

If I have the following function:

await bot.change_presence(
 activity=discord.Activity(type=discord.ActivityType.watching, name=f "about {server_count} server"),
 status=discord.Status.do_not_disturb)

then pycharm gives me the following error: Expected type ‘Status | None’, got ‘str’ instead

The status does not change either. Can someone help me here?

sage tendon
#

pycharm has been a little odd on the latest update

#

it detects enum values (Status is an enum) wrong when passed to (correct) arguments

#

its just a pycharm bug

teal vine
#

Oh, that's right. The fact that the status hasn't changed was down to me. Sorry about that.

sage tendon
#

i get the same with bucket types

#

its a really dumb oversight imo

teal vine
#

Okay thx. :D

sage tendon
#

oh i didnt even see it didnt work first lol

#

also you have a space after your f of the f string, dk if that breaks it

teal vine
#

WTF? Okay i will try it.

sage tendon
#

yea that breaks it, you cant have a space between the f and the "

shadow sigil
#

i expect the answer will be no, but is it at all possible for a command to have some sort of image preview or whatever based on the arguments you've put in

sage tendon
#

no

shadow sigil
#

alright

hexed herald
#

hi, is there any hosted documentation of the components-v2 branch?

hexed herald
#

alright, thank you!

brave ice
#

does py-cord[speed] already include uvloop?

sage tendon
#

install it, then install uvloop, and see if its already installed Shrug_3

sage tendon
#

wow lol i figured itd be more

lapis dock
#

I have a utils file that allowed me to create common "types" of embeds easily. Now that I am converting to components v2. I would sometimes combine an embed and a view, now I would not be able to do that

async def error(traceback: str, **kwargs) -> discord.Embed:
    e = discord.Embed(color=0xFF0000, title="Error")
    e.set_footer(text="Report This In The Support Server")
    e.add_field(inline=False, name="Error:", value=traceback)
    return e

I have 2 options:

  • Accept a view argument async def error(view, traceback: str, **kwargs) and put the given view "below" the rest
  • Make a util function to add together 2 views
    Opinions?
errant trout
#

i was kinda tempted to overload the + operator to allow you to combine view children

#

though i think with how children work the old view on the right side of the operation would lose its ability to run callbacks

lapis dock
#

that would be ideal, if the callbacks could be saved

sage tendon
#

I might be very confused what the actual topic is but I find overloading + really bad practice
it should rather be done with a function

lapis dock
silk spire
#

It's do able using setattr

#

Timeout shouldn't matter I think

#

I had written the following 3 years and afaik it did work
https://mystb.in/60dc827b98ff08e0dc
for dpy but should be the same

I was planning on releasing it as an extension hence the whole documentation and stuff

sage tendon
#

..adopt..

lapis dock
unkempt totem
#

Hello, is the version of pycord in the main branch stable? That is, if I use it in production, it won't break at some point.

sage tendon
#

the github master branch should never be considered stable

lapis dock
#

It is pretty much stable as of now though, just make sure you don't auto update on master branch

sage tendon
#

yea if you do it at all, bind to a specific commit
and even then, bugs can definitely still happen more frequently than on actual releases

echo wraith
#

In general yes, rn no

round heart
#

Three different answers. Awesome

errant trout
#

well i guess they're not wrong

  • generally speaking, master should be considered breakable at any time
  • at the current moment, to our knowledge there are no issues
  • if you do decide to use master, it's better to bind to a commit to avoid unintentional updates (and this is good practice for anything you stick in requirements.txt, version binding is cool)
fresh sierra
#

why is there no get_emoji method ?

#

is it intended ?

echo wraith
#

Idk

humble turtle
#

?tags audioop

limber wagonBOT
#

dynoInfo There are no tags that match your search.

humble turtle
#

?tags

distant owl
round heart
#

.tag audioop

sly karmaBOT
#

Pycord 2.6.1 may work with Python 3.13, but it is not officially supported and can cause various issues. Until Pycord 2.7 includes official support for Python 3.13, it is recommended to use a previous version.

For voice features in Pycord versions before 2.7, you might need to run pip install audioop-lts. Some users have reported issues with voice features when using Python 3.13, so ensure that you clear the __pycache__ and .pyc files before running your bot.

round heart
#

That one?

humble turtle
#

Yes thanks

errant trout
fresh sierra
errant trout
#

it's bot.get_emoji

echo wraith
#

All snowflakes are unique and not bound to anything else in principle

#

I think

errant trout
#

some minor exceptions but yeah

fresh sierra
#

So I can add in my pr guild.get_or_fetch(discord.GuildEmoji, id)

errant trout
#

idk they just didn't think there was a point

#

if you really want we could add it but it'd be rather useless

fresh sierra
#

So I could just add the get method also in my pr or it’s just useless

#

Ig it might be useful, I’ll see to add it inside my pr

errant trout
#

you could also literally just do bot.get_emoji(...) or await guild.fetch_emoji(...)

echo wraith
fresh sierra
#

But Bob ask for a feature for a better get or fetch

#

So I just made one using their suggestion and old commit

fresh sierra
#

well it was and then it has been removed

subtle moth
lapis dock
#

I believe the ping interaction is for bots with interaction URLs, I dont believe users have to do anything with it unless they want. It is a way for discord to know if your bot is online

subtle moth
#

when they are ran

lapis dock
#

yeah

subtle moth
#

alr thanks

hexed herald
#

hey, how do the ids in the components v2 work? are they per interaction? Like when my bot is chatting with one person and has 3 components, numerated 1,2,3 and chatting with a second person do they share the component ids or not?

hexed herald
#

okay, thank you!

wheat tiger
#

Is there any way to get emojis, only emojis uploaded to the discord bot?

wheat tiger
echo wraith
#

Yes but only on the latest git master version

#

.tag install

sly karmaBOT
#

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

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

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

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

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

echo wraith
#

The last one here

wheat tiger
#

(in master branch)?

echo wraith
fiery fable
#

do sku's have to be fetched with bot.fetch_skus()? or are they chached somewhere? because when i call bot.entitlements() the Entitlement has only the sku_id and not the name or something else

fresh sierra
#

because i think there is a lot of issue about entitlment on 2.6

fiery fable
#

2.6.1

fresh sierra
#

well i cant really help you with that, but for sure someone will

flat wind
viscid fractal
#

How to make it so that a command can be only used by a member with a particular role?

#

I've gone through the docs but I couldn't find anyhting

fresh sierra
#

or has_default permission

#

or just from discord settings

viscid fractal
#

pycord

rugged lodgeBOT
#

Here's the slash perms example.

fresh sierra
#

this is for permission

#

else you have

viscid fractal
#

oh okay

little cobalt
viscid fractal
#

i don't understand much about async def tbf

fresh sierra
#

you should first learn python

viscid fractal
#

i do

fresh sierra
#

.tag lp

sly karmaBOT
viscid fractal
#

but

#

api

little cobalt
#

def and async def is pretty much the same at the end, one is asyncio and the other is not

viscid fractal
#

oh okay

#

i know like the basics of api

#

like the basic requests.get(url) and then u get it into a json

#

is that enough

#

or should i know mroe

little cobalt
#

requests is not asyncio

viscid fractal
#

yea hwo to learn that

little cobalt
#

so it would block the whole bot

viscid fractal
#

asyncio

viscid fractal
#

i know the basics of python

#

like functions classes and stuff

#

would that suffice

lapis dock
lapis dock
#

This way you do not have to change the code or create your own permissions system

sage tendon
viscid fractal
sage tendon
#

what roles

viscid fractal
#

nono

#

like

#

uh only a perrson with certain role should be able to u se a paritcular command in the bot

#

i couldnt find that in documentation

sage tendon
#

do what wolfy said for that
you can technically do that using a check but for slash commands, the way wolfy said is much preferred

slender lantern
#

Confirming: webhooks can't reply to messages, only send new messages?

round heart
slender lantern
#

As I feared! Alas. Thanks

flat wind
red mist
#

Ok so freshly installed py-cord;

ModuleNotFoundError: No module named 'audioop'

trying to generate a template bot using;

import discord
import os # default module
from dotenv import load_dotenv

load_dotenv() # load all the variables from the env file
bot = discord.Bot()

@bot.event
async def on_ready():
    print(f"{bot.user} is ready and online!")
         
@bot.slash_command(name="hello", description="Say hello to the bot")
async def hello(ctx: discord.ApplicationContext):
    await ctx.respond("Hey!")

bot.run(os.getenv('TOKEN')) # run the bot with the token

the literal example on the guide

and it fails using the error shown in the beginning

distant owl
sage tendon
#

install audioop-lts

sage tendon
red mist
#

thanks lol

red mist
red mist
distant owl
#

audioop Deprecated since version 3.11, removed in version 3.13

red mist
#

Ah-

sage tendon
#

and Pycord still relies on it

red mist
#

oof

sage tendon
#

one more reason for 2.7

#

but at this point I legit gave up hope

#

if I need something really bad now I'll switch libraries

red mist
#

💀

#

2.7 will come though, no?

sage tendon
#

yea, but my patience is nearing its end

red mist
#

I mean it all depends on lala soooooooo

sage tendon
#

it shouldn't

fresh sierra
#

it depends mainly on the reviewer

#

if they can all review all pr and add it to the master

sage tendon
#

and who can make a pypi release?

fresh sierra
#

2.7 will come faster

fresh sierra
red mist
frail ocean
#

Is pycord already support the component stuff?

lapis dock
#

No, but it is avalable in a PR

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.

echo wraith
#

@eternal kite

#

As Luma said, you should check wether you don't have unnecessary intents.

eternal kite
#

the issue is that the memory usage starts from 100mb when i restart my bot, and it gradually increases to 1gb if i didnt restart it for a couple days, so im assuming it's the commands used by players which caused the memory usage to increase

echo wraith
#

#1316463699518816287 this may be related

eternal kite
#

and my commands doesn't store anything as well

echo wraith
#

members cache can get quite big depending on how many members there are

eternal kite
echo wraith
#

Can you run this code as used by the other member after using the bot a little and letting it run ?

import gc

        leaked_objects = [obj for obj in gc.get_objects() if isinstance(obj, discord.ui.View)]
        print(f"Leaked Views: {len(leaked_objects)}")
#

I wanna see if it is an issue with views or not.

lapis dock
errant trout
#

8000 members is pretty small to be using 1gb ram, but it is 700 servers so i suspect it's higher than that...?

eternal kite
eternal kite
#

i perform a lot of pil manipulation, could that be it?

fresh sierra
eternal kite
#

i thought it gets deleted when the function finishes running

sage tendon
#

if you open a file you have to close it unless you use a context manager which you absolutely should

frail ocean
#

Btw is there a way to get the person which triggered the / command from an other bot?

lapis dock
#

It should be in the interaction meta data

fresh sierra
#

Wait how can you know if someone trigger a slash command from another bot ?

sage tendon
#

the message has an interaction object lol

#

and its not from your bot

fresh sierra
#

didnt now that

#

good to know

lofty parcel
#

@ebon swift #app-commands

ebon swift
#

sorry >< (can't delete)

sage tendon
#

or just use the website..

#

and yes, you can delete it.

fresh sierra
sage tendon
#

like any other message

fresh sierra
sage tendon
#

yes, you can

#

oh wait you are right wtf

lapis dock
#

pretty sure you cannot, might be different for user apps

sage tendon
#

did they change it??

fresh sierra
sage tendon
#

yea it only works for user apps

#

mb

errant trout
#

they actually did briefly allow you to delete your own command responses on guild apps, but it got huge pushback and was reverted

sage tendon
#

ahh

glossy wraith
#

I’m trying to make a basic ass starboard bot, how would I check for messages in all channels for a star reaction? I’m blind and probably aren’t seeing smth lmao

glossy wraith
#

Thanks for the link to the docs :D

#

lemme get to work

lapis dock
glossy wraith
#

followed yt thing for some guidance, i fetched the message and it.. gave back nothing?

round heart
#

What comes after that..? You're putting things into variables but you don't show what you're doing with it

glossy wraith
#

im stupid sorry 😭

round heart
#

Well it looks like it at least understands that the message was starred. Are you sure the message that was starred had content? (e.g. wasn't a message with only an embed)

errant trout
#

probably don't have message_content intent

round heart
#

Ah-hah ,I always forget about intents

lean garnet
#

Hi, is there any way to check someone's tag with pycord ?

#

I'd like to unlock special features to member who are using my tag on my server

#

with a bot that can add/remove a specific role to users according to their tag

sage tendon
#

It's not in the API

#

and honestly I hope it doesnt get added

errant trout
#

I think clan related stuff was at some point? decent chance we see the new boost features on api but no guarantees

glossy wraith
sage tendon
#

you can probably somehow get it with a raw api request but no guarantees

sage tendon
#

@lean garnet

#

thats how to get the tag, there's a few more things about it if you print raw_user["clan"]

lean garnet
sage tendon
#

keep in mind it could break anytime

#

because its not documented

#

i do expect them to update the "clan" thing to something different

#

itll probably be under a different name

lean garnet
#

yeah I see, it's only for my server for now, not a public bot (or at least not yet)

#

so if it breaks it won't be a huge issue

sage tendon
#

will be None if there's no tag btw, so no need to check for none exceptions

#

or rather no attribute* whatever you know what i mean

lean garnet
#

I see, thanks

sage tendon
#

KeyError

#

thats what i meant

#

because the tag key will always exist

echo wraith
#

Is there an event for unhandeled interactions ?

sage tendon
#

wdym

echo wraith
#

like if I have a view with custom ids

#

and no persistent view registered

lapis dock
#

No, you would have to override on_interaction

glossy wraith
#

hai so thsi is probably youtube tutorial/me being a dumbass syndrome but, my app doesnt respondd when i do the slash command and select a channel, any ideas?

echo wraith
#

at the top of your function

#

await ctx.defer()

glossy wraith
#

now he thinks for eternity 😭

frail basin
glossy wraith
#

i did give it something

#

im wondering if it isnt parsing it right?

frail basin
#

Which is why its None

glossy wraith
#

lemme add it

#

it does, weird

frail basin
#

It doesnt

#

The table exists. Not the row.

glossy wraith
#

OHHH

frail basin
sage tendon
#

else you're duplicating so much code

sage tendon
#

Is there any fast way to get every emoji in a message as proper Emoji object?

errant trout
sage tendon
#

isnt this how i send multi-image embeds?

#

thx btw, worked

errant trout
#

uhhh set_image rather than thumbnail

#

but yeah, you send multiple images embeds with matching urls

sage tendon
#

oh yea i just noticed that too

#

guhh do you have the snippet for that

#

i forgot the tag / command

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

im so smart

errant trout
#

as have i uhhh

#

nice

sly karmaBOT
#

You can make multiple images appear in a single embed by matching their url attributes

first = discord.Embed(url="https://google.com", description=..., color=...)
first.set_image(url=...)
# etc. etc, do whatever you want with your first embed
second = discord.Embed(url="https://google.com")
second.set_image(url=...)  # do NOTHING else with the second embed
await ctx.send(embeds=[first, second])
```This works for up to 4 images at once.
sage tendon
#

up to 4? dangit

errant trout
#

and this was recently patched to render on mobile too

sage tendon
#

i kinda want more

#

oh well, first 4 it is

#

rarely more than 4 emojis anyway

errant trout
#

10 is allowed in mediagallery

sage tendon
#

cv2?

errant trout
#

mhm

sage tendon
#

2.7 cant come soon enough

#

im a bit dumb i forgot you can set image by url godsh

#

marvellous

eternal kite
#

also what is this new gradient role color thingy

sudden star
#

Hello everyone,

Can i have a url of documents on pycord for these components?

Thank you in advance💯❤

sly karmaBOT
# sudden star Hello everyone, Can i have a url of documents on pycord for these components? ...

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.

sudden star
#

Thank you

echo wraith
#

np lmk if anyhting else

bleak abyss
#

Is there anyway with or without pycord to remove access to users

#

Like the user installs

fresh sierra
bleak abyss
#

this

#

is there anyway to remove those 27 users

#

so they can't use it anymore

fresh sierra
#

no idea how to remove them from here, however you can just create a global check to only make ur id working

errant trout
#

you can't do that with guild apps either (the bot leaving the servers =/= deauthorizing)

#

essentially, you can't forcefully deauthorize for someone else

sage tendon
#

you can stop providing any user-app commands tho

#

so it's effectively useless

bleak abyss
#

Thanks for the answers

#

it's kinda dumb that you can't manage that

sage tendon
errant trout
#

not really

#

you can already authorise apps without adding them as bots

sage tendon
#

hm, thought they'd be able to join back or smth

errant trout
#

from a quick check kicking it does deauthorise, but if the bot isn't added as a member already then that's not possible

ebon swift
#

Hey while coding my discord bot I get moments where I want to raise errors, for example I want to see if a user has a role, if the user don't I want to raise an error, what would be the best option:

  • Use a basic python error ? ValueError etc..
  • Use a pycord discordExeception ? MissingRole etc.. (If those exist I couldn't find it in the documentation can anyone lead me to them?)
  • Make my own set of errors ? which feels a bit weird since those would look like duplicate of pycord execptions
sage tendon
#

What's the reason you wanna do that for

ebon swift
#

for better logging and overall error handling ?

#

I want my bot to be resilient to logic flaws I might have forgotten to implement and I think it's better to have error raised than printing in each function ("something wrong happened")

sage tendon
#

just check if they have a role and then respond that to them

ebon swift
#

the role missing was an example, in general if I want to raise an error in my code does pycord have a set of exceptions I can use ?

sage tendon
#

if something errors python catches it under on_application_command_error

#

pycord*

ebon swift
#

I know but what if I want to raise an error ?

sage tendon
#

why raise it if you can just handle it then and there tho

fresh sierra
ebon swift
ebon swift
sage tendon
#

i mean i just let all my errors go into on_application_command_error and handle it from there by checking against the pycord exception classes

#

that, or i handle it where it happens

#

i guess you could manually raise the pycord errors but i have no idea if thats intended

ebon swift
#

that's the kind of situation I'm in :

# I'm a cog
def do_something():
    # part to do thing before the overall implementation
    try:
        my_specific_function()
    catch discord.NotFound:
        # The error happened I can handle it cause I'm `do_something` function
    catch ????:
        # Another error happened I can handle it cause I'm `do_something` function


def _my_specific_function():
    # I do actions and interact with the discord
    user : Member|None = discord.utils.get(client.get_all_members(), name='username')
    if user is None:
        # I can handle the error cause I'm `my_specific_function`
        # I can raise an exception to be handled by the caller
        raise discord.NotFound("User not found")
    else:
        # I can do something with the user
        pass

Feels weird to relay on a non caller function and get out of the scope of my actions

sage tendon
#

my first thought would be simply returning None and handling None in the function above, ideally the command directly (just pass None all the way up ig) so you can respond to the user

errant trout
#

this is typically used in the @commands.has_role check

ebon swift
errant trout
#

not particularly

ebon swift
#

okay thank you that's all I wanted to know

errant trout
#

as long as you handle it appropriately, you can use it

ebon swift
#

thank you toothy too I revised my code to make it less tendeous to use the raising of errors

errant trout
#

that docs page also has several other exceptions and utilities like check decorators which you might find useful, so feel free to read through

ebon swift
#

can you give me the link please ? osorry I struggle to find my way in the doc ^^

sage tendon
#

yea I was also thinking about checks but I wasn't sure if it applied here mb

ebon swift
#

hooooooooooo

#

thx !

chilly spade
#

Hey! Is it possible to use chatgpt and gemini api in one bot to generate responses?

sage tendon
#

sure, why not

chilly spade
#

Oh and is there wiki about this?

sage tendon
#

no

#

openai has a python package for it, use that

chilly spade
sage tendon
#

lets you switch the API url too so you can use gemini without changes

chilly spade
#

Thanks!

sage tendon
#

i do that too actually
the only thing you need to keep in mind is to use google's openai-compatible API route, AND gemini doesn't support image input via url, you have to base64 it

chilly spade
#

ok and thanks for helping ❤️

frail basin
#

Is there any way to get bots to join guild application threads? (Even if undocumented)

fresh sierra
#

what is guild application threads?

frail basin
#

You can either approve, deny or make a thread with the applicant

#

I couldnt find anything related to that in the docs

frail basin
fresh sierra
#

oooo i understand that now

frail basin
#

You can enable applications there

fresh sierra
#

check discord.food

#

might be there

echo wraith
frail basin
echo wraith
sage tendon
sage tendon
#

why though

#

i dont think bots can be members of DM groups but why

mint isle
#

?tag git

limber wagonBOT
sage tendon
#

why

frail basin
errant trout
#

bots can technically create group dms, but it requires every participant to grant the bot the gdm.join oauth2 scope and so was never implemented in pycord

sage tendon
#

you could maybe use a user app for the last part, but only manually

echo wraith
#

When using webhook.from_url, it doesn't allow me to send views, even though it is application owned, just pycord doesn't know it. How can I get around / work w/ that ?

errant trout
#

webhook.send didn't have the view param before since they couldn't use any components before

#

(and you don't have to use cv2, you can still use v1 link buttons on webhooks)

echo wraith
#

Wait no then that doesn't work

#

Or do I need to do something more ?

errant trout
#

hmmm? i'll go test

#

working fine on my end

errant trout
shell radish
#

X

echo wraith
#

I use .from_url

#

that's the thing

errant trout
#

uhhh it shouldn't be any different

#

lemme check

echo wraith
#

Cause I store the url in my db

errant trout
#

ah

#

state

echo wraith
#

yeah

errant trout
#

ok actually fixed

humble turtle
#

how can the containers get a color

#

comp-v2

shadow sigil
#

is it not possible to use ctx.respond in on_application_command_error?

sage tendon
#

sure is possible

echo wraith
humble turtle
#

Thanks

shadow sigil
echo wraith
#

await ctx.defer()

#

at the top of the commqand causing the error

#

or at least at the top of your error handling

sage tendon
#

That error happens if you take more than 3s to respond

shadow sigil
#

well it's responding in less than 1s

sage tendon
#

well something isnt responding in time

shadow sigil
#

This interaction failed

sage tendon
#

whats the error of the command causing it

shadow sigil
#

empty message

sage tendon
#

cant you just, fix that in the command lol

shadow sigil
# echo wraith That means you shgould defer

if i put it in the on_application_command_error then it just moves the error to that line
if i put it in the command, it gets stuck thinking and also sends a message with ctx.send

sage tendon
#

it's a button, right?

shadow sigil
#

what is a button?

sage tendon
#

can you just show your command code rq

errant trout
#

This seems like it'd be easier if you just showed the- yeah

sage tendon
#

ideally you rarely ever use ctx.send

shadow sigil
#

i know what's causing the error in the command
i'm just asking if using ctx.respond in on_application_command_error isn't allowed

echo wraith
#

it is allowed

shadow sigil
#

ok apparently it works if the defer is in the command (and i actually tell it to send the error message correctly)

#

but with no defer the interaction just fails and there's no error response

sage tendon
#

i still think there might be a weird thing in your code

#

can you show it

shadow sigil
#

should i just post it here directly lol

sage tendon
#

yes, screenshot ideally if it isnt too long

shadow sigil
#

asking for a screenshot of code is probably what i least expected

sage tendon
#

Experience told me to never trust anything people send here if it isnt an actual undeniable screenshot

#

so many times they changed things "for clarity" and that ended up hiding the mistake

shadow sigil
#

that's crazy

sage tendon
#

just support server things

#

or they write it from memory (???) and obv its different than the actual thing

shadow sigil
#

tried to include whatever I thought was relevant lol

#

if you want the full code i can link you to a github repository, though it's gonna have some slight differences

sage tendon
#

does that function you call ever respond anything
because if not thats a first case where you never respond

shadow sigil
#

i can tell you that in this case that function definitely isn't called

#

but if it is called and doesn't immediately return True, then it does respond

#
async def bot_channel_warning(ctx: discord.ApplicationContext) -> bool | None:
    """Give a warning if the command is not run in a bot channel (if any exist).

    If a warning was not given, or was accepted, returns True. If declined, returns False. If timed out, returns None.
    """
    if ctx.guild_id is None:
        return True

    guild_id = str(ctx.guild_id)
    if (
        guild_id not in bot_data.bot_channels
        or len(bot_data.bot_channels[guild_id]) < 1
    ):
        return True

    channel_id = str(ctx.channel_id)
    if channel_id in bot_data.bot_channels[guild_id]:
        return True

    confirmation = BotWarningView()
    await ctx.respond(
        "❗ you are trying to use a command in a non-bot channel. are you sure?",
        view=confirmation,
        ephemeral=True,
    )
    await confirmation.wait()
    return confirmation.value
sage tendon
#

but thats the first thing you do lol

#

it has to be called

shadow sigil
#

i misspoke

#

i meant that it immediately returns true so it doesn't really change anything

sage tendon
#

alright

shadow sigil
#

the code is a bit bodged due to circumstances

#

normally the defer would happen after the function

sage tendon
#

also just a general code tip, put as little code as possible into a try block

shadow sigil
#

mmm, yeah, though this is a bit of a "if anything gives an error, just respond with an error and stop"

#

i supposed i could use try except else for that

sage tendon
#

you never respond in the command function, that makes it kinda harder to debug

#

cant immediately see the issue

shadow sigil
#

the respond is located in frg.send_message (which is at the bottom of the file i sent)

dreamy hazel
#

hi, im trying to write a discord.Option autocomplete function. i am returning exactly 1 value in the form of List[str], but discord is saying that no option matches. any idea why? i can send over my code, but nothing is hardcoded so it wont make sense i suppose

#

im using autocomplete=discord.utils.basic_autocomplete(func), could that be causing the issue?

#

also i should clarify, when i return all the possible options (for example when nothing is typed in), it works just fine and shows all of them

dreamy hazel
# errant trout Can you show `func`
    @staticmethod
    def rank_level_autocomplete(ctx: discord.AutocompleteContext):
        rank_levels = ranking_data["rank_levels"]
        if ctx.value in rank_levels.values():
            return [rank_name for rank_name, rank_value in rank_levels.items() if rank_value == ctx.value]
        return rank_levels.keys()

rank_levels is in the form of {"text1": "1", "text2": "2", ...}

errant trout
#

eh

dreamy hazel
#

static method because its in the cog class

errant trout
#

it's in a separate class from your command?

dreamy hazel
#

no no, same class

errant trout
#

then you don't need it

dreamy hazel
#

dont need what?

errant trout
#

just do autocomplete=rank_level_autocomplete and add the self param back, remove staticmethod

#

(maybe you can keep it as staticmethod but i can't remember; regardless, it's not required)

#

also it should ideally be async

dreamy hazel
#
async def rank_level_autocomplete(self, ctx: discord.AutocompleteContext):
    ...
``` like so, yeah?
errant trout
#

uhh i guess you can do it either way

#

docs claim it can be both

dreamy hazel
#

nice it works, thanks

errant trout
#

allgood

shadow sigil
#

is there a point to raising an error in on_application_command_error if it's being logged

sage tendon
#

why raise an error if you're already in an error handler tho

shadow sigil
#

idk i just remember reading that somewhere

lofty parcel
#

You could log the traceback

#

I used it to raise it again tho for it to stay in the console

#

And using the error handler just to inform the user

#

Whatever fits your needs, really

ebon swift
#

I'm trying to check if a user joins a voice channel, for a test I used this listener:

        @commands.Cog.listener()
        async def on_voice_state_update(
                self,
                member: Member,
                before: discord.VoiceState,
                after: discord.VoiceState,
        ):
            log.info(f"Voice state updated for {member.name} before: {before} after: {after}")

the listener isn't called when I join any voice channel, I don't see my log . Am I missing something is there any requirement for it to work ? any intent that is mandatory to check on voice channels ?

echo wraith
#

I'm not certain

ebon swift
#

I'll try it

#

doesn't work :/

#

doesn't feel like an intent issue because when give all intents it still doesn't work

#

I added another listener _ontyping() to test if the listeners wher loaded and this last one works only the on_voice_state_update() doesn't

echo wraith
#

I'll take a look

#

If you find the fix in the meantime, please ping me

ebon swift
#

I'll do if I find it !

echo wraith
# ebon swift I'll do if I find it !

I was not able to reproduce your issue with the following code:

import logging
import os

from dotenv import load_dotenv

import discord

load_dotenv()

logging.basicConfig(level=logging.DEBUG)

TOKEN = os.getenv("TOKEN_2")

intents = discord.Intents.default()

bot = discord.Bot(intents=intents)

@bot.listen()
async def on_voice_state_update(
        member: discord.Member,
        before: discord.VoiceState,
        after: discord.VoiceState,
):
    print(f"Voice state updated for {member.name} before: {before} after: {after}")

if __name__ == "__main__":
    bot.run(TOKEN)

Can you try and tell me if that still doesn't work for you ?

ebon swift
#

@echo wraith found it ! I had an identation issue !

echo wraith
#

Alright

ebon swift
#

sorry for the disturbing

echo wraith
#

np lmk if there's anything else

ebon swift
#

I'll do !

eternal kite
#

so i currently have a on_application_command_error event to handle errors, is it possible to let it show a full traceback instead of just the exception?

errant trout
echo wraith
#

Sentry

eternal kite
errant trout
#

uhhh it normally does that yeah

#

you don't need to do anything special

sudden star
#

how can i make the role option as list, so i can add multiple role?

@ticket.command(name="setup", description="Create a report ticket system")
    @IsAdmin()
    @option(name="role", description="Role that can access the ticket", required=True, type=discord.Role)
    @option(name="category", description="Category where the ticket will be created", required=True, type=discord.CategoryChannel)
    async def ticket_setup(self, ctx: discord.ApplicationContext, role: discord.Role, category: discord.CategoryChannel):
    ....
lapis dock
#

You could use a select menu instead

#

After sending the command

chrome plover
#

Can there can be defaults in select type for things such as default userselect?

silk spire
#

Yes

#

Oh apparently pycord doesn't support it

#

#discussion message

chrome plover
#

Alright

lapis dock
#

When using Webhook.from_url can I use an existing session from the bot or am I required to create my own? Also is there a better way for a bot to manage a webhook other the saving and loading from url?

errant trout
#

(class vars that start with __ are considered truly private, but can still be bypassed by using that notation)

#

that's also how the library handles webhooks in stuff like channel.webhooks so there's nothing really wrong with it py def from_state(cls, data, state) -> Webhook: http = state.http session = http._HTTPClient__session proxy_auth = http.proxy_auth proxy = http.proxy return cls( data, session=session, state=state, proxy_auth=proxy_auth, proxy=proxy, token=state.http.token, )

lapis dock
#

👍
Also answered the second half of my questions. Bot.fetch_webhook exists

errant trout
#

yeah if you have the ID

#

if you don't want to fetch for whatever reason then from_url is perfectly fine too

lapis dock
#

I am setting up error logging to a discord channel

errant trout
#

ahh fair

lapis dock
#

so it is only 1

valid panther
#

Good afternoon, I'm trying to review the topic of new features. To be able to use command messages in private chats with other people. How do I manage it?

valid panther
rugged lodgeBOT
#

Here's the slash users example.

echo wraith
#

@valid panther ⬆️

valid panther
sage tendon
#

2.6, i think

valid panther
sage tendon
#

jesus what

valid panther
sage tendon
#

isnt that like 2 years old at this point

fresh sierra
#

i mean 0.2 thing is not that much generally

sage tendon
#

luma, we are talking about pycord

fresh sierra
#

but in pycord its like 0.1 every years

sage tendon
#

where minor versions have breaking changes (?????)

fresh sierra
fresh sierra
#

pycord 3.0 before 2.7 ;)

valid panther
#

2.4.1v rooMonkaS

#

Do you recommend me to do the version jump?

sage tendon
#

do you just not update your packages

sage tendon
fresh sierra
#

i dont think you will have to change a lot of thing

lapis dock
#

What you want is not possible until 2.6 so yeah

fresh sierra
#

i mean if you want you can wait for 2.7 before updating but we dont know when it will be released

valid panther
#

When was 2.6?

sage tendon
#

half a year ago?

#

or so

lapis dock
#

I think last june July 9th, 2.6.1 was september

sage tendon
#

yep

#

so almost a year ago

#

2.4 released in february 2023 jfc

fresh sierra
#

gta 6 before 2.7

#

2.4 : — 12/02/2023
2.5: — 02/03/2024
2.6: — 10/07/2024

valid panther
#

If I make the version jump to 2.6, the change to 2.7 should be minimal

sage tendon
#

man if pycord respected semver you wouldnt need to worry about having to make ANY changes

valid panther
#

How fast time flies

lapis dock
#

I dont think there are any breaking changes in 2.7 other than dropping support for python 3.8

sage tendon
#

2.6, bridge tho

#

bridge options

#

but atp i have no idea who still uses prefix commands

lapis dock
#

Bridge is so broken that breaking changes dont make the code more broken

sage tendon
#

actually 2.5 was breaking too

little cobalt
sage tendon
#

that wouldnt happen

#

"what if one of the major features of the platform just didnt work for a long time" is not something that happens lol

fresh sierra
sage tendon
#

this is just bs

#

if there was even a hint of caring about semver we'd be at like 4.0 minimum

fresh sierra
#

when possible ;)

sage tendon
#

thats not something you can do "when possible"

#

either you respect semver or you don't.

#

and pycord does not

fresh sierra
sage tendon
#

did you ever read semver?

fresh sierra
sage tendon
#

pycord specifically breaks semver exclusively when it comes to the public api

fresh sierra
#

The first thing to keep in mind is that breaking changes only apply to publicly documented functions and classes.

sage tendon
#

no shit

fresh sierra
#

that's why i wrote : however its not respected in my message ;)

sage tendon
#

you can still break semver for the backend code

#

marking patch changes as minor versions for example, or minor changes as patch

#

not breaking changes, but breaking semver

fresh sierra
#

well i dont really care about those thing as long that i have a library that is working, so im just waiting for 2.7 even tho it doesnt respect semver

#

i just want finally a stable release

sage tendon
#

checks first unreleased 2.7 change > breaking

#

YIPPIE

echo wraith
#

Its just 3.8 eol

sage tendon
#

actually seems so

nocturne jewel
#
raw = await bot.http.get_user(member.id)```

Any info about ratelimits?
sage tendon
#

dont do it unless necessary

#

not sure about the ratelimit of fetching users but just avoid it

echo wraith
errant trout
#

everything done through bot.http is ratelimited

nocturne jewel
errant trout
#

(or rather has built-in handling of ratelimits)

#

then eh sure why not

nocturne jewel
#
        "clan": {
            "identity_guild_id": "1044698006395555960",
            "identity_enabled": true,
            "tag": "STAR",
            "badge": "66dd35e973cf6054f84b0edd73ac2b02"
        },
        "primary_guild": {
            "identity_guild_id": "1044698006395555960",
            "identity_enabled": true,
            "tag": "STAR",
            "badge": "66dd35e973cf6054f84b0edd73ac2b02"
        },```
#

whats the difference lol

sage tendon
#

the top one will go eventually

lapis dock
#

The second is also still technically in beta

south radish
#

is there an attribute for hybrid command in pycord (I know nothing but I have made small bots by using deepseek to write my code 😅😅)

#

currently my bot responds to prefix cmds but I want to make it such that I can use slash cmds as well

#

can anyone help?

lapis dock
#

Additionally I recommend not using AI for discord bots

south radish
lapis dock
#

Generally AI is not aware of the newest features that discord has. In addition much of the training material is poor quality (many online discord bot tutorials are terrible). There are also multiple python discord libraries and the AI can get them confused. And if you use AI you dont learn as quickly and it will take you longer to debug issues as you dont fully understand the code.

south radish
#

till now all I've made is to troll my friends

round heart
#

Damn. Is there any way to reference an autocomplete from a different cog (or different class at all) in my command def?

Can't use autocomplete=self.target_cog.my_autocomplete because I can't use self.

round heart
#

CogClass is not defined

#

Even though I am importing it

fresh sierra
round heart
#

Yes, I am aware 🙂 I'm just saying it throws errors about not being defined.

#

from mycog import MyCog

fresh sierra
round heart
#

Which is doubly weird because it doesn't seem to error in my TYPE_CHECKING block. But when I place it outside of that, it whines

fresh sierra
#

because it might be possible that you dont really import the good thing from the file

#

make sure to put the full path or .__setup__ (if in the same folder)

#

the setup is my file name

round heart
#
bot
  - main.py
  \ commands
    - treasury.py (class Treasury)
    - developer.py (class Developer)
    ...

From my treasury.py, I'm trying to from developer import Develooper

Again, works fine in TYPE_CHECKING for doing IDE stuff, but complains at runtime when outside of it

fresh sierra
fresh sierra
#

with a .

round heart
#

Okay, from commands.developer import Developer works.

fresh sierra
round heart
#

Well the IDE whined about it not being a package, so I didn't try

fresh sierra
#

the . do the import from the current folder

round heart
#

Yeah I know. Just don't want to see any squiggles right now 😅

fresh sierra
#

be careful because sometime the ide show an import somewhere but during runtime it import it from somewhere else

#

had this issue with commands.cog that was coming from lumabot.commands even tho i never import commands from lumabot

wheat tiger
#

@sage tendon

#

References: #general message

sage tendon
#

okay first of all why do you do exit() lol

#

do you want your entire bot to shut down if that's none

wheat tiger
#

that's why I asked in general

#

bcz python nerds out here

sage tendon
#

ah

#

I mean you can just ignore it, VSC isn't the smartest with code analysis

fresh sierra
#

and if possible can you share us ur class definition ?

torn barn
#

If you use a exit then add a return below it , it should fix it

wheat tiger
fresh sierra
# wheat tiger

as anonymous said, maybe the exit() is not considered as a return

wheat tiger
fresh sierra
#

or a isistance str

#

or just put a # type ignore if nothing is slved

frail basin
wheat tiger
frail basin
#

works for me ¯_(ツ)_/¯

fresh sierra
#

will it be possible to include this in pycord ? instead of having to use the decorator or Option

async def test(self, ctx: LumabotContext, test: ["test1", "test2"]):
frail basin
#

if you add / remove from test, it will persist across function calls

fresh sierra
#

this would just be for passing directly inside the function def the list so i dont have to use the decorator to add choices = [test1, test2]

frail basin
frail basin
#

This is probably what you want:

import typing as t

async def test(self, ctx: discord.ApplicationContext, test: t.Literal["test1", "test2"]):
    ...

But even this isnt ideal, if you pass different types of objects into the Literal

fresh sierra
#

But will that work in pucord v

#

Like display it as choice ?

frail basin
#

I highly doubt this is currently implemented if thats what you are asking

torn barn
#

It should be already implemented ?

frail basin
#

Are you sure? I doubt it.

#

I've never seen anyone using that syntax before.

torn barn
#

But it should be

fresh sierra
frail basin
sage tendon
#

people really are allergic against easy-as-fuck tools given by the library

#

especially luma

fresh sierra
#
  • as anonymous said it should already be part of it
sage tendon
#

its nearing abusing typehints / defaults

fresh sierra
#

so im technically just using proper python type hint

fresh sierra
fresh sierra
#

i might do a pr for that

sage tendon
#

this syntax should be preserved for actually setting defaults, not feeding into your urge to bend pycord to your needs

fresh sierra
#

if maintainer think that it should not be add they will be free to let me know

sage tendon
#

why break existing python syntax just for the sake of .. zero gain at all

fresh sierra
#

if as anonymous and me they think this should be implemented then it will be implemented

sage tendon
#

is it THAT hard to use options, which you should anyway for descriptions and stuff?

fresh sierra
#

man pls just leave me alone

#

u have just been yapping for the last month and i cannot really stand that anymore

sage tendon
#

no you are literally just trying to bend the library to your very specific needs, constantly

sage tendon
#

good luck

#

just make a fork man

#

you have so many specific and weird wants and needs

#

literally fork it and you can do whatever you want

fresh sierra
torn barn
#

Using literal annotations would make sense for pycord to use choices by default to that

#

But not doing something like opt: str = ['smth']

fresh sierra
#

like im setting a dict as default value

torn barn
#

Nah worse

#

Wait

#

Like

#

Dict for default and annotating as str

#

Or

frail basin
#

I even sent you an example why not to

fresh sierra
frail basin
#

That applies to every reference type object

fresh sierra
#

yeah, idk why i wrote that because that does not make any sense

fresh sierra
#

(in case credit is not english i meant shoutout)

frail basin
silk spire
#

poor luma just trying to improve the lib for everyone

sage tendon
#

Its just bad design imo
Plus, you kinda have to use the decorator if you wanna use a description, or anything else

#

like even setting options via typehints at all is not good practice imo

errant trout
#

The general direction of the library is to be more explicit in how users interface with discord, not less

fresh sierra
tidal pecan
# fresh sierra no worries, i'll continue to use @discord.option then

You know that you're not required to use @discord.option just to present a fill-innable field when users type their slash-command, right?

The whole deal is that Py-Cord devs are not to blame: Discord's API exchanges JSON-encoded objects as (I think) UTF-8 encoded text with "Gateway" bots over Websocket connections. Py-Cord just translates the incoming JSON into runtime events with typed parameters, then translates outgoing function outputs back into JSON for transmission. So the difference between setting up an event-handler (or command-handler, call it whatever you want) with @discord.option versus just plain old input parameters is that @discord.option instructs the Py-Cord framework how to format the JSON object which represents that parameter when it transmits its command definition to Discord's API.

Your typehints in Python are useful to things with IntelliSense, like Visual Studio and PyCharm. Those type hints are only relevant to you as a programmer... even Python itself doesn't really care what data type you put in, and Discord will only give you or accept in return some kind of text-encoded string. Trying to scan those comments and thereby invent documentation comments for the Discord API would be a bit like giving everybody who buys a car the Hayne's Manual which contains all the schematics for every moving part in the vehicle.

fresh sierra
#

im not blaming anyone, i was wondering if this could be a thing

tidal pecan
#

Sure, I get it. I was just trying to expand on the explanation already given, because all Toothy really said is that they probably won't do it. I think I have a pretty good idea as to why they won't.

fresh sierra
#

im only using decorator for list, so i was looking if there was a way to just not use it

fresh sierra
echo wraith
#

You can always use annotated to

fresh sierra
#

and it was logical in a way for me to continue to use typehint since we can already do everything with typehint expect choice/autocomplete

fresh sierra
echo wraith
#

typing.Annotated

sage tendon
#

and idk why you explain it in such an overcomplicated way lol

fresh sierra
sage tendon
#

and discord.option doesnt set up an event handler or command handler or anything

#

what you are saying is literally not true

sage tendon
#

you literally said exactly that, almost word by word

tidal pecan
sage tendon
#

you love using big sentences to explain stuff lol

tidal pecan
sage tendon
#

its really not as complicated as you make it

#

pycord literally just builds the options from whatever it gets, there isn't really a difference if you dont use @discord.option or if you do use it, apart from it giving you a way to actually pass option descriptions (etc)

tidal pecan
sage tendon
#

in about 500 words

tidal pecan
sage tendon
#

what you're doing isnt helping, its throwing around big words for braggings sake

#

and if you have been here even once youd knew luma knows the library enough to not need it explained to him like that

fresh sierra
#

he had a valid point

#

what he said was the typehint should only be for me

#

and nothing related to library

sage tendon
#

there was no point in all his 1000 words

fresh sierra
#

i dont understand why you have to be that mean with people

sage tendon
#

its just "heres many cool words i learnt used in semi-correct ways"

fresh sierra
#

and there is no point of you just being mean for no reason

#

just chill out

sage tendon
#

its literally just showing off, while being partly wrong

#

im not being mean, im sick of people acting like fucking smartasses like that

fresh sierra
#

well @tidal pecan thanks for your explanation, it was greatly appreciate

sage tendon
#

the explanation was literally wrong

#

because pycord literally DOES use the typehints

#

if you do intoption: int it will be an int option inside the discord UI

#

so many words just to be fatally wrong

fresh sierra
#

it does but i should not execpt pycord to use them since as he said its mainly for ide etc

tidal pecan
sage tendon
#

thats what ive been saying all this time lol
the typehint methods (both!) to define command options are just bad practice

fresh sierra
#

and that's true, in fact typehint are for documentation and more readable code

sage tendon
#

oh well they left anyway, good riddance

fresh sierra
sage tendon
#

luma typehints work to define option types

#

or do you specicially mean the literal thingy to define optionchoices

fresh sierra
sage tendon
#

the explanation was just wrong

#

but who cares about facts anymore

#

just use like 500 words to explain a very basic concept and call everyone correcting it mean

tidal pecan
round heart
sage tendon
#

its not discovery, its just showing off and spreading false info

#

if you dont meet that with the appropriate response they will never stop

fresh sierra
sage tendon
#

and if luma actually was a beginner in need of help, that overinflated "explanation" would not help at all

fresh sierra
round heart
sage tendon
#

im fine defi dw

round heart
#

That part is actually true. Pycord relies on typing in Options (and other places I’m sure)

sage tendon
#

yea, hence why im so mad their entire explanation ultimately went to the wrong conclusion

round heart
#

Well, let them figure it out.

sage tendon
#

cant if they block anyone showing em 😂

echo wraith
#

cat /etc/passwd

fresh sierra
#

the thing he tried to explain me what more general (2nd part)

round heart
fresh sierra
echo wraith
sage tendon
#

its immature to use this stupid way of "explanation" just to throw around big words

tidal pecan
round heart
# echo wraith cat /etc/passwd

Actually I saw something where someone getting a canned AI response on LinkedIn tricked the agent into sending the user’s ssh key

tidal pecan
#

Hold ALT and press F4 repeatedly to gain instant Admin powers on any Discord server.

sage tendon
#

or what

fresh sierra
sage tendon
#

huh isnt the library pretty much typed across the board

#

at the very least public bits

fresh sierra
echo wraith
sage tendon
#

i dont think i ever came across anything i used that wasnt typed properly

#

show an example

tidal pecan
round heart
#

Q

fresh sierra
#

it was supposed to "fix" my mic

sage tendon
#

wow

sage tendon
#

hm
i think its prolly because its a decorator

echo wraith
#

That dosn't mean it shouldn't be typed

sage tendon
#

yea

valid panther
#

can I make the “default_member_permissions” in the SlashCommandGroup?

sage tendon
#

sub commands can't have their own default permissions, it has to be passed to the group

#

the other two can stay

valid panther
#

oki doki

#

regarding the “has_permissions” decorator can be done in the SlashCommandGroup object?

sage tendon
#

well, you only need the has_permissions check if you want enforce it in every case
server owners can change the default permissions in the server settings

sage tendon
errant trout
#

example from slash_cog_groups py secret_greetings = SlashCommandGroup( "secret_greetings", "Secret greetings", checks=[ commands.is_owner().predicate ], # Ensures the owner_id user can access this group, and no one else )basically any function that returns a bool

sage tendon
#

oh yea I forgor

tidal pecan
#

Is there a separate channel/forum for general bot-dev questions? I'm using Py-Cord to build the bot, but that's not what my question is really about.

errant trout
#

you can ask in this forum anyway

nocturne jewel
#

discord don't generate previews of images, anyone aware of this?

tidal pecan
lapis dock
#

How would I implement a global error handler for the entire bot? When an error occurs in a button callback it does not seem to trigger on_error. I thought it would as it is an error in the interaction event

#

I guess it is possible that I am overridding it wrong though

#
class SurveyWolf(discord.Bot, ABC):
  async def on_error(self, event_method: str, *args: Any, **kwargs: Any) -> None:
    ...
frail basin
#

I subclassed the view and added the error handler to it

sage tendon
#

im p sure you just do @bot.event no?

#

i think overriding the entire function breaks everything

errant trout
#

no, on_error is a standard Client function rather than event

#

on_error triggers on events, but because view callbacks call their own on_error it sidesteps Client.on_error

lapis dock
#

Ah ok

errant trout
#

honestly

#

we could just PR on_view_error as a new event or something

lapis dock
#

I will make an feature request issue for now 👍

silk spire
#

That would be a really neat addition for everyone really

errant trout
#

in the meantime either just edit view.py or subclass view to have the default on_error call client.on_error or so

echo wraith
#

I did some monkey patching for it to work

errant trout
#

Client.on_error sucks because it doesn't even have an arg for the exception

silk spire
#

typ, error, trackback = sys.exc_info()? lol

errant trout
#

yeah but it doesn't match the other error handlers that explicitly pass the exception

silk spire
#

True

ebon swift
#

hey all ! I was wondering, what's the best way to add a has_role() over all a cog ? I know I could just add @has_role() to each of my commands. but I feel like this open the way to forgetting to add it and have some misuse of certain commands. (I was maybe thinking checks but I don't thinks they adapt well with decorators or the function under the @has_role decorator)

sage tendon
#

make your own version of the slashcommand decorator that adds it to every command its used on

lapis dock
sage tendon
#

oh thats useful

lapis dock
#

Cogs have a lot of stuff that is rarely used

ebon swift
#

thank u

silk spire
#

Is it commands.has_role for slash too?

#

If so, you can call the built check manually in cog_check too:

has_role = await commands.has_role(xxx).predicate(ctx)
#

Oh there are no lib checks for slash

sage tendon
#

because ideally those are handled in discords ui

errant trout
#

they just don't apply on discord's end

errant trout
#

refactored ctx.command -> interaction.command, added interaction.view and interaction.modal, new events on_view_error and on_modal_error; these are called by default if you did not define View.on_error and Modal.on_error

lapis dock
#

Thanks :)

ivory beacon
#

Does anyone know the rate limit for the fetch_invite() function or its underlying endpoint?
Specifically, how many invite links can be checked within a certain time frame?

haughty grove
#

why does discord do this? im using member.mention in the join event and sometimes (especially on mobile client) it shows the mention as unknown member, even tho they didnt even leave

sage tendon
#

client issue

#

unless its in an embed

haughty grove
#

so nothing i can do about it?

#

its a normal message

sage tendon
#

yea then no

errant trout
#

discord explicitly changed the client to stop rendering users you don't have cached

sage tendon
#

wait doesn't it fetch them on mention?

errant trout
#

no

sage tendon
#

but it used to do that right

errant trout
#

i thinkkkkkkk so but i can't remember

#

never worked in embeds, worked in normal text until a couple months back

sage tendon
#

yea that's why I duplicate my embed mentions in the message body

#

ugh

lapis dock
fresh sierra
#

Also sometime on re-edit you can find some info

ivory beacon
#

even tho i was using 0.5s delay

fresh sierra
lapis dock
#

Bulk anything is going to get you ratelimited

fresh sierra
#

So after that you know what number/tome you can use

fresh sierra
#

When it’s from cloudfare

ivory beacon
fresh sierra
#

There is also by bot, guild, etc

#

Also if ur checking ur guilds invite etc you could use guild.invites, might be better

sage tendon
ivory beacon
fresh sierra
#

Guild where ur bot is not in ?

ivory beacon
# fresh sierra But from where are you getting them ?

I run a bot called Dank Alert, which acts as a Dank Memer assistant. I use Dank Memer's Discovery API to fetch and store all server invite links. Recently, I added a feature that checks whether those stored invite links are still valid or have expired

#

I've saved 3.3k+ invite links on production

fresh sierra
#

I’ll try to think about it

ivory beacon
ivory beacon
ivory beacon
sage tendon
#

and why do you save them

sage tendon
#

no, thats not the reason they save them in the first place

#

thats the reason they fetch the invite from discord after saving them