#Basic Pycord Help
1 messages · Page 5 of 1
Read the attributes and learn how you can get the guild and then the role
Here's the slash autocomplete example.
Then it's just returning names
You get the role
The role has a members attribute which returns a list of member objects
You just need the names you you create a new list with them
And then it's just returning them

and what is aiosqlite for then?
an async implem. for SQLite
i'm here rn:
guild = client.get_guild(int(get_config("Guild_ID")))
teamliste = [get(guild.roles, id=1138953881460674560)]
@client.slash_command(guild_ids = servers, name="team-uprank", description="👤 Upranke ein Teammitglied.")
async def team_uprank(ctx, member: discord.AutocompleteContext):```
@cyan violet here is a example for the autocomplete
At the end you have to get creative for it ;3
Just do ctx.interaction.guild.get_role
You're over complicating it
its above the command
what did i wrong??ß
Everything
anyone know what should I put after : ? --> </help:>
the command ID
how to get that?
assuming ctx is discord.ApplicationContext and ctx.command is help, then it is ctx.command.id
Is there another way to find that?
.rtfm bot.walk_application_command
6 results
discord.ext.commands.Bot.walk_application_commands
discord.ext.commands.AutoShardedBot.walk_application_commands
discord.ext.bridge.Bot.walk_application_commands
discord.Bot.walk_application_commands
discord.ext.bridge.AutoShardedBot.walk_application_commands
discord.AutoShardedBot.walk_application_commands
thanks for the help
I don't see why that would make a difference but I'm glad it worked for you
How can I get my bot to show up in the Apps menu when you hold down a message?
You can use message context menu commands
Learn all about Context Menus (User Commands & Message Commands) and how to implement them into your Discord Bot with Pycord!
discord.Option doesn't work with bridge commands?
try it with @discord.option()
Here's the slash options example.
I mean it works when used with slash_command, buth when I use prefix cmd, it raises an error saying can't convert to discord.Option something like tht
@bridge.command()
@discord.option(name="text")
async def command(ctx, text: discord.Member=None):
...
``` try something like this
try running master branch
?tag install
1. Uninstall discord.py or any other forks of discord.py you might have with the namespace discord.
python -m pip uninstall discord.py discord -y
2a. Install py-cord
python -m pip install py-cord
2b. Update py-cord
python pip install -U py-cord
Installing other builds:
Note: You need to have git installed. Use ?tag git to find out how to install git.
Updating the module to master branch (unstable):
pip install -U git+https://github.com/Pycord-Development/pycord
there are many ways to do it
it works tho, ty
not sure. you will need to test
okie
tbh if it is working then no need
lol, I was thinking the same
will on_command get triggered for bridge commands?
like even when user uses slash command nd even when he/she uses the prefix cmd
.tias
it wont for slash version of bridge
master branch has on_bridge_command
it will trigger for both versions
master branch does have a few nice changes
more like a wavelink question, so I am pinging you @fleet cedar
Why the song doesn't start playing even after being added to queue? I did vc.autoplay = True tho
Code:- https://paste.zorino.in/xutaninelipabece.py
Ignore the command's name being command :)
await vc.queue.put_wait(track)
i dont think this is a valid method onasyncio.queueif you are using that
ig i read it somwhere in wavelink docs, wht should i use then?
have you set a limit on max items?
nope
Asyncio queue is just .put()
then vc.queue.put_nowait(track) (without awaiting)
Or that
this works too but kinda useless if no limit is set (need to await this one tho)
ohk, lemme try tht
Well yeah makes no sense if you don't want a limit
that should have errored tho
are your errors being boggled up?
.tag noerror
Not getting an error, but definitely should be?
Do you also have an on_command_error set up?
Please make sure to look at, and implement,** the 3 or so lines starting with 'else'** in the example below. Without this code or similar, your error handler is eating all unhandled errors. As you can imagine, this is bad when you get an unexpected error.
https://gist.github.com/EvieePy/7822af90858ef65012ea500bcecf1612
Do you also use asyncio.run and/or bot.start?
Please make sure logging is setup correctly.
https://docs.pycord.dev/en/stable/logging.html
Ignoring exception in command command:
Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\ext\commands\core.py", line 178, in wrapped
ret = await coro(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\Administrator\Documents\GitHub\Krishna\test.py", line 171, in command
vc.queue.put_nowait(i)
^^^^^^^^^^^^^^^^^^^
AttributeError: 'Queue' object has no attribute 'put_nowait'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\ext\commands\bot.py", line 347, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\ext\commands\core.py", line 950, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\ext\commands\core.py", line 187, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Queue' object has no attribute 'put_nowait'
;-;
what r u doing
adding a track in queue using wavelink
put_nowait is not a valid attribute smh
which queue class are you using 👀
wavelink player's queue
I sent u the code ;-;
uh
oh does it have a built in queue?
sorry didnt know
you might need to refer wavelink docs yk
yeah, tried searching for any possible help there.. turns out there is no reference why the issue I stated in the 1st msg, happens
🤔
Is there anyway to get twitch details such as their username listed in their profile connections?
Other than while they are streaming
Is there a way where i can see what functions does a library offer with the meaning of them?
yeah it's called documentation
is pycord on pacman
no, it's on PyPI
getting this when remotely installing py-cord
pipx install py-cord
if you are out of the loop, most distros made the default python3-pip package unable to install python packages system wide
not even that. just make a venv and then install within venv
@bot.bridge_command(description="send user message")
async def say(ctx: discord.ApplicationContext, *, message: str = Option(description="your message", required=True)):
await ctx.defer(ephemeral=True)
if not ctx.author.guild_permissions.administrator and ctx.author.id != bot.owner_id:
embed = discord.Embed(title="Error", description='You do not have permission to use this command.', color=discord.Color.red())
await ctx.respond(embed=embed, ephemeral=True, delete_after=5)
return
await ctx.send(message)
await ctx.message.delete()
When I don't set a value for the message, the bot sends this
<discord.commands.Option name=message>
discord.Option is meant to be a "typehint" and not a default value
In a function parameter,
smth: Option is a typehint
smth = Option is a default value
Notice the difference
Here's the slash options example.
Check that out
I thought we made the default value a supported syntax
thanks
We made typing.Annotated a supported syntax. Option as default value doesn't work
Vincent was thinking about it for V3 but I'm not sure what he settled on
why when i pick a gif in attachment (slash command) it is just stuck on sending command and then it says application did not respond? and then i cant chat for some reason.. i have to reload discord
in my command, png's work perfectly
Seems like a discord issue
discord has been buggy somewhat since last few days for me
infact if I am in a vc and a bot pings me, my discord client restarts automatically
idk whytf tht happens but it is what it is, re-installing too didn't fix it
anyways, I had a question (not help or py-cord related), can I somehow get a PDF or a few PDFs of pycord's documentation? 😅
how can i conditionally add a SelectOption to a View class? i got a slash command with two select menus for adding/removing entries(an aboutme) but i don't want to have something thats already in there to appear in the add selection
i have tried a few things but i cant get it working
@discord.ui.select(select_type=discord.ComponentType.string_select, placeholder='Add a Field', custom_id='add')
async def addcallback(self, select, interaction):
gid = interaction.guild.id
mid = interaction.user.id
fields, values, aboutme = Social.load_aboutme(self, gid, mid)
vals = select.values
file_path = os.path.join('data', 'guilds', f'{gid}', 'members', f'{mid}', 'aboutme.txt')
if not 'Name' in fields:
self.add_option(label='Name')
if not 'Age' in fields:
self.add_option(label='Age')
if not 'Country' in fields:
self.add_option(label='Country')
if not 'Hobbies' in fields:
self.add_option(label='Hobbies')
with open(file_path, 'r') as f:
lines = f.readlines()
for val in vals:
if val not in fields:
lines.append('\n'+val+': ')
with open(file_path, 'w') as f:
f.writelines(lines)```
you can do that easily
clone the repo, navigate to the docs folder
it might be sphinc-builder -b latex . ./some_folder
followed by make latex
not sure
Hello. When bot creating a new channel, it copies the category rights. How can I disable this?
Target not found, try again and make sure to check your spelling.
Pycord
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 ...
It is combined with those already installed from the category
is it possible to change permission of a discord bot without readding it?
I would say with the User/Bot role permissions?
thats the only way i can think of, but users will need to edit it manually?
Where can I find more information about how and when Pycord caches stuff? I know what the cache is, but I don't know which actions update the cache as a side effect, and I don't know what I can do to update the cache manually if I have a need to do that.
Basically, I know that the answer to "why doesn't Guild.get_member find this member that I know is in the guild?" is "because that member isn't cached", but I don't know what I can do to get the member cached for future use.
what happens if 2 save processes run at the same time in sqlite?
you could use fetch_member and discord.utils.get()
(Moved to https://discord.com/channels/881207955029110855/1141471920118825160 because trying to clarify things turned into a wall of text.)
Does discord.Guild.premium_subscriber_role return a discord.Role object?
.rtfm premium_subscriber_role
1 results
It does.
I found it in the docs it just doesn't say what type of object it returns so I wanted to confirm
Because my poor self doesn't have any boosted servers to test lol
It even have role at the name ;3
Giving it parameters
Here's the slash options example.
So uh, why do some Views have a self.message and others don't? I'm looking at some of my existing code, which uses self.message just fine. But in this new View I'm working with, it's None 
##1572 ##1600 ##1997
Okay, looks like they were fixed after the last release. Thanks
class ItemSelector(discord.ui.View):
def read_data(self):
with open("mylist.json" "r") as file:
data = json.load(file)
return data
def __init__(self, dict_key):
self.items = self.read_data()[dict_key]
super().__init__(timeout=60.0)
@discord.ui.select(
placeholder="Select Items",
max_values=1,
options=[SelectOption(label=i) for i in self.items
])
options=[SelectOption(label=i) for i in self.items
NameError: name 'self' is not defined
is it not possible to create menus using list comprehension for clean code?
my first question is are you using a json file to store persistent data?
and also your select deco is out of scope
thus you can't access self
yes
oh boy you are in for a ride. JSON is not a DB
?tag ?tag json is not a db
No tag ?tag found.
?tag json is not a db
Why JSON is unsuitable as a data storage medium.
-
JSON, quite simply, is not a database. It's not designed to be a data storage format, rather a way of transmitting data over a network. It's also often used as a way of doing configuration files for programs.
-
There is no redundancy built in to JSON. JSON is just a format, and Python has libraries for it like json and ujson that let you load and dump it, sometimes to files, but that's all it does, write data to a file. There is no sort of DBMS (Database Management System), which means no sort of sophistication in how the data is stored, or built in ways to keep it safe and backed up, there's no built in encryption either - bear in mind in larger applications encryption may be necessary for GDPR/relevant data protection regulations compliance.
-
JSON, unlike relational databases, has no way to store relational data, which is a very commonly needed way of storing data. Relational data, as the name may suggest, is data that relates to other data. For example if you have a table of users and a table of servers, the server table will probably have an owner field, where you'd reference a user from the users table. [This is only relevant for relational data]
-
JSON is primarily a KV (key-value) format, for example
{"a":"b"}where a is the key and b is the value, but what if you want to search not by that key but by a sub-key? Well, instead of being able to quickly usevar[key], which in a Python dictionary has a constant return time (for more info look up hash tables), you now have to iterate through every object in the dictionary and compare to find what you're looking for. Most relational database systems, like MySQL, MariaDB, and PostgreSQL have ways of indexing secondary fields apart from the primary key so that you can easily search by multiple attributes.
For more info and resources about storing persistent data, please check out https://vcokltfre.dev/tips/storage/
persistent in this case meaning you are storing data that persists after bot reboots
it's recommended to use a db such as Sqlite or postgres instead
I do soo much good work 😭
hey guys I want to make a discord dashboard but I don't know which way should I follow or what should I need to learn? (if I made a mistake while writing sorry for that I'm not native english speaker)
ipc to communicate between your bot and your web app, and either have the frontend be on the web app or use a js framework like React as the frontend. If you decide to go with the React option, then your web app needs to be an rest or graphql api
but this app I want only for admins
not for users
still same concept will work
i outlined the concept on how you can approach it, not whether admins are able to use it
if you want it for admins, then it's up to you to integrate that feature
i recommend you conduct your own research on this instead
I searched to many resource but i didn't find any resource
best of luck then
to illustrate my point:
The web app way
bot <--ipc--> web server <- web client
Using an JS framework:
bot <--ipc--> rest api <-- http client (axios) <-- user
if you can make a website all id worry about is ipc
fyi there are no good ipc libs for pycord so the ipc approach is basically screwed. ghoul's lib is just a fork of discord-ext-ipc (which has been archived so don't bother thinking of using it) and literally does nothing but switch the namespaces
zeromq is kinda my choice when it comes to ipc
thanks guys
i can just throw in new clients whenever I want
don't need to worry about causing problems by reconnecting or anything
better-ipc kinda works they last time I tried
Might need to install without any deps
better-ipc requires some tinkering to get working for pycord
Oh 👀
how do you send multiple views at once?
Send multiple messages
Create a class for it
ok, ive got a select and i want to put a back button on the panel aswell
thank you :)
It's not adviced to put the .sync_commands() function on an on_ready event, right? And that I should just put plain on my main.py file?
on_ready can fire many times and you also can get a ratelimit for it really fast
true, so ill just keep it near the place where i initiated my discord bot client
You don't need to call sync_commands unless you are changing commands during the time the bot is online.
It is run automatically
I'm using cogs, so it's different.
It shouldn't be. If you load the cogs with load_extension (you should if you are not) you still do not need to use sync_commands.
The 2 reasons you would, is to add, edit, or remove a command without restarting the bot or if you override on_connect
I'm not directly adding the .load_extension to where my bot is initated, I put it in a slash command in my main.py file.
/load_cog command
Ok then yes you are correct due to the fact that you are removing and adding commands while the bot is online. You would only need to call sync commands in your
/load_cog (and remove_cog) commands.
yeah
Mhmmm why does a view can make await ctx.send doesnt sended?
No errors were shown
Fixed
Traceback (most recent call last):
File "D:\Programming Stuff\Discord Stuff\Vistara Project\Vistara\venv\Lib\site-packages\discord\client.py", line 378, in _run_event
await coro(*args, **kwargs)
File "D:\Programming Stuff\Discord Stuff\Vistara Project\Vistara\cogs\events\autmod_ev.py", line 42, in on_message
await message.attachments[0].delete```
can any body help me out with this
Hi there!
I have a question, since the discord update, is there a way to retrieve the player's displayed name?
My profile has the name "teddou." and it's displayed as "TED."
Why does display_name, name all give me "teddou."?
Isn't Py-cord up to date yet?
First, are you using the master branch or the 2.4.1?
And:
?tag pomelo
Before Pomelo-
member.name -> username
member.nick -> guild nick name
member.display_name -> member.nick OR member.name
After Pomelo-
member.name -> username
member.global_name -> global display name (global nick name)
member.nick -> guild nick name
member.display_name -> member.nick OR member.global_name OR member.name
The pomelo changes have only been applied to the master branch so far, no release for it has been made yet.
Any idea when the next update will be released? The global_name attribute seems interesting to me.
master branch is pretty stable
#library-updates tho
If I want to install this on my linux server on which the "requirements.txt" file is used to install py-cord, how do I go about it? I doubt the link can be used.
you can use the link in the file
?tag install
1. Uninstall discord.py or any other forks of discord.py you might have with the namespace discord.
python -m pip uninstall discord.py discord -y
2a. Install py-cord
python -m pip install py-cord
2b. Update py-cord
python pip install -U py-cord
Installing other builds:
Note: You need to have git installed. Use ?tag git to find out how to install git.
Updating the module to master branch (unstable):
pip install -U git+https://github.com/Pycord-Development/pycord
- py-cord
+ git+https://github.com/Pycord-Development/pycord
Thanks, I'll give it a try soon!
Hello there 🙂 Someone has an idea why slash commands of my bot are not showing on some servers? The bot has all permissions he needs and on most servers it works. Also other bots do not have the same problems. The roles the other bots have on the server are exactly the same as the roles of my bot. Any suggestions? 🙂 Using Bridgecommands instead of slash commands btw
Are you sure that the bot has the application.commands scope in all servers?
And that the commands are global and not are for certain guilds only?
Make sure you have done everything in this checklist
.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.
how do i add an emoji to a bot's custom activity?
Can I make a slash command that one can only use on themselves, unless they are an administrator, in which case they can use it on anyone? If so, how?
Hello! How can I check if a member is a bot?
.rtfm Member.bot


?tag install
1. Uninstall discord.py or any other forks of discord.py you might have with the namespace discord.
python -m pip uninstall discord.py discord -y
2a. Install py-cord
python -m pip install py-cord
2b. Update py-cord
python pip install -U py-cord
Installing other builds:
Note: You need to have git installed. Use ?tag git to find out how to install git.
Updating the module to master branch (unstable):
pip install -U git+https://github.com/Pycord-Development/pycord
Hi )
When I call my command, I see the following output (screenshot). But the bot worked correctly. The "Application not responding" message is unexpected.
use ctx.respond instead of ctx.send
Thanks)
np
master has the interaction.edit shortcut, but what if I'm editing the original message from inside a Modal callback and need to (I'm passing in the parent view as self._view (which may be obsolete now?)) -- What's the most pycord-ish way to edit the original message while passing in the new View state?
I recently had to do the same thing
Hi guys, do you have an Idea of how I can put on owner_ids all of the pepoles that have a certain role, and above pls?
I think I just passed the message in?
After the bot starts up, fetch members and find those with the required roles, then set bot.owner_ids to the list of their ids
e.g
class MyModal(discord.ui.Modal):
def __init__(self, *args, view: MyView):
self._view = view
...
async def callback(self, interaction: Interaction):
do_stuff_that_changes_the_view()
original_embed = self._view.message.embeds[0]
original_embed.fields[0].value = 'Dorukyum is cool'
await interaction.edit(embeds=self._view.message.embeds, view=self._view)
Is this still the best way to accomplish? Or am I overcomplicating?
ok I see, but if I want to fetch all osers of a lot of roles, but I dont really know how much roles are above
The message, or the View? Doesn't seem UI components have any visibility into the View itself otherwise.
I just took another look, it seems I passed in the view so that I could use view.stop() (not sure if that's required)
Check the position of the users' top roles
(member.top_role.position)
Check if it's higher than the bottom role you're looking for
AFAICT, yes. I don't see anything (at least in the Changelog) that would suggest that it's being done. Although if it could be done automagically, that'd be kinda swell.
Yep, I would like the view to be removed from cache after it's been removed from a message
idk maybe I'll look into it when I have some time
or if bob returned and started acting like an actual maintainer he could do it...
Can you return error messages in a Modal when submitting? Like you click Submit, it does some verification, and without closing the Modal shows an error right in the Modal UI similar to the "Something went wrong" text (Don't see anything in the Discord docs, but was worth asking)
well you cant customise the error message but if you dont respond then discord will raise an error
you send a response and a button to send another modal
if you want
Sadly not helpful from a user standpoint but I gotcha. Currently building a second embed to show any error messages. The View is fairly complex
Appreciate the confirmation
you can do interaction.message.edit ?
Well I also need access to the View, because various UI state (name, enabled/disabled, selections, etc) may have changed in response to the callback. And this may also come from a helper method, so I don't want to mark it as responded yet.
hmm
await self.change_presence(
activity=discord.CustomActivity(
name="bot",
emoji="🤖",
)
)
why is this not working ( no error )
are you using master branch?
yes
latest commit?
awesome
can you show a pic of how it looks 👀
i wanted to know lol
Oh that's cool that CustomActivity has an emoji; didn't even see that. I'm guessing that can't be a custom emoji(?)
pretty sure it can
as it can be a PartialEmoji
(you can pass a string and it gets auto converted to this)
So here's a fun one.
I'm passing my view into Modals.
From a callback,interaction.message and self._view.message do not refer to the same object.
hmm damn
Moved that question to #discussion
Hi, is there a way to move a Slash Command Group into another file and use it in a cog to make a sub group? I have tried making it a variable in it's own file and importing it, but the command just doesn't show up on discord, but loads fine.
I basically want to use the Slash Command Group for multiple sub groups, that aren't in the same file.
class Example(commands.Cog):
def __init__(self, bot_: discord.Bot):
self.bot = bot_
# Move this line to a seperate file
greetings = SlashCommandGroup("greetings", "Various greeting from cogs!")
international_greetings = greetings.create_subgroup(
"international", "International greetings"
)
@international_greetings.command()
async def aloha(self, ctx: discord.ApplicationContext):
await ctx.respond("Aloha, a Hawaiian greeting")
there is a way
1 sec.
@fleet cedar Do you know what the name was again for it? xd
lmao
Thank you <3
Any ideas for temporary storage(e.g. start time) for a timing system.
If you're just storing the start timestamp of the bot just make a new var under the bot and store it there (ex: bot.start_time = time.time())
Even if it lasts for several hours and there may be multiple timers
Wait wdym
Are you just trying to store when the bot starts up or it smthn else you're trying to store?
Got asked about it a few days ago. I’m still trying to get my head around it.
It’s an arma server and they want to record play time when they organise events
Scenario:
They group up> organiser runs X command <start> -> they play -> X <stop> works out the duration and updates a db with new play time for the month. But there may be multiple sessions starting and ending at different times so there may be overlap
That was my understanding of it
Oh yeah then I'd recommend storing it in the database if you need the data to persist after the bot restarts
And that way you'll be able to handle multiple timers easily
You can probs just store the user id of who started the timer as well as the start and end timestamps
if you dont want a db, just use a dict
Thought as much.
If in doubt put it in a database 😂
Database probably easier. Plus it persists through restarts
a db is always better
aiosqlite* ;3
sqlite here refers to the type of database, not the library used
k
L
M
that's an airline
Lmfao
is it possible respond to a select menu callback using send_modal?
@fleet cedar Do you know if it is possible to join the paginator with a Dropdown?
Hi, where can I find list of functions to override for event tracking? Such as on_member_join)
Yes
You can pass a view to the custom view parameter
paginator = pages.Paginator(pages=self.get_pages())
dropdown = Dropdown_Type()
new_view = discord.ui.View()
for item in dropdown.children:
new_view.add_item(item)
for item in paginator.children:
new_view.add_item(item)
Uh no
paginator = Paginator(..., custom_view=MyView())
Smth like that
Here's the paginator example.
omg
more easy
hahaha 
How do giveaway bots verify you've sent enough messages to enter? Is that literally by saving a record of every message sent by anyone in the server and then using COUNT()?
Probably just by going through each channel in the server when they are entering the giveaway, getting the message count for the user in each channel, adding it all together and then seeing if it meets the requirements.
That's an API call for every channel, I'm not convinced that's possible, or practical
yes thats correct 💀
what ive tried is, save people's message counts after they have tried to enter once
this cuts down on a lot of needless data
but it becomes impractical at some cases
or actually no
I mean giveawayboat must have terabytes of this stuff
i store just the counts of a user
not the message itself
Then how can you do the messages in the past 24 hours
smth like
user1 5
user2 69
user3 420
You can't timestamp them that way, or do you just have a decay of 5% of their messages each hour
i dont really decay
i store the counts per-gaw
so the total messages after a gaw are counted
per giveaway?
yes
Oh so they need X messages by the end to have a chance of being picked
I wonder how giveawayboat does it
Messages would be a new feature
Giveawayboat checks when they join how many they've sent in the past 24 hours
I mean it must just be by saving messages, their database must be crazy
naaah, you could simply count the messages per user, only storing one changing integer. at the end throw some stochastics and a randint at it and you got a winner
i meant like:
user a made 10 messages. user b made 20
randint between 1 and 30. 1-10 a wins... expand as needed.
so no need to store massive amounts of data, a user id + an int will do.
oh that's what you meant, I hadn't intended it to work like that but it's a cool idea
why store more than that? 😄
but i am curious!!
what was your plan/idea?
nothing insane, was just user needs X number of messages in the past Y time to enter the giveaway
Ahh a treshold for entry and equal chances for all that make it.
doesnt sound bad either! My way would encourage spam cause of the higher win chance
at least if participants are aware how it works
how can I check whether or not paginator is allowed to edit its own embed collection in the channel he wants to do so(the channel the slash command was used in)?
PS: Please ping me or use the respond function when you answer.
Or just increment a count in on_message
Could partition it by day or something
eh what?
how can i run lavalink.jar in python bot.py file
why lavalink.jar?
because i want to use wavelink music
i need to have running lavalink to use wavelink
wavelink repo
without lavalink.jar i cant use wavelink youtube music
well, youtube music is against the TOS?
if you still gonna do it
Pycord and Wavelink try to keep the playing of audio as simple and easy as possible, to keep making Discord
Im not sure if this is working
i think its not
even pycord have guides for this
without any warning
lavalink is not yt-dlp
yt-dlp is againt tos 100%
but lavalink i dont think
its not what im searching for
i know how to make music bot
but i dont know how to run cmd lavalink.jar in python file
Jetzt kommt Lala x3
what
everything involving music is grayzone or possible even against any existing tos.
lavalink would fall under tos as well bcs it straight up plays from youtube anyways.
so why there is so many music bots?
even really popular
because no one cares until someone makes money through it, see rythm or similar big bots
And they are not really using YT anymore
They use Spotify and other
But still against the TOS
ye
how can i run lavalink.jar in python bot.py file
for that, you shouldn't do that directly. what you could do, maybe dispatch a cmd on the host to start it and keep track whether the process is running, through checking the process list or just pinging the nodes rest url. i.e. GET http://127.0.0.1:LAVA_PORT/version
do you mean something like this?
not hosting it on my own server?
is it even safe?
thats not what i'm saying 
Or use docker and make the file starts the processes
Wdym too hard. You just gotta add the file and let docker do its things
It's not like i need to make Code specially for docker? I mean to create docker Container Code?
How do I check if a member has a certain permission (ex: manage_channels) using their permissions integer (ex: 2147483647)?
Can I just check if the integer is greater than the value of the manage_channels permission?
create a discord.Permissions object
Pycord
Some classes are just there to be data containers, this lists them. Unlike models you are allowed to create most of these yourself, even if they can also be used to hold attributes. Nearly all clas...
But what if I'm doing this in JavaScript?
I was hoping I could just write the code to do it myself after knowing how to deconstruct the integer
Yeah but how do I undo the bitshift
The docs just say what the individual bitshifts for the permissions are
I searched it up and it says their lossy so idk how I would go about doing it then
check the pycord source code
So do I basically check if the union of the permission and the member's permission integer are the same?
Is there a way to display, for example in an embed, how much RAM the bot uses or, even better, how much RAM is used per shard?
Seems about right
you're probably looking for https://pypi.org/project/psutil/
And can you also check the ram usage per shard there?
iirc no
guys any idea why the modal shows an error although the value is sent in the channel?
how are you sending it?
through a slash command. typing /echo will invoke the modal and i can see the text sent in the channel. but the modal window is throwing this error
send the related code
import discord
from discord.ext import commands
class Echo(discord.ui.Modal):
def __init__(self):
super().__init__(
title="What do you want to echo?",
timeout=5 * 60, # 5 minutes
)
self.description = discord.ui.InputText(
label="Enter Your Text Here",
style=discord.InputTextStyle.paragraph,
placeholder="enter your message here",
required=True,
max_length=4000,
)
self.add_item(self.description)
async def callback(self, interaction: discord.Interaction) -> None:
response = self.description.value
channel_id = interaction.channel_id
channel = interaction.guild.get_channel(channel_id)
await channel.send(response)
class EchoCog(commands.Cog):
def __init__(self, bot):
self.bot = bot
@discord.slash_command(name="echo",description="Echoes this message")
async def send(self, interaction: discord.Interaction):
modal = Echo()
await interaction.response.send_modal(modal)
def setup(bot):
bot.add_cog(EchoCog(bot))```
async def callback(self, interaction: discord.Interaction) -> None:
response = self.description.value
- channel_id = interaction.channel_id
- channel = interaction.guild.get_channel(channel_id)
- await channel.send(response)
+ await interaction.response.send_message(response)
Thanks a ton!
Mobile syntax highlights py but not diff?
mobile syntax highlight is very limited
jokes on you ios doesn't have any
Literally latest commit 💀
proly never merged into code base
when I input a large input in my slash command it says "input a valid integer" is there any way for me to specify a larger bit integer as an input?
string and parse it yourself
that was the solution I was thinking of, but it was kinda janky so I just wanted to double check
thanks!
how long does it take for an ephemeral message to disappear automatically
also is it possible to make an ephemeral message never disappear automatically?
30 mins or so
and no, that's not the reason ephemeral messages exists for
it'd be cool if discord allowed us to send a message in a channel visible to a single client without having to send them a DM
no
that will never happen
use dms for that :p
stop reposting your question
and u don't answer here
bruh
-to @upper drift 5m don't bruh me
⏱ Timed out saq1b for 5 minutes
maybe u are 
are changes to UI components client sided? like if I have a button whose callback changes the color of the button from green to red, does that replicate to everyone or just that specific user?
wanna be the next huh?
💀
no, it's server-side
for an element of bot.commands is it possible to get its subcommands (and sub subcommands) if present?
Anyone know how to do this?
.rtfm discord.Option
Learn all about Slash Commands and how to implement them into your Discord Bot with Pycord!
Target not found, try again and make sure to check your spelling.
thx
what is the differance between the discord app_commands extention and the slash_command one
cause I've been using @app_command but I see a lot of documentation here that uses @slash_command
walk_application_commands will give you all commands that the bot has. Is this what you wanted
An app command is currently one of 3 things. A Slash Command, User Command, or Message Command. The slash_command decorator is just a shortcut to create a slash_command. I assume you specify somewhere in the decorator that you want a slash command. If it works for you it is fine. It is just a bit easier to use @slash_command
the difference I see is that @slash_commands use ctx and @app_commands use interactions?
Hmm, If that is the case I recommend use @slash_command for slash commands. discord.ApplicationContext is better to work with than discord.Interaction
I would have to see your command decoratoer plus function definition to understand more
yeah thank you
what is the difference between
intents = discord.Intents.all() and intents = discord.Intents().all()
i was using intents = discord.Intents().all()
but in pycord examples is intents = discord.Intents.all()
sorry for the late reply! here's an example from my code
Intents() is a function that returns an "Intent" object given certain arguments. Intents.all() returns an Intents object with all intents (needs no arguments)
Is the discussion here about dynamic command options (#discussion message) and close reason given here ("Discord doesn't want you to do this; use autocomplete instead") still valid/up-to-date? (It's been two years, so I wanted to double-check.)
You are actually using discord.py
That's a different library
This is py-cord
And application commands is the biggest difference between the two
turns out I must be running some sort of weird hyrid then
hybrid*
cause I have uninstalled discord.py on my local machine
?tag install
1. Uninstall discord.py or any other forks of discord.py you might have with the namespace discord.
python -m pip uninstall discord.py discord -y
2a. Install py-cord
python -m pip install py-cord
2b. Update py-cord
python pip install -U py-cord
Installing other builds:
Note: You need to have git installed. Use ?tag git to find out how to install git.
Updating the module to master branch (unstable):
pip install -U git+https://github.com/Pycord-Development/pycord
must be that my server uses discord.py still
than you cannot do it
how would I port my bot from discord.py to pycord?
so wich one should i use?
intents = discord.Intents.all()
Whats the recommended way to have server-specific settings (like for my game)? Like if individual servers want to adjust the round length, rules, permissions, etc. maybe just dump it all in some database?
Command structure is the biggest difference. You will basically need to redo all of the command decorators according to the guide/docs.
There may also be some minor changes relating to how you respond to the commands but I have never used app commands in d.py
Or you could have them specified when starting the game every time.
Database is the best way though. Just make sure to use an async compatible library.
that doesn't sound too bad.
Is it possible that you are running in a venv and uninstalled from. A different one?
Everything that does not deal with interactions should be 98% the same
cool cool
how can i check if, for example, both user1 and user2 have both clicked to a button?
Use a variable with True or false?..
record the user who clicked the button's userID?
I mean i was debating if I just wanna store them in json files or some actual database etc,
hey guys how exactly does discord.CustomActivity work? i cant get it to do anything
and per-game settings wouldn't work, there's too many
sweats nervously in .txt
i could probably just repurpose tinydb since I already use that in my bot currently
right now it's dictionaries of dictionaries. which are pretty, but not editable without actually editing the code
i like dictionaries
dictionaries of dictionaries... do... do i want to see that?
surely you like spreadsheets better, right?
hey dictionaries are pretty! though this isn't my bot, just another example of my dictionary abuse
enums exist for this exact purpose
yes
It's not available yet in the current pycord release
my score db gets treated a a dictionary of dictionaries! sort of
score["serverid"]["userid"]["total_accuracy"]
hmhm aslong as i don't have to show what the fuck i am using to store user/server data
but its actually a db file
sadge
what would yall recommend for a complete db noob?
because there are things i HAVE to rewrite anyways, so why not do it (more) properly this time
sqlite or mariadb
Anyone else know why I cannot use the {ctx.author.avatar.url} bit in the embed.thumbnail.url
I like sqlalchemy
Please send some code
you cant really specify the height and width. discord determines it on its own
may be a weird question, but when a user wants to sends a message above the char limit, it can be converted to a .txt but what if a bots message exceeds the limit? what would be the best way to display/send larger heaps of text as message or rather non-file
if the bot tries to send a message too long, you’ll get an error
so its just that, makes sense
If you want to send more text, try using embeds
do embeds have infinite limit or what? or just a higher one?
You can have 15 (?) embeds per message and each embed can have like 6000 chars
whats the max number of fields an embed can have?
oh god
tbf i'm unlikely to hit the cap anyways since the bot barely gets used by the server members but O.o
currently using google sheets but god that code is a mess
💀
The f string is redundant. author.avatar.url is already a string
god, should i try to salvage parts of my funcs, completely scrap the bot and start anew, or rewrite them one by one?
so many hard coded things...
hmm yeah, I have to figure out the char limit thing for my bot too lol
It does a round-end scorecard to show everyone's guesses, score earned, etc. But it's about to get a test of probably a few hundred users
so im gonna have to figure out some way to condense or only show X number
Paginator!
Does pagnater have a helper function to auto paginate? Like give it a string it returns a 5 pages?
Don't think so
you can use utils.as_chunks and just pass that
how would i get someones display name rather than username?
like my display name is 'wallie' but my username is 'sdttr'
member = discord.Member
print(member.___)
?tag pomelo
Before Pomelo-
member.name -> username
member.nick -> guild nick name
member.display_name -> member.nick OR member.name
After Pomelo-
member.name -> username
member.global_name -> global display name (global nick name)
member.nick -> guild nick name
member.display_name -> member.nick OR member.global_name OR member.name
maybe we also should add it that this is only working with the master branch
¯_(ツ)_/¯
@daring grove you also have to install the master branch
the what
?tag install
1. Uninstall discord.py or any other forks of discord.py you might have with the namespace discord.
python -m pip uninstall discord.py discord -y
2a. Install py-cord
python -m pip install py-cord
2b. Update py-cord
python pip install -U py-cord
Installing other builds:
Note: You need to have git installed. Use ?tag git to find out how to install git.
Updating the module to master branch (unstable):
pip install -U git+https://github.com/Pycord-Development/pycord
the last line ^
what would member.global_name display?
you can see anything here
you also could create a command with all of them and see which one is the right one ;3
Or just use jsk
yea
PostgreSQL
With asyncpg
SQLite because you don't have to also think about setting up and running the DB server while you're still learning other DB stuff
I use MongoDB x3
SQLite is a chad move
SQLite.
I mean like, as soon as your bot outgrows "bare bones hobby project" status, absolutely get onto something more solid and full-featured than SQLite (I'm a huge Postgres fan as well), but given that the question was for a DB noob, I really don't think you can beat SQLite at all in terms of "amount of stuff you don't need to learn before you're up and running"
is there any way to catch/ignore these errors without wrapping every respond in a try/catch?
every once in a while it'll just randomly throw that and it'll lock the game up until i restart the bot
it's uncommon
.rtfm on_application_command_error
7 results
discord.on_application_command_error
discord.ext.commands.Bot.on_application_command_error
discord.ext.commands.AutoShardedBot.on_application_command_error
discord.AutoShardedBot.on_application_command_error
discord.ext.bridge.Bot.on_application_command_error
discord.Bot.on_application_command_error
discord.ext.bridge.AutoShardedBot.on_application_command_error
why am i still getting this error?
pip install -U git+https://github.com/Pycord-Development/pycord
I did this
hmmmm, okay. that'll be interesting to try to figure out
is there error on your server or on local machine?
server
i sorta see how using that would work, but the reaction would greatly depend on what /command failed
py-cord is already installed
I already have one pycord thing running on it
just global_name doesnt work
do you have a requirements.txt, docker, nixpacks, or similar?
though maybe I'm misunderstanding how to use this. like if the /start command errored out, i'd need to reset some flags and print an error message. but if the /guess command failed, i'd wanna print a diff message, etc
how do you install py-cord on your server?
Not necessarily - you could catch the exception and have it (say) send something to a logger instead of crashing out to console
pip install?
what type of server do you have?
i guess, though i dunno if i fully understand how to use that lol
Its pretty much just a computer with ubuntu on it
Here's an example I've got:
import logging
logging.basicConfig(level=logging.INFO)
fcy_logger = logging.getLogger("full_course_yellow")
pycord_logger = logging.getLogger("discord")
class FCYBot(discord.Bot):
...
async def on_application_command_error(
self,
context: discord.ApplicationContext,
exception: commands.CommandError, # pylint: disable = unused-argument
) -> None:
"""This listener implements custom error handling for exceptions raised during the invocation
of a Command. The primary goal is to clean up the exceptions that are printed out to the log."""
try: # We need to intentially re-raise the exception so that the logger can pick up the traceback
raise exception
except commands.CommandError:
fcy_logger.exception( # This only works inside an exception handler
f"Exception raised during the invocation of {context.command.name} "
f"by {self.pprint_actor_name(context.author)} "
f"at {self.get_current_utc_iso_time_str()}"
)
How do you run your bot?
What do you mean
(wtf? Does Discord force line-wrapping in triple-backtick blocks now?)
how do you start your bot?
always has been
I use pm2 because im lazy
damn, I could've sworn I'd gotten a horizontal scroll bar at some point in the past - whatevever, I guess
is python3 -m pip list the same as pip list?
hmmm
when someone has time, is there any way to send a paginator without context?
Like i want to send a paginator without the use of a command (have it send like every hour to a specific channel) is this possible or MUST it be generated from a command?
think i see. will play with it
Pycord
The following section outlines the API of Pycord’s prefixed command extension module. Bots: Bot: Attributes activity, allowed_mentions, application_flags, application_id, cached_messages, case_inse...
you still haven't answered this
also could you also show your output?
Unresolved attribute reference 'get_context' for class 'Bot'
It is
could you show the output of pip list?
you got both discord.py and pycord btw
UNKNOWN 2.4.1.dev161+ga2611769
lol
yeah thanks
happen to know what version of pycord added bot.get_context?
which bot are you using? discord.Bot?
1|PickupsM | ImportError: cannot import name 'commands' from 'discord.ext' (unknown location)
uninstall py-cord and re-install it
yes sir
bot = discord.Bot(intents=intents, help_command=None)
just gives me Unresolved attribute reference 'get_context' for class 'Bot'
now back to erm this
what do i do about this...
I am on version like (don't scream) 2.1.3 so I may just need to update?
you don't know what that is? I would uninstall it LOL
version for what?
pycord
py-cord 2.4.1 but this isn't 2.1.3?
Sorry was talking about this error
Unresolved attribute reference 'get_context' for class 'Bot'
hi I'm getting you guys mixed up, could you guys just create your own thread and then ping me into it?
thats my bad sorry dude
sorry
no worries
Any suggestions on tech stack for a pycord bot dashboard?
too vague, more specifications. Thanks
whatever you are comfortable with
wanna learn web dev? React + django or omit the react
Wanna just make a dashboard? Flask
i would also learn react either way if you plan on doing more web dev
its not the best of libraries
but it is a lot faster than plain html
Yeah. Got to learn js a lot better first
ive also seen people use svelt and angular and say its a lot better or something
Was trying Django but the way Django uses ‘apps’ is confusing
Okie
The django model framework is actually really helpful for getting started fast
you make a template once and then you can scale and use it forecer
https://dc.501stlegion-a3.com/roster
Is similar to what I’m looking to do. Some of the functions the bot has can be done on site aswell( including editing roles in discord)
Oh hi Ollie
Hallo
idk if this is pycord issue but using topggpy library don’t work with pycord but it works with discord py it says the port is already in use when it’s not so maybe pycord is not working with it
no, it's a top.gg issue
use the github version of the lib
I have pycord and discord.py-self installed but they both use the same import "import discord", how do I make sure the correct one is being used for the python script
use python environments
can I ask what is inline
whats the different if its False or True
plaese analysis me a easy explanation
Is there a way to make a command both slash and user in one function? Or is it pretty much just have 2 seperate decorators
Inline decides whether an embed field will 100% get it's own line or if it can share a line on a large enough screen, setting it to false will make sure the field is for sure on it's own line
kinda
print("hello\n I'm here to meet you")
lemme whip up a quick embed to show you
@commands.slash_command(name="test")
async def test_t(self, ctx: discord.ApplicationContext, inline: discord.Option(bool, "Whether example should be inline")):
embed = discord.Embed(title="Example", description=f"Inline: {inline}")
embed.add_field(name = "1", value = "elk", inline = inline)
embed.add_field(name = "2", value = "elk", inline = inline)
embed.add_field(name = "3", value = "elk", inline = inline)
await ctx.send(embed=embed)```
inline true would be the first embed in the ss, inline false would be the second embed
hope that helps!
fully helped thanks
one more question
can I have two value or more in the same bracket
like
embed.add_field(name = "a", value = "yo", value = "hi",inline = True)
like this
afaik you can only use value once in the function
so no, you can use \n\n or smth like that to make it kinda look like there is a second value
but you can't define the same variable 2 times in the function
rip I have too do a bot for a server and its extremely hard for me
free to ask here?
becasue Its a bit big problem with it
make sure to read through https://guide.pycord.dev/ and then I'd say you're prolly safe to ask here
sorry for the language problem
so here is the embed I have to do
the table is like
date. class days. time_area
time <list of user>
time <list of user>
- admin can edit the list and members can check their classes via the command so it will show a list which is the table above
- member can't access to the list but they have check the list in any time with the newest version
like this
if their are any incomprehensible mention me please
bot.command(description = "message as embed")
async def message(ctx,user, date: discord.Option(str), Class: discord.Options(str), days: discord.Options(str), time: discord.Options(str)):
embed = discord.Embed(
title = "My message",
color = discord.Colour.dark_purple(),
)
embed.add_firld(name = f"your Class", value = f"{date}",)
embed.add_field(name = f"{time}", value = "User", inline = True)
here is my code Im working on now
where is Mr Alex :< sorry I ask a hard question for you
ngl, this is a more in depth question, and to answer it involves quite a bit of coverage of pycord, I'd suggest starting off with a smaller project and working your way up. this question also depends quite a bit on you figuring out exactly the way you want the onfo displayed and how you're going to implement it, before even getting to making an admin command to change the information on there, which is a whole task of it's own
I know a so actually I’m trying to do this with a new file but I have no idea about it
thats not gonna do in some cases. hang on.
if you need two line breaks (or one that just refuses to show up, use:
\n\u200B
the point of the 2 line breaks was just to put a gap between the 2 paragraphs, but thanks for that i guess
had the same problem a few weeks ago. you're welcome
it depends on where it is used though. on some places double \n works fine
Hey, is it possible to use the @option decorator to change how a command's option looks in the UI? I'm trying to use name= parameter, but it's giving me a "TypeError: option() got multiple values for argument 'name'"
@option(
"group_category",
name="group category",
description="What type of category is this group (i.e. project)?",
required=True,
)```
where group_category is my option variable/parameter, and name="group category" is how I want it shown in discord UI.
name is the UI name. Try using parameter_name
Is there something similar to discord.Option(int) but so that only emoji can be accepted?
how do i check that 2 set users have interacted with a button? i want it to proceed when both users have reacted
unfortunately no. There is also not an easy way to check if a string is an emoji. If you want help with this I recommend starting a thread.
Thanks, I'll try it myself first)
In your view store 2 Boolean values, one for each user. In the button callback if it was one of the users set there bool to true. At the end of the callback check if both are true, if so do what you want possibly stop?
I also would be interested how to check if a string is a emoji
The main issue is that there is a bunch of different ranges unicodes for emojis. Its not like U140683-U141244 are emojis.
mhm
that one is a custome one
Those are easier to find but you would also have to verify if it is a real emoji.
this worked, thanks! now, how would i check whether 2 buttons have been reacted to once by 2 different users?
e.g. 1 user reacted to a button that say "Wizard", another reacts to a button that says "Knight" and once each button has been clicked once it proceeds?
you could disable it after pressing the button
Then you just have to flip the bools instead of having bools for the users have it for the button. You might also want to store what user clicked what button so that you know that 1 user did not press both.
could i insert a users choice into a databse, and check if the 2 values are null or not? if both values have a value in them then it proceeds
why not
How to cast <:pepsi: 1101479961656819712> to discord.Emoji?
how to divide a bot into shards?
.rtfm Autoshardedbot
371 total results
discord.AutoShardedBot
discord.AutoShardedBot.activity
discord.AutoShardedBot.add_application_command
discord.AutoShardedBot.add_check
discord.AutoShardedBot.add_cog
discord.AutoShardedBot.add_listener
discord.AutoShardedBot.add_view
discord.AutoShardedBot.after_invoke
discord.AutoShardedBot.all_commands
discord.AutoShardedBot.allowed_mentions
discord.AutoShardedBot.application_command
discord.AutoShardedBot.application_commands
discord.AutoShardedBot.application_flags
discord.AutoShardedBot.application_id
discord.AutoShardedBot.application_info
discord.AutoShardedBot.before_identify_hook
discord.AutoShardedBot.before_invoke
discord.AutoShardedBot.cached_messages
discord.AutoShardedBot.can_run
discord.AutoShardedBot.change_presence
You shouldn't need a shards until like 50k guilds
oh okay
You can look through Guild.emojis and if it is not there (due to it not being cached) use Guild.fetch_emoji
wait, guilds mean servers yes?
yea
No. Discord doesn't allow you to login without shards past 2.5k guilds iirc
I tried, it keeps giving me a TypeError saying too many arguments for name=, I think it’s automatically referring to the first argument “group_category” as the name. I even tried doing parameter_name=, name= but it didn’t work I’ll try again rn
Figure anything out? I actually didn’t consider this edge case and need a similar functionality
I actually came up with an idea for the emojis. Import an emoji dictionary and use it as your options list?
yes name is a positional argument.
The first arg will be name in your code above try switching name= to parameter_name=. Just a note you cannot have spaces in the option name
I see, I didn’t know I can’t have spaces. Thank you!
I swear I tried this before, but I must've had the name= and parameter_name= switched, but this worked. Thank you! 🙂
@option(
name="category",
parameter_name="group_category",
description="What type of category is this group (i.e. project)?",
required=True,
)```
does this have support for logging in into user accounts?
no
that is against discord TOS so dont do it and dont try to get help with it. There is nothing you need that you cannot access with a bot account.
oh alright got it ty
In my country we named this "костиль", translate: cheekbones
LOL
A good idea for the "just to work" concept, but not for pure programming))
here's a better workaround:
@option(
name="emoji",
parameter_name="emoji",
type=discord.Emoji,
description="Whats a suitable emoji representation for this category? default=👍",
required=False
)```
on run-time if the user enters an emoji that's not found, it'll give an error:
i.e. discord.ext.commands.errors.EmojiNotFound: Emoji "sd" not found in python
And you can handle that error inside discord slash command possibly, that part I don't know how to.
ideally it would show this before the user sending the command
Looks really nice, thank you. If I have a solution, I will definitely let you know)
@slow dock Yeah if you can make a similar error customized for an option, such as how the required=True does, then let me know 🙏
i am about to make the most horrific command ever \o/
trying to figure out the best way to handle changing settings via a command. might just add a bunch of optional parameters in a slash command? like /dat set enabled False or /dat set option1 5
i'd rather have a nice little web dashboard for this but i have no idea how so
this actually doesn't work sorry. It's not recognizing real emojis, might be worth starting a thread like Wofly recommended
Can you please do this?)
hmm. so this will only match regular channels, right? I'm trying to find the right Option to use to match regular channels + threads
or will that do it
Here's the slash options example.
OH sweet
oh i see, it's using a different method than me to add options I guess
i was always doing them inline with the initial @command_group.command() decorator
If I have a View with some Buttons, one of which pops up a Modal, is there a way from that Modal's callback function to access the View, for example, to enable a Save button on that message that was previously disabled, if the form passes validation?
yes
(and if so, what is that way?)
something like this is the approach i'm going lol
(ignore the pass, that's just to keep pycharm from getting annoyed)
you can use modal.wait() or use nested classes, but I prefer the first one
Pycord
The library has helpers to help create component-based UIs. Shortcut decorators: Objects: Attributes children, disable_on_timeout, message, timeout. Methods cls View.from_message, def add_item, def...
sorry, your question is ambiguous. Are you asking how to do the equivalent thing in discord.Option format or convert it to @discord.option format?
nah I figured out what i was looking for, was mostly just posting that so anyone could point out any immediate issues with the approach lol
my original question was just how to match channels + threads but that seems easy enough w/ Union
you don't get type-hinting.
what do you mean
this is how I currently have a command that requires the user doing the command to select a user specifically
no I know what type hinting is, I just didn't know what you meant
you don't get type-hinting on option'ed args
i'm confused because this code results in this behavior
I don't see what's wrong?
you seem to be telling me that shouldn't work
what?
i think we have some confused communication lol
what do you mean here? because i think i'm interpreting this statement differently than you mean it
this is type-hinting, not discord's options
are you talking about within pycharm or something? i'm so confused what you're trying to tell me lol
yes
that's why I sent the article ;-;
like you were saying that using type hinting in the async def command wouldn't work like that
yeah you don't get autocomplete on those args
next fun problem I have to figure out, when I switch over to this server-based settings format with user-based permissions and all that, the permissions list will be empty. so I gotta figure out how to somehow give admins/moderators permissions to begin with. There any sort of flag for that that I can check for?
like on a per server basis i could add the moderator role id to the role permissions list, but for defaults I gotta figure out an option
I guess one option would be to check if a role has a specific permission only moderators would have. like "Manage Channels" or something -- although I'm not sure if the bot would have the ability to check permissions of roles
so if someone uses /dat settings user_elevation username 123 -- ctx.command.qualified_name would be "dat settings user_elevation" right?
given that username and 123 are args, rather than part of the command
@slow dock I got it to work by importing "emojis" python library 🙂
It's not too bad. I can teach you how
example:
are role ids unique per role, across servers?
all IDs are unique from another
?tag snowflake
Can Discord API render custom guild emoji Markdown in the options UI for AutocompleteContext?
In this example, if I search a custom channel emoji it shows as ```:GComb:
nice
no
I see, thanks. I'll try making it so it doesn't represent the large emoji ID <emojiName: ID> and just show :GComb: instead
thanks
In discord slash commands, is it possible to customize your own warning based on specific requirements?
This one is from when you set an option's attribute required=True
no

have any advice for achieving a similar 'warning' using ui?
like after invoking a command
send an ephemeral message with a red-colored embed
And is there a way to add a UI button called "edit" with that message that recreates the command with previous inputs?
I've gotta learn pycord buttons still
Well I noticed on discord when a command's invoked it says @user used /command and when you hover of it gives the entire command with options
but I didn't know that thanks
I was wondering if I can somehow copy that hover hint
when you select a slash command, the discord client will try to parse the addition text as arguments
Yk what I'll just make it easier on everyone and add warning "use the up arrow to edit your command" 🤣
Thank you for your help 💯
doesn't work on mobile but ok
damn. so close to having a pretty way to do this
oh well. I can just do the list comprehension elsewhere
Is it possible to delete a ctx.response from a bot after certain time instead of a message using ctx.send? My bot still expects a response, so I used
await ctx.respond("Warning: warning description !")
I was wondering if there was a way I could delete that message. Possibly with appropriate "manage messages" permission?
There is a delete_after arg
bless you, I found it. delete_original_response is the arg for interaction object
await warning_msg.delete_original_response(delay=10)
🙏
no, there is literally
😮 woah. I didn't see this. How do I use send_response with BridgeContext?
Current Implementation:
await warning_msg.delete_original_response(delay=10)```
when I try using ctx.send_response("") It warns "Unresolved attribute reference 'send_response' for class 'BridgeContext' "
you don't need to use send_response, respond also has that arg
like this?
warning_msg = await ctx.respond("Warning: Duplicate category name!", ephemeral=True, delete_after=10)
that should work
I love pycord. Thank you this is really awesome functionality. I'm learning so much
yay
guh this looks so ugly. Is this actually the right way to typehint with a default value >_>
also yee. I appreciate how intuitive it is despite the complexity. a lot of stuff just works if you try it
discord.Option has a default= kwarg
oo, that sounds less ugly
I just hope that the docs for my discord bot(s) are even half as good as pycord's docs. They're so readable and I've spent like 1-2 days and learned so much from it already. I feel like I can make some really complex discord bots with it.
Do you use bridge commands?
If not you dont need the "= None" stuff
i actually have no idea \o/
ive not looked at any bridge documentation so i'm guessing not, but maybe accidentally
Kind, how to get from button(interaction) the author of slash command? If it is impossible, how to check that the button was clicked by the author of slash command?
Hi I'm just wondering, how would I disable the button that was made in buttonview from Modal callback?
Assuming that the button is attached to the original message with the slash command, you can use interaction.message.interaction.user
Okay, I'll check it out.
you can use modal.wait() in the button and modal.stop() in the modal.
Pycord
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...
Yes, it returns the user, I just need to check if it is the author of the command and not the one who clicked the button again, thanks.
interaction.user is the user who clicked the button and interaction.message.interaction.user is the user who initiated the application command.
Got it, thanks, just never got around to figuring out the api myself :>
This is where I put them and at the bottom of the image is the error I got, what do I do?
not how it works
your button should be
modal = Modal(...)
await interaction.response.send_ ...
await modal.wait()```
and your modal should be self.stop() self is your modal, thats how classes work
and you dont pass self to functions, that arg is given by python
basic oop
Please could you show me how to implement this in my code, I'm particularly not sure what to put in modal = Modal()
What do you mean you don't know
You pass your title or whatever args you're using
It sounds like you have no idea what you're doing if you can't read your own code nor deduct code from a example which is 99% identic to your code
You're required to know basic python and OOP if you want to use pycord
Otherwise, you'll just get stuck at simple issues
You're right, sorry for wasting your time
Its not about wasting my time, it's about yourself getting stuck at simple issues.
You won't get far without python basics.
Is there an argument I can pass to @commands.Cog.listener() that disables the listener? (I've got something that isn't ready for prime time, but I don't want to just comment it all out.)
Or should I just comment out the decorator?
Add a return at the top
i have a command with a button that does the function of another command (which has a confirm button that will edit the message), and the other command should be editing the 2nd message but it's editing the first instead
and idk how to make it edit the other one
how to send messages to a specific channel
await channel.send()
something likepy channel = self.bot.get_channel(channel id) if channel == None: channel = await self.bot.fetch_channel(channel id) await channel.send("message")
I also recommend you to check the guide to get basic understanding on how pycord works
AttributeError: 'str' object has no attribute 'send'
if you aren't using it in a cog, remove self.
ok
also, as fox said: https://guide.pycord.dev/category/getting-started
AttributeError: 'NoneType' object has no attribute 'send'
let's see some more of the code, hard to help properly without more context
it's also possible that it can't find the channel, hence why I included the fetch_channel part
try using await bot.fetch_channel() instead of bot.fetch_channel() and see how that works out for ya, and keep in mind that this requires a channel ID
but I didn't use bot.fetch_channel() anywhere
yeah
In channel_id: Value "#1132998889813848124" is not snowflake.
so it looks like you're calling a channel like #how-to-get-help when running the command, try pasting the channel id instead of calling the channel like that
ок
and why not use the built in commands helper instead of on_message? https://github.com/Pycord-Development/pycord/blob/master/examples/basic_bot.py
with that it's far easier to take in parameters instead of separating the message yourself, or better yet, slash commands
i know, but slash commands displayed to everyone
it works, but so strange
this is an option for that as well, and doesn't display to everyone
idk how to explain by text
does your bot have permission to view and speak in all those channels that didn't work? I don't see anything code wise that would prevent it
it have permissions
then I'm unsure of why it wouldn't work in some channels
I think I'll try doing it by prefixed commands
pls do, it's so much easier and far easier to do something like #how-to-get-help instead of a channel id
can i use in my code prefixed commands and slash commans at the same time?
yee
thanks
why my prefixed commands doesn`t work
Your bot isn’t online
If you just want the avatar object you can do member.avatar but if you want the url for it, then do: member.avatar.url
I am trying to build an embed and member can user the embed to input what they are trying to say. What I am trying to do is I want to set the author to the members name and avatar
@bot.command(description = "message as embed")
async def makeannouncement(ctx, title:str, description:str):
user = ctx.user.id
embed = discord.Embed(
title = f"{title}"
description = f"{description}"
)
embed.set_author(name=f"{user}",icon_avatar = )
this is my progress right now
Ah, ok. First, you should change user=ctx.user.id to user=ctx.user. Then in the set_author set it to user.name and the icon to user.avatar.url
ok let me try
@bot.command(description = "message as embed")
async def makeannouncement(ctx, title:str, description:str):
user = ctx.user
embed = discord.Embed(
title = f"{title}",
description = f"{description}",
)
embed.set_author(name=f"{user.name}",icon_avatar = user.avatar.url)
await ctx.send(embed=embed)
like this?
why it say Im. not work
oh
Also, i suggest using user.display_avatar instead of user.avatar



