#Basic Pycord Help
1 messages · Page 24 of 1
To have a role that can use a command but one can change the role that can use the command during runtime.
But I just remembered: The command.checks are basically the equivalent of just checking it in the callback, right?
That's the new way?
that has always been the way
Hasn't there been a commands.check for roles?
No idea, but i cant imagine a use case where the discord menu isn't enough
ok but is it possible by now to change those values (in the serversettings) from code?
dont think so, but why would you ever need that
if you only use that bot in your server then just limit commands to manage_server perms or use this
you only need to do it once for every command
its pizdec
How can I stop the work wait_for before the timer expires
how to fetch a message?
discord.User.fetch_message
discord.Member.fetch_message
discord.Thread.fetch_message
discord.Webhook.fetch_message
discord.DMChannel.fetch_message
discord.SyncWebhook.fetch_message
discord.TextChannel.fetch_message
discord.GroupChannel.fetch_message
discord.StageChannel.fetch_message
discord.VoiceChannel.fetch_message
discord.abc.Messageable.fetch_message
discord.PartialMessageable.fetch_message
discord.ext.commands.Context.fetch_message
Thanks
Guys, how can I stop a previously running process wait_for?
do you have some example code? it kinda depends
wait_for(event, *, check=None, timeout=None)```
That's an example
You're meant to use check to end it early
Docs has a decent example of how it works
Ok, thanks
How can I add a persistent view if the view class gets additional parameters? I can't just do bot.add_view(myView()) as there will be an AttributeError
bot.add_view(myView(self))
Depending on how many additional parameters you have, insert so many self
...why would they pass self for each parameter, that makes no sense
So I just pass any parameters and it will work?
pass the right parameters..
Basically you just manually create the view. You will not have some of the cached properties like View.message but it is just passing a instance of View in the end.
But where can I get them?
what do you mean lol
pass the stuff you want the view to have
just make the view normally
It has many instances with different attributes
Do I have to add them all separately?
Yes
Most of the time on bot startup you will need to use a database and a for loop to add a bunch of views
So there is no easier way here?
no
if you want views, make them
you cant just magically make them think up arguments for themselves
well you can, but, yknow
Does someone have an example for automod rules
There are no tags that match your search.
block links
block bad words
No i mean a code example
the docs have great code examples for automod iirc
I want to see how the code works.
that's... a bit vague, there's a lot to automod
._.
Add rule and edit rule
like in this case, reading the docs just makes sense
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 ...
How many servers u have to create a rule to get the badge
if you want to edit an existing rule, fetch it from the guild method and then use AutoModRule.edit
oh that
bruh
idk i forgot the threshold but im pretty sure it's a constant check
just to farm the badge?
so you'll probably lose it anyway
i am quite certain its a fixed amount of rules, not servers
But is there an example
just deduce it from the docs
its really not hard
fill the parameters with stuff and you're done
of course
And how can i create slash command which look like that:
/automod blacklist add?
like py await guild.create_auto_moderation_rule(name="Some Rule", event_type=AutoModEventType.message_send, trigger_type=AutoModTriggerType.spam, actions=[AutoModAction(action_type=AutoModActionType.block_message, metadata=AutoModActionMetadata(timeout_duration=60))], enabled=True, exempt_roles=[guild.get_role(...)], reason="example")it's so verbose that you have to read docs anyway
This 3 command names if u understand
Okay thx
you need groups and subgroups
subgroup is the last level, that example shows how to use create_subgroup
international_greetings = greetings.create_subgroup(
"international", "International greetings"
)
yeah
when you fetch them they'll have an ID attached
How will the id look like
uhhhh
i don't think that's saved, only way would be through audit log
wait no
the creator attribute, completely missed it lol
Okay and last question:
Is ther a way to get if a server has premium from a bot or is there a "upgrade" event?
This yes
❤️
i believe you're looking for Entitelment events https://docs.pycord.dev/en/master/api/events.html#entitlements
and perhaps fetch_entitlements
i've never used these, so you're on your own to test
And that gets, when a user subscribes?
these are all user related yes, the docs tell you everything
get what
If a server has subscribed
what
you can try await bot.fetch_entitlements, but again i'm not familiar with this system so it's really up to you to figure out how it works

certified read-the-docs moment
Okay
I finally got it done.. It's good that there is a pickle
huh? what? there is a badge for doint auto-mod nonsense? Did I miss sth?
(not planing to get it if there is, just curious)
if your bot makes X amount of automod rules, it gets a badge for it
...for some reason
You may have noticed a new badge floating around on various bot profile pages. Here is some info about the AutoMod badge and how to obtain it for your application:
💡 If your app has at least 100 ru...
definately dont want that, but i'll take a look at it. thanks for the link!
nqn has it for emoji shenanigans
jeeeesus. I'd never build a censor bot like this. possibly to help protect against raids or massive spam but other than that, no thanks.
okay, squids example may also make the list. but thats it 😄
@austere loom
well it's really just for creating built-in mod rules, but they also added an automod event so bots can throw in their own logic whenever a user messes up
i once got short term banned (and quickly unbaned) when on the discord dev server someone asked why his bot would get rejected. i pointed out his f... nitro garbage in the bots discribtion, auto mod kicked in.
strongly dislike those mechanics cause they never ask for context.
same on a study server where literature was discussed and parts of it happened to be sexual, which is part of the main plot in some classics and was in this case essential to the book.
but i am going a bit of topic 🙃
How do I set a local image as thumbnail of an Embed?
.tag local-file
f = discord.File("some_file_path", filename="image.png")
e = discord.Embed()
e.set_image(url="attachment://image.png")
await messagable.send(file=f, embed=e)```
my images are stored in a folder assets/portraits
I've tried "attachment://assets/portraits/image.png"
but the image does not display
you're a bit off
as in the example above, you specify the file path and the name separately
the path is the actual path on your PC, while the name can be anything you want - that name is what you set in the embed.
what's the issue?
the thing is I store my embed in a subclass
and I have a lot of ui components that edit the message to update the embed
are you running into an issue with the image reverting? or is there something else
no issues, I just have to define the file in every ui component
and my file changes depending on some parameters lol
ah i see, just make sure it's a new object every time because File isn't reusable
hopefully I don't run into a lot of issue lol
(oops I forgot to specify the filename)
damn nice it worked thank you
allgood
this is my view object and the output
how do I rearrange it to become
[OutfitSelect]
[ShinyButton] [ChangeLevel]
it just displays info from the game lol
Use the row= kwarg
Give your select row 0 and your buttons row 1
ah ok
Edit. Its zero indexed
thank you
How many seconds do I have to wait before changing the bot's activity?
to avoid rate limit
Im currently using requests for a small task that runs once weekly and uses a get and a post request, is it worth it to re write it in a non blocking library?
Its for a small 3 server project
From personal experience once per minute works fine
Just checked, you can have 5 updates per 20 seconds
thanks a lot ❤️
Hey
I'm trying to delete all the messages froma channel using
await channel.delete_messages()
what should I set the messsages parameter as? there are < 100 messages in these
you need a list of messages to remove try something like this
messages = [message async for message in channel.history(limit=100)]
https://docs.pycord.dev/en/stable/api/models.html#discord.TextChannel.history
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 ...
sorry for the phantom had to make sure i wasen't just making shit tf up
That worked as it is, perfect!
Thanks Ruthok! 
@fresh totem
messages = await channel.history(limit=100).flatten()
thats what .flatten() does
async def flatten(self) -> list[T]:
return [element async for element in self]
just fyi ;p
You were already answered, but channel.purge is a better alternative for your purpose
Don't typehint context
If it's still broken, show the whole command definition/class
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Yeah just remove the Context typehint
(More specifically it should be ApplicationContext, but really you don't need to specify at all)
Guys, is it possible to have already something in modal?
like i want to make one modal, and i need that it will ask if you can edit like you wrote something in modal and it saying:
publishing modal?
YES|NO|EDIT
and when im clicking on edit it will send to me to modal with the text that i already wrote there so i can edit it
sorry for grammar mistakes if i have any, im not english speaker
yes i already saw a modal like that
and how can i also do it?
idk 
how to fix this error: "Call expression not allowed in type expression"
Set value in the InputText
It's just your IDE being annoying, idk why people have been getting it recently though
The code should still run fine unless your IDE's explicitly blocking it
(In which case there should be some "ignore" button, but it varies)
oh okay
thanks, i will try later
nelo
That's me
`Ignoring exception in command kodartupdatescom:
Traceback (most recent call last):
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python312\Lib\site-packages\discord\ext\commands\core.py", line 180, in wrapped
ret = await coro(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Lenovo\Downloads\KodArt\main.py", line 165, in kodartupdatescom
view = UpdatesView()
^^^^^^^^^^^^^
File "C:\Users\Lenovo\Downloads\KodArt\main.py", line 113, in init
self.add_item(Update())
^^^^^^^^
File "C:\Users\Lenovo\Downloads\KodArt\main.py", line 88, in init
super().init(
TypeError: Modal.init() missing 1 required keyword-only argument: 'title'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python312\Lib\site-packages\discord\ext\commands\bot.py", line 349, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python312\Lib\site-packages\discord\ext\commands\core.py", line 959, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python312\Lib\site-packages\discord\ext\commands\core.py", line 189, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: Modal.init() missing 1 required keyword-only argument: 'title'
`
where do i put title in modals
Inside super init
previously i putted it like this:
modal = Review(title="Отзыв")
await interaction.response.send_modal(modal)
but now i need to do prefix command so idk where to put
In prefix commands, you have to create a button and use that button press to send the modal
Or select, basically it has to be from an interaction
maybe i can put it in View?
class UpdatesView(discord.ui.View):
def __init__(self):
super().__init__()
self.add_item(Update())
why?
Because they're different concepts
Dropdown can be added to a view, yes
But modals and views exist separately
Views are a Pycord concept, on discord everything is a "Component" - Modals are outside of this
oh well it is harder that i guessed
There's also the examples on the repo if you wanna see how it comes together
Here's the modal dialogs example.
Now I wonder how you code your stuff
quick question, is this not how i use once parameter?
@discord.Cog.listener(once=True)
async def on_ready(self):
how can i code no button so when you will click it it will delete message
It should be
Delete the button message? Or another one
delete the message with button
Try interaction.delete_original_response
(You might need to defer first)
do i need to put () at the end?
thanks it worked!
Allgood
i got
discord.errors.ExtensionFailed: Extension 'modules.parent' raised an error: TypeError: Cog.listener() got an unexpected keyword argument 'once'
though i'm using py-cord==2.5.0
Uhhh hold on
I'm.... amazed, we never added it to the decorator....
lmao
There's still @bot.listen... but jeez insane we didn't notice that
i'll wait for the update then, thanks
If you want you could probably just implement it yourself by editing cog.py
Should be a 2 line edit
i’ll try tmr cuz i’m going to sleep soon, thanks!
Does "app_commands" not exist in py-cord?
No, we have our own slash command structure
Trying to create my own autocomplete from an example as I've failed horriblity at trying to implement one myself
Oh autocomplete should be easy
Need to create a fuzzy autocomplete and failing horribly lol
Maybe use regex?
I've used "basic" autocomplete and got that working but really need a fuzzy one, which I'm struggling to create
Or some fuzzy search library
magic weapon .startswith()
Here's the slash autocomplete example.
I've used fuzzywuzzy but I can't get the function to work
This shows how to implement your own function
Much appreciated sir/madam
i dont think this failed because you were typehinting, but because you were typehinting incorrect.
try "ctx: discord.ApplicationContext" instead.
okkk
Do what
If you're on 2.5, use interaction.edit
class UpdatesSubmitView(discord.ui.View):
def __init__(self):
super().__init__()
self.value = None
@discord.ui.button(label='Yes', style=discord.ButtonStyle.success)
async def yes_button(self, button: discord.ui.Button, interaction: discord.Interaction):
if interaction.guild.id == 1214612682951491645 and not interaction.user.bot:
await interaction.followup.send("hello world")
@discord.ui.button(label='Edit', style=discord.ButtonStyle.grey)
async def no_button(self, button: discord.ui.Button, interaction: discord.Interaction):
#what to write there?
...
@discord.ui.button(label='No', style=discord.ButtonStyle.danger)
async def no_button(self, button: discord.ui.Button, interaction: discord.Interaction):
await interaction.response.defer()
await interaction.delete_original_response()
class Update(Modal):
def __init__(self, *args, **kwargs) -> None:
super().__init__(
discord.ui.InputText(
style=discord.InputTextStyle.long,
label="Обновление",
required=True,
placeholder="Введите новое обновление..",
),
*args,
**kwargs,
)
async def callback(self, interaction: discord.Interaction):
embed = discord.Embed(title="Ваше обновление было написанно! Опубликовать?", description=
f"""
**Вот так выглядит ваш текст:**
{self.children[0].value}
""", color=discord.Colour.blurple(), timestamp=interaction.message.created_at)
embed.set_footer(text="Kodart")
view = UpdatesSubmitView()
await interaction.response.send_message(embed=embed, view=view)
i need that when i will click on edit button it will give me back the inputtext
Anything I need to change when I convert a bridge bot to a slash bot? I know the bot definition has to change (to what?), but anything else?
Uhh just check through what decorators you're using for commands
If you still want prefix commands, use ext.commands.Bot
no, only slash
Then discord.Bot is fine
I'm using BridgeBot right now I think
Yeah, BridgeBot supports all commands and is an extension of ext.commands.Bot
and for decorators I think I only have bridge_command (obvious change) and @option so that's not much to change
yes, i want that you can write firstly in modal then it will ask
do you want to send it
YES|EDIT|NO
if you will click on edit it will bring back you to modal
Right, so your edit button can send the same modal with their old input already set
Looking at your Update code, you actually support this already - just pass value as their old input
Oh actually not quite
I'd recommend adding a new argument to update, then setting value in InputText
i didnt really understood what you said
I'll break it down a bit more
To pre-fill an InputText box, you need to set the value attribute (like you already have placeholder etc)
To do this in your Modal subclass, I would recommend adding a new argument to init where you can specify the user's previous input
(I'm going on the assumption that you want to use the same Update modal)
how can i do this?
Where you have *args, **kwargs, before that you can just add another parameter
value=previous_input if previous_input else None
?
and in edit i will put this?
@discord.ui.button(label='Edit', style=discord.ButtonStyle.grey)
async def edit_button(self, button: discord.ui.Button, interaction: discord.Interaction):
await interaction.response.edit_message(view=None)
view = Update(previous_input=self.previous_input)
await view.edit_callback(interaction, self.previous_input)
Uhhhhh
If you want to send a modal, you have to use response.send_modal and no other responses
I'd recommend removing the view after the modal is submitted with some other method
view = Update(previous_input=self.previous_input)
await view.response.send_modal(interaction, self.previous_input)
like this?
but i need modal
What else are you trying to do
i guess i understood
@discord.ui.button(label='Edit', style=discord.ButtonStyle.grey)
async def edit_button(self, button: discord.ui.Button, interaction: discord.Interaction):
view = Update(interaction, previous_input=self.previous_input)
await interaction.response.send_modal(view)
Yep you got it, probably
yes, but theres one mistake
how do i get previous_input??
Ah, from the old modal?
ye
You're gonna have to chain it - repeat the argument part for UpdatesSubmitView to pass it through
(To access it in modal, something like self.children[0].value)
i tried it but not working
it should be the same logic, in theory
maybe json file?
What did you try
previous_input = children value
Did you actually make the param
ye
whats the equivalent of this well, without bridge?
@commands.has_permissions(ban_members=True) right?
and whats the difference to this?
one of them sets the slash command's permissions with discord's and commands performs an internal check
None and handle it internally
yea thats how i do it rn
okay i might be dumb but i have taken a brief= kwarg into my bot from an old codebase and i just learnt that SlashCommand doesnt even have that kwarg???
am i dumb lol
never heard of it
yea its description=
because ctx is defined on the same line
oh channel didn't scroll oops
more specifically, it's the text used for the builtin help command as an alternative for the full description
ahh, thats probably where it stems from
there is always a way, you can overwrite some things in the interaction but is there a point? haha
just user = user or ctx.author
wont that make it a bool?
nah
thats new
user = user or user2 # if user is None then user2, if both are None then None
username = user and user.name # if user is None then None else user.name
if someone used the bottom one in my codebase id smack them
that is just awful
I'm pretty sure I've seen that going through pycord lib
but idk
it's useful sometimes
discord api down?
no
Good place to check is here https://discordstatus.com/
it finally worked thanks!!!!
guys how can i using decision if the arg1 is empty in the bot command?
What you asked makes no sense.
okay
Ask again.
Hey, looking to have the bot send a message to a user when joining a server, but after they have completed onboarding/accepted rules. I don't see an obvious way to do that, is there an existing event like "completed_onboarding" or will I need to make my own way detect that?
on_member_update catches that.
This section outlines the different types of events listened by Client. There are 3 ways to register an event, the first way is through the use of Client.event(). The second way is through subclass...
This is discord.Member.pending on the docs.
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 ...
guys is there any way so bot will message everyone who is on the same guild as bot?
i want to create news command, and it will work like this:
im sending message to bot and this bot will send to all people that are in same guild about those news
Mass DMing is against the Devs ToS.
ok i will think something another
How to put descriptions on the place that written "No description provided"? I want to describe each arguments.
description= in each option
you have to use option for it
Here's the slash options example.
mee6 be like nope don't care
thank you and Toothy for your supports!! It worked!!
Why is it semingly impossible to manually invoke the function for a bridge command?
like?
I finally got it to work after mutiple trial and error attempts, digging through multiple source code files, etc.
what do you even want to do lol
I have to type out this long thing for it to actually work
await self.userinfo_cmd.slash_variant.callback(self, ctx, user=str(member.id))
user context menu command
this?
but when I went to convert my old function to a bridge command it fucked it up
when you try to execute the actual function
its not the function, but a BridgeCommand object instead
which has an invoke function, but wont allow you to pass arguments
so I had to dig around in the code and find this
I just put the code in another method that's not a command and cell that
I personally abuse process_commands by editing an existing message's data
I got a lot of data I am trying to display and im not quite sure how i want to do this. So, its a command called gamestats which users gamestats for specific game. I don't know if i should use autocomplete, or what anyone got ideas?
It returns wins, losses, ties, tie amount, amoutn won, amount loss, current win streak, highest win streak. so just not sure what would make the most sense when displaying the data.
autocomplete for which part
so /gamestats is the command. I want this as easy for the user as possible. So, maybe I could do /gamestats commandname and have that autocomplete? Im assuming teh way autocomplete works is by typing in a few characters it would help fill the rest for user for convenience.
Making it with buttons i dont think would make sense even if done with left and right arrow cause there's like 9 or so games, which im looking to expand on.
again, what do you even want to autocomplete
the game name
make choices
is the limit of choices still 25?
Any definitive examples of translations? I didn't see any in the examples folder (at least by name)
it’s in the guide
it’s called localization
Ah, I used 'translation'. I should have recalled localization (I did it for 10 effing years)
tyty, btw
Here's the slash cog groups example.
there's also pycord-i18n which allows loading from json instead
I did it for every command

Internationalization, 18 letters between
why am I spammed with those?
haven't updated pycord since
Was just looking at that, but looks like it’s geared more towards slash commands specifically vs general localization of arbitrary Views (eg from button press)
Posted a question in Doru’s discord, though
Sometimes some words like "localization" or "internationalization" are so long that writing them many times in one text is quite tiresome.
Let's consider a word too long, if its length is strictly more than 10 characters. All too long words should be replaced with a special abbreviation.
This abbreviation is made like this: we write down the first and the last letter of a word and between them we write the number of letters between the first and the last letters. That number is in decimal system and doesn't contain any leading zeroes.
Thus, "localization" will be spelt as "l10n", and "internationalization" will be spelt as "i18n".
Source: "Way Too Long Words" (codeforces.com)
i made my own 
how can I get the version of the already installed pycord on my system? using linux
I prefer to use less functions, so I'll just stick with what I've found
pip show py-cord
I'm trying to make a bot that does player counter for a game, that will periodically check how many players are online and update an embed in discord.
Where would be the best place for this loop? right now I have it in on_ready with a while True: ... await asyncio.sleep(600) does that seem like the right place?
God. No. That's not how you should do it.
Use tasks.
Here's the background task example.
noice, I'm just re-writing a bot in pychord from discord.py cause me and another guy could not get slash commands to work in it
have any way to reload the command from cogs? i need to cycle the guild and reload, because when i restart the slash command did not reload
btw when i use reload_extension, the slash command also not reload on some server
how do i make a dynamic arguement like i have an arguement which has select option. if the user lets say selects select 1 then the command must be required else no
yes okay thanks
one more thing , is it possible to add like 2 fields in a modal but atleast one is required
both cant be empty
or a modal check
no
like view.interaction_check
but you can add a default value at it with something like "None"
interaction check only applies after it's sent
yes i understand that can i have it like if both fields empty i dont let the modal be submitted?
after clicking on submit
it's not possible, no
i'd recommend check -> if they are both empty, display a button to resend the modal
okay will do
Hello dear community, I need your help. How can I have the database retrieve the name and then insert it here?
options = [
discord.SelectOption(label="test", emoji=":ticket:"),
]``` ```py
class TicketDB(ezcord.DBHandler):
def __init__(self):
super().__init__("db/ticket.db")
async def setup(self):
await self.execute(
"""CREATE TABLE IF NOT EXISTS ticket(
server_id INTEGER PRIMARY KEY,
category_id INTEGER DEFAULT 0,
teamrole_id INTEGER DEFAULT 0,
logs_channel_id INTEGER DEFAULT 0,
ticket_channel_id INTEGER DEFAULT 0,
set_name_count INTEGER DEFAULT 0,
panel_name TEXT DEFAULT NULL
)"""
)
async def set_category(self, server_id, category_id):
await self.execute(
"INSERT INTO ticket (server_id, category_id) VALUES (?, ?) ON CONFLICT(server_id) DO UPDATE SET category_id = ?",
(server_id, category_id, category_id)
)
async def get_category(self, server_id):
return await self.one("SELECT category_id FROM ticket WHERE server_id = ?", (server_id,))
async def set_teamrole(self, server_id, teamrole_id):
await self.execute(
"INSERT INTO ticket (server_id, teamrole_id) VALUES (?, ?) ON CONFLICT(server_id) DO UPDATE SET teamrole_id = ?",
(server_id, teamrole_id, teamrole_id)
)
async def get_teamrole(self, server_id):
return await self.one("SELECT teamrole_id FROM ticket WHERE server_id = ?", (server_id,))
async def set_logs_channel(self, server_id, logs_channel_id):
await self.execute(
"INSERT INTO ticket (server_id, logs_channel_id) VALUES (?, ?) ON CONFLICT(server_id) DO UPDATE SET logs_channel_id = ?",
(server_id, logs_channel_id, logs_channel_id)
)
async def get_logs_channel(self, server_id):
return await self.one("SELECT logs_channel_id FROM ticket WHERE server_id = ?", (server_id,))
async def set_ticket_channel(self, server_id, ticket_channel_id):
await self.execute(
"INSERT INTO ticket (server_id, ticket_channel_id) VALUES (?, ?) ON CONFLICT(server_id) DO UPDATE SET ticket_channel_id = ?",
(server_id, ticket_channel_id, ticket_channel_id)
)
async def get_ticket_channel(self, server_id):
return await self.one("SELECT ticket_channel_id FROM ticket WHERE server_id = ?", (server_id,))
async def get_press_count(self, server_id):
result = await self.one("SELECT set_name_count FROM ticket WHERE server_id = ?", (server_id,))
return result if result is not None else 0
async def increment_press_count(self, server_id):
current_count = await self.get_press_count(server_id)
new_count = current_count + 1
await self.execute("UPDATE ticket SET set_name_count = ? WHERE server_id = ?", (new_count, server_id))
async def set_panel_name(self, server_id, panel_name):
await self.execute(
"UPDATE ticket SET panel_name = ? WHERE server_id = ?",
(panel_name, server_id)
)
async def get_panel_name(self, server_id):
return await self.one("SELECT panel_name FROM ticket WHERE server_id = ?", (server_id,))
db = TicketDB()``` I have everything in the database but I don't know how to transfer the names into the option
Iterate over your results and create the list of SelectOptions?...
Havent you already created a thread for it?
yes, I don't know how to transfer the names from the database
?
stay in one channel pls
?
Does asyncio.sleep() pauses my code just liketime.sleep()?
ok, thanks!
how to send the message after async for?
add it below?
kek?
yeah
dunno what you were expecting lol
idk
So, how to send the message in log channel for one guild? I meant how to send the message about 1 guild, not channel? 🤔

Grammar's so bad I don't even know what you're asking for
I dont know how to describe
well then I don't know what to answer
And i dont know how to describe lol
Almost all of my commands have a description added normally, but two of them do not have it, although it is written in the code. Why?
it's spelled description, but in the code you missed the r
Oh okay when channels are deleted, the bot should send one message that someone deleted chats
if i were you i would just listen for audit log events instead of the actual delete event
or somehow pair them together
never did anything to italicize that for fulfilling line
the username has an underscore
you can use that on the username part
np
can i restrict a bot to only work in a channel list?
actually have any way to reload cogs at all server?
when i use reload_extension, some server have not reload. btw i have wait a day
which commands do you use?
the reload command?
check the bot setting
and other
i have update the command to repair bug
sorry my broken english
like setting bot, view help command
?
How do I get the slash command associated with a message?
I basically just want to see what command led to a message being created
@boreal sky ^
For some reason it just kept returning None
That's the first thing I had tried
I also tried Message.application but that wasn't it either it seems lol
maybe you’re looking at the wrong message?
Uh... There's no other message to look at
i don’t think this has anything to do with it, but do you have the message content intent enabled?
are you sure you the message you are checking for is the correct message
I mean all I'm doing is trying to do is print the interaction name so far
and the only message that ever gets sent is one spawned from a command
during testing, I mean
but even if it did error, I'd be able to see the message that succeeded if such a message existed
uh... never mind, I guess... I tried again and now it's working, I wonder what I did wrong beforehand...
very weird
🪄
I hate when that happens lol
Uh... How is it possible for this to result in a timedelta of about -2 days?
discord.Object(message.interaction.id).created_at - message.created_at
Latest resulted in -1 day, 23:59:59.270000
do it the other way around
huh... I didn't think about that, I still don't understand how it resulted in that but 🥴 I guess that somehow solved the problem
you'd have thought it'd be like negative some amount of time less than a second
very strange
it literally is
strange or less than a second
whose absolute is less than a second, rather
less than a second
I assume you mean 730
In [8]: timedelta(seconds=-0.730)
Out[8]: datetime.timedelta(days=-1, seconds=86399, microseconds=270000)
that is unnecessarily confusing
oh, yea
well it's not confusing at all
it's how datetime works
you can do the subtraction you initially had, and just display the milliseconds component from it
you are just printing it as a datetime which causes that
Though, your initial subtraction is still wrong because it has the values backwards, so, yea
the real difference on that one would be 270ms
yeah but days being -1 confuses the heck out of me
like is days the only thing that can be negative?
like what you add -1 days to 86399 seconds and 270000 ms?
I think that's what it is
so weird
see it like day 1, day -1
I feel like that makes more sense for datetime than it does timedelta
datetime is the achiless heel of every dev
Can someone tell me the ratelimit on how many slash commands can be registered in an interval
200 in one day
how many can a bot have registered max?
if you restart a bot two times which got 100 slash commands
?tag cmd-limits
You can have 100 commands, and each command can have up to 25 sub-command groups. Each sub-command group can have up to 25 sub-commands.
100 x 25 x 25 = 62.5k
Of course, "slash commands can have a maximum of 4000 characters for combined name, description, and value properties for each command and its subcommands and groups", so you're not likely to hit that 62.5k command limit
This can be doubled again with guild commands
damn okay
thanks
Hi! To edit a guild channel's name i need to do:
channel = ctx.guild.get_channel(<channel id>)
await channel.edit(name='New channel name')
or something like that?
Are you doing that in a command?
and yes, that would work, but if you are doing it in a command, you dont need the channel = part because you can do that with an option
keep in mind that channels got a really bad ratelimit
oh really?
ye
how much
The last time I checked it was 2 times every 10 Minutes
oh wow, thats shit
discord got tired of people using them for live stats
Ive put two commands on my bot, one of them appears and one of them doesnt and I cant see the problem - is discord taking a long to update it?
can you show some code?
It showed up now, for some reason discord took 20 minutes
restart your discord when making a new command
Tried that but it still wasn't there
anyone else with this issue, all i see when i look it up is 4 yr old posts about the windows certif experation in 2020
aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host discord.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1000)')]
OS?
win 11
done some of the fixes like https://github.com/Rapptz/discord.py/issues/4159
I don't use windows, can't help you
ubuntu?
this solution is more recommended as you probaby shouldn't be downloading them like that
How to make a ban command?
Have you tried to find something at google to it?
Look and yes but it's a bit complicated
How can I disable all the buttons of this message knowing the message id?
- fetch message (you need channel ID too)
- use View.from_message(message)
- view.disable_all_items()
- edit message with the updated view
thanks
Looks like I forgot to update pycord to 2.5.0 and when I did every single bridge command was broken
It seems to be because now bridge commands use BridgeOption instead of usual Option, so @option decorator now just doesn't work
Is there a decorator for BridgeOption or do I need to make a decorator myself now?
Nvm, figured out it's not BridgeOption's fault but something else, though still not sure what it is
Throws Converting to "Option" failed for parameter "..."
is there a full traceback
(when you import bridge, the default option objects redirect to their bridge variants)
Ignoring exception in command random:
Traceback (most recent call last):
File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/discord/ext/commands/converter.py", line 1154, in _actual_conversion
return converter(argument)
^^^^^^^^^^^^^^^^^^^
TypeError: 'Option' object is not callable
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/discord/ext/bridge/bot.py", line 144, in invoke
await ctx.command.invoke(ctx)
File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/discord/ext/commands/core.py", line 951, in invoke
await self.prepare(ctx)
File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/discord/ext/commands/core.py", line 881, in prepare
await self._parse_arguments(ctx)
File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/discord/ext/commands/core.py", line 792, in _parse_arguments
kwargs[name] = await self.transform(ctx, param)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/discord/ext/bridge/core.py", line 107, in transform
return await super().transform(ctx, param)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/discord/ext/commands/core.py", line 627, in transform
return await run_converters(ctx, converter, argument, param) # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/discord/ext/commands/converter.py", line 1255, in run_converters
return await _actual_conversion(ctx, converter, argument, param)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/discord/ext/commands/converter.py", line 1163, in _actual_conversion
raise BadArgument(
discord.ext.commands.errors.BadArgument: Converting to "Option" failed for parameter "data".
oh
...as per PR #2252 you have to use BridgeOption instead of Option
which is a major breaking change so it's rather concerning that this wasn't talked about more...
and I use @option
so do I need to make a workaround now?
sorry, this entire thing was very poorly planned out
if you want you can reimplement the old logic - at the bottom of discord/ext/bridge/core.py, add these two lines py discord.commands.options.Option = BridgeOption discord.Option = BridgeOption
ty
how do i add 2 buttons to an embed to function as like yes/no buttons? Sounds pretty simple to me but i cant seem to figure it out w the documentation rn
that only confused me more 😅
look up views in the guides
the only thing i can seem to find with that is how to create a button? I have got that figured out i just dont rlly know how to send it in the channel
i found it, got buttons appearing now, now i cant seem to figure out how to await the button click? I would have assumed this would use but.wait_for or ctx.wait for but i cant find anything regarding buttons or views on those docs?
the callback of the button contains the function called when pressing it
example of my yes/no view
idk if im just stupid or i need sleep or both but i dont understand any docs rn
i literally sent you the code how you can do it
im just very confused how i should implement this code into my codebase. ill be honest i dont have a ton of experience with classes but should i put this in a seperate file and import it? I already have the commands in a class inside a cog, can i just add this code as functions in my existing class?
i think i just need sleep mabye but idk
im just very confused rn
you don't need to use classes if you don't want to
i currently have this weird cluster of code but it works apart from listening for the buttonpress
@commands.slash_command(name='changeorigin',
description='Change your origin in the server')
async def change_origin(self, ctx):
embed = discord.Embed(title="Are you sure?", color=0xF66946)
embed.add_field(name='Are you sure you want to do this? The action CANNOT be reversed however you can choose the same origin again', value='')
yes_button = discord.ui.Button(label="Continue", style=discord.ButtonStyle.danger)
no_button = discord.ui.Button(label="Cancel", style=discord.ButtonStyle.green)
view = discord.ui.View()
view.add_item(yes_button)
view.add_item(no_button)
message = await ctx.respond(embed=embed, view=view)
interaction = await discord.Interaction()
print(interaction)
# Wait for the user to click one of the buttons
if interaction == "Continue":
await interaction.respond(content="You clicked 'Continue'!")
# Perform your action here
elif interaction == "Cancel":
await interaction.respond(content="You clicked 'Cancel'!")
else:
print(F"Interaction output: {interaction}")
i would assume so, i have been trying to make it work just inside the command itself as you can see from my code. But i dont know what functions to use and i am trying to understand the documentation but i guess i suck at reading
i just dont rlly know where to look
i thought mabye https://docs.pycord.dev/en/stable/api/ui_kit.html#discord.ui.View.interaction_check but that just seems to get called when the view gets generated not pressed?
The library has helpers to help create component-based UIs. Shortcut decorators: Objects: Attributes children, disable_on_timeout, message, parent, timeout. Methods cls View.from_message, def add_i...
the button callback gets called when a button is pressed
The library has helpers to help create component-based UIs. Shortcut decorators: Objects: Attributes children, disable_on_timeout, message, parent, timeout. Methods cls View.from_message, def add_i...
i have no idea how to "assign" it a callback without just subclassing the view tho
its just the easiest and cleanest imo
idk its just what im used to with the old commands and bot.wait_for('message') but it doesnt seem to work the same way i guess
w..what
thats me trying to figure it out but that code doesnt even make sense to me
just use mine
i have this now
await ctx.respond(embed=embed, view=view)
yes = await yes_button.callback(ctx.author)
print(yes)
no = await no_button.callback(ctx.author)
print(no)
print("callback was called")
but it just gets ran instantly, prints None twice
What the fuck
no. I just dont understand this documentation. I would not call myself an expert and i am kinda feeling in the dark when it comes to awaiting stuff and threading. Also its just a side hobby for me and i dont spend much time on it
But rn i just dont even know what im supposed to do so im just trying whatever i guess
idk tempted to just give up and use text promts again
cause i understand those
i guess? Idk
Almost all my knowledge in python is data handling/SQL
You must learn OOP before handling pycord.
The whole library is OOP based.
I understand this isn't the field you're used to, but you must learn it before using pycord to avoid frustration and not understanding the docs.
(views as they are now are still not the most intuitive thing in the world tho let that be said)
i am one to more wing it and just figure it out tbh. Like i understand that i dont fully grasp how OOP works but its not like this is my first time working with pycord. Most stuff i understand how it works but some stuff i just dont grasp i guess
The repo is full of examples.
If you want that and makes it easier for you to understand.
Here's the confirm example.
okay so i copied the example code without changing anything but if i do this
view = Confirm()
await ctx.respond(embed=embed, view=view)
output = await view.wait()
print(output)
i get false regardless of the input? Even though i copied the entire class just like in the example
thats the same as in the example code
yes ofc, if i dont press the button the code doesnt even run
you should get view.value
Represents a UI view.
This object must be inherited to create a UI within Discord.
.. versionadded:: 2.0
Parameters
----------
*items: :class:`Item`
The initial items attached to this view.
timeout: Optional[:class:`float`]
Timeout in seconds from last interaction with the UI before no longer accepting input.
If ``None`` then there is no timeout.
Attributes
----------
timeout: Optional[:class:`float`]
Timeout from last interaction with the UI before no longer accepting input.
If ``None`` then there is no timeout.
children: List[:class:`Item`]
The list of children attached to this view.
disable_on_timeout: :class:`bool`
Whether to disable the view when the timeout is reached. Defaults to ``False``.
message: Optional[:class:`.Message`]
The message that this view is attached to.
If ``None`` then the view has not been sent with a message.
parent: Optional[:class:`.Interaction`]
The parent interaction which this view was sent from.
If ``None`` then the view was not sent using :meth:`InteractionResponse.send_message`.```
is there a way to recover from this error (reconnect ?): ```discord.errors.DiscordServerError: 503 Service Unavailable (error code: 0): upstream connect error or disconnect/reset before headers. reset reason: connection termination
The current behavior the bot just crashes and closes
I'm guessing you're having a very unstable connection; you might wanna checkout resuming a session.
503 indicates a server is / was not able to handle a request or that it's temporary down.
using a slash command can i set the arguments to be a list of an object? specifically it would be /command <int> <string> <string>, <int> <string> <string>, ...
Not really. Best you could do would be to make optional args for those extra ones, but the UX won’t be super great (especially if users forget them)
@bot.slash_command(description="Set Reminder channel") async def setreminder(ctx, channel: discord.TextChannel, date, text):
how to put a server restriction to use this command? like: just server ID: 1111 can see this command
add the guilds_id kwarg to the decorator:
@bot.slash_command(…, guilds_id=[1234567890])```
hmm ok guess ill just take the entire arg in as a string and ',' split it
how to get user avatar in interaction?
if i want my bot to handle slash commands do i need to enable any permissions besides sending messages?
so it means the discord server was down ? I am already handling the on_resumed and the on_shard_connect
But how can I recover from DiscordServerError: 503 ?
I can always run the bot in endless loop (if it crashes) I do bot.stop() and after bot.start(), but not sure this is the ideal solution
The error 503 is not happening often, maybe once each fiew weeks. But each time the bot goes down
@shell radish hallo 
first of all, the docs' getting started guide is kinda old, so we don't use it. We try to update https://guide.pycord.dev/ instead. The solution to your problem can be found in the "bots" section in your application.
ah ty ill use the new page and ohhh the toggle?
yup
btw the main goal of this bot is to handle some slash commands and then send messages, if possible slightly stylized ones in response. do i need to add any other perms?
I don't know what you're current permissions are
rn i have it bot, messages.read and applications.commands for scopes and then admin for bot perms in OAuth2, but id like to limit the bot perms to only whats needed
you want to uncheck messages.read that is for something else entirely...
for permission, administrator is fine for testing, I don't think you would need anything other than "Send Messages," "Embed Links," "Read message History," "Use External Emojis," and "Add Reactions."
ah it does not deal with letting the bot read messages? xd ok ty ill give that a try
nope, and I'm too lazy to explain it
lol thats fine
do i have to reinvite the bot everytime i change the code? i got the first command to work, i added a second, stopped and started the bot but the second command isnt showing up
No
Refresh your client.
ah it just takes time, weird that i can run a command and it cna reconigze its changed but doesnt update with the change right away xd
can i restrict a command to a category rather than just one channel? i tried copying the id of the category and putting it in guild_ids property but i got an error that discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access
Because guild_ids takes guild ids...
You either implement an internal check or edit the command permissions on the integration settings of your server
no idea how id do either of those. the issue is that we use a ticket system so channels would be created as the bot is running
i see that theres a discord.CategoryChannel that seems like it might be able to help but im not sure how to utilze/call on it
Integrations are managed on your server settings. Server settings > Integrations > Your bot > The command > add/remove channels or categories
hey guys how can i use if isinstance when arguments is missing or arguments not included?
if isinstance(error, commands.MissingArguments)
?
Sorry, i mean required arguments, so when people type it without arguments it will showing the usage of the arguments
Yes, catch the error, reply with whatever you want...
how can i catch the error, can u provide it? i already using if isinstance abot required arguments, but its keeping showing error required arguments on the console, and not showing the ctx.send
Showing your code would be helpful
Aight
@bot.command()
async def webscrapp(ctx, website):
"""Scrapping Usage : ht!webscrapp [url link]"""
if isinstance(website, commands.MissingRequiredArgument):
await ctx.reply("Usage ht!webscrapp [url link]")
await ctx.send("Processing")
req = requests.get(website)
with open("scrapped.txt", "w") as files:
files.write(req.text)
await ctx.send(file=discord.File("scrapped.txt"))
the hell is that supposed to be
commands.MissingRequiredArgument is an error
It's raised when an arg is missing
You're supposed to create an on_command_error listener and catch it and reply accordingly there
Can u provide me the example?
on_command_error is callback?
No, an event
You listen to that event
Assuming you'd do this in a cog:
@commands.Cog.listener()
async def on_command_error(self, ctx, error):
if isinstance(error, commands.MissingRequiredArgument):
await ctx.send("You are missing a required argument")
So i cant do in specific command, like throw a usage of the specific command
But thanks for the example
Uhhh
I think you can?
Try
@webscrapp.error
async def webscrapp_error(self, ctx, error):
if isinstance(...):
....
Below your command.
Im confusing
?
So i need to create this new event?
Just do on a client disconnect check why and then turn back on in this case
How do you guys host your bots?
At a Raspberry Pi
.tag hosting
Tag not found.
Did you mean...
closing

#app-commands message
How do you add a slash command group in a cog?
I could just import bot from the main file but I don't think that'll be very practical
discord.slash_command
Here's the slash cog groups example.
@deft hull
thank you 👍
how did you call this exactly?
never mind, saw it by clicking on it
wasnt aware an example existed for this case
Hey, I'm trying since like the last hour to figure out how to make a url button work, but also with a view class I can't get it to work. Im very new to python still
@discord.slash_command(name='userinfo', description='Provides information about a Discord Member')
async def get_user_info_cmd(self, ctx, member: discord.Option(discord.Member) = None):
target = member if member else ctx.author
view = discord.ui.View
btn = discord.ui.Button(label='View', style=discord.ButtonStyle.link, url="https://cdn.discordapp.com")
view.add_item(self, item=btn)
await ctx.respond(embed=get_user_info_embed(target), view=view, ephemeral=True)```
**Edit: got it!**
"NoneType"
Read the error ;3
You have to fetch the user to get the Banner
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 ...
^
how would I do that tho?
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'm trying my best to figure it out but I'm always getting some error like this
Please give me a code example on how to fetch a user from their id
user = await discord.Client.get_or_fetch_user(self.bot, member.id)
I tested so many things
discord.Client or discord.Bot refers to your bot variable
you've set a bot variable in your code, right...
yes
then just use that
it's in a different file tho
this is a cog, right?
and what's the first thing you set in your cog's __init__
self.bot = bot
this is outside of the class tho
Or no wait, I actually added it to the class as async function
async def get_user_info_embed(self, member: discord.Member):
I tried to pass it through but it always just gives me none
import discord
from discord.ext import commands
import views.lookupUser
class UserInfo(commands.Cog):
# this is a special method that is called when the cog is loaded
def __init__(self, bot):
self.bot = bot
@discord.slash_command(name='userinfo', description='Provides information about a Discord Member')
async def get_user_info_cmd(self, ctx, member: discord.Option(discord.Member) = None):
target = member if member else ctx.author
view = views.lookupUser.lookupUserBTN()
view.add_item(await views.lookupUser.lookupUserBTN().button(url=f'https://discordlookup.com/user/{target.id}'))
await ctx.respond(embed=get_user_info_embed(bots=self.bot, member=target), view=view, ephemeral=True)
def get_user_info_embed(bots: discord.Bot, member: discord.Member):
embed = discord.Embed(
title='User Information:',
color=discord.Color.from_rgb(100, 255, 100)
)
embed.set_thumbnail(url=member.avatar.url)
user = bots.get_user(member.id)
print(user.banner)
return embed
def setup(bot):
bot.add_cog(UserInfo(bot))```
are you trying to fetch any user, or get a member in the guild?
in the guild
I want a userinfo command that sends me info about my member on my server
basically just remove the user = ... line (unless you really need their banner for some reason, then you'd have to fetch)
then you have to change it to an async function and use await bot.fetch_user
can someone please help
how to add fields to a paginators embed
send an example code or anything
the repo is full of examples
ye but idk how to add fields to the embed if im using this approach
just.. add them to the embed like normal lol
Embed takes a fields kwarg.
oh ye tyvm
docs, as always
ye ty 😭
how to create that?
Am I able to nest groups like this?
parentgroup = bot.create_group("parent", "parent group commands.")
childgroup = parentgroup.create_group("child", "child group commands.")
you can definitely have 2 subcommands yes, but im not sure if it works like that. just try it
what's the best way for handling config values across cogs? i can't figure out how to do it without dealing with desynced data
config file?
or a database if you mean that kind of config
i was gonna use a config file but im gonna have a mysql database for my bot anyways so ig i can use that
if its per-server configs, database
its gonna be a self hosted bot, so everything is local and in 1 server
then just use a config file or hardcode it lol
what's the best way instead of constantly reloading the config file to check for changes
what are you even doing that needs you to change the config file lol
well im making a store bot that sends out files
remaking it*
my original version is all in 1 main.py
im converting it to use cogs
so stuff like discounts, permissions, etc
well if you need to change it more than never, use a db
I have a config.py that I import to use constants in any cog. but like toothy said, if the data might change and you don't want to restart the bot, it should be in a db or something.
whats the best schema for a mysql config
literally just a config table?
Uhh it entirely depends on the data
it's just gonna be like global variables
lemme get what it is rn
guild id, variable name, variable value? idk
[SETUP]
depo_world = BANNED
depo_bot = 05u1oyzyk9
pay_as_you_go_price = 30
purchase_count = 482
total_profit = 1283217
rescan_cooldown = 60
admin_checker_channel = 1206053236428247070
admin_checker_price = 0
add_your_own_world_channel = 1206105043426615367
literally just stuff like this
a lot of ints, some strings
i use config parser and .ini normally
but now im working with multiple cogs
Why not keep it an ini
because i keep coming back to the same issue which is desyncing data
if i save the config in one cog it wont update on the other ones unless i reload
the only idea i've had is creating a configparser object in a shared.py file and importing it across all cogs
When you read a config value, just re-read the file?
Do this
i was trying to be efficient and not do this but ig i can
How is this not efficient?
I create a db object and add it to my bot bot.db = DB() that I then use in any cog to query the DB, this is very similar
yeah i figured it out, i was just being dumb
thanks
Not dumb, just unable to access the right information at the time ^~^
You know
If you somehow manage to desync your data with a config file
Just make it a class that sets its fields upon being made, and save the object as a bot variable
i have message id from db, but if i using bot.get_message() after the msg age is more than 1week, it's always return None, why?
I think you can only get a message that’s x amount of days old correct me if I’m wrong
Because bots can’t delete messages that’s older than x amount of days
which are your intents
and do you fetch the message?
I'm trying to host an application which uses a database by fetching data from the google sheets api. Thing is, I don't know how
get_message only works from cache - after a week, there's a very decent chance it's no longer cached (the default message limit is 1000)
if it returns None you need the channel ID AND the message ID, get the channel with get_channel and use await channel.fetch_message
ty I'll try use fetch
you can also use discord.PartialMessage.fetch_message so you just need an ID for the channel instead of get- or fetch-ing it
How can i make this a int
async def get(ctx, page: description="The page with the quest that you want to see.", min_value=1, max_value=6, default=1):
make what an int
Make what an int
slow
Shut
im just a dragon
I menat i want to make a slash command that you can put a nuber
I can't do it directly on async def?
you can but its ugly af in my personal opinion
Do you realise this code here doesn't make sense right?
its so clean wdym
discord.Option supremacy.
inferior
says the dragon
exactly, the superior species
you're fictional
Classic
@bot.slash_command(name="test", description="test")
@option(name: "page", int, description="The page with the quest that you want to see.", min_value=1, max_value=6, default=1)
async def get(ctx, page: int):
@option(name: "page", int, description="The page with the quest that you want to see.", min_value=1, max_value=6, default=1)
^
SyntaxError: invalid syntax
that is.. not how you do python
just do it the way i did
pass the name and type as positional argument
ok
did it work?
To give you the specific issue the name: should be name=
But type has to go first.
it doesnt have to
Kwargs can't be before positional args.
yea, but if they just followed the way i did it, they wouldnt have that issue
Fuck decorators
why?
Ugly af
literally so clean
what looks unclean here
Immo the latest version they added is the best
Crowded mess up top and doesn’t seem pythonic
the multi-line function definition is what i find absolutely disgusting and wrong looking
Typing.anotated just seems more general and closer to other libraries/code
wtf is that
I get that decorators do the best at separating the options visually, but they also make really library specific and counter intuitive
#discussion message
Last version
It looks weird but is properly type hinted
Currently use option kwargs but this is better imo
So I need help with something, I have a main file where my bot is loaded. Now I have another script where I want to put my events inside to make the code more readable. Now how do I access this bot instance from my main file in my event file?
Take a look at cogs in the guide
https://guide.pycord.dev/popular-topics/cogs
Cogs, often known as modules or extensions, are used to organize commands into groups. This is useful
@chilly crow
Okay, so should I basically put all my logging events in logging cog for example?
yes
Quick question
can you set a command desciption like this
@decorator
async def something(ctx):
'''
Description
'''
pass
No
The pycord syntax is different
Learn all about Slash Commands and how to implement them into your Discord Bot with Pycord!
docstring still works for descriptions yes (tested on 2.5)
(just note that user and message commands don't have descriptions, only prefix and slash do)
oop
channel.overwrites_for(ctx.guild.default_role)
why does this return None
For what do you need this and is it at a command?
yes.. I am trying to update a specific permission only.. since its returning None, it is updating all other permissions to default
Hello, i didnt really understand something about slash command, i read the limit is 100 slash command and sub command but with the tag cmd-rate im now a little lost.
If i create a /command math with 25 sub command in it and i does 5 others groups like this i will have a total of 125 commands and subcommands. Does it will work ?
or the limit is still 100 so i cant have a total of 125 sub commands
so this is 7/100 for the commands
it is 1/100
it's actually 2/25 for the sub commands
you have mod and set
something like that. There's probably an official term.
ok thanks you, im planning to put all my prefix command as slash command
but with more than 300 commands, i will need to do better thing
i was planning to do for each category the name like /moderation ban @user, /action agree, /antiraid antispam etc etc, if you have some advice or else tell me
yes, that's generally how its done
and also about /slash commands, what does it mean no rate limit ?
like it doesnt rate for the sending of the command and the invocation ?
if a user sends a slash command, discord will let you respond to it
for text-based commands, there are rate-limits because bots can't send messages that frequently
ok its about that
i have a lot of thing to learn about slash commands...
is there a way with bridge command to something like this :
/moderation ban
+ban
for when i use the slash i have the moderation has group but with the prefix i dont need to speficy the group
what if you just made a regular slash command and a regular text-based command
it also work but 2 times more works
cos when i will change a / i will have to change the text too
but if there are nothing to do it i will make both
I'm not familiar with bridge

