#Basic Pycord Help
1 messages · Page 14 of 1
Currently local as I try to understand Command Cogs
Just running straight from VSC
So, the bot starts up, as it prints "Logged in as testoor#2791 (ID: 1090496264912773185)
------"
But when I kill the program, it throws the RuntimeError.
Correction the bot does come online
Well, the issue is that the extensions are only being loaded once I nuke the bot
And I have NO CLUE why
So, here's another way I tried to break it down:
EXTENTIONS = ["cogs.wallet_verify"]
intents = discord.Intents.all()
bot = discord.Bot(intents = intents)
for extension in EXTENTIONS:
bot.load_extension(extension)
pass
print(bot.extensions)
@bot.event
async def on_ready():
print("Bot is ready")
#Restart Bot
@bot.slash_command()
async def restart(ctx):
print("hello_dally")
bot.run(TOKEN) #Cherub```
When I nuke, it prints "Cogs Loaded"
and throws RuntimeError
EXTENTIONS = ["cogs.wallet_verify"]
class PersistentViewBot(commands.Bot):
def __init__(self):
intents = discord.Intents.all()
super().__init__(command_prefix=commands.when_mentioned_or("!"), intents=intents)
self.persistent_views_added = False
- for extension in EXTENTIONS:
- bot.load_extension(extension)
- print(bot.extensions)
async def on_ready(self):
if not self.persistent_views_added:
#self.add_view(Create_Team())
self.persistent_views_added = True
bot = PersistentViewBot()
+ for extension in EXTENTIONS:
+ bot.load_extension(extension)
+ print(bot.extensions)
perhaps
oh
I also don't see why you would use if __name__ == "__main__":
if you are just going to ignore it
Agreed - it's unnecessary and unrelated tbh
I can just take that out
Updated for clarity, but still doesn't change the current issues, of course
I can't comprehend how it's able to run the bot without hitting the print statement, even. Much less why it DOES drop it when I stop the program
Problem solved...I had bot.run in my module program 
nested bot running 💀
BIG Fs bro.
thx for helping as always, yo!
.tag slashnoshow
Application Commands Not Showing Up?
- Uninstall libraries that conflict with the
discordnamespace (e.g.discord.py). - Invite your bot with the
application.commandsscope. - Load cogs before
bot.run()(e.g. not inon_ready). - Do not override
on_connect. - Update to the newest version of
py-cord(see?tag install). - Turn off
User Settings > Accessibility > Chat Input > Use legacy chat input. - Share your code and errors.
AttributeError: 'NoneType' object has no attribute 'send'
i am legit sick and tired of getting this error over and over again
i keep getting this error when trying to send a message in a specific channel
BOTLOG_CHANNEL_ID = 1234567890
botLog = client.get_channel(BOTLOG_CHANNEL_ID)
await botLog.send("hi")
i tried using fetch_channel(id) instead of get_channel(id) but i got hit with this error instead:
TypeError: can't send non-None value to a just-started coroutine
i searched the internet, couldn't find anything
anyone knows how to fix this?
it was working in another bot, idk why its not working here
You might have not awaited the fetch_channel() method
botLog = await fetch_channel(id)
?tag get_x
Any function that starts with get_ in Py-cord is retrieving the related object from your bots cache. If the object is not in the bots cache the get_ method will return None. Because of this behavior you should check if the get_x method is None and if it is use the fetch_x method.
Why Is Using fetch_ Without Using get_ First Bad?
The fetch_ method makes a call to the discord API. This API call is unneeded if you already have the information. It will also make your command take longer because it will have to send and than wait for a response from the discord API. It will also contribute to the discord APIs global rate limit of 50 requests per second.
What Is Cache?
The cache is a temporary storage inside your bot. It holds many objects from members to messages. When you restart your bot the cache will be empty. When the cache is full it will delete older objects to make space for the new objects.
worked flawlessly
ty
:OO
so like:
botLog = client.get_channel(ID)
async def test(ctx):
botLog = await client.fetch_channel(ID)
await botLog.send("hi")
if the entire thing is within an async function you don't need to create a new one,
botLog = client.get_channel(ID)
if botLog is None:
botLog = await client.fetch_channel(ID)
await botLog.send("balls")
@solid turtle
nah the get_channel() line is out of the async function
anyways thanks jiggly balls
channel = client.get_channel(123)
match channel:
case None:
channel = await client.fetch_channel(123)
;3
all my life i had never knew that match was a keyword
you can also use ; for one liners
async def test(ctx: discord.ApplicationContext):
await \
ctx.respond \
("text")
you can do so much weird stuff with python xd
also unnecessary stuff
(I am trying to find my uselss Hello World program I once wrote)
the \ stuff?
when your lines are too long
^
yes
print("Imagine writing a super long extended message that wont fit on your screen because this is getting ridiculously long just wait lol xd UwU OwO the mommy is the queen the daddy went to get milk and I am crying in my corner of shame because I am the voxy and idk what to do with my life, see how long it gets now do you?")
my brother in Christ
See
are you alright?
can they also be used to join strings as well
yea that's pretty useless
would only be useful if youre trying to save lines or something
and no its not at one line at the terminal
eh
damn
i should learn more python
same
been learning python for 3+ years but didn't know this shi existed
the match case stuff it kinda new to python
I didnt know the ; existed lol
it got added at 3.10
o
im still using the 3.9 lmao
hasnt the 3.12 released already
Wait until the libs update lul
i heard we can use the same string terminators in f strings
I use 3.11
yea lmao
so just 3.11
yea no im not sleeping
import time, random
def main():
hello_world_list = ["H", "e", "l", "l", "o", ",", " ", "w", "o", "r", "l", "d", "!"]
hello_world_string = ""
for char in hello_world_list:
ascii_code = ord(char)
binary_code = bin(ascii_code)
hex_code = hex(int(binary_code, 2))
new_char = chr(int(hex_code, 16))
hello_world_string += new_char
time.sleep(random.uniform(0.1, 1))
print(hello_world_string)
if __name__ == "__main__":
main()
why
ok wait lemme eval it for you
there u go big man
wgat
now sleep
what is the point
cudnt you just print "heelo world!"
easy promotion
- its not even related to computer science
OK
UwU
should've done
import time, random
def main():
hello_world_list = ["H", "e", "l", "l", "o", ",", " ", "w", "o", "r", "l", "d", "!"]
hello_world_string = ""
- for char in hello_world_list:
- ascii_code = ord(char)
+ for index in range(len(hello_world_list):
+ ascii_code = ord(hello_world_list[index])
binary_code = bin(ascii_code)
hex_code = hex(int(binary_code, 2))
new_char = chr(int(hex_code, 16))
hello_world_string += new_char
time.sleep(random.uniform(0.1, 1))
print(hello_world_string)
if __name__ == "__main__":
main()
Please I beg you include py in that cuz I cannot read it on phone
don't then
having issues with the paginator raising 403 being unable to edit itself. none of my other commands that perform edits get these errors. any known issues? please @ me, this is quite frustrating.
You'll have to share the code to get help with this.
there is tons of possible reasons. simplest ones is when your bot sends a paginator message, user looks at it, is done looking, delets the message, then your bot tries to edit.
shortage of permissions is also a possible reson. settings for the room can mess it up.
but in general; @glad spoke 's advice is best: share the code in question and the error message you get and people will try to help.
Is it possible to add .webm image to an embed or is it treated the same way as videos (so not allowed)?
I'm trying to figure out why they're not being displayed despite correct url
image only
or gif
@glad spoke
the error is occuring within the pagination file. the traceback does not reference my files
can you do alias for slash commands
nope
shame
hey !
with this py str(bot.fetch_user(sentances[sentance][sentance_]["author"]))
that print
<coroutine object Client.fetch_user at 0x000001C892352A40>
why ? and how can i have name please?
The function was never awaited hence it doesn't know the user yet
user = await bot.fetch_user(...)
print(user)
oh ok thanks ❤️
No
Do you have something else installed?
vacefron.py==2.0.3
aiofiles==23.1.0
randseal==3.3.1
roleplaycog==1.0.2
py-cord-dev==2.5.0rc5
jishaku==2.5.1
advlink==0.1.0
typing-extensions==4.5.0
Pillow==9.4.0
PyNaCl==1.5.0
aiodns==3.0.0
brotlipy==0.7.0
youtube-dl==2021.12.17
Babel==2.11.0
probably just uninstall and reinstall
it is likely that something went awry when installing
Hey friends. Just confirming something I asked before - how often may my bot DM a user that initiated a DM?
Am worried about the bot getting flagged as spam by Discord.
I don't think you'll get flagged unless you massively send dms to multiple people.
I was hoping to rely on the fact that since the user first DM'd the bot and not the other way around it wouldn't be flagged at all.
Is there a definition somewhere for what counts as "massively send"ing DMs?
You could email discord support and get a better answer.
Oh, I didn't know you can mail them about such things. What a lovely idea, thank you.
Hi there!
I need the global_name of discord.Member.
So I have to use the Master branch. Obviously an update has been made because I have an error.
File "/home/container/.local/lib/python3.11/site-packages/discord/client.py", line 763, in run
return future.result()
^^^^^^^^^^^^^^^
File "/home/container/.local/lib/python3.11/site-packages/discord/client.py", line 742, in runner
await self.start(*args, **kwargs)
File "/home/container/.local/lib/python3.11/site-packages/discord/client.py", line 706, in start
await self.connect(reconnect=reconnect)
File "/home/container/.local/lib/python3.11/site-packages/discord/client.py", line 600, in connect
await self.ws.poll_event()
File "/home/container/.local/lib/python3.11/site-packages/discord/gateway.py", line 604, in poll_event
await self.received_message(msg.data)
File "/home/container/.local/lib/python3.11/site-packages/discord/gateway.py", line 554, in received_message
func(data)
File "/home/container/.local/lib/python3.11/site-packages/discord/state.py", line 733, in parse_message_reaction_add
raw = RawReactionActionEvent(data, emoji, "REACTION_ADD")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/container/.local/lib/python3.11/site-packages/discord/raw_models.py", line 259, in __init__
self.type: ReactionType = try_enum(data.get("type", 0))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: try_enum() missing 1 required positional argument: 'val'
when my command takes longer to execute it times out
I'd reinstall the lib
Because interactions are supposed to take less than 3 seconds. Otherwise, you need to defer it.
how can i fix it?
Read the last sentence.
how do i defer it?
If you're in a slash command, await ctx.defer()
Hey, just thought I'd follow up on this. Their support said they cannot comment on what exactly are their limitations, but that you should be fine if you follow this: https://discord.com/developers/docs/policy#don’t-do-anything-illegal-harmful-or-otherwise-not-cool
I'm surprised by their fast response lol.
Same!
I got an error:
'''
Traceback (most recent call last):
File "/home/[username redacted]/searchcord/test.py", line 6, in <module>
bot = discord.Bot()
AttributeError: module 'discord' has no attribute 'Bot'
'''
?? 
I've rebooted my machine, I have the problem, I'm working on the Master, how will deleting and reinstalling help me?
Show the pip list pls?
?tag clients
No tag clients found.
?tag client
discord.Client # just for events
discord.Bot # events + slash/user/msg commands
commands.Bot # above + prefixed commands
bridge.Bot # above + bridge commands (application commands and text commands in one)
Because something messed up?... how will restarting your PC magically fix the library?
Also show your pip list.
Are there any rate limit guarantees by py-cord? Or should I do some rate limiting in my own code?
requests~=2.31.0
mysql-connector-python~=8.1.0
git+https://github.com/Pycord-Development/pycord
importlib-metadata
prettytable~=3.8.0
aiohttp~=3.8.4
pytz
That is not the pip list
Normal it's on my server, I haven't changed anything, the problem, in my opinion, comes from the master branch.
Dont use requests
Pycord should handle any rate limits discord warns about. I do not think that discord warns about DM rate limits though. Just make sure that you do not send 10+ unsolicited DMs at a time I would say.
Can you try using the dev version instead.
#library-updates message
Is the global_name already there?
I am fairly confident
Thanks! Sounds like a good rule.
Thank you! It's working again.
So there is a problem with the master.
How many embeds could i sent in one message?
10 embeds according to the d.js docs.
Can you show the pip list?
the loads is weird
Yeah
uninstall py-cord and install py-cord-dev
Thats the branche before
Got the same issue
Thats the reason why i installed py-cord
I installed py-cord-dev.
Then i got the error
then i uninstalled py-cord-dev
Then i installed py-cord
Then i got the error too
do you use an env?
No
can you try it with a env?
Its weird
Env is only a virtual env localy in an other directory. So there should be the same issue
Pretty sure something went wrong with your python install
ye
json is an stblib
XD
Yeah
do you use the microsoft store one or the .exe from the website?
I don't use windows so probably just re-install python tbh
Run the installer .exe and try a repair or do a fresh install of it
this isn't a pycord problem. It's a python/installation issue
halloween spoooooky
🤣
xd
I'm keeping the same issue
What is the python version?
3.11.6
I installed python again.
I downloaded the x64 Windows installer.
Then added the tick to "Add python.exe to path" and then clicked "Install now"
Then I installed py-cord-dev and the error is still the same
does import json and json.loads() even work
idk
But I fixed the error with using the embed description instead of the footer
But thats a crazy weird no sense fix 😂
that's not the source of the issue, but ok
There's no stage channel chat support? :O
I'm blind? :O
it's on the pre-release
ohh I see
you can always use discord.PartialChannel.send
or PartialMessageable
something like that
Will probably role with this for now :)
*roll
Hi! What are the correct permissions to send message in a channel, and is there any channel-specific configuration that needs to be set?
message: discord.Message = await channel.send(message_content)
This command is returning a 403 permission denied error. However, this only happens in a particular server. Other two servers that I have the bot it works just fine. I'm pulling my hairs our trying to figure this out, so if you have any pointers for me I'd be very thankful!
For reference, those are the permissions I request
If your bot doesn't have the permission at the specific channel which you want to send the message then the bot will not be able to send it to the channel
Got it. Does the server admin have to do anything special other than accepting the default invite?
The invite does request for permission to send messages and send messages in threads.
No, the admin only needs to invite the bot.
If he doesn't remove the tick from the permissions which you requested or remove the permissions for the bot at channel which you want to send the message to, then you should be fine
- Can developers create an own activity while using the discord activity shelf?```
They didn't untick that, and they don't have 2FA enabled (I saw that matters for some permissions). The bot works correctly in other servers.
I'll see if I can play around in a private server, find a way to deny that permission, and reverse engineer my way from there
Do you have any question in this message? 😄
Or is it just a simple text message?
No question there! Was just looking to provide closure to our conversation and not leave you hanging. Thanks for the help!
No prob ^^
do embed field value has maximum characters? or unlimited?
Yo! Is there a way to get user locale when said user instance is fetched via fetch_user / get_or_fetch_user? Type hints show that it returns type User, which doesn't have locale on it, only ClientUser has
locale only comes with the interation object
unfortunate
any event listener for when somebody comments on a thread? or have to use on_message?
message event is the way
discord.ext.tasks.Loop
discord.ext.tasks.Loop.__call__
discord.ext.tasks.Loop.add_exception_type
discord.ext.tasks.Loop.after_loop
discord.ext.tasks.Loop.before_loop
discord.ext.tasks.Loop.cancel
discord.ext.tasks.Loop.change_interval
discord.ext.tasks.Loop.clear_exception_types
discord.ext.tasks.Loop.current_loop
discord.ext.tasks.Loop.error
discord.ext.tasks.Loop.failed
discord.ext.tasks.Loop.get_task
discord.ext.tasks.Loop.hours
discord.ext.tasks.Loop.is_being_cancelled
discord.ext.tasks.Loop.is_running
Anyone know why my bot stops working after first using a @bot.event command then a @bot.command() command? I added the await bot.process_commands(ctx)
Show your code
why do you have bot.process_commands(ctx) at the command?
Oh idk
I think I was testing
Yeah, it still completely stops after saying that command in discord
the bot.process_commands should be outside of the if statement
OH
Thank you
and it shouldn’t be anywhere else
Thank you very much it works now.
What is the best database to use for the bot, where the information should be stored like this:
{id: {map: {property1: value, property2: value, property3: value}, inventory: {property1: value, property2: value, property3: value}, anykey: value}, anyid: dict}
how do i like
make a command have attachments
like its mandatory to add an attachment
Pass discord.Attachment as the option type
Is there any way to pass data when loading a bot extension BEFORE the cog starts up?
I'm attempting to dynamically name my slash command group based on the bot that's loading the extension, but I'm having trouble finding a way to do that before startup
You could try on_connect
Will give this a shot, thanks! Just playing with the def setup(bot) rq to see if there's any path to success there either :)
👍
Got it running in def setup(bot) by simply assigning the bot.user.name variable to bot.str_name before loading extensions (since only the bot object is passed at that stage.
Oh you could do that too
I just learned today that you could even assign variables to objects in that manner...that is fucking cool ahahah
^forgib my noob
you can even create a full custome help command with the cogs
Me failing to do that yet again:
Hello everyone,
With a slash command, you can't have the options generated dynamically, can you?
Does anyone have an idea how I can best solve this if I want to specify users for a slash command but the number of users is always different?
So it can be that one time 5 users have to be specified and the next time 10 and the next time only 7.
Does anyone have a good idea for this implementation?
Thanks in advance! 🙂
Here's the slash autocomplete example.
oof...this didn't work how I thought it was...back to the drawing boarding on this issue. on_connect() not seeming to get to the SlashCommandGroup fast enough either
But I can't select several users in the Autocomplete like in a Select Menu, can I?
I have to create an autocomplete for each user I want to add, but I can't create them dynamically.
how do i properly make a button owner only? because a non owner was still able to use the button
you would have to check for the id
or if the user who pressed it is the same as the owner
so no fancy decorator?
buttons are not like commands
that... is a fair argument
as i already have a list of owners, i assume a simplepy if interaction.author.id in owners:should do it?
you get the bot owner id with interaction.client.owner_id change owner_id to owner_ids if you set more than one id to it
Is it possible to add 2 discord.ui.select 's to a command?
And if yes, how because I havent got the slightest of idea how.
You add discord.ui.Selects to views. Class discord.ui.Select twice, add both to your view, and add the view to your message
Can I make @self.points.command() work in this structure in any way, or do I have to lose the decorator and actually build the command?
class Economy(commands.Cog):
def __init__(self, bot):
global points_identifier
self.bot = bot
print("init")
self.points = SlashCommandGroup(name=points_identifier, description=f"All commands related to {points_identifier}")
self.advanced = self.points.create_subgroup("management", f"Manage {points_identifier} system")
def create_commands(self):
@self.points.command()
async def add(self, ctx):
print("function")```
Like this?
class MyView(discord.ui.View):
def __init__(self):
super().__init__()
self.add_item(discord.ui.Select(
placeholder='Choose your color',
min_values=1,
max_values=1,
options=[
discord.SelectOption(label='Red', description='Your favorite color is red', emoji='🔴'),
discord.SelectOption(label='Green', description='Your favorite color is green', emoji='🟢'),
discord.SelectOption(label='Blue', description='Your favorite color is blue', emoji='🔵'),
]
))
self.add_item(discord.ui.Select(
placeholder='Choose your shape',
min_values=1,
max_values=1,
options=[
discord.SelectOption(label='Circle', description='Your favorite shape is a circle', emoji='⭕'),
discord.SelectOption(label='Square', description='Your favorite shape is a square', emoji='🟩'),
discord.SelectOption(label='Triangle', description='Your favorite shape is a triangle', emoji='🔺'),
]
))
@discord.ui.select(custom_id="select1")
async def on_color_select(self, select: discord.ui.Select, interaction: discord.Interaction):
await interaction.response.send_message(f'You selected {select.values[0]} as your favorite color!')
@discord.ui.select(custom_id="select2")
async def on_shape_select(self, select: discord.ui.Select, interaction: discord.Interaction):
await interaction.response.send_message(f'You selected {select.values[0]} as your favorite shape!')
class flavor(Cog):
@add_to_group(get_current_folder())
@discord.slash_command(name="flavor", description="testing select menu's")
async def flavor(self, ctx: discord.ApplicationContext):
await ctx.respond("Choose a flavor!", view=MyView())
def setup(bot):
bot.add_cog(flavor(bot))
I am genuinely confused.
Oh wait I think I understand but fk I gotta go rn
brb
No, you either create entirely seperate classes for the discord.ui.Selects (in the same manner that you class discord.ui.View) or you simply add your perameters to the @discord.ui.Select constructor to do everything within the view class.
The difference is that, when subclassing 2 new discord.ui.Selects, you get to use the view's class variables in those select classes (you cannot use class variables in constructors).
I guess I can just subclass the slash commands? That sounds extra annoying...but if I did..is there a decorator to assign the slash commands within a SlashCommandGroup class?
Scratch that...can't add items to commands.Cog...so idk if there's actually any way to do this at all
Is it possible to have a bot watch for a discord event and ping everyone on the interested list when the event starts?
(can't believe this isn't base functionality in discord)
Wait, it should do that already, no?
I get them all the time, personally
Nonetheless, it's not an @ ping
So there's no trace other than the initial noti AFAIK
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 ...
Should be able to get get user.mention objects from this list and ping away
But yea, if anyone has ideas on how you could dynamically change the name of a Slash command cog group based on data from the Bot that is loading the module, please let me know.
The big issue is that it has to happen before the class is created...which might be impossible.
How can I host a Pycord bot? Although Pycord is specified in the "requirements.txt", the bot always starts without Pycord, which is why all cogs do not work
Everything works fine locally via Pycharm
Show your reqs file
And where are you hosting your bot?
Dumb question, why does your command name need to be dynamic?
You have discord and discord.py
You only use py-cord... remove the other libraries...
thanks, i try this
Why would you install 3 libraries to do the same
It's a LITTLE silly tbh, but I create bot modules for varying clients, and I simply want them to have personalized command names.
Otherwise, there's this potential where calling their community currency a "token" or "points" could be confusing to them or the end user. :/
bc nothing worked and i added more to look if this works
That's usually the source of these issues. They don't play well together. :)
How adding extra libraries will make it work lmao
And how you load the module?
Discord and py-cord only?
As in, what gives the names?
No, just py-cord
does py-cord include discord?
Well, the idea is to find a way to get the bot name or ANY variabnle from the bot BEFORE the commands.Cogs class is created. If I can do this, I can use that data to access a JSON that is named according to that data to get that particular servers choice of name for their "currency"
I'm pretty new to this kind of thing. still learning
But as is, I can't figure out ANY way to get that data dynamically before the actual class is created.
And since you can't subclass commands.Cogs....I'm kinda at a loss
Then you shouldnt be coding a discord bot, you should be learning the python basics.
Wdym
NGL though, Discord bots can be a great learning tool
You can subclass cogs
I know the Python basics. The best way to learn is to apply the basics, for example with a Discord Bot
not using self.add_item though, ye?
What I think of is, creating the command manually (so the name is dynamic), assigning it the callback manually and adding it manually
A discord bot isn't a beginners project.
I think this is the only way, but admittedly, I couldn't figure out how to subclass it without the decorator >.<
Since I couldn't use self.add_item, that is
Subclass the command you mean?
I mean, if you manually create it
Then you add it to the bot manually
With uh bot.add_application_command or something like that
Yeah good luck lol
I've done a few projects like rpgs, web-scrapper and the like. but I've never used databases. neither used it to host something
I learned Python entirely through Discord bots. From the conversation above, you can tell I'm still a fucking noob. However, I have learned a TON through developing Discord bots. I wouldn't be discouraged from it as a beginner. Do whatever keeps you interested in learning - that's my take on it.
But it can be irritating for people who are more experienced because we do miss the basics more often...which...is frustrating for everyone.
I also got the Discord Bot working and am just having problems hosting it. What is the problem?
why such dumb answers bruh
???
i mean dark
That's exactly what I mean. The best way to learn is to use what you have learnt. Whether it's Discord bots or Minecraft plugins. It doesn't matter
Found the error. I had mixed up too much in the regs.txt, now it works.
Solved - create a DB in main.py and write a request to a table on startup with autoincrement ID and bot name. Module checks latest DB entry before creating the commands.Cogs class and successfully acquires the user data. 👍
Glad you figured it out
that took longer than expected.
I think I fixed it tho thank you-
got any tips/code examples for handling ext too large for a single embed/embed field? dont wanna send em in masses
Yes yes it did
Add fields :P
Wait
nvm
I read
but not think
I dont know what other option you have my man
what's Paginator again... does it make pages? maybe that'd be it
if worst comes to worst
edit embed > 5embeds in a message
its for a webscraped member list of a game faction, it will look like shit if too long
Definitely what I'd do
Its not that hard to use it tbh
Its just ```py
from discord.ext import pages
embeds = [discord.Embed(...), ...]
paginator = pages.Paginator(embeds, ... other kwargs)
await paginator.respond(ctx.interaction)```
i added a timeout function for my view but even if you press a button it still executes the timeout. is there stop the function from running
I just want the timeout function to not execute if the callback has gone off
is there a good way to do this or would i just declare a "timout" variable on init and use that to not run the ontimout function?
self.stop() or view.stop() depending on the scope
oooh danke
not sure if i should open a thread for this, but what is this refering to as too long (its 3 am cut me some slack)```py
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In components.1.components.0.options: Must be between 1 and 25 in length.
row 1, first component's options are too long/short
i have a select menu on row index 1, ill check it
Bit of a stupid question: the docs suggest using a few flavors of database, but it doesn't explicitly recommend any particular driver. Am I right to assume async versions are preferred E.g. sqlalchemy[asyncio]
with asyncpg?
If you know of any "well built" open source bot I could use as reference of best practices feel free to send them my way. Thank you
Yes, you will need to use an async driver.
Red-DiscordBot Is a big one but it is discord.py
Toolkit is this servers management bot. Those are the 2 main ones. Just remember that lost of the code in Red bot cannot be copy pasted to pycord, use it only for reference.
Tyvm!
@errant trout my bots are crashing since ##1947
here is some traceback if you want to take a look
yeah i did
i got a question when youre individually chunking a singel guild
and more stuff is processing after that, such as a print("guild is chunked") on a task, would that ever get triggered immediately or wait until the guils is chunked
@tasks.loop(seconds=60)
async def checkroles():
await CLIENT.wait_until_ready()
print("inside checkroles")
try:
main_server = await CLIENT.fetch_guild(938836203275452436)
await main_server.chunk(cache=True)
print(f"main server: {main_server}")
print(main_server.self_role)
if main_server.chunked:
print("main server is chunked")
else:
print("main server is not chunked")
beta_server = await CLIENT.fetch_guild(975586060308480070)
await beta_server.chunk(cache=True)
print(f"beta server: {beta_server}")
print(beta_server.members)
if beta_server.chunked:
print("beta server is chunked")
else:
print("beta server is not chunked")
print("got servers")
trial_mod_main = main_server.get_role(992610751724400692)
mod_main = main_server.get_role(967559301742886955)
admin_main = main_server.get_role(1005985486705270976)
print(f"trial mod role: {trial_mod_main}")
for trial_mod in trial_mod_main.members:
print(f"trial mod: {trial_mod}")
except Exception as e:
print(e)
checkroles.start()``` like ie keeps triggering the else
the whole issue is im trying to get all members that has a role in a server, and it keeps returning empty. I've used the members property on the bot object and printed that out and it's just an empty list and doesnt actually return anything.
It's printing out inside checkroles
main server: 24/7 Casino
24/7 Utilities
main server is not chunked
beta server: 24/7 casino beta bot
[]
beta server is not chunked
got servers
trial mod role: Trial Moderator
24/7 Utilities#8842 -> ONLINE | 29ms
intents = discord.Intents.default()
# intents.members = True
intents.members = True
intents.message_content = True
# intents.members = True
CLIENT = discord.Bot(intents=intents, chunk_guilds_at_startup=True)``` this is how im defining the bot / intents. and members is enabled on the discord developer portal
?tag get_x
Any function that starts with get_ in Py-cord is retrieving the related object from your bots cache. If the object is not in the bots cache the get_ method will return None. Because of this behavior you should check if the get_x method is None and if it is use the fetch_x method.
Why Is Using fetch_ Without Using get_ First Bad?
The fetch_ method makes a call to the discord API. This API call is unneeded if you already have the information. It will also make your command take longer because it will have to send and than wait for a response from the discord API. It will also contribute to the discord APIs global rate limit of 50 requests per second.
What Is Cache?
The cache is a temporary storage inside your bot. It holds many objects from members to messages. When you restart your bot the cache will be empty. When the cache is full it will delete older objects to make space for the new objects.
i get that, but if im doing get_role and if that role wasnt in the bot cache, it wouldnt print out nothing right? but it does print out the role name
It returns None
trial mod role: Trial Moderator well here it's printing out the role name
How do I get a user's badges
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 ...
I didnt know it was called either, but that should allow you to get them
user.public_flags should usually just do it
how can i add a delete_after to a paginator.respond msg?
If the keywordarg doesn't exist in the method, you'd have to do it yourself
i found that paginator.send has delete_after, but when supplying it with the standard slash_command ctx(after await ctx.defer()) it just errors: TypeError: expected Context not <class 'discord.commands.context.ApplicationContext'>
maybe i just gotta write a delete after func?
Cause it expects a commands.Context
You just asyncio.sleep and then delete the response...
It's like 2 lines
that's fair...
but anyways, how'd i supply it with commands.Context? do i like, have to specify ctx:discord.commands.Context as a arg?
ctx: discord.ApplicationContext
(self, ctx: discord.ApplicationContext):
...
await paginator.send(ctx.interaction, delete_after=10)
what is with something like that?
nope
TypeError: expected Context not <class 'discord.interactions.Interaction'>
oh, you use paginator.send
change the send to respond
then delete_after doesnt work as keyword
it works via respond yes, but i am just curious if there isnt a way to do delete_after
How can I make the bot turn off its microphone in the voice channel?
I think its something like
await ctx.guild.change_voice_state(channel=channel, self_mute=True)
Thx
Is there anyway to make my bot commands not available in dms
You can use the decorator @commands.guild_only()
@commands.command()
async def memberinfo(self, ctx, user: discord.User):
embed = discord.Embed(title=f"{user.display_name}",color=discord.Color.yellow())
embed.set_thumbnail(url=user.display_avatar)
embed.add_field(name="Account Creation Date", value=user.created_at.strftime("%b %d %Y"))
embed.add_field(name="Joined at", value=discord.Member.joined_at)
await ctx.send(embed=embed)
it shows "<member 'joined_at' of 'Member' objects>" in the embed. any idea?
You are just getting the joined_at property of discord.Member...
Replace it with user.joined_at
and make user discord.Member instead of discord.User
This is why you need to know how to read your own code 
also comment/document
totally not me that scrapped an 500 line Cog cuz i couldnt figure out what the fuck i wanted to achieve with half the code
Sorry 😅
for some reason my IDE doesn't see pycord as discord library. After installing pycord, it still makes me install discord package
Can you show the list?
PyCharm is using a env
You mean?...
The list of the packages
Oh, k
?tag notpycord
The official name of the library is py-cord. When installing the library use py-cord, pycord (without the hyphen) is a completely different package.
did you install py-cord or py-cord-dev?
i've installed pycord. It is py-cord now
you should uninstall py-cord and install py-cord-dev instead
py-cord-dev got a lot of bug fixes
uh, 1 sec.
edit every one second, or should I wait one second now? https://cdn.discordapp.com/emojis/740871197838802985.webp?size=48&name=Lox&quality=lossless
I just want to make a bot that acts like a currency graph, and though it will be edited every hour, I don't want to wait so long to test things
Then edit every 5 or 10 seconds
alright, thanks
Hello.
Is it possible to, disable a specified button with name: 'view_votes' when a different button get's clicked?
I am currently using self.disable_all_items() but it does not seem to work.
view.children returns a list of all your items in the view
But how to like, disable the button then?
You index the children and change the disabled attribute
is there a rate limit to rebooting the bot? mine stopped registering all commands all together
slash commands?
yes
how many commands and how many times did you reboot the bot?
i haven't counted how many i have, but they were all working fine until i rebooted the bot a couple of time while making changes one command... then suddenly, it stopped registering all commands. i can no longer use any command.
and probably rebooted like 10 times
F
and how many commands do you have? x3
the problem is that you can only do 100 commands every day and after that you can kinda shutdown the bot because you got the ratelimit from discord
But I also wonder how you load the cogs ;3
for cog in cogs_list:
bot.load_extension(f"cogs.{cog}")
do you do it at the on_ready event?
negative
good
every other aspect of the bot works, i can change bot.activity, all embeds from events from each cog works
oh, they changed it a bit?
i need help with else statements lol
so by creates per day. does rebooting the server equal a create per command
each reboot
oh it is... oh man that is really stupid
if bot.is_ws_ratelimited():
print("WebSocket is currently rate limited")
else:
print("WebSocket is not rate limited")
just ran this. and it says WebSocket is not rate limited...
Make sure you are on the latest pycord version
2.4.x or py-cord-dev 2.5.x. Newer versions will try not to re-register commands with no changes.
on 2.4.1
Application Commands Not Showing Up?
- Uninstall libraries that conflict with the
discordnamespace (e.g.discord.py). - Invite your bot with the
application.commandsscope. - Load cogs before
bot.run()(e.g. not inon_ready). - Do not override
on_connect. - Update to the newest version of
py-cord(see?tag install). - Turn off
User Settings > Accessibility > Chat Input > Use legacy chat input. - Share your code and errors.
Just make sure all of this is still true ^
yep all is true
Is it possible you have multiple instances of your bot running?
at the time, there was. i forgot to shutdown the bot on the prod server before i ran the one in vscode to test a new command
it was working for quite some time, until one restart. just stopped registering commands
If you have not yet also please restart your discord client. Sometimes it is just a visual or caching issue.
Can you restart you bot without loading any commands (IE comment out cog loading) then restart again with everything as normal (Load cogs)
no dice
i've never seen this before lol
want to buy: percussive maintenance on discord
I dont think you are ratlimited as I believe discord would return an error if you were.
thats what i though too
i did reboot the bot several times in rapid succession, because testing json data from an API
The server or the bot?
the bot
(I saw the edit)
Im out of ideas 🫤 . You could try creating another bot and using its token just to ensure that it is not the code causing the issue.
I would just wait like 10-20 minutes and try it with a simple command again
If its not a ratelimit
i'm going to accuse javascript of this. some how, some way, somewhere, javascript is always responsible
discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access
got this on loading with a new bot from the dev portal. when it tries to do self.register_commands(
Did you add the applications.commands scope
ope nope
though, i never once selected that scope originally for the first bot
selected the scope. same error
I guess it should be enabled by default when you enable bot
yea, bot with administrator
ooh you know what
i accidentally had a debug_guilds id
ok so with the new bot from the portal it works now
also, i only added the debug_guilds id AFTER this issue started, for testing
I think it might just be best to wait for a while and hope that the issue is with discord. sorry :(
Is it possible to have a custom status for the bot?
How is it possible to have invite.inviter as null on invite create event?
Bots: Attributes activity, allowed_mentions, application_flags, application_id, auto_sync_commands, cached_messages, cogs, debug_guilds, description, emojis, extensions, get_command, guilds, intent...
Is it possible to create Button with callback function without using a @discord.ui.button decorator?
An example from my code:
class TicketCloseSelectView(discord.ui.View):
def __init__(self, client, user, channel: discord.TextChannel):
super().__init__(timeout=None)
self.client = client
staff_select = discord.ui.Select(discord.ComponentType.string_select)
for member in channel.members:
if member.bot or member.id == user.id: continue
staff_select.add_option(label=member.display_name, value=member.name)
async def callback(interaction: discord.Interaction):
nonlocal self, staff_select
placeholders = {
"bot": self.client,
"server": interaction.guild,
"user": interaction.user,
"yetkili": staff_select.values[0]
}
content, embed = self.client.get_message_from_config("settings.ticket-system.messages.review-message", **placeholders)
await interaction.response.edit_message(content=content, embeds=[e[0] for e in embed], files=[file for e in embed for file in e[1]], view=TicketCloseRateView(self.client, staff_select.values[0]))
staff_select.callback = callback
self.add_item(staff_select)
Pretty useful trick if you have to make dynamically set names. You can also extend button class and use it but i prefer this way as it is more simplistic
yeah it works, thanks
but how can I pass there a button that is clicked?
You can't, you have to indivually save them somewhere and set callbacks indivually, thats the problem with this approach. You can also try the other one where you extend a class to make button.
https://github.com/Pycord-Development/pycord/blob/master/examples/views/tic_tac_toe.py
Pycord, a maintained fork of discord.py, is a python wrapper for the Discord API - Pycord-Development/pycord
if a slash command option has required=False and no value is provided when running the command, what is the value set to? None?
Correct
perfect, thank you
self.bot.get_guild(GUILD_ID).voice_channels
why do i get "NoneType" Object has no attribute 'voice_channels' for this?
can't even use get_channel
so apparently you cannot use those attributes and functions unless decorated as @commands.slash_command() and takes ctx as an argument, even though ctx never gets used..
?tag get_x
Any function that starts with get_ in Py-cord is retrieving the related object from your bots cache. If the object is not in the bots cache the get_ method will return None. Because of this behavior you should check if the get_x method is None and if it is use the fetch_x method.
Why Is Using fetch_ Without Using get_ First Bad?
The fetch_ method makes a call to the discord API. This API call is unneeded if you already have the information. It will also make your command take longer because it will have to send and than wait for a response from the discord API. It will also contribute to the discord APIs global rate limit of 50 requests per second.
What Is Cache?
The cache is a temporary storage inside your bot. It holds many objects from members to messages. When you restart your bot the cache will be empty. When the cache is full it will delete older objects to make space for the new objects.
cheers, just stumbled across that.
Good morning
Why is my slash_command errors Unknown Interaction?
You're probably taking too long to respond.
It says The Application Did Not Respond after I execute the command and then print the error Unknown interaction
Then you're taking too long to respond. You respond in less than 3 seconds or you must defer.
oh okay
~~Has anyone encountered any issues in 2.5-dev with using dropdowns that modify the original message?
e.g. When selecting a dropdown, the message is edited, but then not being able to select anything with the dropdown again~~
Okay, just tested it. That works as expected. Still trying to track down why Paginator dropdowns are failing when it's updated
Am I going senile?
ApplicationCommandInvokeError
Application Command raised an exception: AttributeError: 'ChainSelector' object has no attribute '_view'
Stack
await paginator.respond(ctx.interaction, ephemeral=True)
/commands/addressbook.py Line 116
view.add_item(ChainSelector())
/views/Addressbook.py Line 259
for chain, entries in self.view.cog.get_non_global_entries().items() if entries
/views/Addressbook.py Line 373
... I see no reference to any _view. I'm guessing it's the auto-inherited _view from discord.ui.Item, but I still don't get why it's complaining here.
hey guys , does anybody know how to get rid of this warning? i've tried using initial_response = await ctx.send(content="Processing your request...") and it still shows the warning
Its ctx.respond
ctx.respond
Not ctx.send
lul
okayy
i was forst zervy >:(
worked. thank you so much
is there a way to way to have a button prompt a slash command?
Why would you do that
Im doing it for a class project
Just copy the callback into the button
wdym
Copy your slash command code and paste it in the button callback
the context is this channel
its my reaction to you posting that here
Is it possible to fetch a list of a User's friends from the api
Not as a bot.
I'm testing context-menus and I don't know if I'm doing it wrong but I don't get it in my app onclick section.
yes.. i used this example in this web: https://guide.pycord.dev/interactions/application-commands/context-menus
Learn all about Context Menus (User Commands & Message Commands) and how to implement them into your Discord Bot with Pycord!
Is this in a cog
yes
nop
Then what 
only work @discord.user_command
That's the context menu you're creating
It doesn't show up under apps?
nop
Is the cog being loaded?
The cog loads correctly, it just came up in the app section, but when I click on click on app it doesn't come up.
You're confusing me
Can you show a screen recording of what's happening
yess
1s
@lofty parcel
You're right clicking the user.
Not the message.
In the 3 points
okay okay
Sorry for the inconvenience

@lofty parcel Can I limit who sees the commands in context menu?
@commands.guild_only() # Only Guild
@commands.has_permissions(administrator=True, ban_members=True, kick_members=True, manage_messages=True) # Who can use it
@discord.user_command(name="User")
async def on_click_user(self, ctx, member: discord.Member):
embed = await self.format_embed_user(ctx, member)
await ctx.respond(embed=embed, ephemeral=True, delete_after=60)
You can use @discord.defult_permissions
Or manually edit it through the integrations tab
If I do it this way, when the user executes it, it will throw an error which I have to control, right? Is there no way they can't get out of it, or is that it?
I have done a test as such the user gets the command, but obviously it no longer lets you run
I'd add Internal checks and the ones discord give
So both commands.has_permissions and discord.default_permissions
PLEASE HELP ME GUYS HOW I GET CTX.AUTHOR IN CLASS MYMODAL
Modals don't use ctx
They use interaction which is discord.Interaction
.rtfm discord.Interaction
discord.Interaction
discord.Interaction.app_permissions
discord.Interaction.application_id
discord.Interaction.channel
discord.Interaction.channel_id
discord.Interaction.client
discord.Interaction.custom_id
discord.Interaction.data
discord.Interaction.delete_original_message
discord.Interaction.delete_original_response
discord.Interaction.edit_original_message
discord.Interaction.edit_original_response
discord.Interaction.followup
discord.Interaction.guild
discord.Interaction.guild_id
discord.Interaction.guild_locale
discord.Interaction.id
discord.Interaction.is_command
discord.Interaction.is_component
discord.Interaction.locale
Read the docs and find out what you need
I want to get the author id
How get?
.
.rtfm discord.Interaction
discord.Interaction
discord.Interaction.app_permissions
discord.Interaction.application_id
discord.Interaction.channel
discord.Interaction.channel_id
discord.Interaction.client
discord.Interaction.custom_id
discord.Interaction.data
discord.Interaction.delete_original_message
discord.Interaction.delete_original_response
discord.Interaction.edit_original_message
discord.Interaction.edit_original_response
discord.Interaction.followup
discord.Interaction.guild
discord.Interaction.guild_id
discord.Interaction.guild_locale
discord.Interaction.id
discord.Interaction.is_command
discord.Interaction.is_component
discord.Interaction.locale
Hm
Is there a global way to use 'await self.bot.wait_until_ready' so that I don't have to include it in every 'tasks.loop'?
start the tasks in on_ready
is there a way to get a jump url to a slash command response?
i'm using it as response = await context.respond(embed=embed) in a slash command, but response has message as None, and no jump_url
i only found the original_response coro, but it performs a request to api under the hood?
You'll indeed have to use that.
nah it's much easier, since interaction ID is the message ID, you can just construct url yourself as f"https://discord.com/channels/{result.guild_id}/{result.channel_id}/{result.id}"
Whatever you wanna use is OK
result is an interaction returned by respond etc.
The only reason I made a Twitter acc is to stalk people
Because Jesus Christ I'm NGL, any "website" web app or community ig wants you to register and use their app or else they won't let you pass
Hiya.
Is @discord.default_permissions(manage_channels=True) also possible with a role?
That the command is only visible to those who have role xx?
Yes, in a way. You can not do this in the code. You would need to instruct your users to go to
Server Settings -> Intagrations -> Your Bot -> Your Command -> Add role -> Enable/Disable
IF you need it in the code you can use
@discord.ext.commands.has_role(role_id) but this will not hide the command and is not the recommended
way.
Would there be any problems if I use the same custom_ID for multipe persistent views?
I am currently doing for 2 and they seem completely fine
do you have many class with the same ID or only one?
Only 1. The class is used in multiple messages views
(The class only contains 1 button)
1 ID would be fine than
Thank you
What would be the problem if more than 2 classes used it?
you would get a error for using the same id
Um I have a question : for the decorator @discord.default_permissions(), when I pass discord.Permissions.all() in the decorator, I get a TypeError : default_permissions() takes 0 positionnal arguments but 1 were given. What's wrong with what I did ?
its like the commands.has_permissions() at the prefix commands
you have to add a permission to it
Wdym
discord.Permissions.all() is basically all the permissions enabled, isn't it ?
That's what I did, in clear :
@discord.default_permissions(discord.Permissions.all())
why do you not just add administrator=True?
If it was as simple as that, why the class all() exists 😂
It's confusing
I just dont know if it works for the slash command permission
It might work has_permissions but with default_permissions the permissions can be changed
at the server
Uh ?
How it's possible?
has_permissions is like "hard coded" while default_permissions is it not
...
X)
I don't understand
How can an admin of a server modify the perms for using a command ?
they can change the command permission if they want to
Okay, thanks for helpin
Hello,
is it somehow possible to dynamically add another option to select another channel?
That I can first select a channel and then maybe another channel and if I have selected this one then maybe another one and so on?
@bot.slash_command(name="channel")
@option(
"channel",
Union[discord.TextChannel, discord.VoiceChannel],
# You can specify allowed channel types by passing a union of them like this.
description="Select a channel",
)
async def select_channel(
ctx: discord.ApplicationContext,
channel: Union[discord.TextChannel, discord.VoiceChannel],
):
await ctx.respond(f"Hi! You selected {channel.mention} channel.")
I think you have to edit the message and changing the view of it
you have to create a channel menu or add a second option OR use autocomplete
But with Autocomplete I don't dynamically get more fields in my slash command
Then I would have to create e.g. 10 options from the beginning and then I would always have to check in the autocomplete whether the field has a value before if yes I can select something again and if no I get no choices or?
Because I can't create the options dynamically so that I always get another one as soon as the previous option has a value, can I?
Is it possible to always start the task on a certain day of the week at a certain time?
@tasks.loop(time=time(23, 0))```
does it still make sense to make commands with a prefix or should you make all commands with a slash
it is your bot and you could do both in one command if you want to
bridge commands exist if you want to implement both prefex and slash at the same time
Is it possible to record audio from each user separately in a voice chat?
Does anyone have an example of an automod?
Hi, i have a quick question.
I have a task that loads each day to do a backup on my database.
Unfortunately, the task launch when i start my bot but i just want it to "be enabled" at first. Is there a way that when i run my bot, the first time the task execute its code is 1 day after ?
#1172489261879140442
how to use hybrid commands with pycord
Concept
thy
I have created a new thread so that if anyone has problems with the automod, we can share problems and solve them. #1172512655198662727
yes as i said
if the bot cant DM or kick the user, will it just keep going or abort the entire current function if i dont use a try except
solved :>
^ anyone ?
Im sure this is not the best approach, but you could use some var on true/false and then skip the loop if the variable is true
Yes that was my first though but i was wondering if there was a "cleaner" way 🥲
Thats the only thing i can think off lmao
i see, but i think the boolean var is easier and maybe a bit better
Yes, probably
Hello.
My Button after an x amount of time, just stops working.
Code: class ReactionView(discord.ui.View): @discord.ui.button(label="Get Session Role!", style=discord.ButtonStyle.primary, custom_id="s_role") async def start_ssu(self, button, interaction): role = interaction.guild.get_role(.....) if role in interaction.user.roles: await interaction.user.remove_roles(role) await interaction.response.send_message("Role removed!", ephemeral = True) else: await interaction.user.add_roles(role) await interaction.response.send_message("Role added!", ephemeral = True)
Because buttons have a default timeout of 3 minutes.
Next time dont crosspost. Only ask in one channel.
If you need it to last longer change the timeout or look into persistent views
Here's the persistent example.
Heya, i cant wait long time
I have
@bot.listen()
async def on_message(message)
@bot.event()
async def on message (message)
And the first affects the work of the second
Dont crosspost.
hello, could i fetch the activity when someone starts playing something?
example my bot is in the srver and it has started already, when someone starts playing minecraft for example, it sends to the console
You will need to use the on_presence_update event. Make sure you enable the required intents as well
How to see the number of bots in a server
sum(1 for member in guild.members if member.bot)
do SlashCommandGroups need the guild_ids applied to it. just noticed my new cog isn't being registered with its slashcommandgroup
Id for only one guild, without for global commands
weird. bots only in one guild anyway, but stopped registering commands
All of them? Or just specific ones?
just my newest cog
Is it being loaded
for cog in cogs_list:
bot.load_extension(f"cogs.{cog}")
and yea the cogs on_ready fires
so you load them at the on_ready event?
no
ok
i had something similar happen the other day with normal slashcommands, and i had to delete the bot from the developer portal and create a new one to get it working again
do you spam the API a lot?
i mean, i reboot the bot in testing, but i have
if bot.is_ws_ratelimited():
print("WebSocket is currently rate limited")
else:
print("WebSocket is not rate limited")
and i've never been rate limited
plus i'd imagine i'd get some sort of error if i was ratelimited, but no errors appear
How many commands do you have
about 30
all slashcommand have that, then i started expirementing with slashcommandgroups. i have one cog with 3 slashcommandgroup commands, that register instantly without the guild_ids
the second commandgroup cog, no luck.
i tried
term = SlashCommandGroup(name="term", description="Terminology commands", guild_ids=[GUILD_ID])
but it did nothing
does each @term.command() also need the guild_ids too?
OMG
im such an IDIOT
i accidentally nested all of the commands inside the cogs on_ready
feel free to pin that im an idiot lol
relax, such nonsense happens to all of us from time to time
Yea I know. I take great amusement in it. Like vscode even draws lines for you to see how deep statements are.
Has anyone here used the automod?
why async for if its a def?
It returns an async iterator
but i can just treat it like a normal for if i dont need any fancy extras right?
You can flatten it into a list
dont need to for just this, no?
you dont need a reason
i want one tho
;3
:3
lul
How the hell do I turn a local image into a bytes obj
It's for image in discord.Guild.create_scheduled_event
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 ...
with open("file.jpg", "rb") as f:
data = f.read()
I would say? ;3
wait, could you also not just use io.BytesIO?
nvm xd
This one works?
When making a slash command, should i use ctx: discord.Interaction or discord.ApplicationContext? Im not really sure what the difference is, and when I should use which. From the docs it looks like they mostly do the same thing. And my code still works when I switch between them
ApplicationContext
discord.Interaction is when you receive interaction in views
And typehinting doesn't affect your code, just what your IDE autocompletes for you
alright thanks
lets say i have a channel called 1 but @everyone is unable to read that channel, would it be able to make the bot change the permissions of @everyone so it can read the channel and then change it back if possible? Could you also link this in the documenation so i can understand the documenation more. Thanks in advance
Pls dont crosspost
#help-rules
my apologies buddy
Will this library continue to be supported, or most effort are placed in pycord 3 ?
v2 will be actively supported for at least another two years
perfect thank you !
Is there anyway to get audio from a sink before I end the recording? My bot requires that I can get the audio in a voicechat about every second. Another idea i had is to stop and start the recording in quick succession, but im not sure if that will cause gaps in the audio
Pycord is also uses logging?
Follow up question: is it possible to end_recording without disconnecting? trying it i get this error: discord.sinks.errors.RecordingException: Not currently recording audio.
.tag logging
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...
File "C:\Users\ethan\Downloads\asdada.py", line 30, in on_message
message.guild.default_role: discord.PermissionOverwrite(read_messages=False),
AttributeError: 'NoneType' object has no attribute 'default_role'
how fix
"NoneType" read the error
so hwo fix!!!
hwo?
Provide more code
Your guild is none. That all we know from what you provided
Does anyone have experience with creating application commands through the API?
Does display_avatar work for default avatars too?
Yes
nice thx
?tag intents
Pycord Docs - Intents
Discord API Docs - Gateway Intents
import discord
from discord.ext import commands
# Get specific intents for fine control
intents = discord.Intents()
intents.emojis = True
intents.guilds = True
intents.messages = True # Required for prefix commands!
...
# Get all non-priveliged intents; this excludes presences, members and message_content
intents = discord.Intents.default()
# Set priveliged intents: these must be enabled on dev portal
intents.members = True
intents.presences = True
intents.message_content = True # Required for prefix commands >= 2.0.0b5
# Get all intents; all intents must be enabled on dev portal.
intents = discord.Intents.all()
# Apply intents when creating your bot
bot = commands.bot(prefix="?", intents=intents)
thank you could i also ask you something about the code sent?
it works but when i click the I'm Sender button it wont update the embed with my name
im expecting for the embed to say sender: @deft kestrel
yeah it just returns like a blank image
doesnt it return the default avatar of that user?
You need to update the view when you disable the button
IE in your edit message add view=view
How to register a Persistent View from another file (from cog)
On Disabling then enabling a Persistent View (through a command), it no longer works (used <view>.enable_all_items())
So I'm trying to register it again as a Persistent View. How to do that from a different file that doesn't have the bot object available?
You need the bot object... how will you use .add_view then?
How would I get it on a different file?
In a cog?
Yes
Just pass the bot object to the cog
def __init__(self, bot):
self.bot = bot
....
def setup(bot):
bot.add_cog(MyCog(bot))```
Ohh thank you
So I have a main.py file. In the Folder (where the main,py file is located) I have a src folder in the "src" folder I have a "commands" folder and in the "commands" folder I have a "slash" and a "prefix" folder (slash is for slash commands and prefix is for prefix commands) How can I make that the Python files getting loaded when launching the main.py file? Im sorry for this question, I made discord bots with python like 2 years ago and switches to Javascript so I lost a bit knowledge.
Ignore the guy. He gone
uh yea what do
do you test py-cord 3 or what?
dont use py-cord 3
it's an internal error so ... nothing
no way 💀
?client
wrong channel for that
wich channel then?
Status does not exist at the moment, I'll be adding it later once I'm done with some stuff I have to do
Project K has been in development since forever
why the fuck did I send that here
it’s not the first time you did that
any way to use something like "ephemeral" but with bridgecommand?
only responses to interations can be ephemeral, so text-based commands simply cannot be ephemeral
As long as you still remember how you get home every night, there's nothing to question :P
Are there ways to accept an image upload (not a url) from a user other than by reading their message or through a slash command? Like from a modal or a prompt after pressing a button?
what other ways would there be lol
either you read the message attachment or make a slash command with an option
theres no other option to get a picture from a user
That's what I thought thanks
Hey so I want to get the ids of a member by using member.roles however when I try to index the list it returns it retursn a string when I want to return an id how do I do this thanks in advance.
How can I dynamically load commands into an embed without making a name:id ?
the ids change every time I update something and it's a bit cumbersome
iirc the id only changes when you delete the command and remake it
@valid panther
yw
I use this code to kick bots, which always select one of two sets of roles. For some reason, a lot of the time, it won't actually kick them until I manually update them long after they already picked their roles
And code further down from the screenshot also does not execute after members selected their onboarding roles
I tried everything and it just seems like an issue with member updates not working correctly rather than my code, so, what do
since sometimes it does work without a forced user update
How do I set a default permission to a group?
mod_group = SlashCommandGroup(name="mode", description="Moderation commands")
mod_group.default_member_permissions = discord.Permissions(administrator=True)
mod_group.guild_only = True
does not work
why doesn't this work
channel = bot.get_channel(1121763166976749630)
for i in range(10):
await channel.send(f"test {i}")
it has a NoneType issue
is there a typo somewhere that I made or?
use await bot.fetch_channel instead
ah
like await channel = bot.fetch_channel(id)?
or
nvm
but how do I call into that channel then?
wdym? Sending a message in there?
ye
use ctx.guild.get_channel. you save an api call
do it in 2 lines
channel = await bot.fetch_channel
await channel.send
ah
alright might need some help again, how do I make something like, I type in a seperate terminal (on my machine), which feeds the message (string) over to the bot (another file) which then sends the message to a channel (channel.send(variable))
roughly like this
you can definitely do this with websockets
so... what do I do?
by creating a separate program that can relay the information to the bot through a websocket. The bot can receive the information and execute on it
there are many ways to create one
nvm I think I found it
I do not know how your bot is structured or how your bot works or what type of information you are relaying. I recommend researching yourself.
aaah that seems so complicated
I'm just relaying a string
which changes
ie I read input from a user in a terminal, which gets sent over to the bot
How to put a custom presence without "playing" or "watching"?
Pass a discord.CustomActivity
Does anyone know how to enable/disable the mention raid detection? If its already enabled, it just gives a 404 not found error when trying to edit the rule.
I tried with CustomActivity
await bot.change_presence(activity=discord.CustomActivity(name='Custom status'))```
but it doesn't work, nor does any error appear
Try set the status with it
Online, dnd etc
pagination_view = PaginationView()
pagination_view.data = list_of_items
await pagination_view.send(ctx)
I have a slash command executing the code above. While it does respond with the correct data requested, it also throws "The application did not respond" before hand.
Does the slashcommand need to respond with something always? was hoping to avoid that as the response is in the pages
like this?
await bot.change_presence(activity=discord.CustomActivity(name='Custom status', status=discord.Status.online))```
doesnt work
maybe try pagination_view.respond
When subclassing commands.HelpCommand, how would I filter commands from ones a user can and cannot use based on command permission checks like the default one does?
For some reason, recently today, images in embeds are acting weird..
First image is me on my pc
on phone
And sometimes even on pc for a few seconds it'll be IN the embed then after a few seconds its OUT of the embed?? Like what's happening, I haven't changed any code, possibly smth to do with disc?
Can you show how you create the embed?
sure
lb_embed.set_image(url=f"attachment://profile.png")
dfile = discord.File(bytes,"profile.png")
lb_embed.set_footer(text = f'Page {self.current_page}/{math.ceil(len(self.data) / self.sep)}')
Btw its happening for all my embeds
I haven't changed anything
I'm using py-cord-dev 2.5.0rc5
But I'm pretty sure its smth to do with discord, its behaving really abnormally, how its twitching in and out sometimes.. I just wanted to see if anyone else is facing this issue
that should work
I'm trying the documentation you have passed me, but I don't understand why it comes out duplicated:I'm trying the documentation you have passed me, but I don't understand why it comes out duplicated:
for command in self.bot.walk_application_commands():
embed.add_field(name=f"{command.name}",
value= f"❯ </{command.qualified_name}:{command.id}> - {command.description}\n"
f"ID: {command.id}\n"
f"Patents: {command.parent}",
inline=False)
It is paginator.respond and you pass ctx.interaction

...

