#Basic Pycord Help
1 messages · Page 16 of 1

do you have an on_interaction event anywhere?
moved to #1180075454766522409
Which one is better to use?
channel.edit(category=...)
or
channel.move(category=...)
i believe the ratelimit is 1 edit / 10 minutes, could channel.move go around that?
iirc move is just a specific use case for edit
is this a known issue, or am i doing smth wrong?
I'm sure it's intents.messages
it’s both
but messages is covered with default
it’s just old code and modern IDE
wait so should i be using intents.messages?
no
if you would like to not have a warning, you can use discord.Intents(…, message_content = true)
how is chesscord going btw
going well, havent had much time recently tho cause school exists
How can I detect when a sent message is responding to a message sent by the bot?
.rtfm Message.reference
depending on the specifics, you may want on_message or wait_for
so a user can add a specific time into a databse with a command, for example they input 2 days, how can i make it then send an alert when the 2 days have passed and it counts down?
Use tasks with the end time argument
ext.tasks.loop then delete the task after the timer is up.
You will need to elaborate on what you mean.
i want to make a view where it has 2 buttons. i have a secret number and i need to guess it. if my guess > secret number then i want to make the button 1 enabled and the button 2 disabled and vice versa
aiohttp/_websocket.c(1475): warning C4996: 'Py_OptimizeFlag': deprecated in 3.12
aiohttp/_websocket.c(3042): error C2039: 'ob_digit': is not a member of '_longobject'
C:\Users\SkyMo\AppData\Local\Programs\Python\Python312\include\cpython/longintrepr.h(87): note: see declaration of '_longobject'
aiohttp/_websocket.c(3097): error C2039: 'ob_digit': is not a member of '_longobject'
C:\Users\SkyMo\AppData\Local\Programs\Python\Python312\include\cpython/longintrepr.h(87): note: see declaration of '_longobject'
aiohttp/_websocket.c(3238): error C2039: 'ob_digit': is not a member of '_longobject'
C:\Users\SkyMo\AppData\Local\Programs\Python\Python312\include\cpython/longintrepr.h(87): note: see declaration of '_longobject'
aiohttp/_websocket.c(3293): error C2039: 'ob_digit': is not a member of '_longobject'
C:\Users\SkyMo\AppData\Local\Programs\Python\Python312\include\cpython/longintrepr.h(87): note: see declaration of '_longobject'
aiohttp/_websocket.c(3744): error C2039: 'ob_digit': is not a member of '_longobject'
C:\Users\SkyMo\AppData\Local\Programs\Python\Python312\include\cpython/longintrepr.h(87): note: see declaration of '_longobject'
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Tools\\MSVC\\14.38.33130\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
[end of output]
Receiving this error for aiohttp when trying to install py-cord with pip install py-cord
you have to install aiohttp in a diff. way
its the version of aiohttp its trying to download
I just downloaded latest no issues.
Yeah the latest CPP buildtools does not support the methods the old version of aiohttp is using

What version of Python do you have? The stable version of aiohttp doesn't currently support 3.12
Then do such login in the button callbacks. Using button.disabled = True and editing the message with the view to reflect changes.
oh alr ty
ctx.interaction
context has no attribute interaction (obviously)
Why would that be obvious from 1 line?
not so obvious because you never clarified which context you are dealing with
bleh ok but the context from the command (@bot.command() async def blah(ctx: Context))
aside, is there a way to send a pagination through editing the message through a button/select interaction instead?
pls dont crosspost
okay
(If I’m reading your question correctly) As long as it has access to the paginator interaction, yes. Like I use a paginator with a drop down that spawns a modal. When the modal is submitted, the paginator is updated
and... how?
As long as you have access to the paginator view, the .update() method, passing in the current interaction from your callback.
That may mean your other UI classes, such as custom dropsdowns, need to be passed in your view in its constructor. Without code, nobody can help further, though.
i currently have an embed and a view with a select. i want to edit the message to have a paginator like above, but i cant get the .edit() method to work
Part of your issue will be your localized callbacks. I tried to do this at first, too... it just doesn't work very well. Save yourself some headache and pull them out to top-level methods.
Although/Alternatively, I'd highly recommend turning this whole thing into a series of classes. Like your dropdown would subclass discord.ui.Select and you'd send your parent view in the constructor, and can define your callback within it (where the callback would access self._view or whatever you've defined it as)
what are localized callbacks and top-level methods 🥲
...oh. This goes beyond my ability to assist 😅
You have method definitions (e.g. weapon_part_inspection_callback) within your top-level invocation method (workshop). I had trouble using UI functionality with methods defined that way, and moved them to top-level (i.e. at the same 'indent level' as workshop)
i dont really see why i would use top-level callbacks...? i dont see any advantage to that, and it adds more functions to the namespace. it would be nice if all (or at least, most) functions in the top-level namespace be commands provided that this is main.py and i put most of my commands here
I mean.. you can argue about it, or you can accept it. I chose to accept it. 🙂
(Although I moved my UI structures into classes, which helped for most of the internal stuff)
Anyone know why I might be getting this error on startup? On Windows 11 with Python 11.6
ERROR: Cannot connect to host discord.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1006)')]
How would I add a reaction to a webhook that the bot sends?
await webhook.send(content=mention, embed=embed)
When you send, are you given a message ID?
Wait for the message back. With wait=True
Ah! There we go thanks, was so confused why I kept getting none but thats it. 
Is it possible to obtain the id of the user who invited the bot to a server?
^ great question, idt its possible
ive wanted to know for a long time, but couldnt find any docs :(
OK. Weird question. Is it possible to have a bot also open to HTTP requests similar to a flask server. I need it for interacting with an external OAuth2 service.
you mean just a normal flask app?
Well yeah, but I don't think you can run a flask app concurrently with a pycord bot? Of am I wrong?
In the same script
Interestingly. I was under the impression that asyncio bot.run() blocked out anything else
bot.start(token)
or you start it at the on_ready event
Interesting. Thanks.
Audit log
you can always add the identity scope and then do oauth2 magic
You can add the identity scope to your bot invite link and re-direct to a website to get the user information
or when your bot joins a new guild, check the audit log
so i'd have to subclass it... then how do i implement it to edit an existing message (that has no paginator) to have a paginator?
Can I also embed a video from Youtube into my embed like Discord does automatically when I send a Youtube link into a channel?
does the async def on_member_join apply for bots too? like if a bot joins?
Yes
hm interesting
If you want to exclude bots, you have to check in the function whether the member is a bot or not and then say that nothing should happen with bots.
no i need it to work with bots lmfao, im gonna open a thread
Does anyone have an idea or an answer?
You can't embed videos.
Okay so this is just an internal function of Discord itself?
Mhm
Then I can only work with the thumbnail and put the link in the embed that takes you directly to the video, right?
Yes
Is it possible to make a slash command that is only availible to a specific server but have all other commands global?
Yes, add guild_ids to the cımmand
hey, how do I install discord package again?
pip install py-cord-dev
ty
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for multidict
Failed to build aiohttp frozenlist multidict
ERROR: Could not build wheels for aiohttp, frozenlist, multidict, which is required to install pyproject.toml-based projects
You're using python 3.12?
Aiohttp doesn't support python 3.12
Indeed
11.6 is fine?
Yes
appreciate it 👍
i added this:
super().__init__(timeout=None)
and its still doesnt work after a restart
ok thanks
How do I catch the event when the container stops in order to properly shut down the bot? Close all connections, unload all
so everything works but
the buttons dont work after 180seconds
(timeout)
and i tried putting in "timeout=None"
but dont know where i have to put it exact´ly
where?
at
I see at the buttons
async def Button(label,style)
yep
I just did a screenshot from a example at github
yus
ty
is anyone else experiencing rate limits? i cant even get my bot online
which type of rate limits
Do you have a lot of slash commands at the bot?
that's not the error
it likely your host's issue. I recommend contacting their support for more information regarding ratelimits, or you can just wait it out since they usually last around an hour
sounds good thanks!
can I convert a discord.ext.commands.Context or a discord.commands.ApplicationContext into a bridge.Context without knowing which type it is?
Why?
I want to resolve on_command_error and on_application_command_error with one function
Do you use bridge commands?
yes
Do you have the version py-cord or py-cord-dev?
not sure
anyways i fixed it by just using on_bridge_command_error instead
that is what I would mention
Hi! How can I make VoiceChannel nsfw (age-restricted)?
await channel.edit(nsfw=True)
Keep in mind that you get really fast a ratelimit if you edit a channel
I think is only 1 or 2 every 10 Minutes
I use bot.get_user(int(user_id)) to send message in DM, but got None. don't understand why. What should I do?
?tag get_x
Any function that starts with get_ in Py-cord is retrieving the related object from your bots cache. If the object is not in the bots cache the get_ method will return None. Because of this behavior you should check if the get_x method is None and if it is use the fetch_x method.
Why Is Using fetch_ Without Using get_ First Bad?
The fetch_ method makes a call to the discord API. This API call is unneeded if you already have the information. It will also make your command take longer because it will have to send and than wait for a response from the discord API. It will also contribute to the discord APIs global rate limit of 50 requests per second.
What Is Cache?
The cache is a temporary storage inside your bot. It holds many objects from members to messages. When you restart your bot the cache will be empty. When the cache is full it will delete older objects to make space for the new objects.
thanks
hey there, how do I get a list of all application commands? Apologies if it's been asked before
the bot respond <discord.embeds.Embed object at 0x7f31f7869090>
embed = embed
or embed = response.get()
thank you
Is it possible to use Localizations for the names of the @message_command, or how can I put the name of the message_command in the user's language?
you should change the language stuff to if someone use the prefix or slash commands
@burnt gorge ^
thanks
@shell radish apparently that method doesn't exist with AutoShardedBot?
How can I set a rate limit on a button in a view?
im on a time schedule here,
what is the permission for managing members?
@command.has_permissions()
ban_members
is there a py-cord version that is compatible with aiohttp==3.9.0? pip complains that py-cord-dev==2.5.0rc5 requires version lower than 3.9.0, and i don't see any higher version for py-cord anywhere
i guess i could install from git commit, but i'd appreciate if there would be some other option
How can I make a slash command available in DMs?
Ooh, I see.. The issue is that I have debug_guilds
can you only assign one server to guild_ids?
you can assign as many as you want, but you may consider using a global application command instead
oh nvm i accidently had an extra number
ty tho
oh another questions is there a way for that to not show up when u are using send and not respond
Commands always need some kind of response. An ephemeral response is probably your best bet.
I assume this isn't a py-cord issue?
what does ephemoral response do?
It sends a response that is only visible by the user who used the command, and is mismissable.
oh ic ty
did some digging
found out it was of python version
from discord.ext import commands
bot=commands.Bot(command_prefix='.')
@bot.event
async def on_ready():
print("BOT is ready")
@bot.command()
async def test(ctx):
await ctx.send("Hello")
bot.run("")
idk why the command is not responding...
what is your Python version?
you have to add intents to your bot
like how do I do that>
?tag intents
Pycord Docs - Intents
Discord API Docs - Gateway Intents
import discord
from discord.ext import commands
# Get specific intents for fine control
intents = discord.Intents()
intents.emojis = True
intents.guilds = True
intents.messages = True # Required for prefix commands!
...
# Get all non-priveliged intents; this excludes presences, members and message_content
intents = discord.Intents.default()
# Set priveliged intents: these must be enabled on dev portal
intents.members = True
intents.presences = True
intents.message_content = True # Required for prefix commands >= 2.0.0b5
# Get all intents; all intents must be enabled on dev portal.
intents = discord.Intents.all()
# Apply intents when creating your bot
bot = commands.bot(prefix="?", intents=intents)
thanks I got it
somebody can help me making invite tracker?
We will not make it for you you have to provide some sort of code or show effort into doing this. A good place to start is
AuditLogAction.invite_create and discord.on_member_join
Is it possible to create sub group like you can with slash commands? So I can do something like !templates webhooks create?
Nvm docs says so
What's the documentation link for that sort of "form" a bot can give you?
Here's the modal dialogs example.
any idea how to fix this?
Can you show your pip list pls
uninstall pycord
and now what?
install py-cord-dev
x = await ctx.respond(file=image_file, view=view)
print(x.id)```
This is how I would print the id of the message it sends correct?
Bro that console 💀
no, you would get the interaction ID
hey im a little stupid can someone show me where my callback is at?
class Roles(discord.ui.View):
def __init__(self):
super().__init__(timeout=None)
@discord.ui.button(label="RP Notified", custom_id="RP Notified", style=discord.ButtonStyle.secondary)
async def button1(self, interaction: discord.Interaction, button: discord.ui.Button):
role = 1183151145129095228
user = interaction.user
if role in [y.id for y in user.roles]:
await user.remove_roles(user.guild.get_role(role))
await interaction.respond.send_mesage("You have removed the role RP Notified", ephemeral=True)
else:
await user.add_roles(user.guild.get_role(role))
await interaction.response.send_message("You have added the role RP Notified", ephemeral=True)
someone said my callback arguments are swapped and I need to know where they are at to have them in the correct order
i'm using ```py
await bot.change_presence(activity=discord.CustomActivity(name="status", emoji='📜'), status=discord.Status.online)
but the emoji is not showing in the status
button1 is your callback function
so it would be the other way around im assuming?
yes, button then interaction
Ok thanks!
i receive a huge error when trying to do that
ahh thanks man
i dont think python likes having both py-cord and py-cord-dev
Is there a quick way to check if a bot is already in a vc and retrieve the vc object? I'm having some cases where my bot crashes and re-launches, but discord isn't kicking the bot from the VC
I'm in the process of making the crashes in question more graceful, but if there's a way to do this I'd be interested
?
sorry I got dragged away yesterday
I like that style
currently downloading a second pack which is uhh
apparently for C# rather than for C++
rn throwing shit at the wall and seeing what sticks
Then is not what you need
not this?
Idk, try
wait...
OH
I KNOW WHY
I FUCKING FORGOT TO DOWNGRADE PYTHON
RIGHT
I WAS GONNA DO THAT LIKE 2 WEEKS BACK BUT GOT DRAGGED AWAY
I feel dumb
You don't need to do that
ye
let me cook
how do you uhh uninstall python again
nvm
I assume 3.11.7 would be fine?
i use 3.11.4
maybe I need sleep
okay fixed it
yeah was making a joke
I flipped cord and dev around
in method, i can put multiple value in Option type?
role: Option(discord.Role, "Role to exempt", required=False, max_value=2)
depends
max_value is only for int and float
Try using a role select menu
the idea is to be able to have the user mention all the roles he wants, i.e. a list of discord.Role
You are looking at doing it this way
@option(name="channel", description="Channel to configure the auto mod", type=discord.TextChannel, required=True)
@option(name="hours", description="Time to timeout the user (hours)", type=int, required=True)
@discord.ui.role_select(
placeholder="Choose the roles to exempt",
min_values=1,
max_values=10
)
async def auto_mod(self, ctx, channel: discord.TextChannel, hours : int, role: discord.Role):
why is the discord role select at a slash command?
the idea is to make an auto_moderation_rule
That is not how you use a select menu
py-cord-dev has pycord voice too?
Can I use an emoji that I have uploaded to server 1 with my bot and then find it in the bot and get it back correctly with the name and ID on another server 2 in a message so that it is displayed correctly there and not just the emoji name?
Ich hole mir das Emoji so von meinem Server 1
emoji = discord.utils.get(guild.emojis, name=emoji_str)```
And if I then send it to server 2 as a message, only the name of the emoji is displayed but not the emoji I fetched from server 1
Can't I just display this as a f string in an embed in a field?
f"{emoji}"```
Because when I add the emoji to a button, it doesn't work with my embed in the field
When I post the emoji content on the server, the emoji is displayed, but when the message comes from the bot, it is not displayed as an emoji but only as text.
Does anyone have an idea why this could be?
Oh nvm had set the authorization for the channel incorrectly🤦🏼♂️
Is the cause of all the Unknown Interaction & Unknown Message errors within my views a result of me not responding fast enough?
yes
iirc its 3 seconds
you could defer it tho and then just send a follow up later
Its saying unknown interaction whenever im trying to defer tho
But im not sure if i instantly defer or do something in between. Need to check
yo i have this error:
Exception has occurred: AttributeError
'Bot' object has no attribute 'remove_command'
File "C:\Users\Assaf Cohen\Desktop\bot\python\bot.py", line 41, in <module>
bot.remove_command('help')
AttributeError: 'Bot' object has no attribute 'remove_command'
my bot keeps going offline after running tasks.loop once and then is unresponsive to any other commands why does this happen
something is wrong in your tasks.loop
It's basically using imap to recieve emails and send it to me but it goes offline after sending a email and as soon as new email comes it sends the mail and goes offline again
can you send the code
I'm currently on my phone and can't take my pc rn can I send it later?
yeah
is it possible to send a paginated embed in a DM without a ctx? I'm running a task loop and I'm trying to send a paginated embed
Im doing this and i want to get all the context after the command, how can i do a separator to include pages
Just switch the arguments.
alr
Why is my command name not updating?
@discord.slash_command(name = 'hastebin', description = 'Upload your text to Hastebin. Useful for sharing code.')
async def modal_slash(self, ctx: discord.ApplicationContext):
modal = hastebin_modal()
await ctx.send_modal(modal)
In my test server it shows as modal_slash even after I gave it a name. What am I missing?
You didn't parse it in the function arguments
@civic plume
My embed is like "saving in cache" or something like that?
even trying to manually resetting it gives me the same embed
nvm
How do I do that?
Did you restart your discord client?
No. I'll try that
Ok, that's why probably why. You need to restart your discord client when you change the command name - as it has the old one in the cache already
It only updates it when restarted
So I restarted my bot and my client and the name has not changed.
Here is my full code:
import discord
from discord.ext import commands
from external.hastebin.api.endpoints.endpoints import create_hastebin
class hastebin_modal(discord.ui.Modal):
def __init__(self, title = 'Message', *args, **kwargs) -> None:
super().__init__(title = title, *args, **kwargs)
self.add_item(discord.ui.InputText(label = 'Message', style = discord.InputTextStyle.long))
async def callback(self, interaction: discord.Interaction):
status_code, response = await create_hastebin(self.children[0].value)
if status_code == 200:
hastebin_url = response
await interaction.response.send_message(f'{hastebin_url}')
else:
await interaction.response.send_message(f'Status code: {status_code} - Response: {response}')
class command_cog(commands.Cog):
def __init__(self, sentinel):
self.sentinel = sentinel
@discord.slash_command(description = 'Upload your text to Hastebin. Useful for sharing code..')
async def hastebin(self, ctx: discord.ApplicationContext):
modal = hastebin_modal()
await ctx.send_modal(modal)
def setup(sentinel):
sentinel.add_cog(command_cog(sentinel))
Does anyone know what the argument is to suppress embed when creating threads in channels?
await channel.create_thread(name=title, message=description, auto_archive_duration=60, type=discord.ChannelType.public_thread, reason=dynCode)
In the docs it says
suppress_embeds=True
That should work but doesnt. I get a unexpected argument error
Is it possible to send an embed here?
chan = self.bot.get_channel(000)
await chan.send(-----)
yes unless the bot does not have permissions to
or the intents
that’s not what intents are
intents determine what information you receive, not what you can send
Indeed, intents are there so people know what exactly your bot accesses before they add it to their server :P
@bot.slash_command(name = "kick", description = "Kicks member")
async def kick(ctx: ApplicationContext, member: Member, reason: Optional[str] = None):
try:
if ctx.author.guild_permissions.kick_members and member.top_role < ctx.author.top_role:
await member.kick(reason)
except Exception as e:
await ctx.respond(f"{e}")
That gives Member.kick() takes 1 positional argument but 2 were given error message. What's your suggestion to solve the problem?
@bot.slash_command(name = "kick", description = "Kicks member")
async def kick(ctx: ApplicationContext, member: Member):
try:
if ctx.author.guild_permissions.kick_members and member.top_role < ctx.author.top_role:
await member.kick()
except Exception as e:
await ctx.respond(f"{e}")
It kicks member when I don't pass reason as parameter but it gives The application did not respond error.
reason=reason
the kick was successful but you never responded
so theres obv. the possibility of sending an attachment to my bot, but what would be the best way to send multiple images at once? (working on an img/pdf converter bot, want to add support to send multiple images to be converted to pdf)
hey guys, I need to set up my very first sql server. you got any recommendation what sqlversion/flavour to use for a bot? (async obviously)
preferably something where setting up the db server isnt too much struggle and the closer it is to sqlite3 the better.
so far i was written and working with sqlite3, but reached its limitations. at least as far as i can configure it.
am i able to post via webhook in a thread?
threads dont have webhooks
yeah but are you able to create a webook on the thread's parent channel and post into the thread through that?
yes, you can specify a thread
sweet, thanks
ty :]
can I add a color as discord Slash Command option?
Hey, just wanted to make sure this is a discord sever error and not an issue caused by my code.
yea error code 5xx are internal server errors
Awesome thx
anyone else had an issue with this r:
aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host discord.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)')]
if so, go to discord and download the certificate
@reset_pings.before_loop
async def before_reset_pings():
await bot.wait_until_ready()
current_datetime = datetime.now(GMT_3_TZ)
time_until_midnight = current_datetime.replace(hour=0, minute=0, second=0, microsecond=0) + timedelta(days=1)
print(f"Current Time: {current_datetime}")
print(f"Midnight: {time_until_midnight}")
await discord.utils.sleep_until(time_until_midnight)```
It works perfect for the first day, but then during the 2nd day, it's triggered an hour earlier than expected (11 PM GMT+3). And I have no idea why
@bot.slash_command(name = "ban", description = "Bans member")
async def ban(ctx: ApplicationContext, member: Member, delete_message_seconds: Optional[int] = None, delete_message_days: Optional[Literal[1, 2, 3, 4, 5, 6, 7]] = None, reason: Optional[str] = None):
try:
if ctx.author.guild_permissions.ban_members and member.top_role < ctx.author.top_role:
await member.ban(delete_message_seconds = delete_message_seconds, delete_message_days = delete_message_days, reason = reason)
await ctx.respond(f"{member.name}({member.id}) was kicked beacause of { reason if reason is not None else 'unspecifed reason'}")
except Exception as ex:
await ctx.respond(f"{ex}")
That gives TypeError: issubclass() arg 1 must be a class because of @bot.slash_command(name = "ban", description = "Bans member") line. I don't get it.
Options are defined as: delete_message_seconds: discord.Option(int, "A description", default=None)
So?
The issue is in how you're defining your options probably
You should define options like this.
oh okay
thanks
Is there an alternative to ffmpeg that doesn't need to be added to the path
why does 'pip index versions pycord' only show 0.1.0, 0.1.1, 0.0.1
?tag notpycord
The official name of the library is py-cord. When installing the library use py-cord, pycord (without the hyphen) is a completely different package.
How can I identify the user who initiated a slash command using the message ID or another method?
i wanna say ctx.user.id
actually other bot's slash command.
wut why
how can i trigger a command using a custom message
for example when a user sends =abcdef i want to trigger !s abcdef where s is a bridge command and ! is the prefix
Why?
idk, trying to mimic another bot
ctx.author*
ty i haven’t done this in a bit
Listen for on_message event
Then access message.interaction.user
In case you want to do it using message id then you will need to either get or fetch the message then do the above
first check if message.interaction is not None
Is it possible to have the cache fill up as get fails. For exemple when a get fail, it fetch the member/role and put it into cache ?
So the cache wont be fill with info that is never used
I know you can disable the automatic fill up of hte cache at start, but can you make it it fill as needed ?
Traceback (most recent call last):
File "C:\Users\Comet\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 399, in _run_event
await coro(*args, **kwargs)
File "e:\github\a\cogs\events.py", line 48, in on_guild_remove
await cha2.send(embed=discord.Embed(title="Leave", description=f"Left: {guild.name}"))
AttributeError: 'NoneType' object has no attribute 'send'
``` not sure why it posts this and then works, also for some reason, the on join event doesnt work
"NoneType"
what is cha2?
cha2 is cha2 = self.bot.get_channel(832008207316549673)
?tag get_x
Any function that starts with get_ in Py-cord is retrieving the related object from your bots cache. If the object is not in the bots cache the get_ method will return None. Because of this behavior you should check if the get_x method is None and if it is use the fetch_x method.
Why Is Using fetch_ Without Using get_ First Bad?
The fetch_ method makes a call to the discord API. This API call is unneeded if you already have the information. It will also make your command take longer because it will have to send and than wait for a response from the discord API. It will also contribute to the discord APIs global rate limit of 50 requests per second.
What Is Cache?
The cache is a temporary storage inside your bot. It holds many objects from members to messages. When you restart your bot the cache will be empty. When the cache is full it will delete older objects to make space for the new objects.
ic, cuz the bot isnt cached at the begining
should i fix this, and if so how would i?
use fetch?
but then it would be worse later
If it returns None, fetch instead
but, it works
as the error is thrown just seconds before the bot begins to cache
also, any way to cache faster?
You will just fetch it one time
In case get returns none
You won't die because of 1 api call
issue with on_member_join function:
i have been trying to make this work but it seems to never work
things i have done.
- checked intents in bot, guilds, presence etc. set to on
- done scripting
@client.event
async def on_member_join(member):
print("entered")
any help?
i even tried bot.event just in case
Show full code please
import discord
import os
from discord import client, message
from dotenv import load_dotenv
load_dotenv()
bot = discord.Bot()
intents = discord.Intents(members=True)
client = discord.Client(intents=intents)
this is the remainder
Why you have two bots instances?...
you meant the intents variable and client variable
I said bots. You have bot and client.
client was when i was testing client.event
You either use discord.Bot OR discord.Client
And I don't think you're looking forward using discord.Client
client was replace and can be ignored
So you keep the discord.Bot and do the edits to your code.
If you're using bot, then you need to pass the intents too...
And run the bot
so i NEED to use the client pass in the client.event
No you don't
discord.Bot supports events.
You won't and will never use two instances of a bot.
or can i just use @bot.event
for and on_member_join?
?tag client
discord.Client # just for events
discord.Bot # events + slash/user/msg commands
commands.Bot # above + prefixed commands
bridge.Bot # above + bridge commands (application commands and text commands in one)
oh i see.
well this is the updated code:
load_dotenv()
bot = discord.Bot()
discord.Intents(members=True)
@bot.event
async def on_member_join(member):
print("entered")
- You're bot passing the intents to the bot
- You're not running the bot
Then read 1.
bot = discord.Bot(intents=discord.Intents.all())
is this correct?
no because you should only request for intents that you need
Can Somone Give me a sample slash command code
How do i refresh the server to update the slash commands which are available
For development, use guild_ids=[<test server id here>] while declaring slash_commands
Example:
@discord.slash_command(name="clear", description="Clears the game environment from the Discord server.", guild_ids=[31231231212312])
should i remove it later?
In a dev-build it is recommended to do so. Slash commands take 3-4 hours to register globally so we do this while development.
but my bot is just in 2 servers
but it takes 10 mins
i want it to load like within 2 min is it possible
Then just put IDs of the server in guild_ids. It'll work
no
??
It takes like 10 seconds to get the command global
I am trying to create a button that moves any user that clicks to the Speaker in the stage channel. The button is as follows:
class QuestionPost(discord.ui.View):
def __init__ (self, question: JeopardyQuestion, voice):
super().__init__(timeout=None)
self.question = question
self.voice = voice
@discord.ui.button(label="Buzz In", style=discord.ButtonStyle.blurple)
async def button_callback(self, button: discord.ui.Button, interaction: discord.Interaction):
button.disabled = True
user = interaction.user
button.label = (f"{user.name} buzzed in!")
await interaction.response.edit_message(view=self)
await user.move_to(self.voice)
It moves the User to the Listner's position, how can I make sure the user is moved into the Speaker position? Is it even possible?
Doesn't look like it's possible at first glance (just checking docs for StageChannel methods)
Can anyone point me in the appropriate direction for learning more about individual Rate Limits for actions such as:
- Global Interaction Responses
- Ephemeral Interaction Responses
- Slash Command ctx responses
I've scanned the Dev Portal Documents, and I understand that they are sent in response headers, but those aren't accessible via Pycord IIRC.
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 ...
You shouldn't need to worry about those limits.
When building apps for large numbers of users, the Rate Limits are super relevant to understanding how to parse the requests from the appropriate sources (in the design phase - i.e starting with a slash command over a global button press with an ephemeral response).
I ran into this problem with an RPG bot with a traversable map (via Button UI) that crashed disgustingly as ~1k users tried to press the Global "Enter" Button.
That example isn't entirely relevant to my existing needs, but it's a good reason to understand the rate limits that are in place and the best ways to navigate them.
how i can mention somebody in embed but i have only the id of the user?
- Get the member
Or - Just format the mention by yourself.
<@ID>
i did that but its just @tropic flint
What is that? A field title?
Field titles can't parse mentions.
yh i can see now
Is it possible to execute another bot's slash command using a bot?
I dont think so
no
thanks
pls dont crosspost
mbmb
Is it possible to access the AuditLog of a server but only for member roles updates and ignore all other actions
I only want that, but I am not sure how to only receives these event
Traceback (most recent call last):
File "C:\Users\jarex\Downloads\TOOLS\Jarexs Tools\HYDRA\hydrabot\bot.py", line 24, in <module>
@bot.has_permissions(administrator=True)
AttributeError: 'Bot' object has no attribute 'has_permissions'
You can specify which action you want to get.
https://docs.pycord.dev/en/master/api/models.html#discord.Guild.audit_logs
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 commands.has_permissions
I see but can you specify in discord.on_audit_log_entry
Check the action by yourself with an if?
yes, but I will still receive all the other log, can you set up to oly receive the types you want on that event
No... the event fires for any audit log entry
You do the checks for whatever entry you need by yourself
Even if it was a built in thing, the library would do the same check that you can do by yourself.
I see so these is no way you can only receive a certain type of log event with discord. I though maybe you could specified what you want to receives, it would make sense since they would have to send over less data
No, the gateway event fires for any audit log entry
It doesn't have an event for specific audit log entries
I see thank you !
Why is that method(on_audit_log_entry) is not in discord package ?
in the doct it says it is discord.on_audit_log_entry(entry)
You don’t need to import it
so how do I use it
Just how you would use any other event like on_ready or on_measage
ooh I see perfect !
I changed my bot's name last week on the developer portal, but it still hasn't updated. Its role is the new name and of course I can change its nickname in the channel, but can't figure out how to change its account name. What am I missing? I know this probably isn't the best place to ask
Did you edit the name in the bot section
Oh wow I'm an idiot. But also that's really unintuitive haha. Thank you.
how would i make so if the user has a role they can use the command but if not then they cant
.rtfm commands.has_role
@compact sparrow
Its a decorator
Just like commands.has_permissions
Because I put the chunk_guilds_at_startup=False, I dont have any member in the members field in a Role object. Is it possible to fetch only the members for a role ?
Should I just do a guild.chunk() and after that manually removes the member not in the roles.members
@moderation_commands.command(name="ban", description="Bans member from server")
async def ban(context: ApplicationContext, member: Member, delete_message_seconds: Optional[int], delete_message_days: Optional[Option(input_type=int)] = None, reason: Optional[str] = None):
try:
if context.author.guild_permissions.ban_members:
if context.author.top_role > member.top_role:
if delete_message_seconds is not None and not (0 <= delete_message_seconds <= 604800):
await member.ban(delete_message_seconds=delete_message_seconds, delete_message_days=delete_message_days, reason=reason)
await context.respond(f"{member.name} was banned beacuse of {reason if reason is not None else 'unspecified reason'}.")
return
raise Exception("\"delete_message_seconds\" must be between 0 and 604800.")
raise Exception("Hierarchically higher members cannot be kicked by hierarchically lower member.")
raise Exception("You don't have permission to kick members.")
except Exception as exception:
context.respond(exception)
I still don't get the type of delete_message_days. delete_message_days must be a integer from 1 to 7. I tried but the type didn't fit at all.
Hey all, I'm deleting an ephemeral message view from a modal's interaction with delete_original_response(). Problem is that if two+ users are filling out my form system around the same time, the delete is happening for other users. Any thoughts on how to make it user specific?
A view's interaction is specific to the interaction, aka specific to the user using the view. If you're using a button interaction to invoke the modal, and you don't have an interaction check to make it so only one person can use the button, that's going to happen no matter what you do. Since you can't make a message disappear for one user unless it's an ephemerl (hidden) message.
Would you be able to please explain your use case and what you are doing so I can better help you?
Yeah absolutely, thanks so much for the response.
It's essentially a form system with multiple steps:
-
Persistent (non-ephemeral) view with button that opens a modal. -- this might be the problem
-
When the modal is submitted, an ephemeral view with several select menus is sent to the user with a button to submit. I'm passing the modal's interaction to the ephemeral view and calling delete_original_response using the modal's interaction here.
-
Then I do the same thing (pass the interaction and delete) across several more ephemeral views.
With #1, you'll want an interaction check if you only want one person to use the view.
.rtfm view.interaction_check
Will multiple users still be able to use the button and open the modal?
No, that's the purpose of an interaction check.
Wait, so what message are you wanting to delete exactly?
The ephemeral view at step 2 that gets sent when a user submits the modal.
The delete_original_response would delete the ephemeral message
Which is specific to the user who submitted the modal
Unless i'm misunderstanding something, it should only delete the user specific ephemeral message, and not others'.
Hmm. But it seems to delete other user's ephemeral views -- maybe because I'm using the same interaction from the modal?
Are modal interactions specific to users? Maybe not if they're being sent from the same button.
On RawAuditLogEntryEvent when a role is added or deleted, why is the new_value field a list ? If I check the documentation it should be only 1 Object
discord doc:
Am I missing someting, or is it really 1 object but pycord but it in a list
pycord is working with fivem (gta)?
what do you mean?
like doing that
but its connected somehow to the fivem server (fivem is a roleplay kind of mod to gta)
so i want to know if its possible to do it with pycord
pycord can connect to anything, you just need to make an api call with aiohttp
.rtfm bot.
discord.ext.commands.Bot.cogs
discord.ext.commands.Bot.command
discord.ext.commands.Bot.commands
discord.ext.commands.Bot.connect
discord.ext.commands.Bot.create_dm
discord.ext.commands.Bot.create_group
discord.ext.commands.Bot.create_guild
discord.ext.commands.Bot.delete_invite
discord.ext.commands.Bot.dispatch
discord.ext.commands.Bot.emojis
discord.ext.commands.Bot.event
discord.ext.commands.Bot.extensions
discord.ext.commands.Bot.fetch_application
discord.ext.commands.Bot.fetch_channel
discord.ext.commands.Bot.fetch_guild
discord.ext.commands.Bot.fetch_guilds
discord.ext.commands.Bot.fetch_invite
discord.ext.commands.Bot.fetch_premium_sticker_packs
discord.ext.commands.Bot.fetch_stage_instance
discord.ext.commands.Bot.fetch_sticker
what are all the bot.(blablabla)
like
{Fore.RED}Logged in as : {bot.user}
.rtfm bot.user
discord.Bot.user
discord.Bot.user_command
discord.Bot.users
discord.ext.bridge.Bot.user
discord.ext.bridge.Bot.user_command
discord.ext.bridge.Bot.users
discord.ext.bridge.AutoShardedBot.user
discord.ext.bridge.AutoShardedBot.user_command
discord.ext.bridge.AutoShardedBot.users
discord.AutoShardedBot.user
discord.AutoShardedBot.user_command
discord.AutoShardedBot.users
discord.ext.commands.Bot.user
discord.ext.commands.Bot.user_command
discord.ext.commands.Bot.users
discord.ext.commands.AutoShardedBot.user
discord.ext.commands.AutoShardedBot.user_command
discord.ext.commands.AutoShardedBot.users
mb but could you help me i cant really find anything docs
What do you need?
.
all the attributes are here in the docs, at least for ext.commands.Bot
like this is what i mean all of these
yep
okie tyty
how can i make this so it says how many users it reads and not ever users info 
len()
like this?
yep
okie ty
docs confusing the shit outta me how do i make a input in my command 😭
like
@bot.slash_command(name="changestatus", description="Change The Status Of The Bot.",)
async def changestatus(ctx):
await bot.change_presence(activity=discord.Game(name=text))
embed = discord.Embed(
title="**Changed Status!**",
description=f"**Successfully Changed The Status To {text}! :white_check_mark:**",
color=discord.Colour.green(),
)
await ctx.respond(embed=embed)
Here's the slash options example.
yeah nvm figured it
In on_raw_audit_log_entry() I am saving payload.id in the database to know what is the last entry processed. When I try to start the bot, I look for missing entries while the bot was offline. However it is giving me all audit of the servers, not the one the bot missed
for guild in self.guilds:
async for entry in guild.audit_logs(limit=None, after=last_process_audit_log_id, oldest_first=True, action=discord.AuditLogAction.member_role_update):
print(f'{entry.user} did {entry.action} to {entry.target}')
Here last_process_audit_log_id is a value that was fetch form the database
to save the last_process_audit_log_id I just do
await self.database.update_last_process_audit_log_id(payload.guild_id, payload.id)
I would want only the event after that one
in the doc it says it take a entry or a datetime
you're not giving it either, you're giving it an integer
how can I transform the entry id in a Snowflake ID in that case ?
because in the doc it says it is a Snowflake
but in the code it says SnowflakeTime:
also if I check the discord endpoint, it takes a Snowflake ID :
make it a discord.Object
SnowflakeTime is an alias for an object or datetime most likely
it just did that, still returns all the entries

I found the bug
In the pycord code, it is assiging to a constant ...
instead of the value provided
and that constant is always 0
That is why if I print the after_strategy the id is always 0
but if I manually put the right value it works as expected
well you can pr a fix or make an issue and i or someone else will handle it tomorrow
I see, I need to take a break tho for today ahah. I have work tomorow morning ,need to sleep
but if the issue is fix in a PR, how much time will it take to make it to a release ?
because the fix is really easy, I believe you can just replace:
self.after = OLDEST_OBJECT
by
self.after = OLDEST_OBJECT if after is None else after
I have summited a issue in the git
how do I correctly indicate that the nsfw command?
when I tried to add @commands.is_nsfw(), even in nsfw channels in the console, this error:
discord.ext.commands.errors.NSFWChannelRequired: Channel '<discord.channel.PartialMessageable object at 0x0000023C71C68A60>' needs to be NSFW for this command to work.
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'Guild' object has no attribute 'fetch_bans'
And the error is right.
https://docs.pycord.dev/en/master/api/models.html#discord.Guild
Read the docs.
Models are classes that are received from Discord and are not meant to be created by the user of the library. Attributes key, url. Methods def is_animated, async read, def replace, async save, def ...
ok thanks
still no way to filter the role_select ?
Blame discord
what the best way to do a role selection menu dropdown now ?
Use a string select and parse the options yourself.
How do i get a list of slash commands? I run my bot and i get application name must be unique. but it doesnt tell me what names are conflicting
You have to review the commands by yourself
I did and i cannot find any conflicting names
which py-cord version do you have?
uninstall py-cord and install py-cord-dev
ok gimme a sec
New question, How do i create command groups (Slash Commands) using cogs?
Here's the slash cog groups example.
New question, Is there a way to limit some commands to some roles?
They can be done from the server settings -> Apps -> Bot but how do i do it from the code?
Dyno and some other bots do it too
yes
you cant do it from the code
they have to do it
How does dyno etc do it?
Yes
hide the commands if a user doesnt have X role
Here's the slash perms example.
^ so that is for everyone who doesnt have the permission for it
Yeah but isnt that just a workaround? If 2 roles have same perms but the command should only be given to one?
yea, that has to be done in the server settings
Yeah how can i do it using code?
if i cant then is it a limitation of discord API or pycord?
In the callback of string_select I can print select.values, any way to have the labels too ? thanks
Is there a way to print all the permissions a role (in this case my bot) has?
yes
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 ...
@bot.slash_command(name="unban", description="Unban a user from the guild")
async def unban(ctx, user: Option(discord.Member, "User"), reason: Option(str, "Reason", required=False)):
if ctx.author.guild_permissions.ban_members:
banned_users = await ctx.guild.bans()
banned_user_ids = [entry.user.id for entry in banned_users]
if user.id in banned_user_ids:
try:
await ctx.guild.unban(user, reason=reason)
unban_embed = discord.Embed(
title="**Successfully Unbanned User!**",
description=f"**User : {user} Unbanned{' for Reason: ' + reason if reason else ' without a reason.'}**",
color=discord.Colour.green(),
timestamp=discord.utils.utcnow()
)
await ctx.respond(embed=unban_embed)
ERROR :
Traceback (most recent call last):
File "C:\Users\jarex\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 1133, in invoke_application_command
await ctx.command.invoke(ctx)
File "C:\Users\jarex\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 381, in invoke
await injected(ctx)
File "C:\Users\jarex\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 139, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: TypeError: object BanIterator can't be used in 'await' expression
guild.bans() returns an async iterator
If you want to use it as a list, you have to flatten it.

Not a PyCord, but a Python/PyCharm issue. Figured y'all are most likly to know the reason anyway, so here we are.
My Issues:
- venvs I create are invalid interpreters, using the global version works fine
- prob unrelated (started occurring 2 months ago): PyCharm auto-disabling windows defender stopped working
Failed attempts to fix this issues: - reinstalled PyCharm
- reinstalled Python versions 3.11.7 and 3.12.1
- made sure Python saved as a PATH variable
- restarted my PC
Any ideas how to fix these issues? -
- issue has priority
- pls ping on reply
||Side Note: Wanted to create a thread, was blocked as I used header markup, but the cooldown applied to me anyways.||
@bot.slash_command(name="authorise", description="Get The Customer Role Through Your Hydra Key")
async def auth(ctx, akey: Option(str, "Key To Authorise", required=True)):
guild = ctx.guild
customer_role = discord.utils.get(guild.roles, name="Customers <3")
RSAPubKey = "auth"
auth = "auth
result = Key.activate(
token=auth,
rsa_pub_key=RSAPubKey,
product_id=23107,
key=akey,
machine_code=Helpers.GetMachineCode(v=2)
)
if result[0] is None or not Helpers.IsOnRightMachine(result[0], v=2):
error_reason = result[1] if result[1] else "Unknown error"
print(f"Authentication failed: {error_reason}")
embed_look_dm = discord.Embed(
title="Look At Your DMs! :white_check_mark:",
color=discord.Colour.green(),
timestamp=discord.utils.utcnow()
)
await ctx.respond(embed=embed_look_dm, ephemeral=True)
embed_invalid_key = discord.Embed(
title="Invalid Key!",
description=f"**The Key : `{akey}` is invalid.**\n\nReason: `{error_reason}`",
color=discord.Colour.red(),
timestamp=discord.utils.utcnow()
)
await ctx.author.send(embed=embed_invalid_key)
else:
if customer_role:
embed_look_dm = discord.Embed(
title="Look At Your DMs! :white_check_mark:",
color=discord.Colour.green(),
timestamp=discord.utils.utcnow()
)
await ctx.respond(embed=embed_look_dm, ephemeral=True)
await ctx.author.add_roles(customer_role)
embed_auth_success = discord.Embed(
title="Authorization Successful!",
description=f"You have been authorized with Key: `{akey}`",
color=discord.Colour.green(),
timestamp=discord.utils.utcnow()
)
await ctx.author.send(embed=embed_auth_success)
else:
print("Customer role not found")
embed_look_dm = discord.Embed(
title="Look At Your DMs! :white_check_mark:",
color=discord.Colour.green(),
timestamp=discord.utils.utcnow()
)
await ctx.respond(embed=embed_look_dm, ephemeral=True)
embed_role_issue = discord.Embed(
title="Role Assignment Issue",
description="The required role was not found. Please contact support.",
color=discord.Colour.red(),
timestamp=discord.utils.utcnow()
)
await ctx.author.send(embed=embed_role_issue)
ERROR :
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\jarex\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 1133, in invoke_application_command
await ctx.command.invoke(ctx)
File "C:\Users\jarex\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 381, in invoke
await injected(ctx)
File "C:\Users\jarex\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 139, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: NotFound: 404 Not Found (error code: 10062): Unknown interaction
You're taking to long to respond. Add await ctx.defer(ephemeral=True) to the start of your callback
huh
@lofty parcel
?
how would i add this
I literally told you what to do 
Add await ctx.defer(ephemeral=True) to the start of your function
oh got it ❤️
channel_id2 = 1186810340235825152
channelmc = bot.get_channel(channel_id2)
if channelmc:
guild = bot.get_guild(1180467100037423155)
if guild:
try:
await channelmc.edit(name=f"members-{len(bot.users)}")
print(f"{Fore.RED}Successfully Updated The Member Count Channel To {len(bot.users)} Members")
except discord.Forbidden:
print(f"{Fore.LIGHTGREEN_EX}Bot lacks permission to edit channel name")
else:
print(f"{Fore.LIGHTGREEN_EX}Guild not found")
else:
print(f"{Fore.LIGHTGREEN_EX}Channel not found")
Why does this shit take so long to initialize
quick question what does this referance? id, mention, name?
edit(roles=roles)
based on
member.edit(roles=roles)
a member object
so it referances the name of the role?
the roles can just be an array of discord.Object(id)
so its just based on the base referance names thrown into an array
ok, so im back. Im here for someone to tell me something obvious that was right in front of my face. But here we go. Right and simple slash command add role to member. no work help
@bot.slash_command(name="role_test", description="")
async def role_test(member2: discord.Member):
await member2.edit(roles=[1182813829986521238])
print("passed")
@grave scaffold read
You don't pass an int
i tried that. unless i need to referance the role inside the discord.Object()
ie. bot.get_guild().get_role()
The docs explicitly say you need a Role object OR, as squid said, a list of discord.Object(id) is enough
so i need an instance of bot.get_guild().get_role() ?
sorry c++ gave me brain damage. its been a while
and heres the error
line 103, in role_test
await member2.edit(roles=[discord.Object(1182813829986521238)])
TypeError: Interaction.edit_original_response() got an unexpected keyword argument 'roles'
The above exception was the direct cause of the following exception:
i can paste the whole error if needed
? the type error is the only one i see as important
its not like changing the nick breaks it, JUST roles
there's no way you made member2 an ApplicationContext
the script above is all there is. Theres no external referances classes etc. everything is scope correct so i dunno
how did you define member2
inside the role_test() coroutine
Lmao I didn't see that
You're missing the context arg
async def role_test(ctx: discord.ApplicationContext, member2: discord.Member)
OH MY GAWD, im dumb
If I want to only chunk a list of guild but not the other, is there a more efficient way to do it than just calling await guild.chunk() on each guild ?
What's the command to change the bot's nickname in a given server?
aiohttp does not support python 3.12
I am currently trying to use Discord Timestamps to display the correct time and date for the user.
Did I understand correctly that if I calculate and create the timestamp in UTC, each user should then get the correct time for their time zone, which the user has set on their system?
Ew Python 3.12 
yes
Okay thanks
You need to change the interpreter in the settings
logger = logging.getLogger("104th Datacore")
# logging.basicConfig(
# level=logging.INFO,
# format='%(asctime)s - %(levelname)-8s - %(message)s',
# datefmt='%Y-%m-%d %H:%M:%S',
# filename=pathlib.Path("logs/104th Datacore.log").resolve(),
# )
handler = StreamHandler()
formatter = ColoredFormatter()
handler.setFormatter(formatter)
logger.addHandler(handler)
# set success level
logging.SUCCESS = 25 # between WARNING and INFO
logging.addLevelName(logging.SUCCESS, 'SUCCESS')
setattr(logger, 'success', lambda message, *args: logger._log(logging.SUCCESS, message, args))
any reason why commenting this out would let the bot work. when its not commented out the bot comes online then goes offline straight away
Edit the command permissions in the integrations tab.
is there a permission user_id?
No. Its permissions for roles and channels.
You can't hide commands from specific users, programmatically or through discord.
So this won't work?
@bot.slash_command(name="grant", description="", permissions={"users": [619460266962452480]})
async def grant(ctx, member: discord.Member, duration: str = ''):
You want to hide it within your server or within all other servers the bot is in?
for all others
No because that doesn't exist
sad
You can just limit the command to your server and set its default permission to administrator
You can just register the command in a private guild of yours
If its you who will only be able to use it
Hello what can i use or do so that i can get the list of roles (role ids) a ctx.author
or like is the a decorator so that the command can only be runned if a user has of the roles needed
The decorator is @commands.has_role() the author roles is just the .roles attribute, which returns a list, from the Member object returned by ctx.author
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...
thank you ❤️
how i can add name to a link like this in embed
Want to inject some flavor into your everyday text chat? You're in luck! Discord uses Markdown, a simple plain text formatting system that'll help you make your sentences stand out. Here's how to d...
thanks
In Autocomplete you can't pass a name as a string and assign a value to it where you can then access it in the function of the slash command, can you?
How can I make the bot send a message to a specific channel, but the code sending it to the channel is inside the button class, and it’s also a CG file, and the action also takes place in the user’s DM
channel = bot.get_channel(id)
await channel.send()
That's probably the most help you're going to get
"bot" cannot be used inside a class, especially one that is in cogs
self.bot
you should read trough cog examples in the guide
How to use it inside discord.ui.View
interaction.client
theres also examples for view classes
Then self.bot like voxy said
.
View doesnt necessarily have to be inside the cog which makes it so that it isnt directly self.bot but rather something like Zervy said
...
...
...
I misunderstood the message, Google translator made a mistake
yes
That's why I said ... as.. if its client and youre in the dms with a bot then... obviously??
Is there a callback to detect view timeout?
do you use a view class?
@outer niche
you can use ```py
async def on_timeout()
Thanks!
discord.ext.commands.Bot.get_channel
discord.ext.bridge.AutoShardedBot.get_channel
discord.ext.commands.AutoShardedBot.get_channel
discord.AutoShardedBot.get_channel
discord.AutoShardedClient.get_channel
discord.ext.bridge.Bot.get_channel
discord.Guild.get_channel
discord.Guild.get_channel_or_thread
discord.Client.get_channel
discord.Bot.get_channel
.
bro
wait
you need to
do exactly as you said
where's your context?
no context here either
Can you please show me exactly what you did
Oh wiaiwait
am I stupid
hodl on
wait try without the context again
i might just be stupid
Am I blind or smth
I thought
@bot.command()
@option(name="stars", description="stars", choices=["⭐⭐⭐⭐⭐", "⭐⭐⭐⭐", "⭐⭐⭐", "⭐⭐", "⭐"], required=True)
async def vouch(ctx, comment: str, stars: str):
channel_id = bot.get_channel(108021788007283528)
embed = discord.Embed(title="**Review added**", description=f"{ctx.author.mention} has added a review", color=0x00ff)
embed.add_field(name="Comment", value=comment, inline=False)
embed.add_field(name="Stars", value=stars, inline=False)
embed.add_field(name="User ID", value=ctx.author.id, inline=False)
embed.set_thumbnail(url=ctx.author.display_avatar)
await channel_id.send(embed=embed)
was initially correct
Is it possible that your channel id is incorrect
Its incorrect or the channel is not anymore in the bot cache
?tag get_x
Any function that starts with get_ in Py-cord is retrieving the related object from your bots cache. If the object is not in the bots cache the get_ method will return None. Because of this behavior you should check if the get_x method is None and if it is use the fetch_x method.
Why Is Using fetch_ Without Using get_ First Bad?
The fetch_ method makes a call to the discord API. This API call is unneeded if you already have the information. It will also make your command take longer because it will have to send and than wait for a response from the discord API. It will also contribute to the discord APIs global rate limit of 50 requests per second.
What Is Cache?
The cache is a temporary storage inside your bot. It holds many objects from members to messages. When you restart your bot the cache will be empty. When the cache is full it will delete older objects to make space for the new objects.
Ohhh-
Didn't someone create an equivalent get_or_fetch for messages? Do I have to know (or be in) the channel id that the message is in?
I tried this...
await utils.get_or_fetch(ctx.channel, 'message', message_id)
... but it doesn't work because TextChannel has no get_message()
Can you make alias with bridgeCommands?
with avatar.url
if a slash command is called and I receive an ApplicationContext object ctx, does a method like ctx.guild.get_channel(...) involve a discord API call? or are the API-related methods all async?
all* API-related functions/methods/etc. are async, but not all async are API calls
*bot.run() and some others are exceptions
how do i make like put a command in a embed
So a message with buttons has a components field, but of course I can't send a message with a components flag. These don't have to be interactions cuz they're just URL buttons, but I want to copy them to a new message.
Is there a relatively easy way to achieve this?
a view
Ooh. View.from_message does what I'm looking to do.
can i make a event listener to check for slash commands runs?
I'm passing 1 argument but? is this a bug from the library
if len(selected_option) >= 2:
response = await interaction.response.send_message("Processing..", ephemeral=True)
message = ""
# Berikan role
for role_name in selected_option:
role = discord.utils.get(interaction.guild.roles, name=role_name)
if role in interaction.user.roles:
await interaction.user.remove_roles(role)
message += f"Removed {role}."
else:
await interaction.user.add_roles(role)
message += f"Added {role}."
print(message)
await interaction.edit_original_response(message)
TypeError: Interaction.edit_original_response() takes 1 positional argument but 2 were given```
if len(selected_option) >= 2:
- response = await interaction.response.send_message("Processing..", ephemeral=True)
+ response = await interaction.response.send_message(content = "Processing..", ephemeral=True)
message = ""
# Berikan role
for role_name in selected_option:
role = discord.utils.get(interaction.guild.roles, name=role_name)
if role in interaction.user.roles:
await interaction.user.remove_roles(role)
message += f"Removed {role}."
else:
await interaction.user.add_roles(role)
message += f"Added {role}."
print(message)
await interaction.edit_original_response(message)
similarly, with edit_original_response
import discord
from discord.commands import slash_command
from discord.ext import commands
from discord.commands import option
# Some functions here
BASE = [f'base{i}' for i in range(2, 11)] + ['DEC', 'BIN' , 'OCT', 'Binary', 'Decimal', 'Octal']
class base_conv(commands.Cog,name='base_conv'):
def __init__(self,bot):
self.bot = bot
async def command_searcher(self: discord.AutocompleteContext):
return [
b for b in BASE
]
async def get_commands(ctx: discord.AutocompleteContext):
return [b for b in BASE if b.startswith(ctx.value.lower())]
@slash_command(name='base',description='base')
@option("base_from", description="Pick a base", autocomplete=get_commands)
@option("base_from", description="Pick a base", autocomplete=get_commands)
async def base(self,ctx, base_from, base_to):
await ctx.respond('e')
def setup(bot):
bot.add_cog(base_conv(bot))
main
extensions = [
'cogs.ping',
'cogs.time',
'cogs.image',
'cogs.help',
'cogs.dank',
'cogs.eightball',
'cogs.mod',
'cogs.purge',
'cogs.bmr',
'cogs.gpt',
'cogs.font',
'cogs.utils',
'cogs.brainfuk',
'cogs.weather',
'cogs.wordle',
'cogs.latex',
'cogs.funds',
'cogs.graph',
'cogs.base_conv'
]
if __name__ == '__main__':
for extension in extensions:
bot.load_extension(extension)
so.. this command isnt showing up
all the other commands ARE showing up and are working
i didnt see a single error in the console
but when i intentionally make errors i do see them
and also ik i wrote base from twice in @option but i fixed it later
umm so i tried to write that code in a different file. a cog thats actually working
turns out i cant make any new commands whatsoever (used different names too)
class AuthNo(discord.ui.Button):
def __init__(self, *, style=discord.ButtonStyle.secondary, label=None, emoji=None, authask=None, original_message=None):
super().__init__(style=style, label=label, emoji=emoji)
self.authask = authask
self.original_message = original_message
async def callback(self, interaction: discord.Interaction):
embed = discord.Embed(
title="Cancelled Users Authorisation.",
color=discord.Colour.red(),
timestamp=discord.utils.utcnow()
)
await self.authask.delete()
await self.original_message.delete()
await interaction.response.edit_message(embed=embed)
File "C:\Users\jarex\Downloads\TOOLS\Jarexs Tools\HYDRA\hydrabot\bot.py", line 120, in callback
await self.authask.delete()
AttributeError: 'NoneType' object has no attribute 'delete'
You are not passing authask to init or it is None
yeah figured it lol
why the danger button not called when i press it? and also no error
class RoleMenu(discord.ui.View):
def __init__(self, role_data: dict):
super().__init__(timeout=30)
...
self.danger.label = self.data["red_button_label"]
@discord.ui.select(row=0, custom_id="reusableMenu")
async def callback(self, select, interaction):
...
await interaction.response.send_message(message, ephemeral=True)
@discord.ui.button(row=1, style=discord.ButtonStyle.danger)
async def danger(self, interaction):
...
await interaction.response.edit_original_message(content=message)
```
class RoleMenu(discord.ui.View):
def __init__(self, role_data: dict):
super().__init__(timeout=30)
# Assuming role_data contains information about roles and button labels
self.role_data = role_data
# Select menu
self.select = discord.ui.Select(
placeholder="Select a role",
options=[discord.SelectOption(label=role['label'], value=str(role['role_id'])) for role in role_data]
)
self.add_item(self.select)
# Danger button
self.danger_button = discord.ui.Button(
label="Danger",
style=discord.ButtonStyle.danger,
custom_id="danger_button"
)
self.add_item(self.danger_button)
@discord.ui.select(placeholder="Select a role", custom_id="reusableMenu")
async def callback(self, select, interaction):
selected_value = select.values[0] if select.values else None
# Logic to assign roles based on the selected value
await interaction.response.send_message("Role assigned.", ephemeral=True)
@discord.ui.button(label="Danger", style=discord.ButtonStyle.danger, custom_id="danger_button")
async def danger(self, button, interaction):
await interaction.response.send_message("Danger button pressed.", ephemeral=True)
try this code @atomic fern
fixed thanks
Is it actually possible to query when an invite was created?
https://max1385.no-friends.xyz/WfOaxeIx.png
Can you tell me what I'm doing wrong?
intents = discord.Intents(messages = True)
bot = commands.Bot(command_prefix="!!", intents=intents, help_command=None)
start_time = datetime.utcnow()
@bot.event
async def on_message(message):
if message.content.startswith('!!'):
channel = message.channel
await channel.send('I moved on /commands')
await bot.process_commands(message)
you also need message_content = True when you define your intents
i forgot
💀
but it doesn't seem to work either
If I run InteractionResponse.edit(file=None, files=None) it still raises TypeError: Cannot mix file and files keyword arguments. How can I fix this?
Just pass one of them just like the error says? 
I would but I'm trying to create a prebuilt message class so I can define a message class and then send it multiple times.
In the source it is checking if file/files is not MISSING
then just use files
Why didn't I think of that thanks!
different people think differently
But youre a squid
is it possible to send photo or any other file after embed, not before in one message?
how do i suppress the error message if i handled it in on_bridge_command_error
only some of them, i want the others to still be printed in console
Nope. That’s how discord formats a message. Can’t really do anything about it.
At best you could add the images inside the embed so it looks better
You can print the error traceback
they already get printed
"exception ignored in command ..."
on_bridge_command_error still receives the exception, and i handle some of them
but i want the handled ones to not print the "ignored exception" stuff
Is this the default thing or is it what you do when handling it?
default
on_bridge_command_error listener
Listeners won’t override the default action
You will need to use @bot.event or subclass Bot and override the on_bridge_command_error function to override
does anyone know why the background is not displayed?
I have background.show()
Yes, that's what I thought about later. Thanks
solved
how do you create the modal instance?
Does anyone know how to get the command id from the slash command that gets executed? Because the command id is different on every guild
An XY problem is when you're trying to ask about your attempted solution, rather than your actual problem.
You are trying to solve problem X, using solution Y. Instead of asking for help with X, you ask about Y. This only results in frustration as whoever is trying to help you needs to ask several questions before even beginning to help you with your actual issue, wasting both their own, and your time. Always include as much information as you can about your problem, including attempted solutions. If there are solutions you've ruled out, include them along with an explanation as to why you've ruled them out.
when moving a text channel with channel.edit(position=...), it seems like the position is relative to all the channels in the server. is there a way to do it relative to only the channels in the category of channel? i know i can write some script to calculate the difference, but wanted to see if there was an easier way
There isn't so you would have to calculate the difference like you said. If discord did it as per channels in the category as the index, there would be a problem with channels that don't have a category.
anyone here know how to resize a frame so it occupies the entire window?
i'm talking about tkinter right now
You will find an answer faster in the python server.
no one answered
Because it is volunteer. But there's a high chance someone who uses tkinter is there, rather than here.
Plus this channel is for "basic pycord help"
i get this fancy error message when i start my bot :c i just moved it from my macbook to my pc, havent had this problem before
Ignoring exception in on_connect Traceback (most recent call last): File "C:\Users\Jade\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\client.py", line 399, in _run_event await coro(*args, **kwargs) File "C:\Users\Jade\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\bot.py", line 1182, in on_connect await self.sync_commands() File "C:\Users\Jade\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\bot.py", line 738, in sync_commands registered_commands = await self.register_commands( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Jade\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\bot.py", line 537, in register_commands desynced = await self.get_desynced_commands( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Jade\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\bot.py", line 360, in get_desynced_commands elif _check_command(cmd, match): ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Jade\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\bot.py", line 275, in _check_command as_dict = cmd.to_dict() ^^^^^^^^^^^^^ File "C:\Users\Jade\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\commands\core.py", line 866, in to_dict "options": [o.to_dict() for o in self.options], ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Jade\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\commands\core.py", line 866, in <listcomp> "options": [o.to_dict() for o in self.options], ^^^^^^^^^^^ File "C:\Users\Jade\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\commands\options.py", line 336, in to_dict "type": self.input_type.value, ^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'value'
wut did i do wronggg?
"NoneType"
That is the same like ```py
text = None
i get the error when i run mt bot, the exact same code didnt have an error when i would run it on mac
Is there a guaranteed way of getting channel category from a message? Since I'm having issues when a message is sent in a thread it doesn't do it
I used message.channel.category.category_id instead of channel.category_id since all types of channel has category
But it still returns None
Commands of a subgroup not working, error:
Traceback (most recent call last):
File "d:\Personal\Documents\GitHub\Grass-bot-rewrite\.venv\Lib\site-packages\discord\commands\core.py", line 124, in wrapped
ret = await coro(arg)
^^^^^^^^^^^^^^^
File "d:\Personal\Documents\GitHub\Grass-bot-rewrite\.venv\Lib\site-packages\discord\commands\core.py", line 1312, in _invoke
await command.invoke(ctx)
File "d:\Personal\Documents\GitHub\Grass-bot-rewrite\.venv\Lib\site-packages\discord\commands\core.py", line 372, in invoke
await self.prepare(ctx)
File "d:\Personal\Documents\GitHub\Grass-bot-rewrite\.venv\Lib\site-packages\discord\commands\core.py", line 292, in prepare
if not await self.can_run(ctx):
^^^^^^^^^^^^^^^^^^^^^^^
File "d:\Personal\Documents\GitHub\Grass-bot-rewrite\.venv\Lib\site-packages\discord\commands\core.py", line 390, in can_run
local_check = cog._get_overridden_method(cog.cog_check)
^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: '_MissingSentinel' object has no attribute '_get_overridden_method'
a command under a slash command group works fine, but a command under a subgroup doesn't work
This is a very old error. Whats your pycord version?
Does on_member_update run when a member is kicked? According to the docs it shouldn't, but it would perfectly explain a weird behaviour my bot has
can you add or remove roles of a member without the member object ? Sometime I need to update a member roles, I have the guild_id, member_id and role_id, but the member is not in the cache. It is useless to fetch the member only to call the function to update the roles. Can the library do it, or would I have to call the discord endpoint by myseft ?
why is the member not in cache?

memory is there to be used
and as you can see, you very quickly run into issues like this without cache
well it is not a very big issue, I just do a api request
I dont need to cache all the members of each guild for my bot usage
if I do I will run out of memory
how much memory do you have and how many users total
I have 1.8 millions users
hm
and only 4 Gb of ram
so is there a way to do a update to a member without the member been in the cache in the library ?
i think you can create a tiny placeholder object that only contains the ID, and use that instead
i used that before but i dont remember exactly how it worked again, maybe one of the regulars knows what i mean
I see that is a good idea ! I will try that, but if one of the regulars know that would be helpfull
Thank you !
I found finally that you can use that: bot.http.add_role()
ah, nice
yess very nice ! I wont have to write the api call code 😄
i mean thats what a library is for
yess that is why I ask before
yeah thats fine and dandy until it isn't there anymore
How do I make shure the author has the permission to kick users?
.rtfm Member.guild_permissions
To avoid the check in the command itself
.rtfm default_permissions
for slash commands
.rtfm defer
discord.ext.bridge.BridgeContext.defer
discord.ext.bridge.BridgeExtContext.defer
discord.InteractionResponse.defer
discord.InteractionResponseType.deferred_channel_message
discord.InteractionResponseType.deferred_message_update
discord.ext.bridge.BridgeApplicationContext.defer
discord.ApplicationContext.defer
with ctx
await
why is this not ephemeraling
did you add it to the defer?
?tag hidden
No tag hidden found.
?tag ephemeral
An 'ephemeral' message is one that's only visible to the person who invoked a command. If you ever got a command error with a blue background, this is an example of one.
To do this, set ephemeral=True when you first use an ApplicationContext. (This includes .defer()ing it; the choice of whether a message is ephemeral or not must be made up front. If you .respond() to a deferred message, setting the ephemeral flag at that time will have no effect.)
This is the equivalent of hidden=True if you're coming from interactions.py
e.g.
await ctx.respond("Imagine a message!", ephemeral = True)
await interaction.response.send_message("Imagine a message!", ephemeral = True)
Hey can I group slash commands ? I dont find anything in the docs
Here's the slash cog groups example.
thx
My slash commands in cogs aren't working: this is my code:
import discord
from discord.ext import commands
class Fun(commands.Cog):
def __init__(self, client):
self.client = client
@commands.command()
async def ping(self, ctx):
await ctx.send(f"Pong! {round(self.client.latency * 1000)}ms")
@commands.slash_command(name='test', description='Test command')
async def test(self, ctx: discord.ApplicationContext):
await ctx.respond('Slash Commands are working')
@commands.user_command(name='Test2')
async def test2(self, ctx, user: discord.Member):
await ctx.respond(f'{user.mention} is cool')
@commands.Cog.listener()
async def on_ready(self):
print('Fun cog is ready')
def setup(client):
client.add_cog(Fun(client))
Also ping me if you want to help
What do you mean with not working?
The command is just not there
how do you load the cog?
Hey I get this error when I run my bot on my Debian 11 Server. But on my Windows 11 PC it works fine. ```log
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/discord/cog.py", line 774, in _load_from_module_spec
spec.loader.exec_module(lib) # type: ignore
File "<frozen importlib._bootstrap_external>", line 786, in exec_module
File "<frozen importlib._bootstrap_external>", line 923, in get_code
File "<frozen importlib._bootstrap_external>", line 853, in source_to_code
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "/home/admin/dnw/mod-system-dev/src/cogs/config.py", line 28
match rank:
^
SyntaxError: invalid syntax
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/admin/dnw/mod-system-dev/src/main.py", line 29, in <module>
MainLoader.LoadCogsFolder()
File "/home/admin/dnw/mod-system-dev/src/main.py", line 19, in LoadCogsFolder
BOT.load_extension("cogs." + f[:-3])
File "/usr/local/lib/python3.9/dist-packages/discord/cog.py", line 910, in load_extension
self._load_from_module_spec(spec, name)
File "/usr/local/lib/python3.9/dist-packages/discord/cog.py", line 777, in _load_from_module_spec
raise errors.ExtensionFailed(key, e) from e
discord.errors.ExtensionFailed: Extension 'cogs.config' raised an error: SyntaxError: invalid syntax (config.py, line 28
It looks like it has something to do with the switch case:
```py
match rank:
case 'admin':
CONFIG['config']['team']['admin'] = role.id
case 'moderator':
CONFIG['config']['team']['moderator'] = role.id
case 'support':
CONFIG['config']['team']['support'] = role.id
case _:
await ctx.send("Rank does not exits!\n Use one of the following: \n- admin \n - moderator \n - support")
return
Could the problem be the version difference?
Windows 11 PC : Python3.11.7
Debian Server : PYthon3.9.2
Match case is only Python 3.10+
ahhh wow such a "big" feature in a update. Ok thx
All other commands in the cog are working. Only the slash command and context menu.
Show your main file
import discord
import os
import asyncio
import aiohttp
import random
import time
import requests
import openai
from keepalive import keep_alive
from discord.ext import commands
keep_alive()
intents = discord.Intents.all()
client = commands.Bot(command_prefix='-', intents=intents)
TOKEN = os.environ['TOKEN']
GPT_KEY = os.environ['GPT_KEY']
openai.api_key = GPT_KEY
cogs = ["cogs.Fun", "cogs.Moderation"]
@client.event
async def on_ready():
print('Monke Bot is online and ready to react!')
await client.change_presence(activity=discord.Game(name="me is monke"))
print('Loading cogs...')
for cog in cogs:
try:
client.load_extension(cog)
print(f"Loaded {cog} cog")
except Exception as e:
print(f"Failed to load {cog}\n{e}")
Like I said all other commands are working. Except context menus and slash commsnds
I'm using replit btw
Because youre loading your cogs on on_ready
I should make a command for them?
You need to load them before so the bot syncs the commands when it connects
No
Load your cogs after you define your bot instance
Then what
Ok
Ill try it
Nope same result,
import discord
import os
import asyncio
import aiohttp
import random
import time
import requests
import openai
from keepalive import keep_alive
from discord.ext import commands
keep_alive()
intents = discord.Intents.all()
client = commands.Bot(command_prefix='-', intents=intents)
TOKEN = os.environ['TOKEN']
GPT_KEY = os.environ['GPT_KEY']
openai.api_key = GPT_KEY
cogs = ["cogs.Fun", "cogs.Moderation"]
print('Loading cogs...')
for cog in cogs:
try:
client.load_extension(cog)
print(f"Loaded {cog} cog")
except Exception as e:
print(f"Failed to load {cog}\n{e}")
@client.event
async def on_ready():
print('Monke Bot is online and ready to react!')
await client.change_presence(activity=discord.Game(name="me is monke"))
@lofty parcel nothing changed, same as before.
Btw this is my cog code
import discord
from discord.ext import commands
class Fun(commands.Cog):
def __init__(self, client):
self.client = client
@commands.command()
async def ping(self, ctx):
await ctx.send(f"Pong! {round(self.client.latency * 1000)}ms")
@commands.slash_command(name='test', description='Test command')
async def test(self, ctx: discord.ApplicationContext):
await ctx.respond('Slash Commands are working')
@commands.user_command(name='Test2')
async def test2(self, ctx, user: discord.Member):
await ctx.respond(f'{user.mention} is cool')
@commands.Cog.listener()
async def on_ready(self):
print('Fun cog is ready')
def setup(client):
client.add_cog(Fun(client))
do commands.Bot().slash_command() auto-registered? 7 hours but still not showed up why?
do i need to set name parameter in slash_command?
why do you create the commands like that?
no
i use decorator so will be like @bot.slash_command()
i also try this way but still not showed up, i invited the bot with application.commands scope
This question doesn't directly address pycord, but is there a list of photo extensions that discord embed supports?
@little cobalt sorry for the ping but could I get a response for my problem?
is your bot with application.commands scope invited?
Yes, I have other slash commands in the main.py file which work
is the prefix command working at the cog?
how do I do that with cogs
tried to pip install py-cord-dev, but got the following errors:
ERROR: Failed building wheel for multidict
Failed to build aiohttp multidict
ERROR: Could not build wheels for aiohttp, multidict, which is required to install pyproject.toml-based projects
Im not sure if aiohttp still not supports Python 3.12
you can have both installed
but only add 3.11 to the path
2.4.1
Why isn't it working?
using PyCharm venvs, just created a new one with 3.11, works like a charm
Regarding #library-updates message, should I switch back to py-cord or continue using py-cord-dev for now
and everything that was fixed while master was down was pushed to master?
just checked and it hasn't been updated since march
idk what you mean since march
do you mean a specific part of the code
You can’t unfortunately. Event listeners in cogs only add up. They don’t override
There hasn't been a release on py-cord since March, which is why I decided to use py-cord-dev for now. Not sure if that's smart or not. Will the next release be on py-cord again? When working on new features/changing code, do you use py-cord-dev for rc's and then release the final version on py-cord? Or to put it simple, which version should I use (py-cord master, py-cord release or py-cord-dev release)?
we plan to release a py-cord version in the near future
so I guess it's best to use py-cord-dev till the release?
so i have to override the bot class itself to disable the default behaviour?
@bot.event also produces the same behavior
that should just work
If anything is broken with pcd, see if it is fixed on master. If not, then open an issue on github
I'm definitely being stupid here.. changed PC (Fresh install of everything)
Tried to install py-cord to no avail.
pip list before attached
pip list after attached
error attached
Are any of these discord.py libraries? TIA
Hey I have a problem installing the py-cord package on my Debian 11 server. Im using Python3.12 but cant install via pip
I have the same problem
we don’t support 3.12 yet
3.12 isn't supported (says on the github)
I just downgraded to 3.10
ahh damn thx
3.11 gives basically the same performance boost as 3.12
so what method of what class do i need to override?
this
everytime the bot logs in i get
Ignoring exception in on_connect
Traceback (most recent call last):
File "/workspace/.pyenv_mirror/user/current/lib/pypy3.10/site-packages/discord/client.py", line 399, in _run_event
await coro(*args, **kwargs)
File "/workspace/.pyenv_mirror/user/current/lib/pypy3.10/site-packages/discord/bot.py", line 1182, in on_connect
await self.sync_commands()
File "/workspace/.pyenv_mirror/user/current/lib/pypy3.10/site-packages/discord/bot.py", line 757, in sync_commands
app_cmds = await self.register_commands(
File "/workspace/.pyenv_mirror/user/current/lib/pypy3.10/site-packages/discord/bot.py", line 534, in register_commands
prefetched_commands = await self._bot.http.get_guild_commands(
File "/workspace/.pyenv_mirror/user/current/lib/pypy3.10/site-packages/discord/http.py", line 365, in request
raise Forbidden(response, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access
how do i prevent it
The bot is in a server that hasnt invited it with the application.commands or you're trying to register a slash command in a guild the bot is not in.