#Basic Pycord Help

1 messages · Page 74 of 1

fresh sierra
#

they need to save them to display them on the website or for user to join those discovery server and fish for limited time rare fish

sage tendon
#

hm

fresh sierra
#

@ivory beacon what is ur message for the rate limit ?

#

is it a global rate limit or a rate limit under the bucket ...

ivory beacon
#

cz everything is working fine, without the fetch invite thing

fresh sierra
sage tendon
#

cant you just occasionally refetch the data, and trust all invites in there to be active, at least at the time of getting new data from the API

ivory beacon
#

so, user can filter expired invite links

fresh sierra
#

gonna rate limit myself to find the limit

ivory beacon
fresh sierra
ivory beacon
sage tendon
fresh sierra
#

do you have logging enabled ?

ivory beacon
ivory beacon
fresh sierra
#

because you can only do 50 request in 10s

#

i'll check

ivory beacon
#

got unbanned

fresh sierra
#

.tag logging

sly karmaBOT
fresh sierra
#

in case this can help

ivory beacon
fresh sierra
ivory beacon
#

@fresh sierra which logging level should i use btw ?

fresh sierra
fresh sierra
# ivory beacon oke

just did a 1000 requests to the endpoint without no rate limit thats strange

sage tendon
#

💀

fresh sierra
#

seems that maybe if i use the same url it get cached or smth like that

sage tendon
#

just random gen it

#

like randomly generate the invite code and try

fresh sierra
#
@bot.event
async def on_ready():
    for i in range(10000):
        await bot.fetch_invite("pycord")

#

because no rate limit wiht that

sage tendon
#

10000 bro what

#

dude wants to be forever banned from the discord api

fresh sierra
#

well i didnt get any rate limit yet

#

it used to be faster

ivory beacon
#

let me use my spamming tool on replit

fresh sierra
#
def random_invite_code(length=6):
    return "".join(random.choices(string.ascii_letters + string.digits, k=length))


@bot.event
async def on_ready():
    print(f"Logged in as {bot.user}")
    for i in range(10000):
        try:
            await bot.fetch_invite(random_invite_code())
        except discord.NotFound:
            pass
        print(f"[{i+1}] ✅ Success")
#

but still not rate limit

#

well

#

now im banned

sage tendon
#

pff

fresh sierra
#

so yeah its a global one

#

<title>Access denied | discord.com used Cloudflare to restrict access</title>

sage tendon
#

damn you were cloudflare blocked

#

thats not even a discord ratelimit

fresh sierra
#

you should just make sure that you dont do more than 50requests per second

fresh sierra
sage tendon
fresh sierra
#

but the thing is 0.5 between each for this might be ok, but since he got other thing on that ip that also do requests it leads to issue

#

so make sure ur ip doesnt do more than 50 requests per second else cloudfare ban

ivory beacon
#

btw the bot running on a Pterodactyl panel

fresh sierra
ivory beacon
#

and I'm chilling

fresh sierra
#
IP addresses that make too many invalid HTTP requests are automatically and temporarily restricted from accessing the Discord API. Currently, this limit is 10,000 per 10 minutes. An invalid request is one that results in 401, 403, or 429 statuses.
errant trout
#

no one's hitting 50 per second unless their bot is exceedingly active, i wouldn't worry

fresh sierra
#

well he got rate limit under fetch_invite, so strange

#

how many bot do you have under the same ip d1p

ivory beacon
#

so idk about that

errant trout
#

is it paid at least

fresh sierra
ivory beacon
#

premium node

fresh sierra
#

its not only for u ?

ivory beacon
fresh sierra
#

if 1 person get rate limit then everyone will be

ivory beacon
#

but the thing is i got rate limited only for invites endpoint

fresh sierra
#

Except if you have ur own ip

ivory beacon
#

i am going to load test ngl

ivory beacon
fresh sierra
#

cos i just did the test

#

and i didnt get any rate limit from discord

#

maybe you can just buy an ip, this should solve the issue of rate limit

errant trout
#

it's irrelevant if the rest of their bot wasn't affected

fresh sierra
#

it was from what i understood

fresh sierra
ivory beacon
ivory beacon
fresh sierra
#

thats mb then, i misunderstood

ivory beacon
#

0.5 delay

errant trout
#

as long as you've set up logging you'll get proper warnings on the ratelimit

ivory beacon
#

ig 45 requests per minute

fresh sierra
#

maybe

fresh sierra
#

is it also new invite code ?

ivory beacon
ivory beacon
fresh sierra
ivory beacon
fresh sierra
#

because i think it will not make again the request for the same invite code

errant trout
#

there's a decent chance the ratelimit is different authenticated vs unauthenticated

#

or did you pass the token and such in

errant trout
#

try your test with the Authorization header set to f"Bot {token}"

ivory beacon
fresh sierra
#

and also generate new invite code each time, when its with the same it does not change

ivory beacon
errant trout
#

you can't post to that endpoint, creating invite is under channels

ivory beacon
#

oke

fresh sierra
ivory beacon
errant trout
#

ic

#

well as long as the delay is sensible

ivory beacon
fresh sierra
#

yeah i think there is just no bucket and its global

ivory beacon
#

i think we should move on, that's a major issue 🥳

fresh sierra
#

let me just get rate limit 1 more time

#

so i can find the limit

ivory beacon
#

got rate limited 💔

fresh sierra
#

so using the same invite i dont get rate limit

ivory beacon
#

i was spamming the endpoint 🤣

fresh sierra
#

and when using different one i get rate limit at
[250] ✅ Success | Elapsed: 77.15s

#

so yeah after 250 requests in 77.15s the bot is not happy

ivory beacon
#

noted

#

pretty weird rate limit 🙂

frail basin
#

Are there plans for a View.from_dict() function for components V2? (Or something similar to Embed.from_dict())

#

I want to load components dynamically from a JSON file

errant trout
#

mayb

silk spire
#

Isn't there View.from_components

#

Nope

frail basin
#

Thanks.

#

How do the callbacks work exactly? (If I supply a custom_id in the json)

errant trout
#

well it's not like you can assign a callback like that

#

hack around it GuraShrug

valid panther
#

Good afternoon, I'm making the version jump from 2.4.1 to 2.6.1. I've mainly seen changes in the groupSlash, but do you recommend that I check out something special?

sage tendon
#

only thing I know of is bridge changes

#

if you don't use bridge just update and see if everything works still

dreamy hazel
#

how can you specify the name and description of a command in a slashcommandgroup?

#
 foo = discord.SlashCommandGroup("bar", "baz")  # works
 @foo.command(...)
``` like this i mean
echo wraith
#

just add name =

#

and description =

dreamy hazel
#

oops yeah i forgot to put guild ids

#

so it worked but it didnt update instantly

#

my bad

#

thx

dreamy hazel
dreamy hazel
#

alright awesome thats all thanks

lapis dock
#

Note: that subcommands cannot have different guild_ids, defualt_member_permissions, etc. Discord limitation

ebon swift
#

Hello, I'm making my own discord.Bot class and I want my discord server to be an attribute of it how can I do it at init ? should I play with the discord.Client object ?

class MyBot(commands.Bot):
  def __init__(self, *args, **kwargs):
          log.debug("MyBot is starting up...")
          super().__init__(*args, **kwargs)
          self.main_guild: Guild = #??????????????
          self.database = Database(str(settings.postgres_url))
          log.info("Successfully connected to the database")
          log.info("Loading cogs...")
          self._load_cogs() # function to load my cogs
little cobalt
#

and why discord.Client if you already use discord.Bot?

ebon swift
# little cobalt Why?

That's an example of a cog using what I'm trying to achieve but on init I need my bot to have main_guild setup:

class Special(commands.Cog):
  def __init__(self, bot: MyBot):
          self.bot = bot
          self.role_special: Role = bot.main_guild.get_role(settings.special_role.id)

      @commands.Cog.listener()
      async def on_member_update(self, before: Member, after: Member):
          if self.role_special not in before.roles and self.role_special in after.roles:
              log.info(f"{after.display_name} was given the special role")
              await self._add(after.guild, after)
          elif self.role_special in before.roles and self.role_special not in after.roles:
              log.info(f"{after.display_name} was removed from the special role")
              await self._remove(after.guild, after)

def setup(bot):
    bot.add_cog(Special(bot))
little cobalt
#

Uhm, first what is "MyBot"?

ebon swift
little cobalt
#

So you imported your bot from a another file?

ebon swift
#

I'll add details so you understand better

#

is it better now ?

#

It's a cog for my bot (at least an exmaple to not paste all the code ^^")

errant trout
ebon swift
errant trout
#

allgood

ebon swift
#

sadly it doesn't work

#

it seems that when the cog is loaded the get_guild returns none 😦

little cobalt
#

well yea, because its using get_x

#

.tag get_x

sly karmaBOT
#

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.

little cobalt
#

"When you restart your bot the cache will be empty"

sage tendon
#

just fetch it on startup and save it

ebon swift
#

HOOO ok thank you ! will try it !

sage tendon
ebon swift
#

Thank you all

#

properties solved it cause I didn't go through inits to call those properties

#

and I didn't even have to use fetch so it's even better

lapis dock
#

Yeah, the init of the bot is run before the code connects to discord.

valid panther
sage tendon
#

I just said bridge lol

fiery fable
#

Is there a way to get the guild_id to the autocomplete function of a slash_command?

fiery fable
fiery fable
# fresh sierra Ctx.interaction.guild.id

somehow it doesnt get triggered 🤔

class Tags(commands.Cog):
    def __init__(self, bot):
        self.bot = bot
    
    async def autocomplete_tag_id(self, ctx: AutocompleteContext):
        tags: list[Tag] = await self.bot.db.get_all_tags(ctx.interaction.guild.id)
        return [tag.id for tag in tags]
    
    @slash_command(name="tag", guild_ids=[937023432929988638])
    async def tag(self, ctx: ApplicationContext, tag_id: Option(str, autocompete=basic_autocomplete(autocomplete_tag_id), description="The ID of the tag to show.")):
        ....
sage tendon
#

autocompete

#

you're missing an l

#

also this isnt necessary or anything but i just personally suggest you use the decorator to define options instead of the typehint, especially if you have many commands / many options
its a lot cleaner

fiery fable
#

oh yeah right looks better.
now i get an error about the self argument:

Traceback (most recent call last):
  File "/home/mcbabo/tagger/.venv/lib/python3.12/site-packages/discord/bot.py", line 891, in callback
    return await command.invoke_autocomplete_callback(ctx)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mcbabo/tagger/.venv/lib/python3.12/site-packages/discord/commands/core.py", line 1105, in invoke_autocomplete_callback
    result = await result
             ^^^^^^^^^^^^
  File "/home/mcbabo/tagger/.venv/lib/python3.12/site-packages/discord/utils.py", line 1373, in autocomplete_callback
    _values = _values(ctx)
              ^^^^^^^^^^^^
TypeError: Tags.autocomplete_tag_id() missing 1 required positional argument: 'ctx'
sage tendon
#

yea, you need that unless its a static method

#

oh wait

#

hm

lapis dock
#

It would need to be a staticmethod

sage tendon
#

yea but they need / want the bot var

lapis dock
#

ctx.bot exists tho so you should be fine

fiery fable
echo wraith
#

.

fiery fable
#

In my log it says gateway-prd-us-east1-b-fcm4. Does that mean it connects to an us server? Are there no eu servers?

20.05.25 - 17:39:53 [INFO] [gateway.py] Shard ID 0 has connected to Gateway: ["gateway-prd-us-east1-b-fcm4", ....
sage tendon
#

where is your VPS running

fiery fable
#

should be frankfurt/de

lapis dock
#

The discord API servers are in the US east region

sage tendon
#

there are no EU ones???

#

no wonder the ping is always this shit

lapis dock
#

I think voice servers are distributed across the globe, but not API

fiery fable
shell radish
round heart
#

Hey, stupid sanity-check.

I have a slash command that normally I just invoke, .defer(), do some work in another class, and then ctx.respond()

If I want to provide some sort of progress message (e.g. "Step 1 complete", etc etc), will I have to change this setup in some way? Like my progress messages would 'respond' but then I'd have to then edit the message afterwards or something, yeah?

And if so, how can I tell if I need to edit vs straight respond - I thought there was an 'is_responded' flag, but can't find it on ApplicationContext

lapis dock
#

respond handles send vs edit for you.

sage tendon
#

followups as well!

round heart
lapis dock
#

wait i might be wrong

sage tendon
#

you are right wolfy

lapis dock
round heart
lapis dock
#

You want
defer -> respond -> edit_original_response

hazy turret
#

Why do I always get None when I try to access bot emojis with emoji = bot.get_emoji(emoji_id) ?

sage tendon
#

application emojis aren't supported yet

#

you can still just use them via the markdown tho

hazy turret
sage tendon
#

copy the markdown from the dev portal and paste it into your bot response

hazy turret
#

Can I also set them as button emoji?

sage tendon
#

no idea

echo wraith
#

Yeah probably w/ PartialEmoji

hazy turret
#

Okay thanks

sage tendon
#

uhhhhh

#

emoji.read() failed, what

hazy turret
# sage tendon uhhhhh

If I simply send the markdown on the server into the chat, the emoji is displayed briefly and then immediately afterwards only :invite:

sage tendon
#

thats not the emoji markdown tho

#

copy it from the dev portal

hazy turret
#

:invite:

#

Oh, but not

sage tendon
#

show your code

hazy turret
#

:invite:

sage tendon
#

that is not the markdown the dev portal gives you

hazy turret
#

But I am in the Dev Portal and click on “Copy Markdown”

sage tendon
#

i just did too, and i get a properly formatted string

hazy turret
#

:invite:

#

It does not work

sage tendon
#

show the actual code

hazy turret
#

It does not work with any Markdown from the Dev Portal, not even with other emojis from bots

sage tendon
#

you cant use other bots' emojis..

hazy turret
#
async def send_test_embed(channel):
    embed = discord.Embed(
        title="Test Embed",
        description="This is a test embed with a markdown emoji from the Dev Portal :invite:",
        color=0x3498db 
    )
    
    await channel.send(embed=embed)```
#

The Markdown is always reformatted directly

fiery fable
#

you need the full emoji

sage tendon
#

dude

#

i said to use the markdown you copy from the dev portal

#

not that shorthand form

hazy turret
#

This is what I send and then it is reformatted directly to when I send it.

sage tendon
#

yea that is correct tho

#

if thats actually how it is in your code

hazy turret
#

Yes, but it is reformatted directly

sage tendon
#

that is normal because the client does that

#

are you 100% sure you uploaded it to the right application

hazy turret
#

I have an idea.
I'll test it tomorrow.
Thank you

fiery fable
#

does somebody uses docker to host the bot? i like the container principle but then i cant reload cogs :/

fiery fable
little cobalt
#

oh wait, container you mean the new discord stuff or what was again?

fiery fable
#

no a docker container. the bot as a docker image

sage tendon
#

that is not what they're asking lol

frail basin
#

Would also have the benefit of not having to build it again and again

echo wraith
faint sky
#

pycord can handle slash commands right? but why arent my commands poping up on discord when i run it?

echo wraith
sly karmaBOT
# faint sky pycord can handle slash commands right? but why arent my commands poping up on d...

Application Commands Not Showing Up?

  • Refresh Discord by restarting or pressing Ctrl+R (or Command ⌘ + R)
  • Uninstall libraries that conflict with the discord namespace (e.g. discord.py).
  • Invite your bot with the application.commands scope.
  • Load cogs before bot.run() (e.g. not in on_ready).
  • Do not override on_connect.
  • Update to the newest version of py-cord (see ?tag install).
  • Turn off User Settings > Accessibility > Chat Input > Use legacy chat input.
  • Share your code and errors.
frail basin
#

Is this a known issue?

Discord doesnt display the possible values like for discord.TextChannel

frail basin
fresh sierra
#

Threads are just considered «subchannel » and so cannot be just shown like this

#

To see all of the thing you can use you should check this

frail basin
#

^

#

Thats a valid option for SlashCommandOptionType.channel

fresh sierra
#

That’s a channel type, not a slashcommandoptiontype

#

Then that’s mb

#

For as far as I know thread cannot be used as option

#

Let me check

frail basin
#

channel_types: list[:class:discord.ChannelType] | None
A list of channel types that can be selected in this option.
Only applies to Options with an :attr:input_type of :class:discord.SlashCommandOptionType.channel.
If this argument is used, :attr:input_type will be ignored.

#

^^^^^
from the docstring

fresh sierra
#

yeah ur corrrect

#

@frail basin do you mean those one ?

frail basin
#

yes

#

Specifically type 11

fresh sierra
#

maybe i do confuse the public thread and the private one tho

frail basin
frail basin
#

for me

fresh sierra
#

this is my current implementation

frail basin
#

Yeah no clue then

fresh sierra
#

and are you on master or 2.6?.1 ?

frail basin
#

master

fresh sierra
#

do you restart ur client between the change ?

frail basin
#

yes

#

ofc

echo wraith
#

Ping me later if this is confirmed to be an issue with the lib, I'll take a look

frail basin
#

"I am sure that the command is up to date"

fresh sierra
#

yeah no idea, we have the same code

fresh sierra
frail basin
#

might be the lib, also happens for someone else on a different device / client

#

same command

frail basin
fresh sierra
#

and working great

#
import discord

bot = discord.Bot(command_prefix="!", intents=discord.Intents.all())


@bot.command()
@discord.option("test", channel_types=[discord.ChannelType.public_thread])
async def test(ctx: discord.ApplicationContext, test: discord.Thread): ...

frail basin
#

could you try putting it behind a slash command group?

#

/group˙test <thread>

fresh sierra
echo wraith
#

Hmm

undone merlin
#

I'll try it too

echo wraith
undone merlin
fresh sierra
echo wraith
frail basin
#

This MRC reproduces my issue

import discord
import os
__import__("dotenv").load_dotenv()

bot = discord.Bot(intents=discord.Intents.all())

@bot.slash_command(name="test", description="Test command")
@discord.option(name="option", description="Test option", channel_types=[discord.ChannelType.public_thread])
async def test(ctx: discord.ApplicationContext, option: discord.Thread):
    await ctx.respond(f"Test command with thread: {option.name}")

@bot.listen("on_ready")
async def on_ready():
    print(f"Logged in as {bot.user.name} - {bot.user.id}")
    print("Bot is ready.")

bot.run(os.getenv("TOKEN"))
#

doesnt even need the group

fresh sierra
#

let me try this

frail basin
#

Actually I am not on master but the cv2 pr

#

ill try master

echo wraith
#

Oh f

fresh sierra
#

wait i was in the wrong guild

frail basin
#

same issue on master

fresh sierra
#

no its working on my end

#

are you sure that the thread is in fact public ?

frail basin
#

forum channels only have public threads

#

and the forum channel is public too, just to make sure

fresh sierra
#

in the guild where the bot is ?

#

to test if it can be a client issue

frail basin
#

oh what the fuck

#

it works for normal threads

#

but not for post threads

#

probably a discord issue then?

fresh sierra
#

maybe

frail basin
#

Could you please test and confirm?

echo wraith
#

.tag ddevs

sly karmaBOT
frail basin
#

Or kids spamming . in the thread

echo wraith
fresh sierra
#

So I can try using the same thing as you

frail basin
#

With your bot I mean

fresh sierra
#

With my bot it’s working

frail basin
#

Forum posts too?

#

TextChannel threads work for me too it turns out

fresh sierra
frail basin
echo wraith
#

@frail basin The issue is it can't show forum posts ? If that is the issue I can't reproduce.

Note that it only shows posts that are open for you

#

My test code:

import logging
import os
from dotenv import load_dotenv

import discord

load_dotenv()

logging.basicConfig(level=logging.DEBUG)

TOKEN = os.getenv("TOKEN_3")

bot = discord.Bot(intents=discord.Intents.all())


class MyCog(discord.Cog):
    manager = discord.SlashCommandGroup("manager", "Commands for managing the bot.")
    @manager.command(name="regenerate-commission-type-post", description="Remakes the post for a commission type.")
    @discord.option(name="thread", description="The post to regenerate.", channel_types=[discord.ChannelType.public_thread], required=True) 
    async def regenerate_ticket_category_post(self, ctx: discord.ApplicationContext, thread: discord.Thread):
        await ctx.respond(f"{thread.mention}")

bot.add_cog(MyCog(bot))

bot.run(TOKEN)
frail basin
#

seems to be a client issue

echo wraith
frail basin
#

trying to narrow down to specific versions right now

frail basin
frail basin
#

works there

#

I guess they are testing in prod again

echo wraith
#

Toothy is gonna be happy

sage tendon
echo wraith
#

Whatever

sage tendon
#

reloading cogs for code changes literally defeats the entire purpose of docker

echo wraith
#

It's fine if it's only while developing

fresh sierra
#

Why is that an issue to reload cog when using docker ?

sage tendon
#

because the entire purpose of docker is to ship an immutable and static environment that you can 10000% rely on once you tested it, because nothing changes

#

if you just change stuff in the same container regularly just dont use docker

fresh sierra
#

How would you do then if there is a code change ? Restart the whole container ?

#

Im not familiar with docker even tho i think ptero uses it

sage tendon
#

build a new image and put it in the container

#

or whatever the exact terminology is

#

it's like versioning
you dont change the files of an existing version, EVER

fresh sierra
#

So like docker is not really somewhere where you put ur code

#

Is more like a image I see

sage tendon
#

luma please just look up docker

fresh sierra
#

Don’t really need to, this explanation is enough for me

sage tendon
#

im 98% sure you misunderstood

fresh sierra
#

And I do like the human contact when it comes to learning things

fresh sierra
sage tendon
fresh sierra
#

Since I’m not using it that’s ok, if one day I need to use it ofc I’ll documente myself more

fresh sierra
sage tendon
#

the point is just, if you want / need to change stuff in a docker container, you dont need docker

round heart
#

Docker is very overused (and overhyped, and overvalued)

sage tendon
#

the world runs on it for a large part tho

round heart
#

That's a stretch. Is it often used? Yes... but "the world runs on it" is a bit exaggerated.

faint sky
#

?tag install

limber wagonBOT
#

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

hazy turret
#

Is it possible to integrate a custom listener in the bot and trigger it at a certain event?

sage tendon
#

of course

hazy turret
sage tendon
#
@discord.Cog.listener()
async def eventname(...):
hazy turret
sage tendon
#

oh you mean a non discord event?

hazy turret
sage tendon
#

do you have two seperate things running on your server or

#

where does the second event come from

hazy turret
sage tendon
#

so its two different processes on your vps?

hazy turret
#

Ah okay, I got the idea myself.
I can access the bot directly then I don't need a custom event 😄

sage tendon
#

so then just call the function lol

hazy turret
#

nvm

fresh sierra
#

bot.dispatch(ur_event), and then just do async def on_ur_event()

sage tendon
#

why would you ever do that instead of just calling the function tho

sage tendon
#

its threaded?

echo wraith
#

no

#

async

#

but uses create task

sage tendon
#

hm

frail basin
terse arrow
#

Hey all - For some reason my slash command is not appearing, I've waited for around an hour but still not appearing. I cant see anything wrong with it any advice would be great -

@bot.slash_command(description="Show recent entries in the command log (admin only).")
async def logo_tool_show_log(ctx: discord.ApplicationContext, lines: int = 10):
    if get_user_privilege(str(ctx.author.id)) != "admin":
        await ctx.send("🚫 Only admins can use this command.")
        return
    try:
        with open("command_log.txt", "r") as log_file:
            entries = log_file.readlines()[-lines:]
            await ctx.send(f"📄 Recent Log Entries:")
    except FileNotFoundError:
        await ctx.send("⚠️ Log file not found.")
sly karmaBOT
# terse arrow Hey all - For some reason my slash command is not appearing, I've waited for aro...

Application Commands Not Showing Up?

  • Refresh Discord by restarting or pressing Ctrl+R (or Command ⌘ + R)
  • Uninstall libraries that conflict with the discord namespace (e.g. discord.py).
  • Invite your bot with the application.commands scope.
  • Load cogs before bot.run() (e.g. not in on_ready).
  • Do not override on_connect.
  • Update to the newest version of py-cord (see ?tag install).
  • Turn off User Settings > Accessibility > Chat Input > Use legacy chat input.
  • Share your code and errors.
little cobalt
#

also slash commandsare using ctx.respond and not ctx.send

terse arrow
#

Thanks - I'll take a look now

sage tendon
#

especially because it hides the command from everyone else

#

and if you log every command invokation you should definitely use an async file handler and also put it into a util function so you don't duplicate it everywhere

lapis dock
terse arrow
#

Thanks for the update, turns out I didn't define my bot properly and all good now thanks all

fresh sierra
lapis dock
#

or use the logging module

sage tendon
#

thanks for repeating what I said

fresh sierra
sage tendon
#

just couldn't remember the name

fresh sierra
#

so you did not say the name

#

so i did not repeat you

sage tendon
#

sigh

fresh sierra
#

so thanks you for the unnecessary yapping ;)

eternal kite
#

I think something is wrong with the view timeout

#

I set it to 10 minutes, but when someone respond to the view, the timeout extends

#

so I have a view and about 30 different people clicked on the view, have been 20 minutes since and it still did not timeout

sage tendon
#

thats expected and by design

eternal kite
sage tendon
#

i mean just what i said

#

it's not wrong

eternal kite
#

huh

sage tendon
#

it's just how its supposed to work

eternal kite
#

it's been more than 10 minutes since the last player who clicked the button

#

so how long are we talking if 30 people clicked the button?

sage tendon
#

the timeout is reset when a person clicks the button

#

that simple

eternal kite
#

yeah i know but it's been more than 10 minutes

sage tendon
#

and if you click the button?

eternal kite
#

nevermind it just timeout now

#

but

#

i got an error saying invalid webhook

#

token

round heart
#

Is the only way to have a callback on a button to subclass it?
Like you can't self.add_item(discord.ui.Button(...)) in the view and have a callback function?

lofty parcel
#

Button.callback = my_function

#

I used to do that in an old project where the callback behaved almost the same in every button so they shared the same func

round heart
#

That makes sense. Thank you.

errant trout
#

just note that when you aren't using the decorator, the only argument callback takes is interaction

round heart
#

Hm. Why is my View not getting the message (where many of my other VIews reference self.message just fine)?

#

Ah, okay. It must populate it afterwards. I can't reference it in the constructor (to to my Button)
(This must also explain why I've had inconsistent referencing of self.view; just depends on where)

sonic onyx
#

How do I actually invite my bot to a server?

lofty parcel
#

You generate an oauth url on the dev portal

sonic onyx
#

It requires a redirect link, but it seems I have to have my own redirect because my bot isn't public?

#

Do I have to host my own website to have a private bot?

shell radish
#

what are the oauth scopes?

errant trout
sonic onyx
#

Oh weird. I didn't realize the URl disappears if you want any scopes other than bot & application commands

fiery fable
#

which git repo should i pull to get the container components working?

sly karmaBOT
# fiery fable which git repo should i pull to get the container components working?

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.

fiery fable
echo wraith
stable coyote
#

hi friends, why do i get an ModuleNotFoundError: No module named 'audioop' error when trying to import discord? maybe lacking dependencies?

sly karmaBOT
# stable coyote hi friends, why do i get an ModuleNotFoundError: No module named 'audioop' error...

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.

stable coyote
echo wraith
#

either pip install audioop-lts or use python 3.9-3.12

stable coyote
rugged lodgeBOT
#

Here's the slash basic example.

echo wraith
#

@stable coyote take a look at the examples

fiery fable
echo wraith
stable coyote
#

is ctx.member not a thing anymore?

errant trout
#

Or do you mean the bot member? That's ctx.me

stable coyote
errant trout
#

Allgood

frail basin
echo wraith
frail basin
#

oh

#

Completely missed that part

fresh sierra
#

Thats a strange decision from discord

#

(In my opinion

echo wraith
frail basin
#

Any workarounds other than @everyone?

fresh sierra
echo wraith
frail basin
#

2nd

echo wraith
#

yeah autocomplete

rugged lodgeBOT
#

Here's the slash autocomplete example.

frail basin
#

I wanted to avoid that since discord doesnt enforce that

#

I guess I'll have to then.

sage tendon
#

the people can always put in the thread ID Shrug_3

frail basin
#

UX nightmare

fresh sierra
frail basin
#

like they do with choices

#

you can enter any value, not just the ones I return with the autocomplete

echo wraith
#

Yerah unfortunately there isn't really any other solution :/

frail basin
echo wraith
fresh sierra
#

That’s annoying I agree with you

tidal pecan
#

You can still take whatever input the user gives and double-check it in your code, and return errors or warnings indicating that a bad value was presented. I think the real issue isn't in the autocomplete itself, but in the way that the Discord App displays those textbox inputs. It's strictly one kind of input box, say a standard Textbox as opposed to a Combobox with limited dropdown options.

stable coyote
#

how was it that we do the response only visible to the author again?

stable coyote
lethal loom
#

Hi, have pycord added components v2?

echo wraith
sly karmaBOT
# lethal loom Hi, have pycord added 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.

nocturne jewel
#

is it possible to set different Rich Presence(s) texts for different Discord servers? For example, having one text on 50 servers and another on the other 50?"

cursive swallow
#

Nope

shell radish
#

you can set it by shard

eternal kite
#

so i've done some analysis about the high ram usage by sorting out gc.collect(), and this is the result i get, is this normal?

#

there are about 326k objects during the time i start my bot, and rises to 500k+ in 24 hours

eternal kite
#

700+?

#

maybe im not sure

#

it doesn't exceed 1k

echo wraith
#

How much ram is actually being used?

eternal kite
#

3gb

#

overtime i mean

#

1gb when it's low

#

i just threw a bunch of data into chatgpt and they said it's a clear memory leak but they did not provide a solution

echo wraith
#

I'm not sure it's a clear memory leak

eternal kite
#

i didn't know my bot was this complicated?

#

yea dict objects increased by 15.7k in garbage collector in mere 10 minutes

#

i think there are like 100+ active users rn

#

it's an economy bot though i understand the frequency of commands used causes more ram usage but that's just too much

echo wraith
#

That's weird... It's possible that something is wrong in pycord internals but tbh I wouldn't know where to start looking. Would you mind sharing what some of those dict objects look like ?

eternal kite
#

one sec i really need to find a way to look through 360k objects

echo wraith
#

Should be enough to see if there's a pattern

eternal kite
#

alr im restarting my bot now, one moment

#

im assuming it's the user data from my database tho

#

because that's the only place i can think of that contains a large amount of dict and lists

#

but aren't variables getting deleted after the function finishes running?

eternal kite
#

one sec, i'll print the variable that gets accumulated over time instead of random picked variables

sour widget
#

got this in one file:

random_commands_group = discord.SlashCommandGroup("random")

and this inside cog in different file:

@random_commands_group.command(
        name="advancements",
        description="Returns random advancement that matches the parameters"
    )
async def random_command(self, ctx: discord.ApplicationContext, title: str)
  ...

but I don't see the command, found this issue https://github.com/pycord-development/pycord/issues/2429, but got this error

Ignoring exception in on_connect
Traceback (most recent call last):
  File "C:\Users\skyreed\PycharmProjects\BACAP_Bot\.venv\Lib\site-packages\discord\client.py", line 412, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\skyreed\PycharmProjects\BACAP_Bot\.venv\Lib\site-packages\discord\bot.py", line 1214, in on_connect
    await self.sync_commands()
  File "C:\Users\skyreed\PycharmProjects\BACAP_Bot\.venv\Lib\site-packages\discord\bot.py", line 742, in sync_commands
    registered_commands = await self.register_commands(
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\skyreed\PycharmProjects\BACAP_Bot\.venv\Lib\site-packages\discord\bot.py", line 595, in register_commands
    data = [cmd["command"].to_dict() for cmd in filtered_deleted]
            ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\skyreed\PycharmProjects\BACAP_Bot\.venv\Lib\site-packages\discord\commands\core.py", line 1341, in to_dict
    "options": [c.to_dict() for c in self.subcommands],
                ^^^^^^^^^^^
  File "C:\Users\skyreed\PycharmProjects\BACAP_Bot\.venv\Lib\site-packages\discord\commands\core.py", line 943, in to_dict
    "options": [o.to_dict() for o in self.options],
                ^^^^^^^^^^^
  File "C:\Users\skyreed\PycharmProjects\BACAP_Bot\.venv\Lib\site-packages\discord\commands\options.py", line 358, in to_dict
    "type": self.input_type.value,
            ^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'value'
#

just don't know how to fix it

sage tendon
#

you cant do that by default, spreading a commandgroup across different files

#

there is an extension for that but I'd honestly just recommend doing it in one file

sour widget
#

uh

#

just need it for different cogs

#

ok, thanks.

fresh sierra
valid panther
#

I have a question, would putting the “context” and the decorator “@guild_only” be repetitive?

valid panther
# shell radish yes

I understand that it is a discord problem, because without the tag “guild_only” I can see the command in private bot_dm

sage tendon
#

no, you are just passing the kwarg wrong

#

it's contexts

valid panther
#

fuck

round heart
#

You may have misspelled 'oops, thank you'

valid panther
lapis dock
errant trout
#

ephemeral*

#

Idk if you use it so much you'll end up remembering how to spell it

shell radish
#

learning how to pronounce words helps

lapis dock
#

Pretty sure it is ephermeral /j

shell radish
#

eh-phe-mer-al

sage tendon
#

ephemereal

lapis dock
hexed herald
#

and then I sit there and just let copilot write it for me xD
I change everything except ephermeral

fresh sierra
edgy nest
#

ephemeral

limber cedar
#

How exactly can I ignore this warning?

DeprecationWarning: interaction is deprecated since version 2.6, consider using interaction_metadata instead. See https://discord.com/developers/docs/change-log#userinstallable-apps-preview for more information.
  if message.interaction.type == 2:
DeprecationWarning: interaction is deprecated since version 2.6, consider using interaction_metadata instead. See https://discord.com/developers/docs/change-log#userinstallable-apps-preview for more information.
  if message.interaction.name == command:

I understand the nature of this warning; I already added some lines to attempt to filter those warnings out but they still print to the console

def is_dank_slash_command(message: discord.Message, command: str):
    if message.author.id == dank_memer_id:
        with warnings.catch_warnings():
            warnings.filterwarnings("ignore", category=DeprecationWarning)
            if message.interaction is not None:
                if message.interaction.type == 2:
                    if message.interaction.name == command:
                        return True
    return False
echo wraith
#

Monkey patching my beloved

fresh sierra
#

but why not use interaction_metadata ? does it lack information that you need ? (it does lack name)

fresh sierra
limber cedar
limber cedar
#

Actually

#

maybe it wil;

fresh sierra
limber cedar
#

never mind, didn't work

fresh sierra
#

but py-cord needs you to activate logging for it to work

#

so that mean its a real error

limber cedar
#

Like this, right?

import logging

logger = logging.getLogger('discord')


class IgnoreDeprecatedInteractionFilter(logging.Filter):
    def filter(self, record):
        if "interaction is deprecated" in record.getMessage():
            return False
        return True

logger.addFilter(IgnoreDeprecatedInteractionFilter())
fresh sierra
limber cedar
#

But yeah the warnings are still showing

fresh sierra
#

well it does use warnings for this part

little cobalt
#

For what do you even need that?

little cobalt
#

I saw that

fresh sierra
fresh sierra
# fresh sierra

idk how accurate this is but this would explain why the with warnings.catch_warnings(): does not work

fresh sierra
little cobalt
#

I mean the "message.Interaction"

fresh sierra
#

because interaction metadata does not have this info

sage tendon
#

the best solution is to not ignore deprecation warnings at all kekw

silk spire
#

^^ the field is deprecated for a reason

#

And discord doesn't want to expose the name for interaction_metadata

#

Find other ways to detect the command or just don't lmao

fresh sierra
#

why do py-cord is blocking the warning message ignore ?

lapis dock
#

Probably just how deprecation warning is set up.

silk spire
#

Because deprecation warnings shouldn't be ignored?

fresh sierra
#

yeah but if the user ignore it that on him and means he knows that

silk spire
#

It's warning you to stop using it over removing it directly and potentially breaking thousands of bots

echo wraith
#

No it doesn't, it means you're using a feature that might stop working at sime point

#

Who in their right mind would to that ?

fresh sierra
#

if you cannot change it at the moment, having ur console flod might be inconvenient

silk spire
#

That's on you for not reading the changelog of a major update or docs for the attr/meth and just blindly updating

fresh sierra
#

Having his console full of warning when he already knows that it’s gonna be depreciated can be annoying

silk spire
#

He can just not use it?

#

It's not supported (anymore)

#

No one needs to rely on checking another bot's command

fresh sierra
#

I do get the initial warning but forcing the user to not be able to easily ignore it I don’t really get that

silk spire
sage tendon
#

imo discord is at fault here for just removing info from the API

#

I use the field too for something completely different

silk spire
#

Other than sending "omg! Thank you for doing that!!"?

sage tendon
silk spire
#

And their reason to not document is stupid

echo wraith
silk spire
#

What are these cases 👀

echo wraith
#

If the feature is deprecated you should just not use it.

lapis dock
#

IE if you want only one command to be able to be used in a channel nevermind you can do that with integration settings

echo wraith
#

eg #1315663969595166720 message

#

There's some others but I can't find them rn

silk spire
#

That doesn't include the reason lol

But ig command usage tracking for the server is a good one

echo wraith
#

Yeah, in any case the feature should just not be used

#

whatever going to go back to doing integrals

sage tendon
#

yikes

silk spire
#

I just looked up what that is.. goodluck 💀

echo wraith
limber cedar
# silk spire He can just not use it?

My bot uses message.interaction in on_message, resulting in many logged DeprecationWarnings. I understand the implications of continuing to use .interaction, my intent in suppressing them wasn’t to ignore best practices but to reduce noise while retaining this feature temporarily

It allows my bot to perform actions based on specific user interactions with another bot, this would be degraded if I removed message.interaction prematurely.

That’s on you for not reading the changelog of a major update or docs for the attr/meth and just blindly updating

I did look out for problems when updating and read the relevant documentation when I discovered this, including the linked API reference in the DeprecationWarning. I also asked about it previously here. I made a deliberate decision to upgrade for the improvements in 2.6 and accept the warnings as a tradeoff.

I find it unfair and patronising to assume I updated “blindly” based on a few messages without the full context. I already looked into everything I could find regarding this change before deciding to proceed.

He can just not use it?
It’s not supported (anymore)

I fully understand what deprecation means. I left the usage of .interaction in my bot with full awareness, not ignorance. Until discord removes it entirely or provides an alternative I need it to maintain accuracy for a live feature.

errant trout
#

uhhh idk what issues you're having with suppressing the warnings, but if you really want you can fully override the function

#
def some_func(*args, **kwargs):
 return None
discord.utils.warn_deprecated = some_func
```run it after your imports in your main bot file
#

(this is pretty silly, but eh if you're that desperate then it's not the worst thing i've ever seen)

#

alternatively, instead of accessing message.interaction you can fetch the raw data -> access the ["interaction"] key

#

(on master/next release, this would be message._raw_data["interaction"])

limber cedar
#

Like it had no effect

errant trout
#

yeah i backread

limber cedar
#

Thank youu

errant trout
limber cedar
#

It’s fine, I’d rather go for accessing the raw data directly, gives me more flexibility especially if it’s removed without warning

errant trout
#

fair

limber cedar
#

Wouldn’t want to accidentally erase any other future deprecation warnings either

errant trout
#

so we can't either

limber cedar
#

Yep I fully understand that, I recall seeing that gh thread before

undone merlin
#

Hello everyone, I'm currently getting this error in my terminal even tho the ID's are all correct. I have the same logic for 2 other ticket systems that take place in a different server but I dont get this issue whereas in an another server with 2 ticket systems I'm getting this issue:

Ignoring exception in modal <discord.ui.modal.Modal object at 0x00000242B22B6F90>:
Traceback (most recent call last):
  File "D:\test\tutorial-env\Lib\site-packages\discord\ui\modal.py", line 341, in dispatch
    await value.callback(interaction)
  File "D:\test\deep.py", line 218, in modal_callback
    ticket_channel = await interaction.guild.create_text_channel(
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<4 lines>...
    )
    ^
  File "D:\test\tutorial-env\Lib\site-packages\discord\guild.py", line 1223, in create_text_channel
    data = await self._create_channel(
                 ~~~~~~~~~~~~~~~~~~~~^
        name,
        ^^^^^
    ...<4 lines>...
        **options,
        ^^^^^^^^^^
    )
    ^
  File "D:\test\tutorial-env\Lib\site-packages\discord\guild.py", line 1102, in _create_channel
    "id": target.id,
          ^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'id'
tidal pecan
#

I think it's saying that your variable target is None at the point where you attempt to retrieve the value of target.id

To clarify: "Your" variable target is actually in py-cord by the time the NoneType exception is raised. You would want to examine your own code in (it looks like) deep.py starting on line 218. One of those 4 lines of code is passing on a value which is ultimately turning into the target var a couple of calls later.

errant trout
tidal pecan
errant trout
#

pretty much

undone merlin
errant trout
#

i mean just check that you didn't pass None as a key

undone merlin
#

I honestly can't figure out the problem as 2 of my other systems follow the same suit and work perfectly fine

errant trout
#

show your overwrites dict

undone merlin
#

Is it better if I store ID's like

example = [1234567889010, 09876543231241]

or in a dictionary

errant trout
#

i mean

#

why a dictionary

undone merlin
#

I didn't think this would be a problem because other ticket systems work

errant trout
#

did you actually check your overwrites dict

undone merlin
#

I did

errant trout
#

one of the keys is resolving to None

#

print all of them

tidal pecan
errant trout
#

They're talking about something else

tidal pecan
#

So I posted this code: #1377282622647963689 message

You can just import this code-file and then instance the Log class and call iter_full, passing your overwrites as 'iterable_thingy.' It will explode the whole iterable and drill into additional iterable-elements found inside, listing off the data type and content of each element in each iterable.

undone merlin
errant trout
#

pls just

#

show your code

tidal pecan
# undone merlin I'm using a list and all all variables are given a value

Your initial call to Guild.create_text_channel is passing 'overwrites' unmodified and untested to Guild._create_channel. At that point, Guild._create_channel is running tests against each 'Permission' member of your 'overwrites' iterable. The permission itself is passing all the tests, verifying that each element is in fact an instance of PermissionOverwrite. This occurs in a for target,perm in overwrites.items() loop. Shortly after, the 'target' parameter (which is totally untested in both calls) is called for its id attribute, and at that point the 'target' is None.

So there's something hinky with your overwrites. It doesn't matter if everything looks right to your eyes. Something isn't right and it's in your KEYS, not in your VALUES.

undone merlin
#

Thank you @tidal pecan and @errant trout

errant trout
#

allgood

tidal pecan
# undone merlin I cannot believe how stupid the mistake was

My best suggestion for avoiding issues like this is to teach yourself how to Rubber Ducky. Also, I'm a big fan of "The Mentor's Manifesto" which states: I made a discovery today. I found a computer. Wait a second, this is cool. It does what I want it to. If it makes a mistake, it's because I screwed it up. Not because it doesn't like me... Or feels threatened by me... Or thinks I'm a smart ass... Or doesn't like teaching and shouldn't be here... Damn kid. All he does is play games. They're all alike.

warm monolith
#
Traceback (most recent call last):
  File "C:\Users\basti\BastiGame\Development\DevHQ\InternalBot\.venv\Lib\site-packages\discord\ui\view.py", line 540, in _scheduled_task
    await item.callback(interaction)
  File "C:\Users\basti\BastiGame\Development\DevHQ\InternalBot\cogs\experiments.py", line 284, in callback
    await interaction.response.edit_message(content=f"Message scheduled for `{self.schedule_time}` UTC!", view=None)
  File "C:\Users\basti\BastiGame\Development\DevHQ\InternalBot\.venv\Lib\site-packages\discord\interactions.py", line 1198, in edit_message
    await self._locked_response(
    ...<10 lines>...
    )
  File "C:\Users\basti\BastiGame\Development\DevHQ\InternalBot\.venv\Lib\site-packages\discord\interactions.py", line 1365, in _locked_response
    await coro
  File "C:\Users\basti\BastiGame\Development\DevHQ\InternalBot\.venv\Lib\site-packages\discord\webhook\async_.py", line 225, in request
    raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In data.content: The 'content' field cannot be used when using MessageFlags.IS_COMPONENTS_V2

        await interaction.response.edit_message(content=f"Message scheduled for `{self.schedule_time}` UTC!", view=None)

How can I edit the message so that it's no longer MessageFlags.IS_COMPONENTS_V2? I just want to have a message at the end.

sage tendon
#

what if you only edit the view away

torn barn
#

Once you send cv2 you cannot remove them

sage tendon
#

I didn't work with CV2 yet but can't you just edit it to be a completely unstyled text area

errant trout
warm monolith
errant trout
#

You don't need a container

#

All new components work without container

wheat tiger
#

How do we add permissions to slash command groups?

#

like if I add perms to individual command using @discord.default_permissions it won't work, users can still use the command

fresh sierra
wheat tiger
fresh sierra
#

group = discord.SlashCommandGroup(default_member_permissions=)

fresh sierra
wheat tiger
wheat tiger
fresh sierra
fresh sierra
wheat tiger
fresh sierra
echo wraith
#

One or the other

errant trout
#

default_member_permissions is the API name, default_permissions is the decorator name (and decorators generally don't have to follow the API, they're for convenience)

echo wraith
#

the decorator should be renamed then imo

errant trout
#

v3 GuraSquintSmol

wheat tiger
#

Is it preferred to enable standard type checking in project?

echo wraith
wheat tiger
#

but here in pycord showing many issues on enabling

echo wraith
# wheat tiger Should I do for pycord?

You could and it would give you some benefits, you can still ignore project wide some issues (e.g. untyped decorator, missing generics, whatnot) and keep the rest. If you want here is my config for basedpyright project wide:

[tool.pyright]
venvPath = "."
venv = ".venv"
reportAny = false
reportUnusedCallResult = false
reportUnknownMemberType = false
reportMissingTypeStubs = false
pythonVersion = "3.12"

then I ignore a bunch of stuff inline as needed when the errors don't matter

#

but idk what type checker you use

wheat tiger
#

and ruff as linter and formatter

echo wraith
wheat tiger
echo wraith
#

me too, but I would also want it to have some more features I feel like will take more than a stable release to arrive, so I'm probably gonna stay w/ basedpyright for some time

echo wraith
#

oh no interesting

#

gonna take a look

wheat tiger
#

now-a-days new rust tools more than C lol 😂

echo wraith
# echo wraith gonna take a look

Seems nice although I reall like the many rules basedpyright has and I feel like it has quite less (as in that one only and only type checks whereas basedpyright hast stuff e.g. to differentiate Any and explicitAny, reportInvalidCast and a bunch others), errors seem less specific too

echo wraith
wheat tiger
echo wraith
#

idk I haven't done lots of desktop dev

#

maybe

wheat tiger
#

better performance

echo wraith
wheat tiger
wheat tiger
#

they ditched go

#

bcz of grabage collector

echo wraith
#

makes sense

lapis dock
wheat tiger
fresh sierra
#

Because too much issue like ctx.guild.id raising an error even tho you set the command as guild only etc

echo wraith
#

no

#

pycharm

echo wraith
#

we ain't gonna make command generic + overloads type checkers are either gonna give up or developers that would be mantaining ts

#

just check if it exists that's it it's one line

echo wraith
#

Why are you passing a slash context to a converter

#

youre doing it wrong

lapis dock
#

What is your goal? and can you show surrounding code

fresh sierra
#

Is there a reason why role.edit is type hint as returning Role|None ? Because ho would this never return None

fresh sierra
wheat tiger
#

wht is Unknown?

echo wraith
echo wraith
fresh sierra
echo wraith
#

If you don't know how type checking works you should probably not use a type checker, pycord or not

fresh sierra
#

So maybe it could be fix inside pycord

#

Even tho yeah there is limitation and I’m not blaming pycord for that

wheat tiger
echo wraith
#

It could be possible with generics

#

and overloads

fresh sierra
#

Also is there a reason to use Optinal instead of | None ?

fresh sierra
fresh sierra
wheat tiger
echo wraith
#

Optional and union are deprecated after 3.10

wheat tiger
#

but now-a-days I prefer doing | None and more usage of | instead of typing classes

#

old codebases use typing classes much

#

like for tuples

#

Tuple instead of default tuple

#

etc...

echo wraith
#

For all builtins

fresh sierra
wheat tiger
echo wraith
#

any is just not the same at all as Any

#

that's different

wheat tiger
echo wraith
#

any is a function

#

that returns true if any of the values passed in are truthy

wheat tiger
#

I learnt py, then learnt js/ts, liked types, switch back to pythoon and used there

echo wraith
#

Any is a type

#

Whereas e.g. Tuple tuple, one is a type the other a builtin but both represent the same thing

wheat tiger
#

btw any fix for this?

echo wraith
#

add this

#
if isinstance(ctx.author, discord.User): return
#

at the top of your command

#

it will fix it

fresh sierra
wheat tiger
echo wraith
#

show the code please

wheat tiger
#

tysm guys for helping me out for today!!

#

❤️

fresh sierra
#

in what condition can interaction.user be None ?

fresh sierra
#

** member is sent when the interaction is invoked in a guild, and user is sent when invoked in a DM

wheat tiger
#

Guys what orm du perfer in python?

#

Never rlly used any ORM in python so confuse, in node there're many like drizzle, kysely etc...

#

I want something like that

fresh sierra
#

and it seems nicz

wheat tiger
wheat tiger
#

See the benchmarks

fresh sierra
errant trout
#

ping interactions from discord exist, which have no user attached

#

regardless, if discord's spec says it's nullable then we will also type it with None

fresh sierra
#

i thought about interaction.response.ping, that's on me

fresh sierra
#

** member is sent when the interaction is invoked in a guild, and user is sent when invoked in a DM

#

so for me it meant it will either be member or user

wheat tiger
#

@errant trout Any thoughts about Tortoise ORM?

errant trout
#

never used it

fresh sierra
#

but idk if the benchlark is really important

wheat tiger
fresh sierra
#

for our usage

wheat tiger
fresh sierra
fresh sierra
fresh sierra
wheat tiger
errant trout
#

uh generally you don't need to worry about it, the library handles them at the base level

wheat tiger
#

and ik how bad it is

#

now trying to shift that to proper db

#

if ur able to, can u help?

errant trout
#

i mean migrating from json to db isn't too hard?

wheat tiger
#

I am comfortable in using drizzle orms

#

basically node

#

then I am planning to fix type errors, I am scared to enable standars/strict type checking in pyright it throws huge no of errors

#

so planning to first migrate then solve these

fresh sierra
#

so i dont think i willhave time

#

but if you have question about specifc thing tell me

echo wraith
echo wraith
#

Plus exams

fresh sierra
#

i got my first pr merge, i think i will make the 30 of may a dya off

#

(just realize 30 of may is the birthday of my ex)

echo wraith
#

Bruh

fresh sierra
echo wraith
echo wraith
#

Just add | none

fresh sierra
#

sad tho that some functions are notreally type proof

echo wraith
fresh sierra
fresh sierra
fresh sierra
echo wraith
echo wraith
#

Try putting the none inside

#

But I don't think that would work, it doesn't put it outside

fresh sierra
#

ok thanks

#

what do you think about this ?

echo wraith
#

Never

#

Nowhere

wheat tiger
#

@echo wraith What's ur age? How du manage ur coding + study?

fresh sierra
echo wraith
echo wraith
fresh sierra
# fresh sierra

the usage of fields.Field isnot thebest in my side because then i cannot do int + 1, i'll justuse normal typehint : int instead of field.Fields[int]

wheat tiger
echo wraith
#

Yes you should be able to

wheat tiger
fresh sierra
echo wraith
#

Try not to code as much, well remove your distractions etc. Rn I have exams, what I did is I literally unplugged my PC at home, and put a 0min screentime limit on ytb Instagram and a bunch of other things

echo wraith
#

Problem with pyroght

fresh sierra
#

using pylance

echo wraith
echo wraith
#

I'm cheating a little

#

All of my study notes are backed up to GH every 10 min or so

wheat tiger
echo wraith
wheat tiger
fresh sierra
echo wraith
#

Im checking rn

fresh sierra
#

also detect cycle that doesnt exist since im using type checking

echo wraith
#

@fresh sierra ¯_(ツ)_/¯

fresh sierra
#

bizrre

echo wraith
fresh sierra
#

Ok si it seems that it works when using an instance and not the class

echo wraith
#

when using the class it should not work you shouldn't use it that way

fresh sierra
#

how should ths be type this i dont know the arg / kwargs ?

echo wraith
#

what class

fresh sierra
echo wraith
#

Check the types in super().delete and use these

#

also seems like it doesn't want *args at all

fresh sierra
#

so i should maybe just do async def delete(self, using_db: BaseDBAsyncClient | None = None) -> None:

#

well that's pretty logical after all

echo wraith
#

Does anyone know if it's currently possible to do

@discord.option(input_type=discord.TextChannel | discord.VoiceChannel)
#

As in using | instead of Union ?

echo wraith
#

ok thanks much

echo wraith
fresh sierra
echo wraith
#

ok

grizzled loom
#

from typing Import Any

Sorry for not formatting, on mobile atm

#

tuple[Any, …]
In your case

silk spire
#

You only type the value, so just Any is correct there

fresh sierra
echo wraith
silk spire
#

Original if feasible else Unpack[TypedDict] if you want else ^

fresh sierra
#

ok

#

strict typing everything is gonna be hard but im gonna try

echo wraith
#

gl

fresh sierra
echo wraith
fresh sierra
#

especially with all those particular case

echo wraith
#

that one you can ignore