#Basic Pycord Help

1 messages · Page 62 of 1

unique wyvern
#

could that be the cause of this?

#

error:
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'ApplicationContext' object has no attribute 'reply'

#

code:
`import discord

bot = discord.Bot()

@bot.event
async def on_ready():
print(f"{bot.user} is ready and online!")

@bot.command(description="Pong!")
async def ping(ctx: discord.ApplicationContext):
await ctx.reply("Pong! Latency is " + str(bot.latency))`

#

oh wait

#

im dumb

#

its respond not reply

lapis dock
#

Btw for future reference you have use 3 backticks to make multiline code blocks look nicer

sly karmaBOT
#

Please put your code in a code block:
```py
Here is your Code
```

That makes reading code in Discord a lot easier:

print("This is an example.")
unique wyvern
#

👍 thanks again!

echo wraith
#

how come is it that sometimes discord.Bot.latency is "infinity" ?

silk spire
echo wraith
#

That's weird, as I'm accessing it only after bot startup... Oh well

latent viper
#

been a while since I touched my bot. Need to disable some commands temporarily, how do I do that? adding disabled=True doesn't seem to do anything, or I need to wait a while?

#

having my cmds in a cog, here's an example ```
class SlashCommandsMS(commands.Cog):
def init(self, bot):
self.bot = bot
...
ms_favorites = ms.create_subgroup(
"favorites", description="Show, add or remove your server favorites."
)
...
@ms_favorites.command()
async def show(self, ctx, enabled=False) -> None:
"""Show your server favorites."""

    await ctx.defer(ephemeral=True)

    user_id = str(ctx.user.id)
    user_favorites = await db.get_favorites(user_id)

...```

sage tendon
#

you can't really disable commands other than by changing their code to just not work afaik

latent viper
#

but that would break my current comments 😦

sage tendon
#

just add return await ctx.respond("...") as the first line?

latent viper
#

smt without responding any text? ctx.defer()?

sage tendon
#

the dots meant for you to just put some useful message there

latent viper
#

right

sage tendon
#

oh, no you can't respond just with an empty message

#

either just remove the command entirely so it doesn't exist anymore or do this, those are the two alternatives

latent viper
#

aite, I'll respond with 'this is currently disabled' or smt

#

thx

sage tendon
echo wraith
lament totem
#

Is there a comprehensive guide for using autoshardedclient?

#

I am moving a bot to use shards (on roughly 2400 servers now) and the bot is using all sorts of event listeners (on_ready, on_guild_remove, on_resume, on_disconnect) as well as starting async task loops on the first time on_ready runs. I will appreciate any insight you guys have 🙏

lapis dock
sage tendon
#

yea it subclasses the normal bot classes (one of them, idk which exactly) but nothing should change or break if you switch

lapis dock
#

I thought there was something about caching as well, like each shard has a separate cache but I cant remember

lament totem
#

I think I'm not using the cache at all (using chunk_guilds_at_startup=False, member_cache_flags=discord.MemberCacheFlags.none())

#

So I don't need to replace on_ready for on_shard_ready for example?

sage tendon
#

im p sure on_ready is called when all shards are ready so no

lament totem
#

Do you know about on_connect/ on_disconnect / on_resume when sharding? I don't quite understand when they would be invoked

#

since there's multiple connections at once

fresh sierra
#

For all event like on_rezdy, on_connect etc

#

(In my memory it says it’s triggered every time but I’m not quite sure for the ln_rezdy)

lapis dock
#

https://docs.pycord.dev/en/stable/api/events.html#connection
It looks like there is an on_shard_x version of some of the events. My guess is the ones that dont have a shard version work the same. You are right, the docs should be more clear about what sharding entails.
I have not used sharding so I am not super knowledgeable about it

sage tendon
#

the docs are probably really sparse because almost no one has a bot that is big enough to be sharded

lapis dock
#

Does not mean that they should be sparse tho. ;)

errant trout
errant trout
#

because of that, pycord includes shard-specific events; e.g. if shard 2 disconnects, both on_disconnect() and on_shard_disconnect(2) will be fired

#

this also applies to on_connect and on_resumed, but on_ready is different; on_shard_ready(id) will fire for individual shards, and when ALL shards are considered ready on_ready() will fire

lament totem
lapis dock
#

Nelo is the best ♥️

lament totem
#

One last thing I don't quite get is, if I run (perhaps not needed right now) multiple processes with multiple shards each. If I do client.guilds on any of these processes, will this get me the all the guilds the bot is in, or just the ones corresponding to the shard cluster?

#

as part of the bot functions it logs some stats periodically of each server on a db, so I'm wondering if I will need to do this on for example only the process with shard 0 or maybe will have to do it in a decentralized manner later on

errant trout
lament totem
#

I see now, thank you 😄

dawn prism
#

Hi it's been a while ! I'm having a weird bug and I don't know if I'm doing something wrong here.

I have a /help command and cog owner. The only way to show the commands of the cog owner and to use them is to match a check which here is being the bot's owner or an admin of the guild.

One of my user who's the administator of a guild see the commands in the help but can't execute them, here is the two code snippets (help then cog check) :

sage tendon
#

you cant limit showing slash commands to only certain people

#

you can limit it to roles inside of discord tho

#

admins are exempt however

dawn prism
# sage tendon you cant limit showing slash commands to only certain people

Not what I'm aiming, the /help command list the commands of each cog so I just skip the cog if its not an owner. My admin commands are hidden to people, I just dont want them to be able to list them.

Its just that I was using the cog_check method to avoid having to write @discord.default_permissions() everytime

#

And I'm wondering why the same code snippet await self.bot.is_owner() or ctx.author.guild_permissions.administrator does not work in different cases

sage tendon
#

ah

lapis dock
#

So it works properly in the cog check but it lists it for everyone in the help command?

Are you sure your logic is correct? What is josix_cog.isOwner?

dawn prism
dawn prism
#

That's why my first thought is that it might come from ctx.author.guild_permissions.administrator but it's weird. The only thing that comes to my mind is that the user it also the server owner but it still admin perms

sage tendon
#

guild owners have admin

lapis dock
#

For debugging purposes can you print both of the tests in the check

dawn prism
#

I'll do that tomorrow, in my cases (bot owner) both are true which is the epxected behaviour

deft bronze
#

How can you make your app work like this?

#

In a message

sage tendon
#

those are message commands

deft bronze
rugged lodgeBOT
#

Here's the context menus example.

deft bronze
#

Thanks

round heart
#

You can link slash commands, but can you link them with arguments pre-filled?

lofty parcel
#

Not anymore

round heart
#

(╯°□°)╯︵ ┻━┻

nova epoch
#

This isn't really Py-cord, but I shall ask anyways because it is Python and Discord related:

I would like to make a script to send a message to a specific channel every x duration. I have accomplished this, working fine and as-intended after testing, but my main concern is the Discord ToS... is there any limitations to using scripts like these?

TIA :)

little cobalt
#

and do you use the discord API for it?

nova epoch
#

It's my personal account (though I used an alt for testing in case of ToS), using [{BASE_URL}](https://discord.com/api/v10)/channels/{chID}/messages.

lofty parcel
silk spire
#

Even with an alt lmao

nova epoch
lapis dock
#

That is something a normal bot can do just fine, there is no reason to use a user token unless it is for malicious purposes

hazy turret
#

Why is it not possible to update the Paginator in a Paginator class class CustomPaginator(Paginator): if it has been sent ephemeral?
That must work somehow? When I click on the Next button, it is also edited 🤔

async def update_pages(self):
   self.filtered_cards = self.filter_cards_by_generation()
   pages = self.create_pages()
   await self.update(
       pages=pages,
       use_default_buttons=False,
       custom_buttons=[self.prev_button, self.page_indicator, self.next_button],
       show_disabled=True,
       show_indicator=True,
       loop_pages=False,
       custom_view=self.custom_view,
   )

I then always get Message not Found

hazy turret
#

When I try it this way, it works:

paginator = CustomPaginator(self.bot)
await paginator.respond(ctx.interaction, ephemeral=True)
await asyncio.sleep(3)
await paginator.update(show_disabled=True, show_indicator=False, use_default_buttons=True)

When I try to use the update_pages function in the Paginator class I always get:
discord.errors.NotFound: 404 Not Found (error code: 10008): Unknown Message

class CustomPaginator(Paginator):
    def __init__(self, bot: discord.Bot):
        self.bot = bot
        self.custom_view = CustomSortView(self)

        super().__init__(
            pages=self.create_pages(),
            use_default_buttons=True,
            show_disabled=True,
            show_indicator=True,
            loop_pages=False,
            custom_view=self.custom_view,
        )

    async def update_pages(self):
        pages = self.create_pages()
        await self.update(
            pages=pages,
            use_default_buttons=True,
            show_disabled=True,
            show_indicator=True,
            loop_pages=False,
            custom_view=self.custom_view,
        )
lapis dock
#

try passing interaction into self.update

hazy turret
# lapis dock try passing `interaction` into `self.update`

What should I do with it then?
Because that's not the only way it works

    async def update_pages(self, interaction):
        pages = self.create_pages()
        await self.update(
            pages=pages,
            use_default_buttons=True,
            show_disabled=True,
            show_indicator=True,
            loop_pages=False,
            custom_view=self.custom_view,
        )```
lapis dock
#

Pass it into self.update as well. You could also have it default to None when you are not using it in the context of a deferred message

hazy turret
lapis dock
#

Hmm, I think this might be a limitation of ext.pages. It does not handle ephemeral messages very well.
I have to go for now though sorry

hazy turret
lapis dock
#

you can pass current_page to the update method

hazy turret
lapis dock
#

You should be able to

hazy turret
# lapis dock You should be able to

Okay, very good. It worked.
If I want to change the content of the embeds then this only works via the update() function or?
I have the problem that I change the order of the embeds from the Paginator and move them one forward or backward using the button. Then of course I have to recreate the embed and update the Paginator so that the new order is displayed. That works so far.
But I would like to have it so that I am then directly back on the page that I have moved and I currently do that via goto_page() but that then solves
This interaction has already been responded to before
is triggered.
If I set current_page in the update function, then I don't end up on the page that I moved but on the page that is then at the position. So if I move from 3 to 2 I want to end up at 2 after the update but with current_page I end up at 3 again.

lean garnet
#
    @discord.ui.button(label="Annuler", style=discord.ButtonStyle.danger)
    async def cancel(self, button, interaction: discord.Interaction):
        self.disable_all_items()  
        await interaction.response.edit_message(view=self)

According to the guide, this is supposed to disable all buttons. But it gives this error :
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction

Can anyone help ?

sage tendon
#

is it an ephemeral message?

ebon swift
#

Is it okey to use pycord with python 3.13 ? since I updated to python 3.13 I get this error message :

Traceback (most recent call last):
File "/app/main.py", line 3, in <module>
import discord
File "/app/.cache/pypoetry/virtualenvs/mybot-9TtSrW0h-py3.13/lib/python3.13/site-packages/discord/__init__.py", line 27, in <module>
from . import abc, opus, sinks, ui, utils
File "/app/.cache/pypoetry/virtualenvs/mybot-9TtSrW0h-py3.13/lib/python3.13/site-packages/discord/abc.py", line 58, in <module>
from .voice_client import VoiceClient, VoiceProtocol
File "/app/.cache/pypoetry/virtualenvs/mybot-9TtSrW0h-py3.13/lib/python3.13/site-packages/discord/voice_client.py", line 55, in <module>
from .player import AudioPlayer, AudioSource
File "/app/.cache/pypoetry/virtualenvs/mybot-9TtSrW0h-py3.13/lib/python3.13/site-packages/discord/player.py", line 29, in <module>
import audioop
ModuleNotFoundError: No module named 'audioop'
torn barn
#

You need to install audioop-lts

#

As the audioop module was removed from the stdlib

ebon swift
#

hooo I didn't knew that, is it written somewhere in the doc ? (just curious if I missed it)

sage tendon
#

no

ebon swift
#

will audioop-lts at some point be a dependency of py-cord ?

sage tendon
#

no

#

itll be fixed in 2.7

ebon swift
#

okay thank you very much for those answers, as always you give short straight to the points answers 👌

torn barn
sage tendon
#

It doesn't fix the underlying issue that python uses a now-removed and previously-deprecated feature of the standard library

ebon swift
sage tendon
#

i'm pretty sure the fixed implementation is already on master anyway

obsidian blaze
ebon swift
#

quick questions : is it normal that even if there is no place my bot is up (I shutted it down a few mins ago) , the bot shows it's up and commands are still available and running ?

little cobalt
#

after that if the bot is still running, do a token reset

echo wraith
ebon swift
#

I swear I'm reading my code line by line to check if my token has leaked

little cobalt
#

You can do a force shutdown with a Token reset

ebon swift
sage tendon
#

yknow, you can just search for the token in your project files?

#

or as zervy said, just reset the token

ebon swift
ebon swift
sage tendon
#

why would someone who has your bot token clone your bot repo and run your bot

ebon swift
#

I work in cybersecurity and make some CTFs challenges, some participant who know my github often browse my code in hope to find challenges solves before competition starts

sage tendon
#

not even comparable at all

ebon swift
#

still it already happened

#

and I was jsut wondering if it was mostly possible that it was an error on my side or that discord somehow when bot is able to run the most simple commands that don't require any outside discord interactions

sage tendon
#

you just have a rogue terminal still running on your pc, its nothing

ebon swift
#

okay I'll check that weird that it still shows up after rebooting my computer tho, I'll have a look thank u

sage tendon
#

VPS?

ebon swift
#

self hosted on mini pc

#

rn I'm less freaking out cause yes I can just token reset but I'm getting really curious if no one is running it where is it running x)

sage tendon
#

just reset the token, then the problem is solved

ebon swift
#

found it

#

really dum situation , forget about me burries himself

sage tendon
#

what was it

nova epoch
#

Looking for a solution to read the config.yml file ONCE, but being able to use it in the main.py along with all other cogs (there is only one at the moment, but there will be 8+). Directory structure is in the screenshot attached. TIA!

ebon swift
#

thank you for talking about VPS, I add an old VPS which I used for testing purposes, I tested the bot on it once to debug some firewall issues on my network , I gave ownership of the VPS to a friend when he booted it up the docker service booted up too....

ebon swift
#

I asked him to compose down the bot

nova epoch
sage tendon
#

load it and save it as a bot attribute in main.py

ebon swift
nova epoch
#

Using bot['attribute blah blah'] = value?

sage tendon
#

bot.attr should work

nova epoch
#

oooh okay, one sec lemme try it rq

#

Works (kinda) as intended so I shall do some playing around and see what I can do, thank you :D

errant trout
ebon swift
#

Really?

errant trout
#

yes

ebon swift
#

That's op ! Are you notified ?

errant trout
#

pretty sure? haven't tried it myself

#

iirc the admins here also have a command that posts tokens people post in help threads to a github gist to forcefully reset it

lofty parcel
ebon swift
#

really great

lapis dock
loud kayak
#

How do I fix this error that randomly happens during runtime?

#

Causes the bot to crash

obsidian blaze
obsidian blaze
# lapis dock Sorry, try `file=`. My bad

No worries!

This is what I currently have

await channel.send(file=discord.File(tts, filename="motivation.mp3"), voice_message=True)```

Put I seem to be getting this `TypeError: Messageable.send() got an unexpected keyword argument 'voice_message'`
lapis dock
#

Are you sure you have the PR installed? IT has not been merged yet

#

I have to go for a bit but if you are still having troubles I will look into it later

obsidian blaze
#

Ah I see, didn't realize when you switched branches in github it would default to the main branch for install. got it thanks!

sage tendon
unkempt shore
#

what is the difference between pycord and something like discord.py or nextcord or disnake

sage tendon
#

its just different libraries, they're largely the same featurewise and mostly differ in syntax

sage tendon
unkempt shore
#

woah

#

ty

obsidian blaze
silver lichen
#

Any idea why it doesn't work at all and bot is not even listening to it? No errors in console

from discord.ext.commands.cog import Cog

bot = discord.Bot()```

class logging(Cog):
def init(self, bot):
self.bot = bot
@Cog.listener()
async def on_member_join(self,member):
some code

def setup(bot):
bot.add_cog(logging(bot))

Everything works fine except on_member_join,on_member_remove,on_member_ban
silver lichen
# rare marlin @commands.Cog.listener()

i'm using "from discord.ext.commands.cog import Cog" is it so much difference between from "discord.ext.commands.cog import Cog" and "from discord.ext import commands"?

rare marlin
#

Weit

#

Weit go am on pc

silver lichen
rare marlin
silver lichen
#

It's not the thing

little cobalt
rare marlin
#

hm

rare marlin
little cobalt
#

with discord.Bot it would be discord.Cog.listener()

silver lichen
#

Guys.
Cog.listener() is the right way for me.
For example

@Cog.listener()
async def on_ready(self):
  some code

works fine
But not on_member_join()

sage tendon
#

do you have the intents to receive that event?

silver lichen
sage tendon
#

show

#

oh I saw above

#

you never pass the intents to your bot

silver lichen
sage tendon
#

you tell me

silver lichen
sage tendon
#

well in the code you sent it's wrong

silver lichen
sage tendon
frail basin
#

can bots fetch this somehow?

sage tendon
#

no afaik

#

you have to track invites manually for that

frail basin
#

Thats so dumb

#

Are there any alternative ways to join other than invites and server discovery?

sage tendon
#

theres a lot of stuff bots cant get, even indirectly

frail basin
#

With the OAUTH scope you mean?

sage tendon
#

these are the official ones

#

student hub doesnt apply, ofc

#

manual verification only applies to "guilds"

frail basin
#

right, forgot I can query that

frail basin
sage tendon
#

No, the new guilds feature

frail basin
#

oh that clan thingy

sage tendon
#

clan servers, yknow, with the dumb tags next to ones name

round heart
#

They clobbered the term guild?

#

Or do they call it clans

sage tendon
#

They call it guilds

round heart
#

Fucking discord

echo wraith
#

😭

sage tendon
#

nice embed dipshit

round heart
#

Yes let’s rename the entire base concept of our platform

sage tendon
#

i think they wanted to avoid the name "Clan" because Clan is seen quite negatively outside of the narrow scope of gaming

#

e.g. KKK....

#

etc

round heart
#

lol that’s fair

#

“Groups”

sage tendon
#

No, guild is a fair name

#

The real stupidity is discord calling servers guilds internally

#

i never understood that

#

guild is a common name for clans in RPGs

round heart
#

Yeah and the servers were originally used for those likeminded groups of people.

sage tendon
#

I mean to be really honest
I dont see the need to call it guilds, or clans, or anything
these features should just be available, period

#

I've been on the waitlist ever since i heard of guilds
Guess whether i'm in yet
(no)

#

yet another abandoned feature by discord
abandoned before even releasing it, new best

#

i do wonder what discord is working on
its been a bit since the last "woah nice" release imo

silk spire
#

They don't even want to document the shit

lapis dock
obsidian blaze
hazy turret
#

Are the bot emojis now integrated in 2.6.1 so that you can use them as normal?

sage tendon
#

no

shell radish
#

yes

sage tendon
#

2.7, no?

shell radish
#

you can use them

#

there’s nothing special to using them

sage tendon
#

yea but there is no proper library support for fetching them all etc pp

shell radish
#

you can’t upload/edit them via lib yet

shell radish
sage tendon
#

yea but thats meh

shell radish
#

you don’t have an enum for all your emojis?

sage tendon
#

no

hazy turret
# shell radish yes

I only have 6 emojis that I use, of which I know the ID. Can I get them with 2.6.1 without problems with get_emoji and display them in an embed?

shell radish
#

no

hazy turret
# shell radish no

How can I then use the bot emojis across servers without having to have the emojis on a server and always having to retrieve the emojis there?

shell radish
#

if you know the ids, you can just use them in markdown form

hazy turret
shell radish
sage tendon
#

press this in the dev portal

hazy turret
#

Ah okay and then I can display the emojis on any server where the bot is also on it?

sage tendon
#

yes

hazy turret
#

Okay, thanks!

errant trout
flat wind
#

is it possible to get this information from the bot ?
I tried guild.system_channel but it returns me None on my community server, and returns me a random channel in the non community servers

#

okay mb it was guild.public_updates_channel

hazy turret
#

Is it possible to define a discord.SlashCommandGroup outside of a cog and register it at bot start and then use it in multiple cogs?

fresh sierra
hazy turret
fresh sierra
hazy turret
# fresh sierra https://github.com/Dorukyum/pycord-multicog

I have tried that:

config = discord.SlashCommandGroup(
    "config",
    description="Commands for configuring the bot or server.",
    default_member_permissions=discord.Permissions(administrator=True),
    contexts={discord.InteractionContextType.guild},
)
bot.add_application_command(config)
from group import config

class Test(discord.ext.commands.Cog):

    def __init__(self, bot):
        self.bot = bot

    @config.command(description="test")
    async def test(self, ctx: discord.ApplicationContext):
        await ctx.send("test")

def setup(bot):
    bot.add_cog(Test(bot))

But I always get this error:

       | Ignoring exception in on_connect
       | Traceback (most recent call last):
       |   File "/usr/local/lib/python3.11/site-packages/discord/client.py", line 412, in _run_event
       |     await coro(*args, **kwargs)
       |   File "/usr/local/lib/python3.11/site-packages/discord/bot.py", line 1214, in on_connect
       |     await self.sync_commands()
       |   File "/usr/local/lib/python3.11/site-packages/discord/bot.py", line 742, in sync_commands 
       |     registered_commands = await self.register_commands(
       |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
       |   File "/usr/local/lib/python3.11/site-packages/discord/bot.py", line 595, in register_commands
       |     data = [cmd["command"].to_dict() for cmd in filtered_deleted]
       |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
li     |   File "/usr/local/lib/python3.11/site-packages/discord/bot.py", line 595, in <listcomp>
       |     data = [cmd["command"].to_dict() for cmd in filtered_deleted]
       |             ^^^^^^^^^^^^^^^^^^^^^^^^
       |   File "/usr/local/lib/python3.11/site-packages/discord/commands/core.py", line 1341, in to_dict
       |     "options": [c.to_dict() for c in self.subcommands],
       |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
       |   File "/usr/local/lib/python3.11/site-packages/discord/commands/core.py", line 1341, in <listcomp>        
       |     "options": [c.to_dict() for c in self.subcommands],
       |                 ^^^^^^^^^^^
       |   File "/usr/local/lib/python3.11/site-packages/discord/commands/core.py", line 943, in to_dict
       |     "options": [o.to_dict() for o in self.options],
       |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
       |   File "/usr/local/lib/python3.11/site-packages/discord/commands/core.py", line 943, in <listcomp>
       |     "options": [o.to_dict() for o in self.options],
        |                 ^^^^^^^^^^^
         |   File "/usr/local/lib/python3.11/site-packages/discord/commands/options.py", line 358, in to_dict
        |     "type": self.input_type.value,
        |             ^^^^^^^^^^^^^^^^^^^^^
        | AttributeError: 'NoneType' object has no attribute 'value'
```
sage tendon
hazy turret
sage tendon
#

Yes

fresh sierra
#

Like custom decorator etc

#

But multicog is the easiest way

sage tendon
#

yea but that's unnecessary lol

fresh sierra
hazy turret
#

Okay, I'll have a look at it

#

Thanks

undone merlin
#

Is there something that can forcefully move the user out of a channel when their permissions have been revoked

#

Like lets say I'm the user and my ticket has been closed. I can't type anything in the ticket/channel nor can I see it in the channel list. However I can still ''see'' it as a ghost page

sage tendon
#

afaik that only happens for public threads

#

for channels and private chats you should be completely taken out unless you are a moderator or admin

undone merlin
#

Not happening for me. I can invite you to the testing server to see it

fresh sierra
#

i dont think we can do anythng

sage tendon
#

you are the owner there, right?

fresh sierra
#

except report that to discord

undone merlin
sage tendon
#

yea then you cant test it yourself lol

#

unless you have an alt

undone merlin
#

I tested it on my alt

#

from my alt*

fresh sierra
#

because its mostly a bug

sage tendon
#

ah

#

so what is it, a private thread?

undone merlin
#

A channel

#

It's basicall a ticket system. There's a "Close" button when a user makes a ticket. When a user clicks on it their permissions from the channel gets revoked and only moderators can see the channel

sage tendon
#

well, either way you wont receive any new messages, so its not a privacy / safety issue in that regard

fresh sierra
#

here a demo

sage tendon
#

at most you could give them like a "back to <main channel>" message i suppose

fresh sierra
#

so just report it to discord thats the only way

sage tendon
#

can you test the same with a private thread? threads do work differently

fresh sierra
undone merlin
sage tendon
#

yea something like that doesnt exist

undone merlin
sage tendon
#

that would be basically a hostile takeover of the UI lol

fresh sierra
sage tendon
#

if anything they'd get a blank middle pane

errant trout
#

yeah that's been a thing forever

#

the only way to actually redirect would be to delete the channel/thread entirely

sage tendon
#

oh, that blanks out the middle pane too?

errant trout
#

strictly speaking they could apply the same logic on permission changes, but they don't for whatever reason GuraShrug

#

(i don't really think it's too important because ultimately you're only seeing messages you already had access to, but i can see why the behaviour is annoying)

hazy turret
#

Can I delete an ephemeral Paginator message if I have defined the Paginator as a class?
class CustomPaginator(Paginator):
Somehow via self.message.delete() or another option?

tawdry prism
#

I don’t know if this is more suitable in #general or not. Is the paginator a discord api thing or just a pycord thing built using interactions?

sage tendon
#

its pycord

hazy turret
#

Okay, that's how it works. I don't know if it's the cleanest way, but the message can be deleted in any case.

interaction = await paginator.respond(ctx.interaction, ephemeral=True)
paginator.response_message = interaction


await self.response_message.delete()
lapis dock
# obsidian blaze So sorry to keep bothering you. But I was able to get the right repo installed. ...

When creating the file you should wrap it in a discord.File object with waveform and duration_secs set

tts = await TTS().generate_tts(script)
channel = self.bot.get_channel(987475882732036098)
await channel.send(file=discord.File(tts, filename="motivation.mp3", waveform="AA==", duration_secs=5.0), voice_message=True)

These values do not need to be accurate for this to work. Waveform can be any base64 encoding string. I think AA== just means blank. And duration seconds will be regenerated to be accurate when a user hovers over the voice message "card".

obsidian blaze
#

Got it thanks

obsidian blaze
round heart
#

Am I able to have the potential for both ephemeral and public responses for a command? I want to give errors privately but results publicly.

#

mm, I see @sage tendon and @daring valve discussed this in #general a couple of weeks ago. Guess not.

#

...although public calls will get my exception handler privately. 🤔🤔

lapis dock
#

You can (almost) always use .send

errant trout
round heart
errant trout
#

well it's a pain to explain

#

if you defer, your next response is locked to either ephemeral or not

#

anything after that, you can freely switch between ephemeral=True and ephemeral=False

round heart
#

your next response is locked to either ephemeral or not

... vs what other type of response?

errant trout
#

well like

#

when you defer, ephemeral is attached to the defer itself

#

so let's say you defer(ephemeral=False) at the very start of the command but then you error, your error message can't be ephemeral

#

though you could do some hacky delete/response before erroring

round heart
#

Oh, so when deferring, you can only respond based on the ephemeral state of the defer?

errant trout
#

yes

#

that only applies to the immediate next response

#

after that response, switching is allowed

#

(rules are also different for components)

round heart
#

But if you are responding, that's the end of the interaction, is it not? At least when talking specifically about message responses

And even if it wasn't, is there some other type of 'non-message response' one could use to hack around it, so that I can do that operation and then actually reply to the interaction with the ephemeral message?

errant trout
#

the easiest hack is ctx.defer -> ctx.delete, but that will show to the user

undone merlin
round heart
crimson lily
#

How to preserve the image while editing the embed?

#

Any other way rather than setting it to the image_url again

sage tendon
#

by editing you mean replacing it with a new embed while editing the message right
because then no, there's no way around that

crimson lily
#

Alright

#

And is there any way to refresh slash_commands?

#
async def add_post(ctx, campaign: Option(str, "Select Campaign", choices=get_active_campaigns())

This is how they get their options, and once a campaign gets added they dont change because I'm guessing slashcommands are registered right on startup

#

so wondering if there's a function that re-registers them per se

#

I'm guessing i can do

await self.bot.remove_command(command.name)
self.bot.add_slash_command(self.add_post)

but doing that for each command doesnt seem to be the best method

sage tendon
#

you can use autocomplete instead

#

but autocomplete does not force the user to select a given option, its just suggestions, so you still have to check it yourself

#

the other option is to sync your commands but that will run you into issues sooner or later if you change the options often

crimson lily
#

hmm ill check it out, thanks

#

yep await client.sync_commands() works
dont change them often, maybe twice a week
wont be an issue right?

sage tendon
#

no

jaunty blaze
#

I want my bot to do certain things when a cog is loaded and the bot is ready. Is it safe to put one listener into each cog? Given that they all do only their stuff and don't interfere with each other.

@Cog.listener(once=True)
async def on_ready(self):
  do_stuff()

E.g. I'd like to have each cog to retrieve and register any persistent views that were created with its respective commands.

lofty parcel
#

Yes

sage tendon
#

doesnt the on_ready event mean the bot's on ready?

jaunty blaze
#

yeah

sage tendon
#

then you cant use that (?), just do it in the cog's init
on_ready is (usually) only called a single time

jaunty blaze
#

I can't do it in the init, since the initialization is happening async, though.

sage tendon
#

asyncio.run()

lofty parcel
#

I have an on_ready listener for my cogs that have persistent views

#

¯_(ツ)_/¯

sage tendon
#

oh nvm im dumb, forget what i said

jaunty blaze
#

okay obamaxd

#

Until now I had a separate EventCog with the listeners, but I figured it would be better for maintenance to have all functionality for a certain feature bundled in a package, including setup like persisting views.

#

Thanks for the response!

nova epoch
#

py-cord compatible with 3.13 yet? Having a lot of issues related to libraries/packages/etc not being found even after uninstalling & reinstalling py-cord. Have also tried creating a venv but that flags other errors that I really can't be bothered to deal with (I am not the best with using venv). TIA

sage tendon
#

all you need to do is install audioop-lts

#

until 2.7 releases

lapis dock
#

The only things that are not compatible that I am aware of are audioop (solution install audioop-lts) and commands Flags for prefix commands

sage tendon
#

wait why are flags affected?

nova epoch
#

I'm not using prefix commands so I'm assuming I just ignore that bit?
I'll do a quick py -3 -m pip install audiooop-lts and see what happens :)

lapis dock
#

only 2 os but yeah

sage tendon
nova epoch
#

Just realised that lol >.>

lapis dock
lofty parcel
graceful spindle
#

Can I add images to a bot activity like as a game?

#

Like for example
Playing

GTA V

image

lofty parcel
#

As far as I know, no. Those are rich presences and I don't think there's a way for bots to have them.

graceful spindle
#

Alright no worries thank you :D

fallen torrent
#

are thhere any public user applications i can look at to get an idea of how to make one? dont know what changes there are between a user app and a bot

rugged lodgeBOT
#

Here's the slash users example.

errant trout
#

e.g. assuming the bot doesn't share the guild with the user, it wouldn't be able to access anything useful in ctx.guild

fallen torrent
errant trout
#

no

#

wait

#

sorry, misread

#

it'll work as normal for guilds the bot is actually in

fallen torrent
#

okay sweet

errant trout
#

you can check if it was run in user install by getting ctx.interaction.authorizing_integration_owners and seeing if user_id is set; you should thoroughly debug what resources are available in either context

deft kestrel
#

how do I install the dev version ?

fresh sierra
#

.tag master

sly karmaBOT
#

pip install -U git+https://github.com/Pycord-Development/pycord

deft kestrel
#

that would install the normal py-cord right

fresh sierra
#

As you can see, it will install the development one so should be the development version/master

deft kestrel
#

Okay. Thank you

tawdry prism
#

You should be able to do pip install -U git+https://github.com/Pycord-Development/pycord.git@refs/pull/2598/head

shadow bear
#

How do you use commands.flags?

#

I can't find any docs for it outside of docstrings

#

nvm, found docs

#
class UserOrEmailFlags(commands.FlagConverter, delimiter=' ', prefix='--', case_insensitive=True):
    member: discord.Member
    reason: str
    days: int = 1
Traceback (most recent call last):
  File "/home/nex/PycharmProjects/ces-bot/.venv/lib/python3.12/site-packages/discord/cog.py", line 784, in _load_from_module_spec
    spec.loader.exec_module(lib)  # type: ignore
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/home/nex/PycharmProjects/ces-bot/src/ces_bot/cogs/email_verify.py", line 13, in <module>
    class UserOrEmailFlags(commands.FlagConverter, delimiter=' ', prefix='--', case_insensitive=True):
  File "/home/nex/PycharmProjects/ces-bot/.venv/lib/python3.12/site-packages/discord/ext/commands/flags.py", line 340, in __new__
    for flag_name, flag in get_flags(attrs, global_ns, local_ns).items():
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/nex/PycharmProjects/ces-bot/.venv/lib/python3.12/site-packages/discord/ext/commands/flags.py", line 173, in get_flags
    flag = Flag(name=name, annotation=annotation, default=flag)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Flag.__init__() got an unexpected keyword argument 'name'

Do flags just not work? I'm literally using the example code

#

or am I doing something daft

sage tendon
#

which pycord version

#

@frank otter apparently even on 3.12 flags are broke

shadow bear
#

Went as far back as 2.5.0, same issue. Can't go lower without downgrading python

#

Is there an issue open?

shadow bear
little cobalt
#

I wonder if flags got even updated in the past (I dont even know how to use them xd)

shadow bear
#

well the last update was a year ago to "fix flags again..."

#

I can't see why they're broken tbh, the code looks fine

#

Well, I've gotten around it by making my own Flag class, using a pydantic model and just inheriting from commands.Flag

#

It doesn't error now but it also doesn't work 😛

#

It's fine, I'll just use something else

sage tendon
#

tho, what did you change since it last worked

shadow bear
shadow bear
#

But, it doesn't actually work in practice, since the flags just use their default values, I presume not being populated properly for pydantic

lapis dock
sage tendon
#

F

#

was wondering why the ping was only called wolfy

shadow sigil
#

is it possible to have slash commands on a bot added to a user?

sage tendon
#

yes lol

#

you can't have prefix commands for a matter of fact so slash commands are your only choice (+ message and user commands)

shadow sigil
#

are you able to use those commands in servers or is it limited to like messaging the bot or something

sage tendon
#

everywhere

#

thats the whole point of user apps

shadow sigil
#

do you need to do something different from when it's on a server then?

sage tendon
#

in what way

shadow sigil
#

cause the commands are not showing up everywhere for me

sage tendon
#

It's a discord bug

#

On desktop, they dont show if you dont have either of the "use application commands" permissions
But you can still find them in the list if you only type / and then navigate there by mouse

#

On mobile it works like normal

#

but you can use user app slash commands everywhere you can type

shadow sigil
#

i can't say i could find them anywhere

sage tendon
#

are you sure you installed the bot on your account

shadow sigil
#

not when using the menu or when typing a slash or on mobile

#

yes

sage tendon
#

and did you set proper integration types in the commands?

shadow sigil
#

like
it shows up in the apps thing

#

but there's nothing there

sage tendon
#

just do this if its only a user bot and not meant to be installed on servers

shadow sigil
#

it's meant to work for both

shadow sigil
sage tendon
#

then add guild_install as well into that list

shadow sigil
#

okay

sage tendon
#

thatll make every command work for a user install and server install

#

you can also do it per command but i suppose you want all commands

rugged lodgeBOT
#

Here's the slash users example.

lapis dock
shadow sigil
#

i don't really have any server specific commands that aren't already set to only be usable in a server so

round heart
#

Hm. View.add_item() supposedly injects item._view, (here), but getting an attribute error when trying to access it.

Wasn't that supposed to be A Thing that happens?

mint solar
#

@discord.utils.copy_doc(Interaction.respond)
^^^^^^^^^^^^^^^^^^^
AttributeError: type object 'Interaction' has no attribute 'respond'. Did you mean: 'response'?

why is it like this when I run the bot?

#

File "/home/runner/dcbot/.pythonlibs/lib/python3.11/site-packages/discord/commands/context.py", line 271, in ApplicationContext
@discord.utils.copy_doc(Interaction.respond)
^^^^^^^^^^^^^^^^^^^
AttributeError: type object 'Interaction' has no attribute 'respond'. Did you mean: 'response'?

torn barn
#

This means you installed other packages that use the Discord namespace

#

Please make sure you only have py-cord installed

#

.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

lapis dock
#

Yeah, you installed discord which is not compatible with py-cord

tawdry prism
#

Are there any good examples on how to modify a view based on a component callback? Adding/removing/disabling other components and such?

sage tendon
#

view.add_item is one i know

echo wraith
tawdry prism
#

That was my guess, I just need to figure out if I'm finding the right edit.

    async def button2_callback(self, button, interaction: discord.Interaction):
        self.get_item('schedule_button').enabled = False
        await interaction.edit_original_response(view=self)
sage tendon
#

does it work?

tawdry prism
#

Nope, threw a 404 exception (let me know if I should just create a separate post).

Ignoring exception in view <ScheduleView timeout=180.0 children=2> for item <Button style=<ButtonStyle.primary: 1> url=None disabled=False label='Hide Schedule' emoji=<PartialEmoji animated=False name='😎' id=None> sku_id=None row=None>:
Traceback (most recent call last):
  File "/home/planbot/venv/planbot/lib/python3.9/site-packages/discord/ui/view.py", line 426, in _scheduled_task
    await item.callback(interaction)
  File "/home/planbot/planbot/planbot.py", line 17, in button2_callback
    await interaction.edit_original_response(view=self)
  File "/home/planbot/venv/planbot/lib/python3.9/site-packages/discord/interactions.py", line 513, in edit_original_response
    data = await adapter.edit_original_interaction_response(
  File "/home/planbot/venv/planbot/lib/python3.9/site-packages/discord/webhook/async_.py", line 222, in request
    raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10015): Unknown Webhook
sage tendon
#

is it an ephemeral message?

tawdry prism
#

Yes.

sage tendon
#

oof

#

try await interaction.response.edit_message

tawdry prism
#

I think I did so but let me try again. Like this: await interaction.response.edit_message(view=self)

sage tendon
#

also consider upgrading your python version lol, 3.9 is really old

tawdry prism
#

I know, working on a vhost I'm running another bot on. Not keen to write another d++ bot though.

sage tendon
#

d++?

tawdry prism
#

"Lightweight and simple" kekw

#

So edit_message is not throwing any error, it just doesnt disable the other button.

errant trout
#

(also for convenience, interaction.edit exists)

tawdry prism
#

Ouch, thanks. I did confirm the oops was on me by editing buttonstyle.

#

Thank you Toothy and Nelo.

errant trout
#

allgood

tawdry prism
#

Is there a smart built in way to persist selections when you edit the interaction?

errant trout
#

but i'd only recommend this in ephemeral messages, or if your menu is disabled

tawdry prism
#

Will be ephemeral, yes. Several selects where the choice will populate the next.

errant trout
#

then yeah that's fine

#

just wouldn't bother in a public-facing menu since everyone will see the defaults that some other user just applied and it gets messy

tawdry prism
#

Oh, values is just List[str]. Have to next .options and .values then.

errant trout
#

oh yeah mb, i guess just map values back to options

tawdry prism
#

This worked fine, need to reset in case you remove one of the options that were previously selected:

    def _select_default(self, select: discord.ui.Select) -> None:
        for option in select.options:
            option.default = False
            for value in select.values:
                if option.value == value:
                    option.default = True
errant trout
#

you could probably flip it and do for o in options: if o.value in select.values: ... else: ...

tawdry prism
#

That’s true. My usual style is brute forcing while doing poc and cleaning up after. 🙂

errant trout
#

fair ww

round heart
tawdry prism
tawdry prism
round heart
#

I don't, no. But I always put my Selects as a separate class and add using add_item() in the View because I tend to have additional logic (whereas buttons are just a single callback)

errant trout
#

mmmm shouldn't be? always worked fine on my end

#

your decorated functions are typically treated as the object itself

#

works with commands too

tawdry prism
#
    @discord.ui.select(placeholder='Select day to schedule for...',
                       options=[discord.SelectOption(label='Select day')],
                       custom_id='day_select',
                       disabled=True)
#

Should I be able to refer to this as self.day_select in another handler?

errant trout
#

no by the function name

round heart
#

Not unless the function you're wrapping is also called day_select

errant trout
#

well idk what it is in that snippet

tawdry prism
#

Oh. Doh.

#

Again, thank you very much.

tawdry prism
#

Is it possible to remove an ephemeral response completely or is it up to the user to dismiss?

errant trout
#

(forgot to implement interaction.delete)

tawdry prism
#

await interaction.delete_original_response() throws a 404 for me.

errant trout
#

did you actually respond

#

defer also counts

tawdry prism
#

Do I need to respond or defer before I delete? It's in a button callback.

errant trout
#

yes

lofty parcel
#

What would you delete if you didnt respond ?

errant trout
#

if it's a button, defer is ideal because by default it's "invisible"

#

so it doesn't create a new message

#

(whereas defer in command always creates a new message)

tawdry prism
errant trout
#

if it was the original command response, you want ctx.delete

tawdry prism
#

The slash command handler posts a message with a view, the view has a cancel button. Should I save the context my slash command handler gets?

errant trout
#

there's a few approaches

tawdry prism
#
        await interaction.response.defer(ephemeral=True)
        await interaction.delete_original_response()
errant trout
#

either pass the ctx to your view class, or you can use view.wait to pause the current code until you run view.stop and get some value to run back in the slash command

tawdry prism
#

This worked just fine. The slash command is just to post the ephemeral message with my view. From there the component callbacks do the work.

errant trout
#

icic

tawdry prism
#

Something like this

errant trout
#

wow if only discord released the datetime picker they silently added 2 years ago

tawdry prism
#

I knoooooow

errant trout
#

death be upon ye

tawdry prism
#

The idea is to have the schedule button post a non ephemeral view where users can sign up to any scheduled times.

#

One step at a time though.

shell radish
tawdry prism
#

People won’t. We’re having a hell of a time scheduling things and I end up having to post each hour separately and add yes and no emoji on each. So I’m automating it for me.

#

And scope creep is my middle name so here I am.

loud kayak
#

how do i fix this error that happens periodically?

client_connection: Connection<ConnectionKey(host='gateway.discord.gg', port=443, is_ssl=True, ssl=True, proxy=None, proxy_auth=None, proxy_headers_hash=None)>
container@pterodactyl~ Server marked as stopping...
Event loop stopped before Future completed.
Task exception was never retrieved
future: <Task finished name='Task-4' coro=<Client.run.<locals>.runner() done, defined at /home/container/.local/lib/python3.9/site-packages/discord/client.py:789> exception=RuntimeError('Concurrent call to receive() is not allowed')>
Traceback (most recent call last):
  File "/home/container/.local/lib/python3.9/site-packages/discord/client.py", line 791, in runner
    await self.start(*args, **kwargs)
  File "/home/container/.local/lib/python3.9/site-packages/discord/client.py", line 755, in start
    await self.connect(reconnect=reconnect)
  File "/home/container/.local/lib/python3.9/site-packages/discord/shard.py", line 475, in connect
    raise item.error
  File "/home/container/.local/lib/python3.9/site-packages/discord/shard.py", line 180, in worker
    await self.ws.poll_event()
  File "/home/container/.local/lib/python3.9/site-packages/discord/gateway.py", line 610, in poll_event
    msg = await self.socket.receive(timeout=self._max_heartbeat_timeout)
  File "/home/container/.local/lib/python3.9/site-packages/aiohttp/client_ws.py", line 315, in receive
    raise RuntimeError("Concurrent call to receive() is not allowed")
RuntimeError: Concurrent call to receive() is not allowed
Task was destroyed but it is pending!
task: <Task pending name='Task-3' coro=<Loop._loop() running at /home/container/.local/lib/python3.9/site-packages/discord/ext/tasks/__init__.py:177> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x7f3e64e92040>()]> cb=[_gather.<locals>._done_callback() at /usr/local/lib/python3.9/asyncio/tasks.py:767]>
Exception ignored in: <coroutine object Loop._loop at 0x7f3e9dca5c40>
Traceback (most recent call last):
  File "/home/container/.local/lib/python3.9/site-packages/discord/ext/tasks/__init__.py", line 201, in _loop
  File "/home/container/.local/lib/python3.9/site-packages/discord/ext/tasks/__init__.py", line 75, in cancel
  File "/usr/local/lib/python3.9/asyncio/base_events.py", line 751, in call_soon
  File "/usr/local/lib/python3.9/asyncio/base_events.py", line 515, in _check_closed
RuntimeError: Event loop is closed
#

i mainly get this on bots that are autosharded

errant trout
loud kayak
errant trout
loud kayak
errant trout
# loud kayak 2.3k guilds

my best guess is you don't have enough shards / one of your shard processes is being overloaded with events

#

in which case maybe try manually increasing the shard count

loud kayak
errant trout
#

you can manually pass shard_count into your bot init/constructor

#

though do verify how many it's currently on and choose accordingly

loud kayak
#

oh ok, it says it has 2 rn so ill increase it to 3

#

is it bad if i increase it to 4? my vps has enough resources and im only using ~3-4% of the CPU allotted.

errant trout
#

yeah just go for it

#

worst case scenario you go back down

round heart
#

While we're all gathered, anyone know why view.add_item() doesn't inject _view like the code says it does?

#

although I just realized that self.view works. I don't know why, but ok.

loud kayak
errant trout
#

Sorry I don't have much of a clue beyond it possibly being excessive events or manual reconnection logic

loud kayak
errant trout
#

That's kinda low if anything

#

So I guess the issue is elsewhere

round heart
edgy nest
#

because they're a dpy relic and nobody really knows how they work

round heart
#

Fair enough.

#

Despite the code injecting ._view in view.add_item(), as noted above, there is also a regular .view that gets populated.
...but only if you explicitly pass the _view into the Select's init method and set it to self._view

I thought maybe it was because I tried to access my view before super() (to build options), but .view continues to be None even if I super() it early.

So it's either both or nothing. Fun stuff.

shadow sigil
silk spire
# round heart Despite the code injecting `._view` in `view.add_item()`, as noted above, there ...

No, this makes sense lol

You're supposed to pass an instance of an Item to add_item, which then sets the _view attribute.

The "problem" here is that you need the view in the __init__ method, but that's already called when you instantiate it. Calling super() in early or later isn't going to fix that, it simply doesn't know about any views since it's just a stateless class.

You can consider a separate construction method where you pass the view or do your things after add_item / \_\_init\_\_\

Also, .view is a literal property that returns self._view.

shadow sigil
shadow sigil
#

is there a way to check if the bot can send a message in the context channel

sage tendon
#

generally its easiest to just send, then catch an exception

#

there are way too many reasons why you cant send in a channel, it'd be a sissyphus task to try check them all every time

#

but remember, .respond always works

shadow sigil
#

i know, just don't like how it looks in certain situations

#

such as when chaining messages

#

also, thank you pycord, very cool

Ignoring exception in on_application_command_error
Traceback (most recent call last):
  [...]
  File "D:\GitHub\fractal-rhomb\src\fractalrhomb_globals.py", line 378, in send_message
    elif not ctx.can_send(message):
             ^^^^^^^^^^^^^^^^^^^^^
  File "D:\GitHub\fractal-rhomb\.venv\Lib\site-packages\discord\abc.py", line 1833, in can_send
    if not getattr(channel.permissions_for(channel.guild.me), permission):
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\GitHub\fractal-rhomb\.venv\Lib\site-packages\discord\channel.py", line 263, in permissions_for
    base = super().permissions_for(obj)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\GitHub\fractal-rhomb\.venv\Lib\site-packages\discord\abc.py", line 734, in permissions_for
    if self.guild.owner_id == obj.id:
                              ^^^^^^
AttributeError: 'NoneType' object has no attribute 'id'
sage tendon
#

Oh right, you were the user app guy

#

yea, you cannot use .send with a user app

#

at all

#

you have to use respond

shadow sigil
#

doesn't tell me what i have to give to ctx.can_send()
gets pissed off when i give it the wrong thing

shadow sigil
sage tendon
#

yea, but just as a reminder

#

also, can_send doesn't work great and doesn't catch all cases

#

as i said, trying to send and catching the exception is the only way to be 100% certain on whether you can or can't send a message

shadow sigil
sage tendon
#

the fix is to use .respond lolw

shadow sigil
#

my problem isn't that i'm not using respond, it's figuring out when i have to use it xd

sage tendon
#

that exists, cant find it right now, give me a minute

#

if guild_id is 0, it's a user app (or someone DMing the bot)

#

e.g.

if ctx.interaction.authorizing_integration_owners.guild_id == 0:
    //respond
else:
    //send
shadow sigil
#

TypeError: Webhook.send() got an unexpected keyword argument 'silent'
the world if this thing specified its keyword arguments in a way that code analysis tools can pick up on

sage tendon
#

use the docs

shadow sigil
#

that's at least the second time i've had an issue with that

sage tendon
#

webhooks dont take silent= for some reason

shadow sigil
#

but at least this time it gave an error instead of silently ignoring it

sage tendon
#

can you show your code

shadow sigil
#

(the previous time was with commands/options and i misspelled description and wondered why it wasn't showing)

#

ok i think i got it to work

#

by just having a try except

sage tendon
#

Shrug_3 always the most reliable way as i said

shadow sigil
sage tendon
#

i mean .send will work in that case, so

shadow sigil
#

i mean
yeah

#

i guess i'll keep the try except

#

tbh, probably about time i turned my if not ctx.response.is_done(): ... else: ... into a dedicated function cause god damn i use that just about any time i send some kind of message

sage tendon
#

what does that do

shadow sigil
#

basically, makes it use .respond for the first message and .send for messages after that

errant trout
#

you could just make a custom context

rugged lodgeBOT
#

Here's the custom context example.

lapis dock
#

I don't know the full context, but why are you not just using follow-ups?

sage tendon
#

they said they don't like how it looks

loud kayak
round heart
echo wraith
#

but it feels a bit too hacky to me

round heart
#

To me, the explicit get_context is more hacky 😅

#

In an ideal world, as a bot developer, I shouldn't have to think about internals, it should Just Work

errant trout
errant trout
round heart
errant trout
#

Tf is introspection? Are we meditating in 3.0

round heart
#

Identifying the typehints in the callback and knowing which one to utilize. It's something I've seen in another module called meatie that Paillat and I have been looking at

#

Unrelated, is there a way to fix the 'bouncing' for View items? When pressing a button or using a dropdown that changes which buttons are available, the button press obviously disables the inputs, but then it returns, making buttons 'active' for a moment until the interaction.edit() goes through

Is it because I'm doing a defer?

errant trout
#

I don't think you can prevent that

#

The lag between the button "re-enabling" and the edit applying should be minimal

round heart
#

It is, but looks 'hacky' (to use the word of the day). Discord clearly knows the state of the buttons before the submit, wasn't sure if you could update that before it returns

errant trout
#

Idk if you're editing as fast as possible then not much else you can do

tawdry prism
#

Could you disable instead of deferring and then editing the response afterwards?

round heart
#

I tried that already, but unfortunately it doesn't seem the Discord client actually cares about state when completing the interaction. It's just locking/unlocking the View as-is.

Kinda shortsighted as it would actually save round-trips to get new state info before unlocking the View, but as Nelo says, whatcha gonna do

loud kayak
# errant trout You couldddd but I can't guarantee anything

is this error related to the other one? this also crashed the bot, keeps happening

Event loop stopped before Future completed.
Task exception was never retrieved
future: <Task finished name='Task-4' coro=<Client.run.<locals>.runner() done, defined at /home/container/.local/lib/python3.9/site-packages/discord/client.py:789> exception=RuntimeError('Concurrent call to receive() is not allowed')>
Traceback (most recent call last):
  File "/home/container/.local/lib/python3.9/site-packages/discord/client.py", line 791, in runner
    await self.start(*args, **kwargs)
  File "/home/container/.local/lib/python3.9/site-packages/discord/client.py", line 755, in start
    await self.connect(reconnect=reconnect)
  File "/home/container/.local/lib/python3.9/site-packages/discord/shard.py", line 475, in connect
    raise item.error
  File "/home/container/.local/lib/python3.9/site-packages/discord/shard.py", line 180, in worker
    await self.ws.poll_event()
  File "/home/container/.local/lib/python3.9/site-packages/discord/gateway.py", line 610, in poll_event
    msg = await self.socket.receive(timeout=self._max_heartbeat_timeout)
  File "/home/container/.local/lib/python3.9/site-packages/aiohttp/client_ws.py", line 315, in receive
    raise RuntimeError("Concurrent call to receive() is not allowed")
RuntimeError: Concurrent call to receive() is not allowed
exception calling callback for <Future at 0x7ff0a194ddc0 state=finished returned dict>
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/concurrent/futures/_base.py", line 330, in _invoke_callbacks
    callback(self)
  File "/usr/local/lib/python3.9/asyncio/futures.py", line 398, in _call_set_state
    dest_loop.call_soon_threadsafe(_set_state, destination, source)
  File "/usr/local/lib/python3.9/asyncio/base_events.py", line 796, in call_soon_threadsafe
    self._check_closed()
  File "/usr/local/lib/python3.9/asyncio/base_events.py", line 515, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
Task was destroyed but it is pending!
task: <Task pending name='Task-3' coro=<Loop._loop() running at /home/container/.local/lib/python3.9/site-packages/discord/ext/tasks/__init__.py:169> wait_for=<Future pending cb=[_chain_future.<locals>._call_check_cancel() at /usr/local/lib/python3.9/asyncio/futures.py:384, <TaskWakeupMethWrapper object at 0x7ff105703580>()]> cb=[_gather.<locals>._done_callback() at /usr/local/lib/python3.9/asyncio/tasks.py:767]>
wise harness
#

(didn't want to sound too pedantic, just hitting my head around this issue so i thought i'd let this be known)

sage tendon
#

hm

shadow sigil
shadow sigil
sage tendon
#

Shrug_3 then check for none

#

docs are wrong then ig

shadow sigil
#

hmm

#

The ID of the guild that authorized the integration. This will be 0 if the integration was triggered from the user in the bot’s DMs.
Flemtcher

#

well then

loud kayak
torn barn
#

Lemme see your code, I’ll be back in a few minutes

sage tendon
#

seriously

torn barn
#

Nice it is private anyways

torn barn
#

Although I have not yet tested it

loud kayak
edgy nest
little cobalt
loud kayak
#

Oh fuck

#

Could I just add you to the private repo @edgy nest if you’re able to help find the issue?

edgy nest
#

took a gander already

#

didnt see anything out of the ordinary

loud kayak
#

Ok

#

I know for a fact it’s Pycord too, and it only happens with bots that I have the bot instance as discord.AutoShardedBot

#

Causing the bot to crash

glad bone
#

Hello. Switching from a different library, does Pycord have a setup_hook function being autocalled prior to bot.run?

loud kayak
# edgy nest took a gander already

it keeps happening and idk why. seems like its gotten worse since ive manually increased the shard count from 2 to 15. definitely overkill for the shard count but my hosting can definitely handle it, only using 7% of its allocated cpu and memory usage is low.

#
Event loop stopped before Future completed.
Task exception was never retrieved
future: <Task finished name='Task-4' coro=<Client.run.<locals>.runner() done, defined at /home/container/.local/lib/python3.9/site-packages/discord/client.py:789> exception=RuntimeError('Concurrent call to receive() is not allowed')>
Traceback (most recent call last):
  File "/home/container/.local/lib/python3.9/site-packages/discord/client.py", line 791, in runner
    await self.start(*args, **kwargs)
  File "/home/container/.local/lib/python3.9/site-packages/discord/client.py", line 755, in start
    await self.connect(reconnect=reconnect)
  File "/home/container/.local/lib/python3.9/site-packages/discord/shard.py", line 475, in connect
    raise item.error
  File "/home/container/.local/lib/python3.9/site-packages/discord/shard.py", line 180, in worker
    await self.ws.poll_event()
  File "/home/container/.local/lib/python3.9/site-packages/discord/gateway.py", line 610, in poll_event
    msg = await self.socket.receive(timeout=self._max_heartbeat_timeout)
  File "/home/container/.local/lib/python3.9/site-packages/aiohttp/client_ws.py", line 315, in receive
    raise RuntimeError("Concurrent call to receive() is not allowed")
RuntimeError: Concurrent call to receive() is not allowed
exception calling callback for <Future at 0x7fc35e122c40 state=finished returned dict>
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/concurrent/futures/_base.py", line 330, in _invoke_callbacks
    callback(self)
  File "/usr/local/lib/python3.9/asyncio/futures.py", line 398, in _call_set_state
    dest_loop.call_soon_threadsafe(_set_state, destination, source)
  File "/usr/local/lib/python3.9/asyncio/base_events.py", line 796, in call_soon_threadsafe
    self._check_closed()
  File "/usr/local/lib/python3.9/asyncio/base_events.py", line 515, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
Task was destroyed but it is pending!
task: <Task pending name='Task-3' coro=<Loop._loop() running at /home/container/.local/lib/python3.9/site-packages/discord/ext/tasks/__init__.py:169> wait_for=<Future pending cb=[_chain_future.<locals>._call_check_cancel() at /usr/local/lib/python3.9/asyncio/futures.py:384, <TaskWakeupMethWrapper object at 0x7fc3341105b0>()]> cb=[_gather.<locals>._done_callback() at /usr/local/lib/python3.9/asyncio/tasks.py:767]>
loud kayak
fresh sierra
#

Ok no pb

echo wraith
glad bone
echo wraith
#

you can have a main coroutine and do what you want inside the await bot.start

glad bone
echo wraith
glad bone
#

eh it's not really relevant anymore since i just called it myself. Thanks tho

echo wraith
glad bone
#

👍🏾

wise harness
#

although ctx.guild.name returns None

sage tendon
#

expected

lofty hedge
#

How do I check if someone is timed out?

#

was able to find it on docs

sage tendon
lucid crest
#

The images from the Discord CDN now have an expire time, can someone tell me how I can refresh the image link?
At the moment I simply set the embed image with the discord.Attachment.url

class Attachment(Hashable):
    """Represents an attachment from Discord.

    Attributes
    ----------
    url: :class:`str`
        The attachment URL. If the message this attachment was attached
        to is deleted, then this will 404.
image: discord.Attachment # received by the command
embed.set_image(url=image.url)
sage tendon
#

that will work fine

lucid crest
sage tendon
#

for all i know, if the request comes from within discord, the expiration for the link is basically ignored

#

try send the link yourself and see if it loads

lucid crest
#

im lost

sage tendon
#

yea no clue, i hate the whole url expiration thing

lucid crest
#

i think I just host the image myself somehow

silk spire
#

Imgur!

loud kayak
#

anyone know what this error actually means? causes the bot to crash what seems like every 2 hours ish

Unclosed connection
client_connection: Connection<ConnectionKey(host='gateway.discord.gg', port=443, is_ssl=True, ssl=True, proxy=None, proxy_auth=None, proxy_headers_hash=None)>
#

using discord.AutoShardedBot

#

bot is in 2.5k servers

echo wraith
#

It would be beneficial to be able to reproduce it locally to then debug it

bronze garnet
#

is it possible to see the list of all users who user-installed my app?
would it be reasonable to fear someone abusing my bot by spamming it via user-install? or will discord rate-limit them for me?

sage tendon
#

spamming how

little cobalt
sage tendon
#

i know

bronze garnet
sage tendon
#

discord will handle that

#

p sure its the same kind of ratelimit as if sending normal messages

lapis dock
#

You also get the user information with the interaction. So no you can't get a list of all users but your use case does not need that

unkempt shore
#

how can i disable just 1 button after some time

echo wraith
#

ill send an example

#
class AsyncioTaskSetWithCallback(commands.Cog):
    """
    Demonstrates managing a set of asyncio tasks where tasks register their
    own removal via add_done_callback.
    """

    def __init__(self, bot: commands.Bot):
        self.bot = bot
        self.tasks = set()  # Set to keep track of active tasks

    @commands.slash_command(description="Create a button and disable it after a delay.")
    async def delayed_buttons(self, ctx: discord.ApplicationContext):
        """
        Command to create a button and disable it after a delay.
        """
        button = discord.ui.Button(label="Click Me", style=discord.ButtonStyle.primary)

        # Disable the button when clicked
        async def button_callback(interaction: discord.Interaction):
            await interaction.response.send_message("You clicked the button!", ephemeral=True)
        button.callback = button_callback

        view = discord.ui.View()
        view.add_item(button)

        # Send the initial view
        message = await ctx.respond("Here is your button:", view=view)

        # Task function
        async def disable_button_task():
            await asyncio.sleep(10)  # Wait for 10 seconds
            button.disabled = True
            await message.edit_original_response(view=view)

        # Create a task and manage it
        task = asyncio.create_task(disable_button_task())
        self.tasks.add(task)

        # Register a callback to remove the task from the set upon completion
        task.add_done_callback(self.tasks.discard)
unkempt shore
#

thanks

stoic hazel
#

2 questions:
how would i ctx.respond() with multiple files attached? i can do one file but i don't know how to do multiple
is there a way to pause execution of a command at a certain spot if another instance of the command is already running and continue when the other command finishes

sage tendon
#

files=[]

#

and for the second thing, sure, just set a variable in the cog that is set whenever the command is running, and unset when its done

stoic hazel
#

so [discord.File(), discord.File()]?

sage tendon
#

yes

stoic hazel
# sage tendon yes

file=[discord.File(...)] gives AttributeError: 'list' object has no attribute 'fp' while file=discord.File(...) does not

sage tendon
#

files

stoic hazel
#

oh hold on you said files not file

tawdry prism
#

Can the embed author url be set to bring up the user popup somehow? Or is it only external urls?

sage tendon
#

thats not possible for all i know

silk spire
#

seems like it always opens the url in a browser

tawdry prism
#

How do I get the top message here from the select callback, created by interaction.respond?

sage tendon
#

message = interaction.respond(..)?

tawdry prism
#

Yes, I could do that and pass it to the view awkwardly after its created.

#

Do people use views? They sometimes feel a bit forced.

sage tendon
#

how else would you do that lol

#

oh, then its just self.message

#

if you only need it in the bottom view

tawdry prism
#

Yeah the callback from the select will update the embed in the top message.

sage tendon
#

oh

#

then just pass the above message to the second view upon creating it

tawdry prism
#

Makes a bunch of sense, thanks.

#

The reason I asked initially is that the response below is created by clicking the button so I figured there would be a trail leading back to it from the interaction object in the select callback.

nova epoch
#

Random goofy ahh question that I cannot find an answer to anywhere: how can I add an option to a message's app menu (i.e: when you right click a message and go into the "Apps" bit)?

shell radish
lofty parcel
#

You cant

#

Goddammit squid

shell radish
#

gods

sage tendon
#

modal tho?

nova epoch
sage tendon
#

if you mean add a command to that list, you can
if you mean give a command there options, no

nova epoch
#

I just want an option to be able to process a message & it's user with a button on that menu.

sage tendon
#

yea thats a message command

nova epoch
#

Is there a way to add one? I tried to find some kind of snippet or something similar but I don't think Google or Github knew what I meant lol

shell radish
#

message command is ambiguous with text-based/prefixed command

rugged lodgeBOT
#

Here's the context menus example.

shell radish
#

@nova epoch

sage tendon
nova epoch
#

omg I feel so stupid now. That was the only thing I found that I thought could work but I didn't think that's what I wanted >.>
Thank you!!

shell radish
sage tendon
#

says who

shell radish
#

#guide message

#

we also talked about re-writing the guide to be more comprehensive

sage tendon
#

well yea it is outdated

#

but still the only place to find information in that format

shell radish
#

i mean formatting is kinda broken atm

round heart
tawdry prism
#

Narrator: the community didn't fill it in

round heart
shell radish
#

do we even have a brand kit?

nova epoch
# shell radish <@969254887621820526>

I've managed to get this to work, but some ctx.respond() arguments don't work. For example:

  • the ephemeral keyword argument has no effect on the response to the interaction;
  • instead of sending a whole embed, it only sends that embed's description;
  • some messages are sent twice.

Any ideas? Is this worth it's own post in #969574202413838426?

lofty parcel
glad garnet
loud kayak
#

Every 3-4 hours

glad garnet
loud kayak
sage tendon
#

and yea show your code

glad garnet
#

why specifically, I can't deduce from just the error

fresh sierra
#

if a shard is closed, does that mean its offline ?

#

can a shard be offline and not closed ?

glad garnet
fresh sierra
glad garnet
fresh sierra
# glad garnet if the shard is offline/closed you won't receive any events about the guilds it ...
for shard_id in range(self.bot.shard_count):
    shard = self.bot.get_shard(shard_id)
    connected = not shard.is_closed()
    shard_status = {
        "shard_id": shard_id,
        "connected": connected,
        "rate_limited": shard.is_ws_ratelimited() if connected else False,
        "latency": round(shard.latency * 1000) if connected else None,
        "servers": (
            len([g for g in self.bot.guilds if g.shard_id == shard_id])
            if connected
            else 0
        ),
#

does this will works for the servers ?

#

because even if i dont recevie any event is it still linked or its put in another shard

#

and i dont really understzand the different between closed and offline shard

sage tendon
#

why do you not just do for shard_id, shard in bot.shards

fresh sierra
short rivet
#

get_shard and .shards brings the data from the same source that is Client.__shards

fresh sierra
#

client.shards will for exemple only show 3 out of the 4 because the 4 got disconnected

#

but im not sure about that

loud kayak
glad garnet
loud kayak
#

Then yeah, probably a library bug

torn barn
#

I tried to reproduce this error and had no success

loud kayak
#

Can the bug be investigated?

torn barn
#

The error also said that the event loop was closed

#

(And the task was destroyed with that pending exception that could not be raised)

loud kayak
#

It’s only been happening since I made the bot auto sharded, so it’s the shards. Maybe it’s because I’m overriding the shard count from 2 to 3?

torn barn
#

It should not be that tho.

#

Every shard has its gateway connection.

glad garnet
#

I think that's missing the point, the lib should have some sort of internal error handling that doesn't crash the bot completely in this situation ideally

torn barn
#

Yes, but the library also depends on the loop, so if it dies, everything else does

glad garnet
#

and I think it does? or at least I'm not sure how this error would propagate from aiohttp to closing the event loop

torn barn
#

This is more likely due to asyncio

glad garnet
# torn barn This is more likely due to asyncio

if the shard has to reconnect somehow and asyncio fails to cancel the previous task which under certain circumstances I believe still be connected, then the aiohttp error emitted would occur, but that would be a huge regression which I think would happen more widely if that was the case

tawdry prism
#

Is there some logging I can setup to see why either bot isn't getting anything from discord or ignoring it? No exceptions are thrown. The callback for the button just defers and then responds. This worked yesterday so I'm guessing it might be some kind of timeout.

torn barn
#

Did you set your timeout to None, and made the view persistent?

tawdry prism
#

Nope. I thought that was for things you want permanently posted but then again the difference between a few days and permanent might not be any. 😄

#

Thanks for the hint.

torn barn
#

If you reset your bot process without making the view optional then you'll lose the ability to respond to it

tawdry prism
#

I haven't.

#

It's been running since it posted the above.

echo wraith
tawdry prism
#

I just noticed. And when testing you usually don’t hit that. The 180 is in seconds I’m guessing?

#

I’m going to have to go persistent anyway since I want those posts to survive a restart. Might be scheduling almost 2 weeks in advance.

tawdry prism
#

Any special trick to newlines in embed fields? I'm doing field.value += f"{user.mention}\n" to just append people reporting in my list but the newline seems to get lost on the way.

sage tendon
#

p sure you cant

tawdry prism
#

This is my other bot in dpp.

#

Only difference is the dot, code is similar from a conceptual level.

#
        std::string EmbedList;

        for (dpp::snowflake User : m_Entries)
        {
                EmbedList += "• <@" + std::to_string(User) + ">\n";
        }
#

Sorry for polluting with other language.

#

Even pasted the wrong thing... sigh

#

Nvm I saw the issue, depending on the trailing newline.

round heart
#

I tend to put lines in a list and then '\n'.join(mylines)

tawdry prism
#

I could do that, just being lazy since the embed field is my actual datastore.

tawdry prism
#

So that broke spectacularly when lots of people wanted to update at the same time. Need to db after all.

#

All discord ID's are 64bit right? Which means bigint in most databases.

loud kayak
glad garnet
#

For now, I could try making a branch for you that has a lock on poll event which should fix it, but it's more of a temporary fix, however it should be fine for the moment

glad garnet
humble turtle
#

help please

[ERROR] Error while executing /test
Traceback (most recent call last):
  File "C:\Users\Schüler\AppData\Local\Programs\Python\Python312-32\Lib\site-packages\discord\commands\core.py", line 138, in wrapped
    ret = await coro(arg)
          ^^^^^^^^^^^^^^^
  File "C:\Users\Schüler\AppData\Local\Programs\Python\Python312-32\Lib\site-packages\discord\commands\core.py", line 1078, in _invoke
    await self.callback(self.cog, ctx, **kwargs)
  File "C:\Users\Schüler\Documents\Botify\cogs\Utility\test.py", line 13, in test
    await check_entitlements(self.bot, ctx.author.id)
  File "C:\Users\Schüler\Documents\Botify\utils\extensions\entitlements.py", line 34, in check_entitlements
    async for entitlement in user.entitlements(skus=[discord.Object(id=str(sku_id))]):
  File "C:\Users\Schüler\AppData\Local\Programs\Python\Python312-32\Lib\site-packages\discord\iterators.py", line 126, in __anext__
    return await self.next()
           ^^^^^^^^^^^^^^^^^
  File "C:\Users\Schüler\AppData\Local\Programs\Python\Python312-32\Lib\site-packages\discord\iterators.py", line 1008, in next
    await self.fill_entitlements()
  File "C:\Users\Schüler\AppData\Local\Programs\Python\Python312-32\Lib\site-packages\discord\iterators.py", line 1028, in fill_entitlements
    data = await self._retrieve_entitlements(self.retrieve)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Schüler\AppData\Local\Programs\Python\Python312-32\Lib\site-packages\discord\iterators.py", line 1048, in _retrieve_entitlements_before_strategy
    data = await self.get_entitlements(
                 ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Schüler\AppData\Local\Programs\Python\Python312-32\Lib\site-packages\discord\http.py", line 2936, in list_entitlements
    params["sku_ids"] = ",".join(sku_ids)
                        ^^^^^^^^^^^^^^^^^
TypeError: sequence item 0: expected str instance, int found
import discord
import os

# SKU_ID is read from the environment variable, defaulting to None if not set
sku_id = os.getenv("SKU_ID")

async def check_entitlements(bot, user_id: int, ctx=None) -> bool:
    """
    Checks if a user has purchased a specific SKU.

    Args:
        bot: The bot instance.
        user_id (int): The Discord user ID.
        ctx (optional): The context for messages (optional).

    Returns:
        bool: True if the user has the entitlement, False otherwise.
    """
    # If no SKU_ID is defined, log a warning and abort
    if not sku_id:
        print("No SKU_ID defined. Please set the environment variable SKU_ID.")
        if ctx:
            embed = discord.Embed(
                title="Internal Error",
                description="The premium service is currently unavailable.",
                color=discord.Color.red()
            )
            await ctx.respond(embed=embed, ephemeral=True)
        return False

    user = await bot.fetch_user(user_id)
    try:
        # SKU_ID is passed as a string to discord.Object
        async for entitlement in user.entitlements(skus=[discord.Object(id=str(sku_id))]):
            if entitlement.premium:
                print(f"User {user_id} has premium access for SKU {sku_id}.")
                return True

        print(f"User {user_id} does not have premium access for SKU {sku_id}.")
        if ctx:
            embed = discord.Embed(
                title="Premium Required",
                description="You need Botify Premium to use this feature.",
                color=discord.Color.red()
            )
            embed.add_field(name="Price", value="$2.99", inline=False)
            await ctx.respond(embed=embed, ephemeral=True)
        return False

    except discord.HTTPException as e:
        print(f"Error while checking entitlements: {e}")
        return False

humble turtle
#

uh

edgy nest
#

update to master branch if you want fix

humble turtle
#

i can't install git is it possible without git

edgy nest
edgy nest
#

you could probably monkeypatch

#

if you want to try

sage tendon
#

why can you not install git, but python and everything else needed for programming lol

edgy nest
#

not that bad of a fix

sage tendon
#

you program without git?

humble turtle
#

i can install python but when i install git there is a git icon in the taskbar but when i press it nothing happens

sage tendon
#

use the cli

#

you dont use git as GUI, ever

humble turtle
#

what do you mean

sage tendon
#

i mean that you use git in the command line, and never as GUI

echo wraith
sage tendon
#

everything git does is on the command line

#

the GUI is just a fancy wrapper

humble turtle
echo wraith
sage tendon
#

type git -v in a command line

humble turtle
sage tendon
#

..

#

cli means command line interface

echo wraith
#

type git --help

#

If it doesn't seem to work, please send the output here

humble turtle
#

when I enter this I get

git : The name “git” was not recognized as the name of a cmdlet, a function, a script file or an executable program.
executable program. Check the spelling of the name, or whether the path is correct (if included), and
repeat the process.
In line:1 char:1

  • git --help
  •   + CategoryInfo : ObjectNotFound: (git:String) [], CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException
sage tendon
#

if you ran the git installer with default settings, touching nothing, that should work

echo wraith
sage tendon
#

--id ?

echo wraith
humble turtle
# echo wraith Run this winget install -e --id Git.Git

winget : The name “winget” was not recognized as the name of a cmdlet, a function, a script file or an executable program.
executable program. Check the spelling of the name, or whether the path is correct (if
is correct (if included) and repeat the process.
In line:1 char:1

  • winget install -e --id Git.Git
  •   + CategoryInfo : ObjectNotFound: (winget:String) [], CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException
sage tendon
#

are you on windows 7

#

lol

humble turtle
#

11

sage tendon
#

what did you do to your windows

#

oh

#

type cmd

#

and try running git again

humble turtle
#

yes

sage tendon
#

you opened powershell

#

powershell is fucking useless

#

it acts like its a terminal but its not

humble turtle
#

thx

echo wraith
sage tendon
#

it cant take basic CLI commands, which makes it useless

#

exhibit A seen above

echo wraith
#

But they are both shit compared to bash

sage tendon
#

like git

#

or winget

echo wraith
echo wraith
sage tendon
#

no, powershell gives me errors when i try running anything, its a broken shit program and should be removed

#

anyway back to pycord

little cobalt
echo wraith
little cobalt
#

winget always comes with windows

echo wraith
echo wraith
#

Ik that's weird but oh well

round heart
#

If you insist on developing with non-Microsoft languages on Windows, you owe it to yourself to install WSL

round heart
#

What would cause a message not to be ephemeral even when you tell it to be? 🤔

await ctx.respond(embeds=embeds, view=view, ephemeral=True)

Is there something in my view that could be overriding it somehow?

round heart
#

ah dammit, good looking out. Forgot I had one at the top of the method; thanks.

tiny fractal
#

disregard im an idiot

#

meant to be APplicationContext

tidal vessel
#

Guys, quick question, I'm working on a role system

For example, if I save the Member object to later check the roles it has on the server. If the Member's roles change, is the Member object updated automatically? Or do I have to get the updated information myself?

sage tendon
#

it's updated

tidal vessel
lofty parcel
#

It is?

sage tendon
#

yes

#

because it points to the member object in memory, and since the member won't just randomly be uncached (thus creating a new object) itll still be the same object for the bot's entire runtiume

#

really gotta remind myself every so often that python is pass by reference

lofty parcel
#

true

nova epoch
#

Any ideas? Bot doesn't use Voice at all??

Traceback (most recent call last):
  File "C:\Users\there\OneDrive\Desktop\Projects\personal-starboard\main.py", line 2, in <module>
    import discord
  File "C:\Users\there\AppData\Local\Programs\Python\Python313\Lib\site-packages\discord\__init__.py", line 27, in <module>
    from . import abc, opus, sinks, ui, utils
  File "C:\Users\there\AppData\Local\Programs\Python\Python313\Lib\site-packages\discord\abc.py", line 58, in <module>
    from .voice_client import VoiceClient, VoiceProtocol
  File "C:\Users\there\AppData\Local\Programs\Python\Python313\Lib\site-packages\discord\voice_client.py", line 55, in <module>
    from .player import AudioPlayer, AudioSource
  File "C:\Users\there\AppData\Local\Programs\Python\Python313\Lib\site-packages\discord\player.py", line 29, in <module>
    import audioop
ModuleNotFoundError: No module named 'audioop'```
sly karmaBOT
nova epoch
#

omg sometimes I hate coding

#

that is literally so dumb like

sage tendon
#

why dumb?

nova epoch
#

if it's needed regardless of if you use voice or now, why doesn't it just come with the py-cord installation?

sage tendon
#

It was a built in, deprecated since 3.11, now it was removed

#

pycord just didnt update the implementation in time

lapis dock
#

it is because py-cord 2.6.1 does not officially support python 3.13

nova epoch
#

Sometimes I regret starting to code, things like this make me lose it

sage tendon
#

why? it's a really straightforward issue

lofty parcel
#

Gawd it's installing a library

#

Not the end of the world

floral ice
#

how can i delete view message after button is clicked?

#

when i try await self.message.delete() i cant because of 403

sage tendon
#

is it an ephemeral message

floral ice
#

yea

sage tendon
#

good luck

floral ice
#

??

#

can i at least disable the buttons?

sage tendon
#

its super weird to delete ephemeral messages and i dont remember how

lofty parcel
#

.rtfm delete_original_

lofty parcel
#

Second one.

sage tendon
#

ah yea that
why is that needed tho?

floral ice
#

can i update ephemeral view?

#

like .edit() ?

lofty parcel
#

On button click?

sage tendon
#

edit_original_response

floral ice
#

yea

sage tendon
#

i think

floral ice
#

oh ok i will try

lofty parcel
#

interaction.response.edit_message if youre responding

rugged lodgeBOT
lofty parcel
#

Otherwise what toothy said

floral ice
#

thx

sage tendon
#

i always remember deleting ephemeral messages to be much harder than it is but by next time i forgot already

floral ice
#

wait

#

it just edits the button response

#

not the view

#

i need to edit the view it self, not the button response

echo wraith
sage tendon
#

what view

floral ice
sage tendon
#

show a screenshot and tell us what exactly you want to edit

echo wraith
#

then you have to pass in interaction with your view pobably idk

echo wraith
floral ice
sage tendon
#

so there is only one message?

floral ice
#

yes

#

the one created with the slash command

lofty parcel
#

interaction.response.edit_message should work

floral ice
lofty parcel
#

Yes

#

Should be your first response

#

You don't need to send any other message

floral ice
round heart
#

btw, if you ever do want to outright delete an ephemeral message in your button callback, you can either

await interaction.response.defer()
await interaction.delete_original_response()

or (and I'm not entirely sure why this works, just found it in another View I built)

await self.parent.delete_original_response()
sage tendon
#

Do on_message events also work for threads the bot isn't actively part of? Be it private or public?

#
Traceback (most recent call last):
  File "C:\Code\Paw\bot.py", line 1, in <module>
    import discord
  File "C:\Code\Paw\venv\Lib\site-packages\discord\__init__.py", line 27, in <module>
    from . import abc, opus, sinks, ui, utils
  File "C:\Code\Paw\venv\Lib\site-packages\discord\abc.py", line 58, in <module>
    from .voice_client import VoiceClient, VoiceProtocol
  File "C:\Code\Paw\venv\Lib\site-packages\discord\voice_client.py", line 51, in <module>
    from . import opus, utils
  File "C:\Code\Paw\venv\Lib\site-packages\discord\opus.py", line 29, in <module>
    import ctypes
  File "C:\Users\chose\AppData\Local\Programs\Python\Python313\Lib\ctypes\__init__.py", line 157, in <module>
    class py_object(_SimpleCData):
    ...<5 lines>...
                return "%s(<NULL>)" % type(self).__name__
AttributeError: class must define a '_type_' attribute

wtf is this error

#

okay it only happens on 3.13.1, and looks like a python bug