#Basic Pycord Help
1 messages · Page 40 of 1
Because I definitely wasn't working on prod
its a bot for like 10 people, its not that important
bruh
Push to remote -> remote builds docker image -> docker image is pulled locally -> restart -> test
couldn't be arsed grabbing a token for local dev
wtf
idk where my phone is so I can't get my 2fa code
that is omega cursed
Am I allowed to have async functions in a class?
and then just await those functions?
Yes?
and i can just await those and it'll just work like not having them in a class?
What are you trying to do?
Class methods can be async, yes.
but you will need ot use aenter and aexit if you want a class to be async
and init are not allowed for async class
no init is allowed?
in my memory you cant use init for an async class
There are no tags that match your search.
.tag asyncinit
Add this to you class to allow async init-
async def __new__(cls, *args, **kwargs):
obj = super().__new__(cls)
await obj.__init__(*args, **kwargs)
return obj
I just changed it from __init__ to init() and then just called that directly after a reference is made
is that alright?
neat
async def init(self, db_path: str = "database.db") -> aiosqlite.Connection:
i still wonder why its not supported natively tho
oversight imo
I'm getting this error, no idea why: ```bash
data_handler = await data_handler.init()
^^^^^^^^^^^^
UnboundLocalError: cannot access local variable 'data_handler' where it is not associated with a value
You add this
And you leave your async init as it was before
nope, doesn't work
i added it
Show your new code
class DataHandler:
async def __new__(cls, *args, **kwargs):
obj = super().__new__(cls)
await obj.__init__(*args, **kwargs)
return obj
async def init(self, db_path: str = "database.db") -> aiosqlite.Connection:
...
bruh
"as it was before"
sorry its working now (so far)
await ctx.followup.send(
"You can't do that!", ephemeral=True)
What is the best way to send a followup thats ephemeral? This obviously doesn't work.
ctx.respond should handle followups and responses for you.
You shouldn't need anything else.
I'll look into it, ty.
How can I make a command that can only be run by a user who ran a different command?
In this example, I need the user that ran /host_lie_to_me to be the only one who can run /cancel_lie_to_me
also the command descriptions don't show up idk why
the descriptions are put in the decorator
what do you mean? It shows up like this for me
@game.command(description="...")
Oh
hmmm you can use the checks parameter of your command group and check if a command was executed before
I don't know if there is another way but I can think of that solution.

only interaction responses can be ephemeral, not followups
yep, I got my answer of switiching to respond and how it follows what value I put in ctx.defer
wrong!
for i in range(5): await ctx.respond(str(i), ephemeral=bool(i%2))```
oop, sorry. Is it because followups still use the interaction token?
and did that change at some point or am I completely mis-remembering?
yep, and always been possible !
so you have 15 minutes to do as many ephemeral responses as you want
3.11
I'm lost idk how to check if a command was executed before
Oh wait
Maybe I can update a variable
Okay, I updated it but I'm not sure how to assign the user who ran the command into the variable the_host
discord.Thread.add_user():
You must have ~Permissions.send_messages_in_threads to add a user to a public thread. If the thread is private and
invitable is False, then
~Permissions.manage_threads is required.
What permissions do I need, if the thread is private but invitable is True?
Oh I guess no permissions are needed in that case? Because everyone in the thread can invite other users, including the bot... Got it xD
save that user in a cog variable
Is that normal that await bot.sync_commands([command], method="individual") doesnt raise any error while loading an invalide command while await bot.sync_commands() does ?
File "C:\Users\rahul\Downloads\Prix Bot\main.py", line 2, in <module>
from discord.ext import commands
ImportError: cannot import name 'commands' from 'discord.ext' (unknown location)```
I have uninstalled discord.py and installed pycord 2.5.0 correctly but why is it not working???
can you show ur pip list ?
sure wait
aiosignal 1.3.1
async-timeout 3.0.1
asyncio 3.4.3
attrs 23.2.0
beautifulsoup4 4.12.3
blinker 1.7.0
bs4 0.0.2
certifi 2024.2.2
cffi 1.16.0
chardet 3.0.4
charset-normalizer 3.3.2
click 8.1.7
colorama 0.4.6
DateTime 5.5
discord-py-slash-command 3.0.3
discord-ui 5.1.6
ffmpeg 1.4
ffmpeg-python 0.2.0
Flask 3.0.2
frozenlist 1.4.1
future 1.0.0
googletrans 3.0.0
h11 0.9.0
h2 3.2.0
hpack 3.0.0
hstspreload 2024.4.1
httpcore 0.9.1
httpx 0.13.3
hyperframe 5.2.0
idna 2.10
imageio-ffmpeg 0.4.9
itsdangerous 2.1.2
Jinja2 3.1.3
MarkupSafe 2.1.5
multidict 6.0.5
numpy 1.26.4
openai 0.28.0
pip 24.0
py-cord 2.5.0
pycord 0.1.1
pycparser 2.22
pyfiglet 0.8.post1
PyNaCl 1.5.0
pystyle 2.9
python-dotenv 1.0.1
pytz 2024.1
requests 2.31.0
rfc3986 1.5.0
setuptools 69.5.1
sniffio 1.3.1
soupsieve 2.5
tqdm 4.66.2
typing_extensions 4.10.0
urllib3 2.2.1
Werkzeug 3.0.1
yarl 1.9.4
youtube-dl 2021.12.17
youtube-search-python 1.5.1
zope.interface 6.3```
Here all pips
idk why i have installed useless pips 🤡
discord-py-slash-command 3.0.3
discord-ui
good job installing the wrong pycord and the right pycord at the same time lol
discord-py-slash-command 3.0.3
discord-ui 5.1.6
yes yes ik
try to remove this one
okk
and also uninstall both pycords, and reinstall the right one after
just to make sure everything is cleanly installed
which is the right one?
py-cord
??
yes
the bot started but not responding to my commands and not showing any errors on terminal
intents = discord.Intents.all()```
Are these intents enough to run the bot?
I don't think you understand python
I am beginner
I know
show your code and how it looks in discord
thats why getting errors
if you use all intents you also need to enable all in the developer dashboard
I have enabled all
Heads up @karmic river! We've detected one or more tokens in your attachments!
- Found token of 1239810411541430302 (Prix) in attachment
main.py. You can regenerate it here.
Fyi: Each token might trigger a system message by discord, if it's valid.
Please avoid uploading tokens in future, even if they aren't valid anymore.
Stay Safe!
bruh
regenerate your token now
what is the point to have 2 times the same variables with different value
I was about to say that
wait did you put your bot on GitHub with the token lmao
oh ok
nah
idk
so why are u doing that ?
exactly
are you coding without thinking ?
they're new to programming they already said that
chill out
making the bot for my own server
no but like
yes
luma
there's no need for this
this will help you to improve this it will make u understand how does that work
you're basically telling them "I think you're stupid"
that doesn't really help
I mean, Luma is right lmao, you won't learn if you code without thinking what you're typing
i am trying from 3 days 🤡
in which way im saying that he is stuping ?
because you are basically saying they don't think when coding
im saying that he should understand what he is doing to improve
If they don't know how the code they copied from somewhere works, or the programming language at all, it doesn't matter how much they think about it
they need to learn about it with tutorials or whatever
Lack of knowledge isn't to be confused with lack of thinking
man like ur trying to do idk why but there is not need for that
im saying he should try to understand his code
that's all
there's also no need for this
this isn't helpful in any way
it's just rude
for telling to someone you should try to understand what ur are doing ?????,
~~ @sage tendon you are a helper~~
okay so lucifer continue to not understand anything about ur code
I know, but I don't need some stupid role to tell people what they're doing isn't nice
I mean you could mute some like Luma
i am sorry but i dont understand why telling to someone he should understand his code to improve his rude
like explain me
because you're saying it in a very specific way that has a rude undertone
fine by me
not discuss this here >.<
that took kinda long to write ;3
I was going to say shut up but I realized in the topic of rudeness I am not much better if I say that
@karmic river im sorry if you were thinking it was rude that was not my intention, what im trying to tell you is when you are putting a line try to understand the purpose of that, you can for exemple use comment like so :
intents = discord.Intents.default() # put intent by default
intents = discord.Intents.all() # activate all intents
Then it will help you to understand for exemple that there is no need to put intents by default since just after you are putting all
^^ also Luma is french, english is not his first language so saying something thats meant good and accidentally ends up "rude" if you look at it that way is just an accident.
it's also my second language
my english still need some improvements
ik but i forgot to remove the default intents thats why it was there
I'll continue this discussion in#general tho, stick to help here.
what ur issue then ?
(without sending the token)
The issue is that my bot is running but not responding to my commands
are you using slash or prefix command ?
well, I / we still need your code and what you see in discord lol
prefix
are you using an on_message event ?
no i am using bot_command()
can you just show your code lol
uh wait
?tag paste
Please copy and paste your code here. This makes it easier for everyone helping you.
if you send the token again you win a prize
.
not sending this time lol
can you please send it as a normal text message lol
I can't open that on mobile
its working fine
it'll automatically send as message.txt :)
so also the help
yes
are you using the good prefix ?
lol
yes
with which scopes did you invite your bot?
my friend told me to make this type of bot so I started
yea well that dodged my question lolw
when you made the invite link for your bot did you actually check the bot checkmark
I think that's actually the only necessary one but not sure rn
does the on_ready is triggered ?
wdym?
yes
I mean what I mean lol
you made an invite for the bot at some point
did you check the bot scope y/n
yes
does it have permissions?
yes
administrator cuz just testing the bot rn
can you add an on_message to check if the bot can see the message typed by the user ?
dont forget to add the process
okay i could check your code now and holy HELL why do you have a billion imports
.rftm process_message
yea sure
.rtfm process_message
Target not found, try again and make sure to check your spelling.
.rtfm process_command
It is certainly a github bot
and you should also consider cog
ok I'll remove it
you dont need like 90% of that code in general lmao
all the imports, all the add_commands..
🤡 that was a waste of time?
also the way that help command is done is so unbelievably messy lmao
you copied it from some template repo right?
well, yes
and it might actually be the reason your commands dont work
lol the bot is working with the on_message command
ok i can remove them
How can I set the overwrites for @everyone, when using discord.Guild.create_voice_channel? What do I use as key in the dict?
the everyone role is a normal role with an ID, so i think you can just get that (somehow) and then put it there like any other role
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 ...
just use this, then you get the role object directly
yeah. I was just thinking what if I just have the guild id, but if I can use the create channel method I already have the guild object xD
i think its because you fixed the prefix
try without whatever you did with on_message too
not necessarily :)))
but yes
np
is there a big difference between on_connect and on_ready for the shard ? or should i use only one or the other, its for simple logging
I think on_connect is not a discord event but a pycord internal event. Meaning that on_connect is probably called before the bot is ready. I'd use on_ready
Hey all, is there a way to know when a Member has completed their onboarding? I want to trigger a message once they've properly entered the server. 
Does pycord update the position of all channels in cache, if I create, delete, move a channel?
it should, yes
which kind of onboarding
like the actual actual onboarding with role select? I think that isn't possible
Bummer. That's kinda what I figured.
there is Member.pending but to this day i could not get a clear answer on what that means
I THINK it only checks if people agreed to the rules (if you set that up)
i never tested it with an alt yet so maybe try that (and tell me if you do)
I'll keep you posted!~
Well, you could listen to the role add event and if it's any of the roles from the onboarding use that as onboarding finished...
ok so
i have a command that also checks member.pending
and some people there have onboarding roles
so its not determined solely by the role selection
let me check smth
discord also says they agreed to the rules
so god knows why they're pending
maybe it also includes the verification level but not sure
This could work, but I would think it would also get triggered if they add roles post-onboarding too.
or maybe they have not completed all the additional onboarding steps like say hello in..., go to this channel etc
well i just put my verif level to email-only and they are still all there so god knows what member.pending actually means
but from experience, a member that is pending is unable to chat, and a member that ISNT pending is always able to chat
Currently it sends a message after 60 seconds based on the roles the member has at that time.
It would, but you could also consider the time they joined...
this is as exact as my testing gets, take from that what you will
I appreciate you poking around for me! 
yea no i already knew that before lol
but thats literally all i know about it still
i wish it was clearly documented
Sameeee
you actually gave me an idea
currently, I'm waiting 20s after join to send my welcome message (for bot kick reasons)
but i could actually wait for a member update that changes pending
doesnt the on_member_join is trigger after the on_boarding ?
No, that appears to trigger once they enter the guild - like pre-onboarding
i did this now, thx for the idea
Yay, I helped ^.^ lol
okay... apparently pending doesnt rely on onboarding at all
just tested my new thingy and the pending flag changed before they selected any roles
(unless i messed smth else up)
Ill tell you when i know
pending is for the rules section, not roles/channel selection
but doesnt that come after the roles and channels?
i'm 99.99% sure that is the order
roles > rules
and i have mandatory roles, so, it cant be that someone has no roles but isnt pending
can't you track role that are from the boarding pass and then when the user got those role you trigger ur thing
yea i'm doing that
by len(member.roles) though, i have like 70 onboarding roles
Can I use the discord.ui.button decorator to add a button with dynamic properties (label, custom id, etc.) to a view?
I don't want to define a whole class for it, so I thought maybe I can just use the decorator in the view init. Does that work?
well, you can, but where are you gonna define the callback
(Button, not button)
No. I mean button xD
no
That's the decorator
in the view
oh wait
just do self.button_callback_name.attribute = ... in your init
like self.button.custom_id or whatever
that does work?
yeah but I want to use the same callback for two different buttons...
...
without writing it twice ofc xD
then make the buttons manually instead of using the decorator
By subclassing you mean?
no
button = Button(...)
button.callback = self.callback
or alternatively you can define on_interaction in your view as a callback for all items
that's probably the wrong name
it's interaction_check
oh that's nice. Totally forgot about that
How would I register a persistent View only for a certain message? I have a view that I want to be persistent but it holds message specific data so I can't use it for every interaction but only for one message each. Would it be enough to use Bot.add_view with the message_id parameter set? I don't really understand what they mean with "The message ID that the view is attached to. This is currently used to refresh the view's state during message update events. If not given then message update events are not propagated for the view."
db i suppose
I want to avoid that. But I think Bot.add_view works the way I need it to.
well, what data are we talking about
Bot.add_view(ViewInstance1, message_id=111)
Bot.add_view(ViewInstance2, message_id=222) # this would not overwrite ViewInstance1 and will only be called, when from message 222
just some semi-temporary data. Meaning it's not that bad if it's gone after a bot restart.
Basically who clicked what button
I'm just now learning the cogs system, but cant find anything about SlashCommandGroups within cogs, should the be their own cog, own extention?
Here's the slash cog groups example.
thank you my friend
I don't understand sorry
How does the cog know what I wrote in the LiarGame class?
what do you mean?
I don't know how to explain it
For example... how do I get it to recognize the class? Does that make sense?
mmm you want to know how a class is recognized as a Cog?
🤔
I don't know

Also the description you told me to put into the bot command gives me a syntax error
This is why you need to learn python. No offense.
is there a way to do something like this?
await ctx.defer()
if something is True:
await ctx.respond('true', ephemeral = True)
await ctx.respond('bla...')
can i do something in reverse? or use ctx.send for the last message
if the condition check for whether it should be ephemeral or not doesn't take too long, do it before the defer
how much time do i have to defer?
seems like im like 2 or 3 seconds away from being able to fit it in
3 seconds
oof, can't fit it in then, is it better to just delete the message and ctx.send after?
Does anyone happen to know what the problem could be?
https://max1385.no-friends.xyz/Discord_7UDJEaeHnC.png
sometimes when i edit the embed on button click. the embed message disappears
How did you edit it?
await interaction.message.edit(embed=embed, view=self,attachments=[])
embed.set_image(url="attachment://plot.png")
and where is embed definied ?
because you are here replacing the emebd with embed=embed
embed = interaction.message.embeds[0]
ur message only have 1 embed ?
yes
its like sometimes when people click placed bet the image vanishes
all the other things work
and thats just some random times
if that can help you, im doing like that :
file = discord.File("Resources/Images/xpIMAGE.png", filename="card.png")
embed.set_image(url="attachment://card.png")
await interaction.message.edit(embed=embed, view=self, file=file)
the file is a bytesio file generated when the bot first posts the embed so i am not saving the file
even when im not saving it im using discord.File, you should give it a try i guess
i dont have any other solution
so shouldn’t you also add file=chart ?
seperate function
u mean this , file=file?
i cant really get this file as it is not saved in
how do i even ddefine file = discord.File("Resources/Images/xpIMAGE.png", filename="card.png")
this
Resources/Images/xpIMAGE.png file is not saved like this
if i were to save files i might need 1tb of space lol
this one was save, but i also do that without saving it
i dont remeber where in my bot but let me take a look
here i did :
captcha_code = ''.join(random.choices(string.ascii_letters + string.digits, k=6))
image = ImageCaptcha(width=280, height=90)
data = image.generate(captcha_code)
file = discord.File(data, "captcha.png")
embed = discord.Embed(title=welcome.captcha.title, description=welcome.captcha.description)
embed.set_image(url='attachment://captcha.png')
await new_channel.send(content=member.mention,embed=embed, file=file)
Is this a random error? Does it happen everytime you start your bot or does it just happen after a few minutes / hours
Because your connection gets closed for some reason.
I do know that discord tends to pause and resume sessions in the background which is normal (except for when you're spamming the discord API) but you could probably get a lot more info by implementing an event log by using the logging module.
https://docs.pycord.dev/en/stable/logging.html here's some information to get you started
Pycord logs errors and debug information via the logging python module. It is strongly recommended that the logging module is configured, as no errors or warnings will be output if it is not set up...
after a few hours after I start
Yeah- try the logging module :>
It could be that some task or some of your code which is constantly checking something or updating nonstop crashes on a client pause- and cannot live with a few second pause.
Or you're spamming the API somewhere and discord rate limits you :P
Again- logging module is the way to go- it'll also show you if you're making too many requests.
Or posts- whatever
What is the __cancel_callback method in discord.Modal for? It doesn't seem to have any purpose...
shouldn't it be called in the discord.Modal.stop method?
its an internal methode so i dont think we should use it
It's never used anywhere... That's what I find strange.
because its an internal methode, user have no point to use it
its used in the _start_listening_from_store function
I know that it's not supposed to be used by the user. But it does not even get used internally. So it's basically useless. And I'm wondering why it's there.
its used internally
It's only defined there, not used.
in the _start_listening_from_store
with used I mean called
That's from discord.ui.View not discord.ui.Modal
when a view is stop its used to remove everything iguess
I'm talking about discord.ui.Modal!
I guess too... But it could actually serve a purpose if it were implemented...
and since we cant stop a modal, it's useless
i think thats intended to be the callback for when the user cancels a modal
well, it depends. We can, but all it currently does it calling the on_timeout method. It could be used to remove the modal from the store or something similar.
I think the modal in general is missing some functionality... But I'm too lazy for a PR xD
It can be removed from the internal modal store. But it can only be removed per user not per modal.
that's probably why they didn't implement it because when the timeout happens it's (currently) not possible to know which user the modal is for.
just paste that into the code? I think it's down to a few tasks.
this doesnt do any api requets
its just logging
in my console?
are you hosting ur bot on a computer or an host
mb i didnt read correctly, paste the first one that will show u discord log
It does show if your client stops and continues a session
Or couldn't connect- / tries to connect but fails
okay
yeah i didnt read correctly
.
i think the issue is simply ur wifi/ host has some issue and disconnect nothing dangerous, logging can help
is that possible to disable the logging info from pycord while using it for urself ?
i want to use logger.info() in my code but i dont want to get every message from pycord about the info, i really dont think that possible but we never know
(i dont want to remove completly the logging from pycord because of the warning etc)
Can I get the message ID if I clicked the button?
with the interaction

I tried that but when I clicked it shows me a random number
original_response()
Thanks! I got it
honestly i have no way to recreate the image like u do. The point is the image is recreated through data from an api. If i were to re request the data everytime someone clicked the button, it would be a bummer
Can you open a post explaining everything from the beginning ?
It will be more easy because I’m lost rn so it’s a little bit hard to help u
I can't defer an interaction and then send a modal, can I?
no

L /s
loser
Thx. I just received the notification for this message and was a bit irritated why you would call me loser xD
merp!
Using a slash command group inside a cog seems to break the parameter list and considers ctx as a Discord slash command parameter.
grotto_translate = bot.create_group("grotto_translate", "Grotto Translation Commands")
class Grottos(commands.Cog):
@grotto_translate.command(name="english", description="Translate a Grotto")
async def grotto_translate_english(self, ctx, ...):
How can I fix this?
that's not how you make a scg in a cog
Here's the slash cog groups example.
Well, obviously because it doesn't work lol, but how do I? That's what the docs say
Thanks
where
because if it says that then it's wrong
yeah because it doesn't work in cogs
Well then it should mention that
k
If you don't have the power to change that, don't be snarky, instead point me to where I can make a suggestion
i can change that
I don't think I see a practical difference
Unless using a group created with bot.create_group outside of the cog is the crucial detail?
yes
what does this mean
I changed the folder that my cog was in to a subfolder
and also changed the path
and it prints in the file's setup function
do all other commands work?
was the bot invited correctly
commands worked before so I assume so
ooooo
something interesting
I have a print statement when it syncs commands
but it doesn't print
wat does that mean
nvm it prints now
that's so weird
WHOA
ok I figured it out
I had to REFRESH and then click instead of press enter to run the slash command
heh sorry
& ty
:o
heisenburger
I think this happens when the integration is updated while the discord client is "accessing it". IE you have the command typed in the text bot and than restart the bot than press enter. I might be wrong tho
probably something along those lines
Looks great, thank you!
Im using an f-string spread over multiple lines for my bots response. Is there a way to stop the response being tabbed in like can be seen in forst screenshot?
It's in the f string itself, shift tab it out
those tabs are characters in the actual f string
what you could do instead is .replace(" ", "")
which would remove all sequences of four spaces
Thank you! That did it.
its fine 🙂
I am looking to host my discord bot on a cloud service (looking for 4 Gb of RAM). I found that OVH looks like a great option (very cheap). I was wondering if anybody used it before, because when checking comments on internet a lot of people are saying their Ip are in a lot of blacklists. Would it work to host discord bot ?
because when checking comments on internet a lot of people are saying their Ip are in a lot of blacklists
if that's a big problem sparkedhost might be good cause they have a really really good customer service (from my experience)
but
are bad ips a problem for a discord bot?
exactly, I am not sure if it is a problem. If it is not, them no problem with OVH
I will go take a look at sparkedhost !
How can I add my commands inside of the bot class?
class TicketsBot(commands.Bot):
def __init__(self):
super().__init__(
help_command=None,
command_prefix='+',
intents=discord.Intents.all()
)
async def on_ready(self):
print(f'Successfully logged in as {self.user}')
why do you want to do that
but if you do that, you can probably just see how the decorator adds the command and do that in __init__ for a function that you make inside the class
found it
self.add_application_command(result)
def add_application_command(self, command: ApplicationCommand) -> None:
"""Adds a :class:`.ApplicationCommand` into the internal list of commands.
This is usually not called, instead the :meth:`command` or
other shortcut decorators are used instead.
.. versionadded:: 2.0
Parameters
----------
command: :class:`.ApplicationCommand`
The command to add.
"""```
Cool;
Thanks.
Here's the slash cog example.
@wary wyvern
Guys, can someone help me with an example of how to use the checks parameter of the SlashCommandGroup class?
for a custom check ?
Yes, I want to check if a user is an administrator
here an example :
example = discord.SlashCommandGroup(name="example", default_member_permissions=discord.Permissions(administrator=True))
oh, it works, thank you very much 
(Note that admins can change this permission !)
I noticed that group commands no longer appear for non-admin users, is this correct? 🤔
If you are using default_member_permissions, yes that's how it works
It will hide it if the user can't use it
Server admins can change the required permissions; on the other hand, checks is a list of internal checks that are always enforced, but they do not change visibility on discord
I have learned something new, thanks for the clarification 
Can I edit an interaction's response given only the interaction ID as an integer, and not the full interaction object?
No, because interactions also have a token required to make further responses.
you could probably edit it if you have the channel and message id
Would it be possible if I saved the token alongside the ID?
how long after are you trying to edit
if you mean interaction reponse from the ctx.repond; only way is to do ctx.interaction.original_responset() and edit that
Trying to see if I can edit previously sent messages in a user bot where I don't have direct access to messages
Though I'm aware that interactions have a short timeout period it should be fine for my purposes
because in the context of interactions, bots can respond in channels/guilds they don't have access to
is it under 15 mins?
It is yes
its possible to run a slash command in a channel where the bot has no access ?
then just store the interaction object itself? surely your bot will be alive during that time
always has been
never knew that
cant you do :
await ctx.repond()
message = await ctx.original_message()
await message.edit()
This is likely a better idea it would just require some refactoring
nope
Was curious if there was a quicker solution to avoid that :P
why ?
just use on_interaction to store every interaction by ID
bot cant edit message if there have no access to the channel?
because you can't edit a message in a channel you can't access
ok
(botvars are very useful)
for what usecase do you need a user to run a command where the bot has no access to then edit it after ?
well just for general followups, as long as it's within 15 mins it's not too unusual
the "bot doesn't have access" context is completely irrelevant, because this is not uncommon with interactions - they're built on strict rules where they can act freely in that context
with the release of user commands, this will be even more common
for the most part though with app commands context is fixed right?
unless it interacts with the rest of the server if it's a mod bot or something
as in?
you can run an app command from a bot anywhere in the server if you have perms
right
but text commands the bot might have problems because it won't even be able to respond at all and you won't know if it can respond
which is why they aren't encouraged
yeeeep
like do you have an example
for what
oh lol you already mentioned that
you're starting to sound more like toothy Ultimately i don't know how their bot is structured, but literally just
- Respond to command
- Do something in the background for like, 10 mins?
- Update the same response
wow thx
:)
no like im trying to underrstand the usecase lmao
but i have a reason, namely, the xy problem
like i learbned thing like that
it wasnt meaning to be like is useless
its more like if i underestand why i might need it later for something
most people would have all this code in one command, but it's possible that people have structured their bots differently to feed stuff across different files or classes
you could defer it and pass the interaction to whatever different class you use
that'd work right
but if i understand is not like an actual feature is more to just prevent in case it doesnt have access
well no, it is explicitly a feature
discord gives you 15 minutes to do whatever you want with an interaction token
so you want to respond to something that you don't have access to after 15 mins but the command might take more an 15 mins
I see!
well for this user, it's under 15 minutes so it's a valid question
no but i mean his command was not for a channel that he doesnt have access at the begining, its just in case it doesnt have access that he wants to do that if i understand
so it is possible
now i understand
the point is that developers are making their bots on the assumption that the bot doesn't have access
i was thinking the point of his command was to be run in a channel where he doesnt have access to it
yes i understand now
i should implemenrte somethjing like that too when i need to edit after
sorry again if you were thinking i was saying it was useless, i was just trying to understand ;)
wat
how would they even
nah it's fine LOL
who
not everyone of course, but with interactions this isn't unusual
if the bot doesnt have admin it is useful
and people making dedicated bots/commands for user contexts, where the bot has access to even less data
text commands = prefix command ?
before bots could run commands in channels they don't have access to, now they can run in guilds they don't have access to
...user commands have existed for a month now
wasnt it already kinda possible with integration ?
..........................................................................................
indeed, but http bots weren't as commonplace
hooooww
(not merged yet since it's still a "preview" feature)
no waaaay
wait so how does that work
are you just able to run the bot wherever
but only you can see it
which makes sense
for now
its not ephemeral in servers <200 members right now
and always*, the permission will force ephemeral instead of disabling them
yea ok true
wait is it accessible or not even ephemeral
not
ephemeral
(by default)
might there be a thing like discord.Attachment but instead of just uploading 1 attachment you can upload bunch?
in slash commands
nope
Hi, How do some bots have commands with 2 words? Is that possible with py cord, I know obv underscore, but there's like /prune messages with a space. How do you define that?
slash command groups
thanks for that. probably bit too elaborate for what my implementation though
it's really not hard, it's one line of code at best
Ehhhhhh- trust me- if you try hard enough you can have a very complicated core architecture.
My command groups for example are being self generated based on my folder structure.
Yes, but I like to adhere to KISS
I will never understand these whole command builders and shit, I don't see the point
what
what
I wrote my own command builder ;3
is there a server size limit of when the on_presence_update events stops working?
Hi. Is there any way to retrieve a user's avatar to a form which Pillow can understand? Ideally I don't want to be downloading it and saving to the filesystem if possible. Thank you
nvm, i think Image.read(io.BytesIO(await user.avatar.read())) should work, right?
Can you elaborate on how it work ?, like it automatically create a group based on the folder and the file in the command are sub command ?
To do what and how does it work ?
Try and see, if it doesn’t work I have a solution for that
So, you know that you have to write discord.Option and all the other stuff
Yes for the decorator
And for a description you have to add every time a description=""
I don’t need to do that I have a function for when the bot start it automatically add each name description and localization and choices
So like you put a decorator and it put the description from file ?
My own decorator for it
Its the best way do to it at your own so you gonna learn from it
So ur decorator put name description for options etc
I think the best way is to do a fonction before the bot start to itinerare into the pending command to add all of those for u don’t even have to put the decorator before each command
I will have to learn how to subclass application context also
And also for the slash command
I'm using pycord-multicog extension;
using that decorator
@add_to_group(get_current_folder()) above my normal slash command
it just adds the command to the command group based on where the cog is located in the dir (in what folder);
note I have a cog for every command;
and the get_current_folder() function just does what it says;
import os, inspect
def get_current_folder(stack: int = 2):
"""
Returns the name of the current folder a file is in.
Returns
-------
:class:`str` The name of the current folder.
"""
return str(os.path.basename(get_current_path(stack)))
def get_current_path(stack: int = 1):
return os.path.dirname(os.path.abspath(inspect.stack()[stack].filename))
It gets the current folder where the file that executes the function is located in.
thats smart
rn im doing somehting like that
i have the init where all the group are created
and then folder are sub subgroup
about the same.
i have a suggestion
idk if that possible
but instead of putting the same decorator for each command
cant you at the begining make a function that will do that for each command ?
here how look my commands
what is the use of stack ?
You technically can (according to google), but decorators are meant to be for single functions as they're supposed to be modifiers for a function.
yep so it depend if they used that for each command or not
but why? you still have to put the description somewhere
he does if i understood :
@slash command
@decorator
for then he doesnt need to put name options etc, which is a good idea because i will be too lazy to do each time name=, description=, name_localization=, description_localization=
are they really people who does that for each ?
I never use name= or description=
but then where do you put them
personally i dont i have a function in my setup_hook that put all those attribute. But if i understand zervy does like that :
@config
@slash_command()
async def (self, ctx: discord.applicationContext, member: discord.Member) etc etc
and he doesnt use the decorator since the @config put name description etc, even if i dont know how he can do for choice or more than 1 not required without decorator
With the pycord paginator is it possible to have the embeds for each page get created per page change
I would like to fetch data from the database and present it
The config one is adding choices
And how do u do for multiple non required or autocomplete
Because rn with my thing I can do all of that except multiple required None, default and autocomplete
I'm too lazy to test it: What error do I get, if I try to use discord.Interaction.edit_original_response() on an interaction that I have not responded to?
I tested it anyways. Seems to be a NotFound.
Why does discord.Interaction.edit_original_response() on a component interaction edit the message the component was attached to but in a slash command interaction it edits the response or throws an error?
Considering the following code:
print(await interaction.original_response())
print(interaction.message)
print((await interaction.original_response()) == interaction.message)
Why do I get this output?
<InteractionMessage id=1246171041382797398 channel=<TextChannel id=1117427672683917403 name='help' position=13 nsfw=False category_id=1117427563107721226 news=False> type=<MessageType.application_command: 20> author=<Member id=925830334547910686 name='Testimesti' discriminator='4483' bot=True nick=None guild=<Guild id=717770840221024422 name='The Archive' shard_id=0 chunked=True member_count=14>> flags=<MessageFlags value=0>>
<Message id=1246171041382797398 channel=<TextChannel id=1117427672683917403 name='help' position=13 nsfw=False category_id=1117427563107721226 news=False> type=<MessageType.application_command: 20> author=<Member id=925830334547910686 name='Testimesti' discriminator='4483' bot=True nick=None guild=<Guild id=717770840221024422 name='The Archive' shard_id=0 chunked=True member_count=14>> flags=<MessageFlags value=0>>
False
InteractionMessage and Message have the same id and thus should compare equal. But they don't. Why?
this is the __eq__ method of both of them:
def __eq__(self, other: object) -> bool:
return isinstance(other, self.__class__) and other.id == self.id
Oh and that's exactly the problem.
It checks the class too. Is that intended?
I guess, whoever wrote that didn't consider that self.__class__ doesn't refer to EqualityComparable but to the actual object...
class EqualityComparable:
__slots__ = ()
id: int
def __eq__(self, other: object) -> bool:
return isinstance(other, self.__class__) and other.id == self.id
def __ne__(self, other: object) -> bool:
return not self.__eq__(other)
Hi, if I have an Image object in Pillow, how can I convert it into an EmbedMedia object, or is it necessary for me to save it?
The amount of directories to move
I cant explain
Wait-
Oh- that's a lot of blackmark. I hope this won't be seen as flooded text
Why so many black mark lmaoo. But I think I understood
Like if for example if you have a folder in a folder
Euhhh
So it need to check the first folder read all file and then check for the other folder inside of the first one ?
Wait I'm stupid I should just share a link to it 
You save it to a BytesIO object and seek back to 0, then it's usable in discord.File
what.
Uhhhhhhhhhh
When you call get_current_folder(), it looks two levels up the call stack by default:The first level is the call to get_current_folder itself.The second level is the caller of the function that called get_current_folder.When you call get_current_path(), it looks one level up the call stack by default:The first level is the call to get_current_path.This allows you to dynamically determine the directory or folder name based on where the function was called from, which can be particularly useful for logging, debugging, or handling file paths in scripts and modules.
It just looks 2 levels up >.>
Just encountered the weirdest error in my opinion:py discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction
I'm not sure if this is a once off thing or what. The code is py ctx.respond(embed=embed)
in a bot command
you get an error if the command takes for than 3 seconds to respond
do you use anything like requests?
also try to defer the command
I get this error for some reason
File "/usr/local/lib/python3.10/dist-packages/discord/ext/bridge/__init__.py", line 26, in <module>
from .bot import *
File "/usr/local/lib/python3.10/dist-packages/discord/ext/bridge/bot.py", line 29, in <module>
from discord.interactions import Interaction
ModuleNotFoundError: No module named 'discord.interactions'```
How do I fix this?
Bot was working before
Can you show the pip list pls
----------------------- ----------------
aiohttp 3.8.4
aiosignal 1.3.1
aiosqlite 0.19.0
async-timeout 4.0.2
attrs 23.2.0
Automat 20.2.0
Babel 2.8.0
bcrypt 3.2.0
blinker 1.4
certifi 2020.6.20
chardet 4.0.0
charset-normalizer 3.1.0
click 8.0.3
colorama 0.4.4
command-not-found 0.3
configobj 5.0.6
constantly 15.1.0
croniter 2.0.5
cryptography 3.4.8
dbus-python 1.2.18
discord-py-interactions 5.12.1
discord-typings 0.8.0
distro 1.7.0
distro-info 1.1+ubuntu0.1
dnspython 2.6.1
emoji 2.12.1
ffmpeg-python 0.2.0
frozenlist 1.3.3
future 1.0.0
httplib2 0.20.2
hyperlink 21.0.0
idna 3.3```
is that the full list?
yep
do you use py-cord or discord.py?
than why is it not at the list?
also uninstall the discord.py stuff
also what is that?
idk, tbh, that was from the last botmaker
tried to install, got this:
Requirement already satisfied: ffmpeg-python>=0.2.0 in /usr/local/lib/python3.10/dist-packages (from pycord) (0.2.0)
Requirement already satisfied: numpy in /usr/local/lib/python3.10/dist-packages (from pycord) (1.26.4)
Requirement already satisfied: imageio-ffmpeg>=0.4.2 in /usr/local/lib/python3.10/dist-packages (from pycord) (0.5.0)
Requirement already satisfied: future in /usr/local/lib/python3.10/dist-packages (from ffmpeg-python>=0.2.0->pycord) (1.0.0)
Requirement already satisfied: setuptools in /usr/lib/python3/dist-packages (from imageio-ffmpeg>=0.4.2->pycord) (59.6.0)```
so it's there but... it's not there?
pycord != py-cord
You need to have py-cord
fuck
uninstall these like zervy said too
discord-py-interactions 5.12.1
discord-typings 0.8.0
you should probably uninstall like everything
And you probably are installing them in the wrong place if it says its installed but not showing up
except for pip
Are you using a venv?
nope, previous bot guy wasn't even using fucking git
Im also not really using git
Probably best to start a venv. Than the packages will install to the right place
well, they didn't use any version controll at all
pip freeze > pip.txt
pip uninstall -r pip.txt
@wintry pawn
install py-cord
lmfao
is there really no command to uninstall everything
that’s like saying you should be able to install everything
use_soundboard=True,
how it's called this permission?
sorry, soundboard hasn't been fully implemented yet
how to add
saddo
is there any inbuilt function, which can convert multiple embeds to paginator directly?
you can simply use multiple at once
Just do a list of those embed
And then pass them
embeds = []
Embeds.append(embed) * 10
pages=embeds
Like si
here is how i did it, with a subclass but otherwise its the same:
paginator = MyPaginator(
pages=embeds, show_disabled=False, author_check=True, disable_on_timeout=True, timeout=300
)
await paginator.respond(interaction=ctx.interaction)
"embeds" is a list with several embends in it
alright thanks
welcome
is it something like i can add only 10 embeds in paginator?
embeds has a maximum of 10 elements.
im getting error like this
you can only have 10 embeds per page
(10 embeds per any message)
ohk thanks
isn't it possible to like pass on all the embeds as a list and it the will optimally create the pages and make the paginator?
what do you mean by optimally? It can put 1 embed per page if thats what you mean
Does anyone have a base strucutre of everythingf embeds can include?
its also at the docs what you can do with embeds
its not very clear
which docs are you refering to?
wdym
.embeds
@deft kestrel ^
thank u
i mean like i will pass the whole list, and it will make the pages of 10-10 and rest elements in another page automatically and then send
Just look up how to chunk lists in Python
Then make a page object for each set of embeds
Note that even with the 10 embed limit, all text must be under 6000 characters per message
Hello
How long does it normally take for a guild-only slash command to register?
Added a new one and it's not registering as it usually is
thanks, should do be followed be a ctx.followup or will ctx.respond() work just fine?
respond
ty
thunderinmc@bots:~/listingbot$ python3 bot.py
Traceback (most recent call last):
File "/home/thunderinmc/listingbot/bot.py", line 8, in <module>
from views.account_owner import AccOwnerView
File "/home/thunderinmc/listingbot/views/account_owner.py", line 3, in <module>
from discord.ui import Button, View
File "/home/thunderinmc/.pyenv/versions/3.10.7/lib/python3.10/site-packages/discord/ui/init.py", line 11, in <module>
from .button import *
File "/home/thunderinmc/.pyenv/versions/3.10.7/lib/python3.10/site-packages/discord/ui/button.py", line 32, in <module>
from ..components import Button as ButtonComponent
File "/home/thunderinmc/.pyenv/versions/3.10.7/lib/python3.10/site-packages/discord/components.py", line 30, in <module>
from .enums import ButtonStyle, ChannelType, ComponentType, InputTextStyle, try_enum
ModuleNotFoundError: No module named 'discord.enums'
any ideas guys?
i slapped this on a vps and it very much not willing to run
What's the requirements.txt?
its possible to make 2 select menus in 1line?
like buttons with rows
like that
all what i got its my bestxd
you can't make select menus side by side
i've a interaction code,
Even tho I haven't set ephemeral=True it still doesn't show to others.
Can you show some of the code?
Oh don't mind my bad there I missed it in another file,
Anyways, Another Issue I am facing is that options are limited to 25, isn;t there a way to increase the limit or a better approach to it?
choices? at slash commands?
one is a select options for a select menu and the other one is at slash commands
the prior one
dropdown got a limit of 25 sadly and you cannot increase it
do you use a str menu?
nope, I didnt define such thing
so you just did ui.Select?
Yes, Can i get a visual represention of its types to get a better understanding of difference between them
Although am just using them to show strings so naturally i should be going for string type by the ring of it. It increases the limit?
Ah I see
Whats the limit for string one
.
Learn all about implementing Select Menus or Dropdowns in your Discord Bot with Pycord.
I read somewhere that its 40 for string ones?
nope, 25
(you can only specify string anyway; the others are automatic)
hey, anyone noticed missing avatars while not using cache?
nope
I know this isnt pycord related but pythong isnt pythoning right now, basically i have the bot token set in an Enviroment
i can read it from all python files
but it doesnt work on 1 specific one
even though it read it the same way as the other ones:
from os import getenv
from dotenv import load_dotenv
load_dotenv(override=True)
...
forgot to mention that i set it
what
Like i get the token from the database wit ha function
set it an an enviroment variable and then read it back liket hat
...why
because i want to use the token between different python files for various discord requests
Yeal lemme store 60000 bot tokens in a env file
If you have 60000 bot tokens you're doing it wrong
or abusing 
Just look at my profile conections
why do you tell people to look at your connections in your about me lol
So people know im not an imposter
basically i launch my bot in a docker container which gets the token from the database. reading BOT_TOKEN from the ENVIROMENT (NOT .ENV) works fine on 3/4 files
but it doesnt on that one specific one
why set a token in a environnement if you get it from the database ?
So i dont have to read it 4 different times
fetchall from the database
for token in tokens :
do your thing
why not just store it as a variable ?
because i have 4 different files
from ... import token
thats a thing?
bruh i thought that only worked for functions
the more you know
that was it
so now everything is working fine ?
yeah i have to fix some parts of the code to use that from ... import tt
good luck then
i also had some issues with loading it via aiohttp CS as they were outdated 
btw
member = member or ctx.author
does this member has an avatar for the server?
use f Strings lol
member.color that a thing ?
i dont understand what is member.color
its display_avatar
oooo
im more into .format in this bot for consistency haha
display_avatar should show the avatar of thge member in the server by definition(i guess) so maybe i does an error with that
I'll be real I think I had a similar issue now that I think of it
server - (is missing) > user - (is missing) > default
also do you have this issue using user and not member ?
yeah its mostly invalid when someone change avatar
I pass display avatars to an API
and the past days it's been broken a couple of times
I thought it was the API, but it might have just been discord not working then
yeah i think its more like api issue
but i pref to ask
discord is a lot broken lately
where is your .url at the avatar?
any i think
its asset so theres no need for that
not needed (?)
yesterdaty it was not possible to add some bot
can you give me l'id of the member where you cant get the avatar ?
just to try if i have the same issue for that member
not missing but invalid *
but i think it would be strange then
cause they work after hard bot restart
so i was wondering if its not issue related to lib also
possible
ill add some debug for it
and mby ill find some issues haha
tf
avatar in logs was valid
i mean url
How do I set the presence to 'watching me' using pycord
yeah discord embeds are broken
Can I have the full snippet
that is literally everything lol
its a kwarg for the bot constructor
yeah but before activity=Activity
manual PIL load vs embed
discord.Bot(activity..)
async def on_ready():
print(f"WORKING AS {bot.user}")
discord.Bot(activity=Activity(type=ActivityType.watching, name="you"))
await main() ``` ??
lol
you can set / change it in on_ready
but there's no point if its supposed to be static
you should not use discord.Bot in the on_ready
if you want to make it change in the on_ready you should use :
await bot.change_presence(activity=activity)
kinda stupid but fetching it and passing as attachment works without any problems haha
it seems that discord embed breaks after setting a newly changed avatar/banner etc.
how can i add try my command in the bot profile ?
what if i want it to be changing
then change it when you want
can you help with this
Concept
oh cool
Okay, so I wanted to have a single command that is prefix only (not a slash command) and there are 2 problems
- bot.command() still creates slash command
- if the function does not use .respond(), but .send() then discord shows message that the app is not responding
bot = discord.Bot(command_prefix='?', intents=intents)
@bot.command(name='debug', description='debug stuff etc.')
@commands.has_role(RoleId.admin)
async def debug(ctx: discord.ApplicationContext):
await ctx.send('test')
this should be prefix command, but it's not + shows up (and works) as a slash one
you need to use commands.Bot for prefix commands
ohhh, will try, thanks
you currently mix slash and prefix commands
yup, during migrating (from discord.py) I changed it to discord.Bot as it said in one tutorial (guide.pycord.dev) but changing it back fixed everything, thanks