#Basic Pycord Help (Quick Questions Only)
1 messages · Page 40 of 1
what is the error message?
Its in German
pip : Die Benennung "pip" wurde nicht als Name eines Cmdlet, einer Funktion, einer Skriptdatei oder eines ausführbaren Programms erkannt. Überprüfen Sie die
Schreibweise des Namens, oder ob der Pfad korrekt ist (sofern enthalten), und wiederholen Sie den Vorgang.
In Zeile:1 Zeichen:1
- pip install py-cord
-
+ CategoryInfo : ObjectNotFound: (pip:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
I can send it here
try python -m pip install py-cord
It says that Phyton couldnt get finded
do you have python installed?
try this py -3 -m pip install -U py-cord
into the black console?
yes
reinstall python
Okay
Not sure why I'm getting this error
Any ideas why the if statement never get's triggered?
do you use commands.Bot or discord.Bot?
discord.Bot
change commands.Cog to discord.Cog
what is your py-cord version?
I don't remember the command to check
that is basic python...
💀
I had to update
I have the latest version now but it still gives me the same error
show ur pip freeze
can you do commands.slash_command()
discord.py...
it's the discord.py
uninstall discord.py and py-cord and reinstall py-cord
restart vs code
The error clearly explains it lmao
Why do you want to do that?
Keep my code clean and have everything inside a class
Keeping everything inside of one class is not "clean". And it's not the intended way of using the library.
Just use cogs
Ok
code?
can you try installing git+https://github.com/Pycord-Development/pycord@fix-automod and seeing if that fix works
I already fixed it (#969580926885580801 message), thanks though!
I'm trying to get a message by it's ID with this:
for channel in self.bot.get_all_channels():
try:
message = await channel.fetch_message(message_id)
except NotFound:
continue
But it's throwing an error every time I try it: Value "998272089343668364-1049395251992862830" is not snowflake.
I suspect this is due to the fact that I'm passing in a str to a function that (in the docs) needs an integer, but I can't exactly parse this string into an integer due to the hyphen. Does anyone know how to fix this?
A message ID never has a hyphen
oh, I think I'm using the wrong ID
AH I see, if you hold shift and hit copy ID on a message, it copies <channel_id>-<message_id>
however if you use the three dots and hit copy ID, it copies only the message_id
Question:
If I want to make a button persistent, but I already have a class for it, how would I go about it? I already looked at the documentation examples, but they are creating a class decorator and creating a new class. I already have a class. Is there a way to integrate it into the persistent view?
Ah idk should I make a thread
buttons cannot be persistent, only views can
ah ok
now excuse me, I will go back to studying
but if I want to add a custom ID to the button it would make it persistent right?
oh sorry
Hi !, how it is possible to get this error ? It only appear sometimes, most time it work like normal. I don't get how the Member object can be a User and not a Member.
Error: add_timed_role_to_user with values [{'value': 'member id', 'type': 6, 'name': 'member'}, {'value': 'role id', 'type': 8, 'name': 'role'}, {'value': 0$
Error -> Application Command raised an exception: AttributeError: 'User' object has no attribute 'roles'
If the user is not in the guild you will get a User
it is possible, but the mention will only show the ID
so it would look like @186427363909697536
and clients can have members of servers cached, despite them not being in the server anymore
I see thank you !! Could I just check if the object is of type User to return a error message or their is a better way to do it ?
I'd just do a try except
I see thank you 🙏
How do I make my bot have a streaming status? Whenever I try to do it, it just gives me a playing status or no status at all
show your code
hold on
Is the background task blocking? Then use asyncio.to_thread
I know that it is possible to make an argument like a boolean that has choices other than True and False, but there isn't adequate documentation.
How would I go about doing this?
Well you could use enums?
How would I be able to log images
log images?
Nevermind I was looking for discord.Option
Oh lol
I thought you meant with python in general
Not pycord specifically
Yes, I'm making a bot with a moderation section, that section logs messages before edit after edit etc. (people know it does that dw.)
but I am trying to make it log files / images attached to a message.
it has to just hold for 3 days minimal since it auto deletes the log after 3 days.
i have a slash command but it wont respond to user is there any way to hide/stop that "application didnt respond error"
Respond to the slash command
i dont want to
Then you'll see the error 🤷♂️
ok, thanks 🙂
i thought there will be some way to hide it 😄
Hi all, hope you are fine, I'm creating a category and I need to set notifications OFF for this one, do you know how can I do that ?
what?
i think it is client settings, so bot cant do anything
is there a rich presence feature in pycord?
just send a response and delete it immediately
i thought there will be something else
😅
what is the difference between using asyncio.to_thread, asyncio.create_task, and asyncio.run_in_executor?
so for some commands, I handle it via @command.error, but it gets passed on to on_command_error again. How do I prevent that
no
you can check out py presence for that
and the rich presence would run even after i turn the bot on in pycord?
are you thinking of rich presence for the user or for the bot?
bot
bots can’t have rich presence
so how do i make the "add to server" button
you go to the developer portal and under oauth2 you can add it there
How do I use the "Options" thing for the input on slash commands?
Here's the slash options example.
something like
@bot.slash_command
async def hello(ctx,yeah: Options(str,"Hey")):
await ctx.respond("Hello")
But I want the autocomplete function
And also input a list of stuff
how do I error handle per cmd for Bridge
how do i give my bot "listening to x"?
Activity
how?
Make a function and sub into the autocomplete arg
Check the docs or Google
thx
yeah that's for autocompleting, but would you happen to know how to input a list of values?
activity = discord.Activity(type=discord.ActivityType.listening, name="commands")
bot = commands.Bot(activity=activity)
help pls
As in a set values that users need to choose from?
choices=[]
yes, basically they will have to do
/list [yes,yes,yes] [no,no,no]
how do i give a list input
What are you trying to do?
interaction.guild should return the guild where the interaction is being used
hey , how would i delete a previous view sent by the bot ?
Just edit the message and set view=None
thanks !
np
hey uhm , how would i get the last sent message by the bot ?
i cant seem to find any infos about it on internet
Or read the docs like it's telling you https://mariadb.com/kb/en/update/
You'll need to on_message and check for if the message is by the bot, save the channel , guild and message ID in a dB and then every message update the data
woah
never though it'd be that hard , ill find another way to remive my view then lol
thanks CLearMist anyways !
You technically can only store in channel and message ID idk why I said guild ID as well but the other part is needed
how can i give bots a different role than that of normal members
For some reason only the admins can use my bot?
@slash_command(description="Richte das Autoreact-System ein.")
@commands.has_guild_permissions(administrator=True)
async def autoreact_add(
self,
ctx: discord.ApplicationContext,
textchannel: Option(discord.TextChannel, "Wähle einen Textkanal aus, wo automatisch reagiert werden soll.", required=True),
emoji: Option(str, "Wähle ein Emoji aus, welches automatisch reagiert werden soll.", required=True),
emoji2: Option(str, "Wähle ein Emoji aus, welches automatisch reagiert werden soll.", required=False),
):
"""Richtet das Feedback-System ein"""
if textchannel not in ctx.guild.channels:
await ctx.respond(
content="Dieser Channel exestiert nicht",
ephemeral=True
)
if emoji not in discord.Emojis:
await ctx.respond(
content="Dieses Emoji exestiert nicht",
ephemeral=True
)
if emoji2 not in ctx.guild.emojis:
await ctx.respond(
content="Dieses Emoji exestiert nicht",
ephemeral=True
)
if str(ctx.guild_id) in list(data.keys()):
await ctx.respond(
content="Das Autoreact System ist bereits laufend.",
ephemeral=True
)
return
if textchannel is None:
textchannel = ctx.guild.get_channel(ctx.channel.id)
Why is it saying "Dieses Emoji exestiert nicht" (This emoji doesn't exist) when I select a regular emoji from Discord?
Is there a recommended way of adding a help to command to a slash command bot? If yes, how?
You mean that when the bot is pinged then a message is sent from the bot?
maybe, or like a command /help. I know this is possible by just creating a command, but for the old commands there was a handy utilitiy
use /help
/help is the most common one
dunno actually what we do at pycord, but other libs even autogenerate the /help based on the code
asyncio.to_thread is the same as loop.run_in_executor . to_thread is a high level api call. Meaning it is simpler and easier to use. Both run a blocking function in a different thread so your event pool never gets blocked. This returns a coroutine https://docs.python.org/3/library/asyncio-task.html#asyncio.to_thread
Same analogy with asyncio.create_task and loop.create_task . asyncio one is higher level and easier. It submits a coroutine to the event loop to run in the background. This need not be awaited. Task execution starts the moment you call create_task .
See this question and accepted answer https://stackoverflow.com/q/62528272/13088701
||More details but this may confuse you. If yk python has a GIL so only 1 thread can be run at a time. So the switch between tasks happens when you await something inside it||
So basically use create_task if you have a coroutine you want to run in the background
Use to_thread if you have a blocking function you want to run in the background
||you can also use to_thread inside create_task but i don't think that does anything different||
All the above stuff is like intermediate level async python
That mostly makes sense -- I solved my problem using loop.run_in_executor, however it's caused some problems that I'm trying to fix -- basically what I'm trying to do is run some code specified by the user (owner only command, I'm aware it's quite dangerous), and then capture the everything that went to stdout. However, if I run a more process-intensive task, it blocks the main event loop and effectively freezes the bot
so loop.run_in_executor works fine for now, but if I run one piece of code while another is running, sometimes the stdout goes to the wrong place for some reason
yeah I'm putting that in rn
will just changing the function work? like result = await loop.run_in_executor(None, run_in_background, args) vs result = await asyncio.to_thread(None, run_in_background, args)
No asyncio.to_thread has a different order of parameters
First goes the func and then its args. It doesn't have the None part
same issue...
I was thinking maybe something like multiprocessing could solve this? idk how that would work though
context: the second one should return a message saying nothing went to stdout
my code is basically just:
with io.StringIO() as output, contextlib.redirect_stdout(output):
exec(code, global_vars)
output = output.getvalue()
``` (this runs in the to_thread, and `code` is a compiled code object)
That would be great...
is there anway I can close an option after using the other?
nope
you can use command groups tho
mkay thanks
Hmm idk bout that lol
You can pass in a multiprocessor pool to run_in_executor . No idea if that's of any use
I wanna make a poker game with pycord, but I want to add a dealer role so that only the dealer can do certain commands, is there a way to make only a certain role able to execute slash commands?
alright well I have something working for now, thanks anyways!
hmmmm updated to the newest pycord version and got :
discord.errors.ExtensionFailed: Extension 'cogs.dcCommands' raised an error: AttributeError: 'MainBot' object has no attribute 'bridge_commands'
show your pip list
there is no discord.py or nextcord repo 😉
just show it
I'm not sure if the channel is made for that, but as long as it's not for personal gain I don't see why not. Probably better to ask in #general though
Okie, I'll ask there thanksss
Hi, how i can fix this please ?
user = guild.get_member(int(id.group(1)))
AttributeError: 'NoneType' object has no attribute 'group'```
```php
@cog_ext.cog_slash(name="profile", description="User stats (mention, username)", guild_ids=None, options=[discord_slash.manage_commands.create_option(name="user",description="User profile", option_type=str, required=True)])
async def profile(self, ctx, user:str):
if "@" in user:
id = re.search('<@!(.+?)>', user);
guild = ctx.guild
user = guild.get_member(int(id.group(1))) # LINE 84
read the error
consider using user options instead of strings
Here's the slash options example.
you can use the user option type
but i need both options..
user also handles mentions
i dont understand
If you set the option type to discord.User it does the conversions for you, it can take an ID too @bright jetty
discord.Member*
Oh yeah mb didn’t fully read what they were trying to do
but i need the user to be able to write something other than mention
and mention too
for 1 optin = 2 values (mention, nick)
you get both from discord.Member
so if i write /profil NICK (without @) so i can use this command ?
That option type allows them to search for the member within the server, so there’s no need to @ them in the command
The bot would make you select a member from a list before the command is run
How would I use discord.Slashcommand.mention ?
(To mention slash commands)
but option nick is not user
Do you want to be able to search for them by a nickname too? Cause you can do that by having one option with the type discord.Member
Just try it and see if it’s what you need
No, i need this for example:
/profile @bright jetty
/profile something_other_text
It returns the string that will correctly embed into discord, so you just need to send that in a message
Yeah the slash command can do that conversion for you if the other text is a nickname
But i want it to work even if its not a nickname

Tried to put it in a description of a slash command, then called it via client.get_application_command(ping). description
it would it give me the <property at Object...>
option=user has 2 options..
mention(nickname) and something_other_text (but this text is not nickname)
You can't have both member and text as an option type, if that's what you are asking
You can implement something like that yourself using autocomplete
No, my question is how i can fix this error 😄
˘
You can fix it by making sure id is not None
But id is always None
So why are you trying to do id.group then?
if id is None:
return await ctx.send("none")```
why is id none ?
Because you're trying to match a string with ! in it
and that doesn't have a ! in it
How can I make a custom cooldown apply per server, not globally? If its a global slash command. Would I have to store data on when the command was last run in a db?
there is example on github repo for cooldowns
https://github.com/Pycord-Development/pycord/blob/master/examples/cooldown.py
Pycord, a maintained fork of discord.py, is a python wrapper for the Discord API - pycord/cooldown.py at master · Pycord-Development/pycord
you just need to use BucketType.guild
Hi, on this line:
await msg.add_reaction('')
I'm getting an error:
File "/usr/local/lib/python3.8/dist-packages/discord/message.py", line 1487, in add_reaction
await self._state.http.add_reaction(self.channel.id, self.id, emoji)
File "/usr/local/lib/python3.8/dist-packages/discord/http.py", line 359, in request
raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In emoji_id: Value "dv_wCyanHeartOwO" is not snowflake.
The bot has been running for many days and it only started throwing this error the last hour. I'm not sure what's wrong
The msg is a discord.Message object
I need it to be per-user and per-guild, so a user has separate cooldowns per guild for the same command
Then use the member bucket type
it tells you exactly what the problem is
Try using a PartialEmoji
.rtfm PartialEmoji
discord.PartialEmoji
discord.PartialEmoji.animated
discord.PartialEmoji.created_at
discord.PartialEmoji.from_dict
discord.PartialEmoji.from_str
discord.PartialEmoji.id
discord.PartialEmoji.is_custom_emoji
discord.PartialEmoji.is_unicode_emoji
discord.PartialEmoji.name
discord.PartialEmoji.read
discord.PartialEmoji.save
discord.PartialEmoji.to_dict
discord.PartialEmoji.url
discord.PartialEmoji.with_state
discord.ext.commands.PartialEmojiConverter
discord.ext.commands.PartialEmojiConverter.convert
discord.ext.commands.PartialEmojiConversionFailure
discord.ext.commands.PartialEmojiConversionFailure.args
discord.ext.commands.PartialEmojiConversionFailure.with_traceback
so multiple people can run it once per X amount of time or only 1 guy can run it in guild once per X?
I can read errors, I just don’t understand
-
why it just stops working all of a sudden, considering my usage of a string for a custom emoji has worked for months
-
why it thinks the snowflake ID is the emoji name when I placed the whole emoji string in
Well the error says the emoji name is not a snowflake
I'm pretty sure the emoji id should be passed there and not the emoji name
I’ll try that, thanks 
Did the emoji name change
Multiple people can use it once per X amount of time in each guild. So each user can use it once every 4 hours in each guild
Nope
there is BucketType.member, i'm pretty sure it works on per guild basis (member is commonly used to describe guild member specifically, not overall user)
still exists, it’s the exact same name and ID
did you updated pycord recently?
No, it’s on 2.1.1
Member bucket works per guild. User bucket works for the user globally
Update lol
mhh first thing > update
yeah, that's what i was thinking, so it should work for the guy
Yep
Alright
Perfect that works, thanks a lot!
you're welcome
I was only able to update up to 2.2.0, on >=2.3.0 I encounter this error on startup
File "C:\Users\laiye\Desktop\Bots\dank-vibes-bot\cogs\mod\mod.py", line 287, in Mod
class RoleFlags(commands.FlagConverter, case_insensitive=True, delimiter=' ', prefix='--'):
File "C:\Users\laiye\miniconda3\envs\dank-vibes-bot\lib\site-packages\discord\ext\commands\flags.py", line 335, in __new__
for flag_name, flag in get_flags(attrs, global_ns, local_ns).items():
File "C:\Users\laiye\miniconda3\envs\dank-vibes-bot\lib\site-packages\discord\ext\commands\flags.py", line 168, in get_flags
flag = Flag(name=name, annotation=annotation, default=flag)
TypeError: __init__() got an unexpected keyword argument 'name'
I have a simple FlagConverter that I use for a command
class RoleFlags(commands.FlagConverter, case_insensitive=True, delimiter=' ', prefix='--'):
roles: Optional[str]
mhh could you share that particular code?
I'm pretty sure you don't make subclasses like that
Aren't you supposed to pass the delimiter and all that stuff in the init ?
Oh? I used the documentation's example
i think those are 'Class' arguments
not instance ones
Oh
Hearing that for the first time lmao
Well idk then
That's all of the code for the RoleFlags
not sure if this would be useful but this is how I pass the roleflags in the command
@checks.has_permissions_or_role(manage_roles=True)
@commands.command(name="self", aliases=["selfroles"], usage="--roles (role names separated by commas) (optional)")
async def selfroles(self, ctx, channel:Optional[discord.TextChannel] = None, *, flags: RoleFlags):
Hmm can you send me some more examples or docs for that
you have class variables, aka global for it, and instance ones, that are only present in instances of this class, you can basically set those while subclassing
at least its what it seems to be?
Ohh. So delimiter and prefix are class variables in this case?
i gotta test smth
class FlagConverter:
delimiter="something"
prefix="smth else"
...
These are class vars right
yea, i but i might've fuck'd up myself, one second
👍
I tried using the flagconverter in some simple code, it worked in 2.2.0 but failed past that version
Removing the delimiter and prefix did nothing too
token = ""
import discord
from discord.ext import commands
intents = discord.Intents.all()
bot = commands.Bot(command_prefix="!", intents=intents)
class TestFlags(commands.FlagConverter, delimiter=' ', prefix='--'):
one: str
two: str
@bot.command(name="testflag")
async def testflag(ctx: commands.Context, *, flags: TestFlags):
await ctx.send(f"one: {flags.one} two: {flags.two}")
bot.run(token)
well, dunder __init_subclass__ handles those sort of argument, i mistaken shit
class FlagConverter:
def __init_subclass__(cls, delimiter=None):
super().__init_subclass__()
cls.delimiter=delimiter
...
class RoleFlags(FlagConverter, delimiter='A')
kind of like that
but you can set class variables using this
there doesn't seem to be any documented changes for this, might be a bug
not sure
could you fill in a bug report on gh?
Ah I believe one's been created already https://github.com/Pycord-Development/pycord/issues/1805
Ohh makes sense
slash commands are not registering for me
is anyone else experiencing similar issues
Are you overriding the on connect event?
i fixed that issue but slash commands still wont register
do you think it may have something to do with the fact that im using AutoShardedBot?
wait i managed to fix it
thank you for your assistance
it probably would have helped if i loaded the cogs before i synced the commands 🤣
Is the bot at many server?
the bot is currently only in a few servers atm, but it will be releasing publicly in mid January so it will probably be in more servers then.
ik sharding is only required when your bot reaches 2500 guilds, but i wanted to have it implemented from the start, as then if and when the bot reaches 2500 guilds then i have 1 less thing to worry about 😂
Hey 🙂 Is there a way to get the guild creation date ?
Thanks
how do i add links to buttons
i keep getting an error saying
@discord.ui.button(label="LC", row=0, style=discord.ButtonStyle.link, url='https://elevateservices.sell.app/product/lastcheat-rust')
TypeError: button() got an unexpected keyword argument 'url'```
can you show me the pip list?
The pip list
Not your requirements.txt
Using a decorator for url buttons won't work
They don't have a callback
Create a button object using the Button class and add it to the view
im new to buttons so can you help me further?
how do you handle bridge command errors
the same like prefix and slash commands
do you know basic python?
yes
- that was not the pip list
- Om already told you what you have to do for the Url button
i have to have 2 error handlers?
one for application and one for prefix?
I would do it like that
No way around it?
I mean globally
well, there is on_error, but it will catch literally almost everything
i don't think on_command_error is universal either, so you need to manually assign the same coro method to all comands
or use on_error
||you can try using on_command_error and see if it works, but i don't think so||
it just gives me this
Code?
elif command:
cmd = client.get_application_command(command)
if command == cmd.name:
commands_desc = (f'{cmd.description}\n Usage : {discord.SlashCommand.mention}')
em.title = (f'{cmd} - Help')
em.description = commands_desc
em.color = em_blue
await ctx.respond(embed = em)
not entirely sure if I am using it correctly
huh
Do you realize you're trying to get a mention from a non intiated class
wait hold up-
discord.SlashCommand is a property
is it possible to fetch the id of a reference message using a slash command?
as in: you reply to a message with a slash command, how do you get the id of the message that you replied to?
msg = await ctx.respond('...')
You can't reply to a message and use a slash command at the same time.
hm
When you execute the slash command the reply goes away
oh i see
You'd need to do it with prefixed commands
well that's annoying
thanks
Np
is there any way to limit commands to some server?
like only to those servers who has bought premium
you can define a check for a command via @commands.check decorator
and check for stuff here
it will still show in /?
yes
anyway to remove it from that
i don't think so
the thing is, command are registered on the bot's startup
and you can't really change them in the runtime, at least in a somewhat friendly way
so discord api limitation?
i'm not sure, but i do not know the way to get it working
don't think it's possible
am i explaining it correctly?
sorry if i am not
- user checks available command using
/, there is one commandhelp - a user buys premium
- user checks available command using
/, there is two command nowhelpandpremium
well, you can set guilds on the command creation, so you can pass a data from db
but it's only on startup
i think it is pycord's limitation?
no other way to handle this, manual command check is the best way i guess
ok
i think it's discord's limitation afterall
yeah, you're welcome
How do I make a slash command only show for certain users?
Not based on permissions, but only for some users
you cant
only with permissions
Aw
How do I make a command with prefixes then?
Like a message command instead of slash command?
the same like a slash command
Here's the basic bot example.
@median ridge
Thanks man
Here's the audio recording example.
is there any to change guilds in not global commands while bot is running?
Is there a way to check if a command has options?
and if it has, to print out those options
as plain text ig
cmd.options
Is there a way to modify an options list when executing a slash command based on previous options already selected
so for example if you run a slash command with 2 arguments is there a way to modify the options list for the second argument based on what you chose for the first argument
Use autocomplete
Here's the slash autocomplete example.
AutocompleteContext has a options attribute
ctx has no user attribute
It's author
You literally typed it in the footer text.
yeahhh..
so ctx.author.display_avatar.url or user.display_avatar.url or something completly diffrent?
..
any way to just get the name of the Option(s) out of the string?
no. ctx.user.display_avatar_url does work lol
because user is defined as a discord.Member or as the author
um
it returns a list of discord.Option's
get the discord.Option from docs

Then use user.display_avatar.url. Don't add a ctx. What i said still stands, the context object has no user attribute, its author. Don't expect me to know how your code works when you provide 2 lines of it.
yep i know, i will try it
thx for the help buddy
Yes I know how to get the Options, but it returns me this list:
[<discord.commands.Option name=member>, <discord.commands.Option name=reason>]
And I was wondering if I can just get the value of name=x out of the string, since doing it with .find() is a huge pain.
that list is of a command which has the options "member" and "reason" obviously.
Then just get the attribute...
wdym
If you want the name, then just loop again and get the names
or that..
options = [option.name for option in cmd.options]```
yeah, thanks
help
keko = Button("Joo") TypeError: Button.__init__() takes 1 positional argument but 2 were given
Code:
@slash_command(description="Erhalte Hilfe zum Bot.")
async def help(self, ctx):
select = TutorialSelect()
select.append_option(keks)
keko = Button("Joo")
view = discord.ui.View(timeout=None)
view.add_item(select)
view.add_item(keko)
embed = discord.Embed(
title=":Night_Bot: 𑁉 Hilfe | Fishy",
description=f":NU_Text: Hey {ctx.author.mention},\n"
f":NU_Text: hier findest du alle Informationen zu Fishy.",
color=0x545EE2
)
embed.add_field(name=":NU_Uhr: Bot-Wartungen:", value=":NU_Pfeil: Bis zum 20.11.2022 (geschätzt)", inline=False)
embed.set_thumbnail(url=ctx.author.display_avatar.url)
embed.set_image(url="https://media.discordapp.net/attachments/1018494599548915742/1018904011224645743/unknown.png")
embed.set_footer(text="© Sian, 2022")
await ctx.respond(embed=embed, view=view())
Pycord, a maintained fork of discord.py, is a python wrapper for the Discord API - pycord/link.py at master · Pycord-Development/pycord
Button(label="")
I have already a Button I wan't add the button to the view
Your button init takes no arguments. Don't know why you're passing one
Is there a way to change the thinking message? Like from [bot] is thinking... to something custom?
no, that's a Discord limitation.
Ah okay. Well, for one command that routinely takes around 40 seconds to generate something, I have it respond with message = await ctx.respond('please wait around 40-60 seconds'), and then after send the thing it generates (embed). Right now, it does await ctx.followup.send(file=file, embed=embed). How do I get it to delete the old message and reply the embed to the original command? or at least ping the user? Mainly having trouble with the deleting old message part as message.delete() doesn't work
why not edit?
Oh yeah true, how would I do that
.rtfm applicationcontext.edit
Thanks! Works just like I wanted it to
is ti possible to make our own activity in voice channels?
How can I print something to console whenever someone joins a voice channel?
Is there anywhere I can find examples on how to use that?
You use it like any other event listener
Why would you be able to
it looks more interactive
hey! when using attachments in slashcommands (SlashCommandOptionType.attachment, or equivalently 11), is it expected that the attachment is an actual image (like sending an image over a message) or is it the url to an image? ive been under the impression for some time that it was the former so i thought i'd get some clarification
edit: attachments as an input option / parameter
An attachment is a file, not a url
can it be attached through conventional copy pasting?
Why would the method you use to attach it matter?
at the moment, pasting an image doesnt seem to do anything, and i can only enter strings (which get accepted when i send the command, which is why i started thinking it might be a url).
Option(name="image", description="Image containing riven.", input_type=SlashCommandOptionType.attachment),
i can open a separate thread if this requires a deeper look
i've moved this to #1050319151324999690 to keep it clean here
How can i send mesage to a specific channel in my server? The bot has admin rights
Get the channel object, and use https://docs.pycord.dev/en/stable/api/abcs.html#discord.abc.Messageable.send
is a slash command group counted as one command here?
Thanks
Well.. not gonna go into detail
Discord limits creation of activities to selected partners of the company. There is an apply form for it but they don’t accept normal users
thanks
How do I use the discord.Build() class?
I don't know what to put in the arguments.
There is no such thing as discord.Build in pycord
Why do you want to manually create an instance of a guild?
To automate the creation of roles using the bot's slash command.
There is no reason to create a new instance of a guild class for that
Just access the guild from the commands ctx
So how do you use the create_role() method?
read the docs
From what I saw, I thought it would use the create_role() method of the discord.Guild() class.
yes?
I'll try again.
Thanks.
Is there a limit to how many options you can have in a select menu?
25
Cool, thanks
My bot's ping is very bad even though the network speed is fine
any clue why?
class Bot(bridge.Bot):
def __init__(self, command_prefix="c!", help_command=MyNewHelp()):
super().__init__(command_prefix, help_command, intents=intents, owner_id=871024566472966175)
async def on_ready(self):
setattr(bot, "db", await aiosqlite.connect("databases/bot.sqlite"))
bot.db = await aiosqlite.connect("databases/bot.sqlite")
await asyncio.sleep(3)
async with bot.db.cursor() as cur:
await cur.execute("CREATE TABLE IF NOT EXISTS member (health INTEGER, id TEXT, status TEXT)")
await cur.execute("CREATE TABLE IF NOT EXISTS memberstats (attacks INTEGER, sword TEXT, defense INTEGER, id INTEGER)")
#Deaths (Instant revive)
await cur.execute("SELECT * FROM member WHERE status = ?", ("Dead",))
r = await cur.fetchall()
for x in r:
await cur.execute("UPDATE member SET status = ? WHERE id = ?", ("Alive", x[1],))
await cur.execute("UPDATE member SET health = ? WHERE id = ?", (1, x[1],))
await bot.db.commit()
my bot class
Where is your bot hosted?
?
so i use
async def kill(bot, user, time):
async with bot.db.cursor() as cur:
await cur.execute("UPDATE member SET status = ? WHERE id = ?", ("Unconcious", str(user.id),))
await cur.execute("UPDATE member SET health = ? WHERE id = ?", (0, str(user.id),))
await bot.db.commit()
await asyncio.sleep(time)
async with bot.db.cursor() as cur:
await cur.execute("UPDATE member SET status = ? WHERE id = ?", ("Alive", str(user.id),))
await cur.execute("UPDATE member SET health = ? WHERE id = ?", (100, str(user.id),))
await bot.db.commit()
``` this
when someone's health is 0
but this stops my stab command for 60 seconds as this sleeps for 60s
how do I let the stab cmd go through and as well as do this in the background?
don't ping me
nvm fixed guys
How can I find which invite a person joined with and then find who made that invite
how do i get a channel object? i have the channel id
Don't name the parameter message, it's not a message it's an ApplicationContext object.
And use .respond
i used respond but it still gave error
show your code
does that mean i need a guild object first?
I do not see any .respond here...
it send error so i removed it
wait i add and show u
thanks, i was trying this:
is that wrong?
Try it and see
i give it a valid channel id from my server and it prints None
Then it's not cached, use https://docs.pycord.dev/en/stable/api/clients.html#discord.Bot.fetch_channel
means it cant find the channel?
oh okay
message = "asfasfsad"
await message.channel.send("you passed ", user)```
why does this not work?
"not work" is useless, show errors or explain how it doesn't work
oo
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'str' object has no attribute 'channel'
Wait, you're actually trying to use .channel on a string?
@client.slash_command(name="pass")
async def testt(ctx, user:Option(discord.Member, "who passed in the forum o-o"), channel: discord.TextChannel):
#channel = client.get_channel(1050359690384638043)
message = "asfasfsad"
await message.channel.send("you passed ", user)```
why?
i want to send message to an channel
thank you
And why would "asfasfsad".channel give you a channel? It's just a random string?
oh
yea im dumb
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: TypeError: Messageable.send() takes from 1 to 2 positional arguments but 3 were given
@client.slash_command(name="pass")
async def testt(ctx, user:Option(discord.Member, "who passed in the forum o-o"), channel: discord.TextChannel):
channel = client.get_channel(1050359690384638043)
await channel.send("you passed ", user)```
i also tried this
because send only takes one positional argument, the others are keyword only
how can i fix it?
Read the docs
And why are you pre defining channel when you taking channel in cmd 🤔
i tried it ends here i cant seem to find how it works
thanks i got it my error was i was doin message.channel.respond instead of message.respond
Then you need to read rule 1 in #help-rules
Through error handling 🤔
how to play another song after the previous song ends?
Just a reference or a hint is fine for me
how do i send message in a channel without an event? like i don't want the message to be sent when a command is invoked or when a member joins, i just want it sent
like every 10 mins or smth?
yeah
https://docs.pycord.dev/en/stable/ext/tasks/index.html I think ur looking for this
thank you
one quick question, if the documentation says that a function is a coroutine, what does that mean?
it means it has to be a async def
not def
yep
thanks
np
hi, the pycord introduction lists these topics to be learnt before building discord bots. i think i know up till loops. i would like to start with classes. any good tutorial online for that? thanks
you first have to learn the basic´s of python
i think i know the basics, so i would like to start with classes
How would i take a image file as a input in a slash command?
examples/app_commands/slash_options.py lines 51 to 67
@bot.slash_command(name="attach_file")
@option(
"attachment",
discord.Attachment,
description="A file to attach to the message",
required=False, # The default value will be None if the user doesn't provide a file.
)
async def say(
ctx: discord.ApplicationContext,
attachment: discord.Attachment,
):
"""This demonstrates how to attach a file with a slash command."""
if attachment:
file = await attachment.to_file()
await ctx.respond("Here's your file!", file=file)
else:
await ctx.respond("You didn't give me a file to reply with! :sob:")```
Oh thanks
?tag lp
Official Beginner's Guide: https://wiki.python.org/moin/BeginnersGuide
Official Tutorial: https://docs.python.org/3/tutorial/
Shortcuts:
https://wiki.python.org/moin/BeginnersGuide/NonProgrammers
https://wiki.python.org/moin/BeginnersGuide/Programmers
Learn Python:
https://automatetheboringstuff.com/ (for complete beginners to programming)
https://learnxinyminutes.com/docs/python3/ (for people who know programming already)
https://docs.python.org/3/tutorial/ (official tutorial)
http://python.swaroopch.com/ (useful book)
http://www.codeabbey.com/ (exercises for beginners)
thanks
Hey
I need help
const config = require('./setttings.json')
const token = config.token
const { Client } = require('discord.js')
const client = new Client({intents:[]})
client.once("ready", () => {
console.log('ich bin online')
client.user.setActivity({name: "ich bin kuhl", type: "PLAYING"})
})
client.login(token)
Is there something false?
if I do index.js it doesnt work
no js?
no..
Is there a way to disable a select menu after it was used?
Select has a disabled attribute which is a boolean. Then when responding edit the message and provide the view again.
I mean directly after someone chooses an option
Without editing the message
You must edit the message
It's like trying to get Cash from the ATM without putting your card in it.
Can I run multiple bots on one vps, like ovh?
I was just wandering if there is any downside of using py-cord[speed] instead of the regular version ?
what?
then you would work with a stream instead
How to edit a respond?
If I am getting a lot of OperationalError: database is locked, does it mean I should switch database away from SQlite ?
Is it possible to access a user's roles from interaction.user?
Or do I need the member intent
It probably means you're accessing your database in parallel way too frequently, or you're doing something wrong that's causing it to not unlock
nvm I fixed it
yeah I do a lot of parallel access.
Then you should find a way to decrease the load on your database
I see, I heard some database supports parallel access much better than SQLite, maybe I will need to change databases
To me it sounds like you need to find a better way to handle your data, switching to another database is just ignoring the root problem
I see, I am pretty new to databases in general, it is possible I am doing thing hte wrong ways to
You are rigth, I should try to see if it is possible to fix it first !
What is the reason you're accessing it so often?
I have a loop in the background removing roles. My bot is timed roles. But at the same time I get user that want to had new roles
i recommend MongoDB
And how often does this loop run?
each minutes
But I am doing remot operation to discord in the database, maybe it is that
Querying your database once per minute is not even close to being too often
but sometime the loops itself last more than 1 minutes
and what do you mean by "remot operation to discord in the database"?
because it takes a long time removing all the roles
20 ms per remove call to discord
It takes more than a minute to remove roles from a user? Why?
for exemple if I have 1000 roles to removes
it will take more than 1 minutes
It is literally impossible for a member to have 1000 roles
Well in that case you shouldn't be reading or writing to your database until you're sure your bot is done removing the roles
Here is the remove exemple:
The remove is after
I try to remove all the expired role, If it succeed I had it to a list. After the get I do a delete on all the deleted roles
But yeah thank you for your help ! I will try to find the place that is using to much write operation, it is probably somewhere
Hey, how i can get the main channel from a server?
i can't find in the docs to this
What do you mean by main channel?
maybe the system channels
If you mean a general chat like #general, you can’t since that’s a Discord limitation.
Too bad.. but thanks for you answer
So I went ahead and got rid of the guilds=... paramater on all of my slash commands because I want to make them global, but now im getting the All application names must be unique error, and ive triple checked all of the commands. Ive noticed that only the bot.py commands are loaded, and theres two of every one??
Is it because they are still guild-specific commands? If so, I thought the bot.sync_commands() fixed that
You can run an empty bot (one with just bot.run and no events or cogs or commands) to de-register all commands and re-register them.
what is going on
I just ran the empty bot and now
I would also like to point out that none of these fake ghost commands do anything and just time out
(I commented out them all in the code)
Okay the ghost commands are gone ill try the full code again (without cogs loaded)
okay it seems that two commands somewhere in the cogs are conflicting so ill reload the bot one cog at a time added to see
ok
oh my god i think i found it
i did actually have two commands named the same in a cog im so sorry I hope you have a good rest of your day mr. squid
same to you. 
Also, I thought global commands take like an hour to update, these came on immediately
awwwww this is amazing! for once people are being nice in #969574202413838426
yeah discord reworked them
lol
so this whole time i could have not been importing a list of guilds the bot is in and passing that through the slash command
yeah
can paginators not respond to interactions that have been defered ephemerally?
with ephemeral=True
paginator forms but is un useable
with ephemeral=False it works fine no errors paginator works as intended
Not sure why the view isn't functioning but once you make a response ephemeral it cannot change to be a normal response, which is why it errored.
Yeah, or if you don't pass the ephemeral arg it will default to true iirc
Do you get interaction failed hen you try to interact with the paginator?
Strange, the other errors regarding this is when people pass ctx into .respond() but you've already got it as an interaction
yeah, im not sure
and the fact its not throwing an error is even weirder
my error handler catches everything
member.roles returns a list of objects I think, is there a way to get only a list of the role names? is there a method for that, or is there something I can do with code.
[<Role id=1047755837541720115 name='@everyone'>, <Role id=1050590117363974267 name='b'>, <Role id=1050590093825544233 name='t'>]
[role.name for role in member.roles]
tysm * 2
this code can't iterate through any members but the bot itself
any idea why?
for g in bot.guilds: print(f"Checking {g.name}...") for member in g.members: if member.bot == True: break else: print(f'Checking {member.name}...') await writeuserdata(member.id)
u have intents?
which ones do i need?
no i don't, is there anyway i can add it alongside discord.Intents.default() without getting an error?
i = discord.Intents.default()
i.members = True
@fast badger make sure to enable it in discord dev portal
that doesnt work on lists
ok did the intents work?
yeah, i just had to do that and tweak some other stuff and it works now, tysm!
alr
Hello! May i ask why my code is not working? It should send a message every 5 seconds to every channel registered. ```py
@tasks.loop(seconds=5)
async def autoad():
try:
all_configs = configguilds.find()
for config in all_configs:
all_ads = autoads.find()
for ad in all_ads:
try:
await bot.get_channel(config['bumpcid']).send(ad['advertisement'])
except:
pass
except:
pass
@bot.event
async def on_ready():
autoad.start()
(I don't get any error)
You won't cause you passed every except lol. Remove them
And what's a multiselect for you?
Multiselect=user can check 1 or more options
I still don't get any error.
You can't. Unless you take a string and parse it yourself.
Dirty but efficient ahah ok thanks
Why don't you use a select menu
Have you an example pls ?
Here's the dropdown example.
@quartz thunder
Thanks dark, checking it 🙂
Has anyone tried returning a .json? I'm trying to get the message to return a .json and I can't get it to return a .json.
@commands.slash_command(name="dict")
async def return_json_test(self, ctx):
dict_test = {
"10": "test"
}
dict_to_str = json.dumps(dict_test)
await ctx.respond(dict_to_str)
return_file = discord.File(filename="test.json", description="test", fp=dict_to_str)
print(type(return_file))
await ctx.respond("Here's your file!", file=return_file)
You have to save the file locally. Or convert the json to bytesio
Then the idea will be to convert it to bytesio
thx
@proud mason
@commands.slash_command(name="dict")
async def return_json_test(self, ctx):
dict_test = {
"10": "test"
}
await ctx.respond(json.dumps(dict_test))
json_bytes = json.dumps(dict_test).encode("utf-8")
await ctx.respond(file=discord.File(fp=json_bytes, filename="test.json"))
Try wrapping json_bytes in io.BytesIO
And pass that to fp
Cuz discord.File runs open on it
Well... it is so much easier to do
how can i edit vc role permissions
.rtfm VoiceChannel.edit
Why can't we get the nitro badges? Is this a library limitation or discord one?
I think discords
You have premium_since iirc
But I think it's for server boosting, not nitro
.rtfm premium_since
a message every 5 seconds to every channel registered
Are you ok? That's spam.
And discord will ratelimit you hard. Or might even block your bot for api abuse.
I was testing- in the future imma make it 6 hours
Target not found, try again and make sure to check your spelling.
hmm
that's only possible via oauth and the field would be premium_type
Discord doesn't allow bots to read that normally, because that's not an user information bots are supposed to know / log
@commands.has_permissions(administrator=True)
@client.slash_command(name="fjoin")
async def fjoin(ctx):
channelid = 1050359690384638044
channel = client.get_channel(channelid)
overwrite = discord.PermissionOverwrite(connect=False)
role = discord.utils.get(ctx.guild.roles, name=c.forum_role_name)
print("Aaaa")
await channel.edit(overwrites=[role, overwrite]) # issue is here
print("got here")
await ctx.respond("done")```
i don't get an error
but the command dosen't work aswell
where tf is c definied
why tf don't you defer the command on such a long operation (channel get, role get, channel edit)
You should read the docs a bit more and see the examples in our repo.
That might help
c is an config file 😅 , can u provide me the link to it that would be helpful
sigh.. we're lazy huh?
oh alright lol
Here's the slash basic example.
Well Wick does it?
who tf is wick
then they're probably self botting for that
No
yes, that's all info bots get from discord
It's an actual bot, which has shards and is very popular
yeah they still could make an seperate api call with a self bot to get the info
not at all
I would suspect then how tf Wick got into App Directory and got verified
Alr thanks for the info
they would've to get this data part and bots don't have access to that route
bcs discord can't check everything
Also is the bridge command not having the parent attribute issue fixed?
look into the prs/issues/changelog
idk
Degraded to 2.3.0 rn
Alright it said waiting for adding it to changelog earlier today, I'll check it again
hey, how can i calculate how much time passed since there was a message in a channel?
is there not something like message.created_at()?
update: there is
Sometimes, devs don't look at changelogs
I’m just doing Management 

I have my own lib to maintain. Can’t remember the whole pycord lib 

All dogs I have on this acc rn
Nowadays searching things in the new docs is difficult tbh, if I search discord.Member, i have to scroll down for ages
I don't like the 4th, 9th one
Yeah. We know that and we’re trying to rework that. But it isn’t easy
Others are lovely
Why not cats?
Don’t ask for cat
that would flood the chat

I no have nitro rip
Cats are great!

Dogs better
sushi
I have too many images in my keyboard
That’s too much 
Lol
Anyways
Members who don't have nitro :
L
Yeah let's either move to general or yeah
discord.Member
show the code where you want to use the avatar
one sec
i = await self.bot.application_info()
member = i.owner
embed.set_thumbnail(url=member.avatar_url)`
avatar.url
do you use discord.py or py-cord?
py-cord forsho
await ctx.respond(embed=my_embed, view=my_view, ephemeral=True)
doesn't send an ephemeral response but a normal one, why?
checkout my_view if you have mentioned the opposite
I though you only needed to pass ephemeral argument to ctx.respond()?
if my_view is classed then it kinda overrides i think
is okay
also a little help here
Pycord version?
isn't it throwing any errors or something?
u sure that the code is correct?
Did you looked at the docs / examples
bcs i don't know it myself.
i just can say how it's handled at discords end
Oh wait
You have the intents enabled?
I'm pretty sure u don't and .owner is returning None
AttributeError: 'NoneType' object has no attribute 'url'
why is there an `
Prob an error while code blocking it
maybe, but maybe not
thats not the part of code
yeah
welp
^
Or ur getting a partial member
Just make sure .owner is a discord.Member type and user has an avatar
i am the owner ofc
And if .owner isn't discord.Member or .User, make sure u have intents
and i have an avtar
for the app info user you don't need the intent for avatar normally
Who knows
I'm a guy that is dumb
Maybe
I.owner gets a member so...? I'm not sure
Hm
nyaw!eval ```cs
return Client.CurrentApplication.Owners.First().AvatarUrl;
yep
mhmmmmmmm
can I like copypasta
He just named it that
no, that's c#
Lol
bigbren u are
That is no where close to py
i just hate python
still working for pycord tho?
Returns an :class:`Asset` for the avatar the user has.
If the user does not have a traditional avatar, ``None`` is returned.
If you want the avatar that a user has displayed, consider :attr:`display_avatar`.```
Yes
but discord returns owner as a list of users
so basically, if you have a team, you can't get the single owner like that i think
but only i am the owner
He got a discord.User though
like only 1 guy in a team
@silent meadow does .id work
not sure
Try it
lemme tias
If so just fetch a user
if it doesn't work:
call discord.AppInfo.team
there the first discord.Team.members
and from that discord.TeamMember.avatar
that might work
Just see if the .id works
seems like pycord does something weird for owner
self.owner: User = state.create_user(data["owner"])
My brain hurts a bit
discord/appinfo.py line 147
self.owner: User = state.create_user(data["owner"])```
i did id did
Then fetch a user
discord/state.py lines 364 to 365
def create_user(self, data: UserPayload) -> User:
return User(state=self, data=data)```
await bot.fetch_user(id)
it does not
o
man just switched the tables
ikr
its so weird
but it does not :(
I feel like this is a bug
finally
@silent meadow are u sure the type is discord.User
R u gonna be the only owner
yessir
okay wtaf
AttributeError: 'NoneType' object has no attribute 'url'
this is way to dumb
Normally we should handle it in pycord like this: https://github.com/Aiko-IT-Systems/DisCatSharp/blob/main/DisCatSharp/Clients/BaseDiscordClient.cs#L197-L220
DisCatSharp/Clients/BaseDiscordClient.cs lines 197 to 220
if (tapp.Team == null)
{
app.Owners = new List<DiscordUser>(new[] { new DiscordUser(tapp.Owner) });
app.Team = null;
app.TeamName = null;
}
else
{
app.Team = new DiscordTeam(tapp.Team);
var members = tapp.Team.Members
.Select(x => new DiscordTeamMember(x) { TeamId = app.Team.Id, TeamName = app.Team.Name, User = new DiscordUser(x.User) })
.ToArray();
var owners = members
.Where(x => x.MembershipStatus == DiscordTeamMembershipStatus.Accepted)
.Select(x => x.User)
.ToArray();
app.Owners = new List<DiscordUser>(owners);
app.Team.Owner = owners.FirstOrDefault(x => x.Id == tapp.Team.OwnerId);
app.Team.Members = new List<DiscordTeamMember>(members);
app.TeamName = app.Team.Name;
}```
It is C#
c# in a python library server 
bro
Ykw just set ur ID in the bot
1: working with a list or array of owners in any case
-> if we have no team detected (team = None), init new list of owners with just the raw owner
-> if we have a team, build the list of the owners from the team members object
Don't turn the tables again
should I start with rust? xd
yes it did fr
Ok
how about exlixir
how about I start with brainfuck?
the language
or jsfuck
bf is fun as lang
How about QBasic
ikr
lets go to #general. lets not get a ban
i'm the only one banning for that
and i won't ban if i take part in this shit
Uhhh that's not possible to get a ban
thanks




