#Basic Pycord Help
1 messages · Page 62 of 1
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
Yes, using send instead of respond cause this
Btw for future reference you have use 3 backticks to make multiline code blocks look nicer
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.")
👍 thanks again!
how come is it that sometimes discord.Bot.latency is "infinity" ?
It returns float("inf") if the heartbeat is not set yet:
https://github.com/Pycord-Development/pycord/blob/master/discord%2Fgateway.py#L586
Also interesting, Client/Bot.latency returns float("nan") if the websocket is not set yet:
https://github.com/Pycord-Development/pycord/blob/master/discord%2Fclient.py#L318
I assume its because it's supposed to always return a float instead of None sometimes.
That's weird, as I'm accessing it only after bot startup... Oh well
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)
...```
you can't really disable commands other than by changing their code to just not work afaik
yeah, first thought was just commenting stuff
but that would break my current comments 😦
just add return await ctx.respond("...") as the first line?
smt without responding any text? ctx.defer()?
the dots meant for you to just put some useful message there
right
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
you can disable commands
yea but there's no discord mechanism for it
you can change the command group with guild_ids=[some_test_guild_id_here] and the entire command group will only be available in the test guild
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 🙏
As far as I am aware it is as simple as switching the bot class from discord.Bot to AutoShardedBot.
Have you seen this article? https://guide.pycord.dev/popular-topics/sharding
yea it subclasses the normal bot classes (one of them, idk which exactly) but nothing should change or break if you switch
I thought there was something about caching as well, like each shard has a separate cache but I cant remember
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?
im p sure on_ready is called when all shards are ready so no
Yeah, I just thought there's not much that's explained on it, like how sharding works internally and how different event listeners are handled when using sharding
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
On the doc it says it is trigger for each shard that connects, however in my use case it triggers only 1
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)
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
the docs are probably really sparse because almost no one has a bot that is big enough to be sharded
Does not mean that they should be sparse tho. ;)
The docs aren't really the place for sharding to be explained extensively, unless we make a separate page for it; there's a brief overview at https://docs.pycord.dev/en/master/api/clients.html#discord.AutoShardedClient, and it's also touched on in the guide https://guide.pycord.dev/popular-topics/sharding
discord will dispatch these events whenever it happens to any shard
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
I see, it's reassuring to hear this from someone, this is what I'm seeing while testing / reading the source code
Nelo is the best ♥️
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
the guilds for all shards on that connection
I see now, thank you 😄
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) :
you cant limit showing slash commands to only certain people
you can limit it to roles inside of discord tho
admins are exempt however
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
ah
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?
nah that's the opposite, it filters the users for the commands listing, but the allowed people can't execute the command
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
guild owners have admin
For debugging purposes can you print both of the tests in the check
I'll do that tomorrow, in my cases (bot owner) both are true which is the epxected behaviour
those are message commands
Could you provide me with a wiki link or a example?
Here's the context menus example.
Thanks
You can link slash commands, but can you link them with arguments pre-filled?
Not anymore
(╯°□°)╯︵ ┻━┻
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 :)
is it with a bot or user account?
and do you use the discord API for it?
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.
Automating user accounts is against ToS.
Even with an alt lmao
I figured something like that, thanks though :D
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
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
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,
)
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,
)```
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
Okay, that works now.
But now I have another problem.
With
self.paginator.goto_page(interaction=interaction)
What I execute afterwards I get This interaction has already been responded to before
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
Is there another way to get to a specific page after updating the Paginator?
you can pass current_page to the update method
Okay thanks 🙂
Can I use
async def update_pages(self, interaction):
self.update_custom_view(self.custom_view)
Update the custom view in the Paginator class?
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.
@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 ?
is it an ephemeral message?
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'
hooo I didn't knew that, is it written somewhere in the doc ? (just curious if I missed it)
no
will audioop-lts at some point be a dependency of py-cord ?
okay thank you very much for those answers, as always you give short straight to the points answers 👌
Or just adding a audioop-lts;python-version >= '3.13' line on requirements.txt would fix it..
no
c:
It doesn't fix the underlying issue that python uses a now-removed and previously-deprecated feature of the standard library
I think as it is a workaround for now it not good to place something that won't be a long term solution in the documentation, but I get that it's a bit confusing
i'm pretty sure the fixed implementation is already on master anyway
@lapis dock do you by any chance have an example for https://github.com/Icebluewolf/pycord/tree/voice_messages
👀 I know there are still issues with getting it to work with interactions
Pycord, a maintained fork of discord.py, is a python wrapper for the Discord API - GitHub - Icebluewolf/pycord at voice_messages
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 ?
check again after 10 minutes
after that if the bot is still running, do a token reset
you might have a terminal running in the background or something
I swear I'm reading my code line by line to check if my token has leaked
You can do a force shutdown with a Token reset
how does that help
well if any one ahs the token and my code since it's a public repository they could have run my bot and get access to my server
yknow, you can just search for the token in your project files?
or as zervy said, just reset the token
I know I did , just a bit paranoid on that
I think I'll do it
why would someone who has your bot token clone your bot repo and run your bot
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
not even comparable at all
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
you just have a rogue terminal still running on your pc, its nothing
okay I'll check that weird that it still shows up after rebooting my computer tho, I'll have a look thank u
VPS?
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)
just reset the token, then the problem is solved
what was it
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!
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....
for what?
I asked him to compose down the bot
...configuration values?
maybe initiating an object with a dict of the said values at start up ?
Using bot['attribute blah blah'] = value?
bot.attr should work
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
if your token gets posted on github, it automatically resets
Really?
yes
That's op ! Are you notified ?
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
Yes, you get a system dm
really great
Sorry for the late reply
You just have to set voice_message=True when you are sending audio files.
channel.send(attachments=[...], voice_message=True)
Discord does have limitations on what additional content can be sent in what circumstances though. You will have to see what works because what is allowed where is not super consistent.
How do I fix this error that randomly happens during runtime?
Causes the bot to crash
What format do you send in the attachments parameter? I keep getting TypeError: Messageable.send() got an unexpected keyword argument 'attachments'
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'`
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
Ah I see, didn't realize when you switched branches in github it would default to the main branch for install. got it thanks!
just a reminder, 3.9 is in its last year of support, you might wanna update
what is the difference between pycord and something like discord.py or nextcord or disnake
its just different libraries, they're largely the same featurewise and mostly differ in syntax
hm
thanks
Compares Discord libraries and their support of new API features
So sorry to keep bothering you. But I was able to get the right repo installed. But now it seems I am running into this
HTTPException: 400 Bad Request (error code: 50161): Voice messages must have supporting metadata
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
@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"?
ja save to 30%
@commands.Cog.listener()
async def on_member_join(self, member):```
No.
It's not the thing
that is wrong with discord.Bot
hm
hm
with discord.Bot it would be discord.Cog.listener()
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()
do you have the intents to receive that event?
Sure
All needed intents are assigned
Did I forget intents=intents?
you tell me
I'll check
(I'm not at home rn)
well in the code you sent it's wrong
well, you are right, i forgot to pass the intents to the bot
bot = discord.Bot(intents=intents)
can bots fetch this somehow?
Thats so dumb
Are there any alternative ways to join other than invites and server discovery?
theres a lot of stuff bots cant get, even indirectly
yes, being added by a bot
With the OAUTH scope you mean?
these are the official ones
student hub doesnt apply, ofc
manual verification only applies to "guilds"
right, forgot I can query that
Arent all servers guilds?
No, the new guilds feature
oh that clan thingy
clan servers, yknow, with the dumb tags next to ones name
They call it guilds
Fucking discord
😭
nice embed dipshit
Yes let’s rename the entire base concept of our platform
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
to be fair, guild is only the internal name
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
Yeah and the servers were originally used for those likeminded groups of people.
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
They don't even want to document the shit
Sorry for the late reply, I might have time to look at this in the next 2 days. Could you share the code you were using to get this error? I have not encountered this yet but I have also not tested the PR in a few weeks. Just be aware that there is a reason that the PR was marked as a draft, it is not complete and I am unsure if discord is still changing things with their implementation of it.
No worries at all!
tts = await TTS().generate_tts(script)
channel = self.bot.get_channel(987475882732036098)
await channel.send(file=discord.File(tts, filename="motivation.mp3"), voice_message=True)```
tts return a .mp3 file
Are the bot emojis now integrated in 2.6.1 so that you can use them as normal?
no
yes
2.7, no?
yea but there is no proper library support for fetching them all etc pp
you can’t upload/edit them via lib yet
you don’t need to if you just use the raw text markdown?
yea but thats meh
you don’t have an enum for all your emojis?
no
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?
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?
if you know the ids, you can just use them in markdown form
What do you mean exactly?
press this in the dev portal
Ah okay and then I can display the emojis on any server where the bot is also on it?
yes
Okay, thanks!
the string/markdown can be used anywhere you would use a regular emoji; messages, buttons, reactions, polls etc
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
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?
using pycord multicog you can use a group in different cog
How does it work?
Pycord extension for splitting command groups into multiple cogs - 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'
```
it doesn't work like that. read how multicog works.
Okay then it only works with multicog?
Yes
No u can created ur own way
Like custom decorator etc
But multicog is the easiest way
yea but that's unnecessary lol
Multicog lacks some compatibility
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
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
Not happening for me. I can invite you to the testing server to see it
i dont think we can do anythng
you are the owner there, right?
except report that to discord
yea
because its mostly a bug
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
well, either way you wont receive any new messages, so its not a privacy / safety issue in that regard
at most you could give them like a "back to <main channel>" message i suppose
so just report it to discord thats the only way
im almost certain it didnt do that before
can you test the same with a private thread? threads do work differently
it been months
I guess but it would be nice if the user could automatically be moved to another channel
yea something like that doesnt exist
I see you got the same issue as me lol
that would be basically a hostile takeover of the UI lol
everyone i dont think its clients specific
if anything they'd get a blank middle pane
yeah that's been a thing forever
the only way to actually redirect would be to delete the channel/thread entirely
oh, that blanks out the middle pane too?
a channel being deleted forces anyone viewing it completely out, because the url no longer exists
strictly speaking they could apply the same logic on permission changes, but they don't for whatever reason 
(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)
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?
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?
its pycord
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()
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".
Got it thanks
Got it working. Thanks a lot!
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. 🤔🤔
You can (almost) always use .send
as long as it's not the first response, yes
What do you mean? I can't .defer(), then?
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
your next response is locked to either ephemeral or not
... vs what other type of response?
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
Oh, so when deferring, you can only respond based on the ephemeral state of the defer?
yes
that only applies to the immediate next response
after that response, switching is allowed
(rules are also different for components)
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?
the easiest hack is ctx.defer -> ctx.delete, but that will show to the user
For the error message have ephemeral = True and for the normal/result message have ephemeral = False
Wasn't working, hence the question; when doing regular defer, the errors were still public, and when defer was ephemeral, the standard responses were coming in as ephemeral - certainly for the reasons discussed above
How to preserve the image while editing the embed?
Any other way rather than setting it to the image_url again
by editing you mean replacing it with a new embed while editing the message right
because then no, there's no way around that
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
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
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?
no
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.
Yes
doesnt the on_ready event mean the bot's on ready?
yeah
then you cant use that (?), just do it in the cog's init
on_ready is (usually) only called a single time
I can't do it in the init, since the initialization is happening async, though.
asyncio.run()
oh nvm im dumb, forget what i said
okay 
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!
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
The only things that are not compatible that I am aware of are audioop (solution install audioop-lts) and commands Flags for prefix commands
wait why are flags affected?
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 :)
only 2 os but yeah
Just realised that lol >.>
I dont know, I just remember nelo or squid discussing it with someone.
#discussion message
Can I add images to a bot activity like as a game?
Like for example
Playing
GTA V
image
As far as I know, no. Those are rich presences and I don't think there's a way for bots to have them.
Alright no worries thank you :D
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
Here's the slash users example.
above is an example, the main difference is that you have to consider that the majority of the time the bot will not have access to a lot of stuff in context
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
will it have access to info about every guild the user is in and access member data for users in mutual guilds etc
okay sweet
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
how do I install the dev version ?
.tag master
pip install -U git+https://github.com/Pycord-Development/pycord
that would install the normal py-cord right
As you can see, it will install the development one so should be the development version/master
Okay. Thank you
I am still waiting for this pr to be merged https://github.com/Pycord-Development/pycord/pull/2598
You should be able to do pip install -U git+https://github.com/Pycord-Development/pycord.git@refs/pull/2598/head
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
2.6.1
Went as far back as 2.5.0, same issue. Can't go lower without downgrading python
Is there an issue open?
cc @sage tendon, forgot to ping in reply lmao
I wonder if flags got even updated in the past (I dont even know how to use them xd)
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
tho, what did you change since it last worked
nothing. Haven't used them before
The only thing I changed to get them to not error on startup was a custom Flag class, injecting Pydantic into it instead of the built-in dataclasses
But, it doesn't actually work in practice, since the flags just use their default values, I presume not being populated properly for pydantic
you pinged the wrong person, but I see it now XD
is it possible to have slash commands on a bot added to a user?
yes lol
you can't have prefix commands for a matter of fact so slash commands are your only choice (+ message and user commands)
are you able to use those commands in servers or is it limited to like messaging the bot or something
do you need to do something different from when it's on a server then?
in what way
cause the commands are not showing up everywhere for me
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
i can't say i could find them anywhere
are you sure you installed the bot on your account
and did you set proper integration types in the commands?
elaborate
just do this if its only a user bot and not meant to be installed on servers
it's meant to work for both
but i feel like the short answer here is no
then add guild_install as well into that list
okay
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
Here's the slash users example.
Here is an example oflf how to do it per command
i don't really have any server specific commands that aren't already set to only be usable in a server so
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?
@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'?
This means you installed other packages that use the Discord namespace
Please make sure you only have py-cord installed
.install
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
Yeah, you installed discord which is not compatible with py-cord
Are there any good examples on how to modify a view based on a component callback? Adding/removing/disabling other components and such?
view.add_item is one i know
there is .disable_all_items, or you can just disable items manually by setting .disabled=True then edit the message with the view
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)
does it work?
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
is it an ephemeral message?
Yes.
I think I did so but let me try again. Like this: await interaction.response.edit_message(view=self)
also consider upgrading your python version lol, 3.9 is really old
I know, working on a vhost I'm running another bot on. Not keen to write another d++ bot though.
d++?
"Lightweight and simple" 
So edit_message is not throwing any error, it just doesnt disable the other button.
it's not enabled, it's disabled
(also for convenience, interaction.edit exists)
Ouch, thanks. I did confirm the oops was on me by editing buttonstyle.
Thank you Toothy and Nelo.
allgood
Is there a smart built in way to persist selections when you edit the interaction?
iterate through select.values and apply default=True to them
but i'd only recommend this in ephemeral messages, or if your menu is disabled
Will be ephemeral, yes. Several selects where the choice will populate the next.
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
Oh, values is just List[str]. Have to next .options and .values then.
oh yeah mb, i guess just map values back to options
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
you could probably flip it and do for o in options: if o.value in select.values: ... else: ...
That’s true. My usual style is brute forcing while doing poc and cleaning up after. 🙂
fair ww
btw, you can also directly refer to the buttons by their callback name, assuming you're wrapping it in the @button decorator.
self.schedule_button.disabled = False
Thank you. Didn’t look at the decorator source but that makes sense.
Do you know if this is different for the @select decorator? That is not working for me.
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)
mmmm shouldn't be? always worked fine on my end
your decorated functions are typically treated as the object itself
works with commands too
@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?
no by the function name
Not unless the function you're wrapping is also called day_select
well idk what it is in that snippet
Is it possible to remove an ephemeral response completely or is it up to the user to dismiss?
ctx.delete or interaction.delete_original_response
(forgot to implement interaction.delete)
await interaction.delete_original_response() throws a 404 for me.
Do I need to respond or defer before I delete? It's in a button callback.
yes
What would you delete if you didnt respond ?
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)
I want to delete the ephemeral message I post in response to a slashcommand.
if it was the original command response, you want ctx.delete
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?
there's a few approaches
await interaction.response.defer(ephemeral=True)
await interaction.delete_original_response()
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
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.
icic
Something like this
wow if only discord released the datetime picker they silently added 2 years ago
I knoooooow
no
;3
death be upon ye
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.
we just used a website instead lol
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.
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
do you have custom logic for reconnecting
no
how many guilds/shards?
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
how do i do that?
you can manually pass shard_count into your bot init/constructor
though do verify how many it's currently on and choose accordingly
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.
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.
happened again, i have 5 shards.
client_connection: Connection<ConnectionKey(host='gateway.discord.gg', port=443, is_ssl=True, ssl=True, proxy=None, proxy_auth=None, proxy_headers_hash=None)>
Sorry I don't have much of a clue beyond it possibly being excessive events or manual reconnection logic
i checked and its about 450 servers per shard on average. is that too much for one shard?
... actually, self.view only populates if I intentionally pass _view
Why are Views so broken D:
because they're a dpy relic and nobody really knows how they work
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.
follow up question: does everywhere include dms with other users
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.

is there a way to check if the bot can send a message in the context channel
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
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'
Oh right, you were the user app guy
yea, you cannot use .send with a user app
at all
you have to use respond
doesn't tell me what i have to give to
ctx.can_send()
gets pissed off when i give it the wrong thing

it's not purely a user app
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
(and also, that's the thing i'm trying to solve rn)
the fix is to use .respond lolw
my problem isn't that i'm not using respond, it's figuring out when i have to use it xd
that exists, cant find it right now, give me a minute
https://docs.pycord.dev/en/stable/api/models.html#discord.Interaction.authorizing_integration_owners
Models are classes that are received from Discord and are not meant to be created by the user of the library. Attributes key, url. Methods def is_animated, async read, def replace, async save, def ...
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
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
use the docs
that's at least the second time i've had an issue with that
webhooks dont take silent= for some reason
but at least this time it gave an error instead of silently ignoring it
can you show your code
(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
always the most reliable way as i said
is there a way to have that check if you're dming the bot or should i just using the try except
i mean .send will work in that case, so
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
what does that do
basically, makes it use .respond for the first message and .send for messages after that
you could just make a custom context
Here's the custom context example.
I don't know the full context, but why are you not just using follow-ups?
they said they don't like how it looks
Would I be able to send you the GitHub link that has the entire code source and maybe that could help you figure it out? Cuz I have no clue.
Wonder if introspection could be used to remove the get_context layer. I suck at low-level stuff like that, but have seen similar things. (Would only work for typehinted methods, obvs)
That could be very nice ig
but it feels a bit too hacky to me
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
You couldddd but I can't guarantee anything
Not having an explicit get context sounds like hell, because then the library has no concept of it
Why not? With introspection it could
Tf is introspection? Are we meditating in 3.0
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?
I don't think you can prevent that
The lag between the button "re-enabling" and the edit applying should be minimal
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
Idk if you're editing as fast as possible then not much else you can do
Could you disable instead of deferring and then editing the response afterwards?
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
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]>
i did print(ctx.interaction.authorizing_integration_owners.guild_id) and it prints the server id instead of 0 when its not guild installed. According to the docs, it's 0 only when the command is used in the DMs
(didn't want to sound too pedantic, just hitting my head around this issue so i thought i'd let this be known)
hm
discord.errors.HTTPException: 400 Bad Request (error code: 40094): This interaction has hit the maximum number of follow up messages
```oh
well, i'm getting a None from that when trying to use the bot in a server
hmm
The ID of the guild that authorized the integration. This will be
0if the integration was triggered from the user in the bot’s DMs.
well then
anyone know why this is randomly happening with Pycord? code: https://github.com/Nzii3/partnerpal-source
This error is because the loop was destroyed before all the tasks were finished
Lemme see your code, I’ll be back in a few minutes
Nice it is private anyways
your repository is private
This should be fixed on the PR I made
Although I have not yet tested it
Mb fixed
you have db creds in here
also a github token?
Oh fuck
Could I just add you to the private repo @edgy nest if you’re able to help find the issue?
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
Hello. Switching from a different library, does Pycord have a setup_hook function being autocalled prior to bot.run?
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]>
Give me a 404 error
sorry only giving access to support members since it has db info and github keys
Ok no pb
You can run whatever you want before bot.run
I meant does it run itself?
I'm not sure I understand what you want to achieve
you can have a main coroutine and do what you want inside the await bot.start
In Discord PY, there is a function called "setup_hook" which you define, and it is automatically called
What are you doing in there ?
eh it's not really relevant anymore since i just called it myself. Thanks tho
I don't really see the point for that honestly, you can run your code yourself
👍🏾
sounds weird
although ctx.guild.name returns None
expected
Models are classes that are received from Discord and are not meant to be created by the user of the library. Attributes key, url. Methods def is_animated, async read, def replace, async save, def ...
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)
that will work fine
its not, the image is not loading anymore from the sent embed
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
- The Embed shows this Image i linked
- When I open the Link the the browser its not available
- When I send the Link myself into a channel its loading on my PC but not on my phone (app)
im lost
yea no clue, i hate the whole url expiration thing
ye i saw on reddit that you can somehow "refresh" the image but i have no clue on how discord handles this
i think I just host the image myself somehow
Imgur!
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
It would be beneficial to be able to reproduce it locally to then debug it
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?
spamming how
you can kinda use every bot if one permission is not disabled at a guild which is by default at on
i know
Spamming slash commands / message commands etc.
discord will handle that
p sure its the same kind of ratelimit as if sending normal messages
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
how can i disable just 1 button after some time
use an asyncio task that waits some time then edits the message with the view and the disabled button
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)
thanks
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
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
so [discord.File(), discord.File()]?
yes
file=[discord.File(...)] gives AttributeError: 'list' object has no attribute 'fp' while file=discord.File(...) does not
files
Can the embed author url be set to bring up the user popup somehow? Or is it only external urls?
thats not possible for all i know
seems like it always opens the url in a browser
How do I get the top message here from the select callback, created by interaction.respond?
message = interaction.respond(..)?
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.
how else would you do that lol
oh, then its just self.message
if you only need it in the bottom view
Yeah the callback from the select will update the embed in the top message.
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.
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)?
you can't add options to context menu commands
gods
modal tho?
You can't add to this menu?
if you mean add a command to that list, you can
if you mean give a command there options, no
I just want an option to be able to process a message & it's user with a button on that menu.
yea thats a message command
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
message-based context menu
message command is ambiguous with text-based/prefixed command
Here's the context menus example.
@nova epoch
the guide calls it that, so will i
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!!
guide is deprecated
says who
i mean formatting is kinda broken atm
Write some outlines on what it should have and let the community fill it in. Nobody wants to write the whole thing; documentation is the worst slog ever.
Narrator: the community didn't fill it in
Or vice-versa. Like I still want more visual guides https://github.com/Pycord-Development/guide/issues/476
do we even have a brand kit?
I've managed to get this to work, but some ctx.respond() arguments don't work. For example:
- the
ephemeralkeyword 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?
Open a post and provide code
from just reading it there, the connection might've been dropped from the Gateway for a shard while still connected to discord
It causes the entire bot to crash tho
Every 3-4 hours
is it only that error or is there anything else? the more verbose the better
This is the same issue: #1132206148309749830 message
Make sure you aren't deferring, if you defer that forces the message to be ephemeral or not depending on which way you deger
and yea show your code
based on the error, the client is trying to poll for an event / wait for a websocket message more than once in a single shard
why specifically, I can't deduce from just the error
Can I find out what is the technical reason for this restriction?
if a shard is closed, does that mean its offline ?
can a shard be offline and not closed ?
afaik it should and if it doesn't it's most likely a bug
Ok perfect, I’m planning to use that to make a shard status. Also if it’s closed does some guild will be on this shard or they will all be moved
if the shard is offline/closed you won't receive any events about the guilds it is assigned to until it's online again
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
why do you not just do for shard_id, shard in bot.shards
Because if a shard is disconnect I feel like it will not be shown here
get_shard and .shards brings the data from the same source that is Client.__shards
that now what i said
client.shards will for exemple only show 3 out of the 4 because the 4 got disconnected
but im not sure about that
What’s your GitHub username? I can add you to the private repo so you can scan the code
I doubt it's an error on your part, shard connections and polling should all be handled by the client so unless you're interacting with shards directly this is most likely some type of library bug
Then yeah, probably a library bug
I tried to reproduce this error and had no success
Can the bug be investigated?
The error also said that the event loop was closed
(And the task was destroyed with that pending exception that could not be raised)
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?
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
Yes, but the library also depends on the loop, so if it dies, everything else does
and I think it does? or at least I'm not sure how this error would propagate from aiohttp to closing the event loop
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
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.
Did you set your timeout to None, and made the view persistent?
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.
If you reset your bot process without making the view optional then you'll lose the ability to respond to it
Views have a default timeout. You can change it, or if you want the view to exist for very long, can use a persistent view
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.
Yup
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.
p sure you cant
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.
I tend to put lines in a list and then '\n'.join(mylines)
I could do that, just being lazy since the embed field is my actual datastore.
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.
would you be able to investigate into the issue and possibly implement a fix? i have to unshard my bot which causes it to have higher latency and isnt ideal. or i have to switch to discord.py for my verified bots and thats also not ideal.
.tag snowflake
I've been investigating it however I can't find any regions where poll event specifically can be triggered concurrently
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
that would be great, thank you
https://github.com/anavereum/pycord/commit/d02337ff1db7cbac65c64eb67225cb1c435d1c1a this should work (this is targeting master though, I could just put it on an older version if it's really a problem)
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
library bug
uh
update to master branch if you want fix
i can't install git is it possible without git
specifically commit 05cf45e
- Fix #2627
Signed-off-by: UnBonWhisky <[email protected]>
- Update CHANGELOG.md
Signed-off-by: UnBonWhisky <[email protected]...
no
you could probably monkeypatch
if you want to try
why can you not install git, but python and everything else needed for programming lol
not that bad of a fix
you program without git?
i can install python but when i install git there is a git icon in the taskbar but when i press it nothing happens
what do you mean
i mean that you use git in the command line, and never as GUI
Are you on windows ?
yes
Open the "terminal" app
type git -v in a command line
yes
Then you can use git in there
type git --help
If it doesn't seem to work, please send the output here
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
if you ran the git installer with default settings, touching nothing, that should work
Run this
winget install -e --id Git.Git
--id ?
Id of the Winget package
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
11
yes
you opened powershell
powershell is fucking useless
it acts like its a terminal but its not
thx
PowerShell is so much better than CMD I'm sorry
But they are both shit compared to bash
Like what
Winget is just not installed
Idk it always worked for me
no, powershell gives me errors when i try running anything, its a broken shit program and should be removed
anyway back to pycord
??
Yeah let's not have such debate here
winget always comes with windows
You have to install it from Ms store
Sometimes
Ik that's weird but oh well
If you insist on developing with non-Microsoft languages on Windows, you owe it to yourself to install WSL
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?
a previous defer
ah dammit, good looking out. Forgot I had one at the top of the method; thanks.
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?
it's updated
Ok, thanks for the confirmation 
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
true
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'```
.tag audioop
Pycord 2.6.1 works with Python 3.13, but you may need to pip install audioop-lts for voice features until Pycord 2.7 includes a Python-based audioop implementation.
why dumb?
if it's needed regardless of if you use voice or now, why doesn't it just come with the py-cord installation?
It was a built in, deprecated since 3.11, now it was removed
pycord just didnt update the implementation in time
it is because py-cord 2.6.1 does not officially support python 3.13
Sometimes I regret starting to code, things like this make me lose it
why? it's a really straightforward issue
how can i delete view message after button is clicked?
when i try await self.message.delete() i cant because of 403
is it an ephemeral message
yea
good luck
its super weird to delete ephemeral messages and i dont remember how
.rtfm delete_original_
Second one.
ah yea that
why is that needed tho?
On button click?
edit_original_response
yea
i think
oh ok i will try
interaction.response.edit_message if youre responding
Otherwise what toothy said
thx
i always remember deleting ephemeral messages to be much harder than it is but by next time i forgot already
wait
it just edits the button response
not the view
i need to edit the view it self, not the button response
self.message.edit
what view
403
show a screenshot and tell us what exactly you want to edit
then you have to pass in interaction with your view pobably idk
he responds ephemeral with a view to a message then wants to edit the message containing the view
- i use slash command
- view is sent with 2 buttons
- when button is clicked edit the view
yea
so there is only one message?
interaction.response.edit_message should work
should i call that on the button press interaction?
okay it works, thx
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()
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


