#Basic Pycord Help (Quick Questions Only)
1 messages · Page 17 of 1
hmm but that edit may break because you're sending an empty view
For some reason shard 0 (of 9) of my bot keeps getting ratelimited
sorry i got messed up its not editing message
is it not specifying the route that's causing it?
what are you trying to do
and what is the exact error you're getting
Unfortunately not.
Just constantly getting:
WARNING:discord.gateway:WebSocket in shard ID 0 is ratelimited, waiting 50.98 seconds
WARNING:discord.gateway:WebSocket in shard ID 0 is ratelimited, waiting 60.00 seconds
WARNING:discord.gateway:WebSocket in shard ID 0 is ratelimited, waiting 60.00 seconds
Repeatedly after the bot starts
Seemingly I don't get an on_ready either because its still logging on?
All my shards send their identify payloads and log on, but shard 0 keeps hitting the ratelimit
i wonder what happens if you disable intents again
you haven't been restarting repeatedly or anything?
message or guild member intent?
No.
Message content and guild members
just before continuing, how much do you rely on cache for members?
this shouldn't affect much but just checking
I don't often call anything for members. Only thing I use members for is a serverinfo command that pulls number of users. Everything else is just member-info for specific commands
inside where you call your bot class, can you set chunk_guilds_at_startup = False
and see if that improves anything
Will do. My info command uses bot.users. Gets the length of the list
You want me to do that in my client.run() or when I initialize my AutoShardedBot class?
the latter
will do
Just deployed... lets see how this goes
Ofc it happens when we push the new codebase to production 😆
Makes things much less convenient to deal with, but production is the only environment where sharding even matters haha
mmm prod
nice
Nope. Not hitting any ratelimits
awesome, since on_ready wasn't firing you could assume it was due to trying to cache members from your 9k or so guilds
Heh welp. That's not good 
well havefun
Thanks so much lol. You saved production 😆
Should I file that as an issue?
Nah, it does warn of this happening in the docs to some extent
chunk_guilds_at_startup (bool) –
Indicates if on_ready() should be delayed to chunk all guilds at start-up if necessary. This operation is incredibly slow for large amounts of guilds. The default is True if Intents.members is True.
how to invoke a slash subcommand?
works fine on one word slash commands
await ctx.invoke(self.bot.get_application_command('auction info'))
File "C:\Python310\lib\site-packages\discord\cog.py", line 616, in add_cog
cog = cog._inject(self)
File "C:\Python310\lib\site-packages\discord\cog.py", line 514, in _inject
command._set_cog(self)
File "C:\Python310\lib\site-packages\discord\commands\core.py", line 1270, in _set_cog
subcommand._set_cog(cog)
File "C:\Python310\lib\site-packages\discord\commands\core.py", line 572, in _set_cog
self.cog = cog
File "C:\Python310\lib\site-packages\discord\commands\core.py", line 777, in cog
self._validate_parameters()
File "C:\Python310\lib\site-packages\discord\commands\core.py", line 668, in _validate_parameters
self.options: List[Option] = self._match_option_param_names(params, kwop)
File "C:\Python310\lib\site-packages\discord\commands\core.py", line 748, in _match_option_param_names
raise ClientException("Too many arguments passed to the options kwarg.")
discord.errors.ClientException: Too many arguments passed to the options kwarg.
another bug in 2.1.1?
it does not happen when i switch to 2.0.1
also if you have any idea how can i avoid this try: except statement won't work neither defer() works
await inter.response.defer(invisible=True)
File "/home/container/.local/lib/python3.10/site-packages/discord/interactions.py", line 559, in defer
await self._locked_response(
File "/home/container/.local/lib/python3.10/site-packages/discord/interactions.py", line 959, in _locked_response
await coro
File "/home/container/.local/lib/python3.10/site-packages/discord/webhook/async_.py", line 211, in request
raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction
Ignoring exception in view <View timeout=300 children=2> for item <Button style=<ButtonStyle.primary: 1> url=None disabled=False label='Join' emoji=<PartialEmoji animated=False name='🗿' id=None> row=None>:
Traceback (most recent call last):
File "/home/container/bot.py", line 383, in buttons0_callback
await inter.response.send_message("You joined the list", ephemeral=True)
File "/home/container/.local/lib/python3.10/site-packages/discord/interactions.py", line 712, in send_message
await self._locked_response(
File "/home/container/.local/lib/python3.10/site-packages/discord/interactions.py", line 959, in _locked_response
await coro
File "/home/container/.local/lib/python3.10/site-packages/discord/webhook/async_.py", line 211, in request
raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction
hey, what is the maximum timeout from bot.wait_for?
None? But Im not 100% sure
what do you think is the safest place to store the token?
Hi, i tried to create a "Bridge_Group" but it throws me this error against my head:
positional argument: 'callback'
Here is my code:
@bridge.bridge_group()
async def status(self, ctx):
await ctx.send("Subcommand not found.")
I've tried to look into the docs but i was unable to find any solutions
Ah ok thanks
ImportError: cannot import name 'ManageTicket' from partially initialized module 'api' (most likely due to a circular import)``` Why does it come on suddenly and not go away?
Can you show the import line?
Problem is, there are multiple py File "c:\home\main.py", line 3, in <module> from interactions_api import ManageTicket File "c:\home\interactions_api.py", line 3, in <module> from ticket_api import getTickets, setTickets, createTicket, deleteTicket, errorTicket File "c:\home\ticket_api.py", line 3, in <module> from src.api.interactions_api import ManageTicket
no
can i get list of error i can get in pycord? need to make a error handler
how to invoke a slash subcommand?
works fine on one word slash commands
await ctx.invoke(self.bot.get_application_command('auction info'))
(3rd repost)
anyone know how to get a python interpreter on mac?
why is my Member.status coming up as offline even though they're online
Look in the docs.
You need members intent
thanks
where do i put timeout=None in buttons/view because i dont want them to expire?
pls reply with ping because im about to go
super init
im new to python, do u mean in class?
Yes
how to invoke a slash subcommand?
works fine on one word slash commands
await ctx.invoke(self.bot.get_application_command('auction info'))
(4th repost)
So i added a test slash command by execcode like:
@client.slash_command(
brief='This command is for testing.',
description='This command is for testing.',
usage="Whatever you want to type.", guild_ids=[811864132470571038])
@commands.check_any(is_bot_staff())
async def testcase(ctx, *, code: str):
pass
would it register?
I did
but it didn't register till now
Even tho its a slash command for specific guild_ids
i don't really see those kwargs you are providing in it
this?
yea
brief and usage?
brief and usage
just for generalisation
I've used it in normal commands too
bro
check above my pblm
🤔 I have a whitelist feature on my bot so you can whitelist members, channels, roles etc having loads of slash commands with like /whitelist member user], /whitelist channel [channel] etc means there are loads of slash commands anyway to do /whitelist add [member/channel/role etc] and then depending on what they last selected show the member list/channel list or whatever?
I believe you could try using auto completes, check the docs for more info
🤔 Alright lemme take a look.
You can also find examples on the github
^^
Alrighty
how can make my bot able to read txt files
Take a discord.Attachment and read it?
description*
... can anyone help me
nope
whyy
you asked a question and i, to the best of my ability, answered it
im facing the problem in on_ready since the function can be called multiple times im having issue starting my tasks.loop() there i tried try:except but it does not work for some reason and same happens in my command
You shouldn't do things on on_ready
INFO:discord.gateway:Websocket closed with WSCloseCode.ABNORMAL_CLOSURE, attempting a reconnect.
INFO:discord.shard:Got a request to RESUME the websocket at Shard ID 7.
INFO:discord.gateway:Shard ID 7 has sent the RESUME payload.
I presume this is normal as I've had similar on my bot before using Pycord, but I'm just wondering what would cause an abnormal closure?
They seem to occur quite regularly.
if you read #discord-api-updates you can see that the gateway for all bots is being restarted, it could be related to that
oh yours is abnormal though
Ahh that's probably it. Thanks 🙂
what host are you using?
maybe reach out to them and see if there's been any network errors on your account?
If there were, you'd think all shards would be restarted. It's only doing it for individual shards every so often
Plus according to Discord, bots on v10 who were approved for the Message Content intent won't be restarted so it shouldn't be that either. Pretty sure Pycord 2.1.1 uses v10, no?
correct
I still think it's worth reaching out 🤷
Will do.
I'm also occasionally just getting requests to resume.
INFO:discord.shard:Got a request to RESUME the websocket at Shard ID 8.
INFO:discord.gateway:Shard ID 8 has sent the RESUME payload.
But since a few hours ago it has all been abnormal closures
is it all on different shards?
so you know how in the integrations, that you can limit to where and who can use the commands, is there a way to do that in the code itself?
you can limit it based on discord permissions, yes
for instance you can add this to your slash command
@discord.commands.default_permissions(ban_members=True)
In the past hour (Shard, # resumes)
Abnormal closures:
1: 1
2: 1
5: 1
6: 1
7: 2
8: 2
Resume requests (no visible reason):
0: 1
7: 2
and I presume it'll only show on the integrations to those users?
correct
is there a way to do it do the channel that it can be viewed in as well?
you can also add @discord.ext.commands.has_permissions(ban_members=True), with this pycord will enforce it (just in case discord screws up and shows them the command)
no
you can only set the permissions, you can't add specific roles or channels
but you can use @discord.ext.commands.has_any_role() for instance
and then in on_application_command_error:
await ctx.respond(f"You do not have the required role to use this command.", ephemeral=True)```
if you want a specific channel you'll have to do that check yourself
E, I'm made it in integration channel that it can be viewed only in ticket created channels (using the view_channel all overriding it) and the rest that you can't. However that means you can use it in DMs
I'll have to manually had a check to it
@commands.guild_only
That's all the RESUME requests my bot has recorded in the past hour on its shards.
They all happen minutes apart from one another. Anywhere from 2-15.
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
What would be causing them to Disconnect?
You'd think a network error would just cause all the shards to Disconnect.
Random resumes are pretty normal and not something you need to worry about
Should be starting in just over 2 hours
Thanks 🙂
I've had them constantly in my old bot... Its just the abnormal closures that spark worry for me.
1006 abnormal closure doesn't come with a specific reason because it's a generic error for a disconnect, it's either a network issue, possibly blocking code or something else out of your control
Thanks so much for the clarification. I really appreciate it ❤️
Also huge appreciation to you too Jab for helping to work through it.
Then where am i supposed to do
just have a boolean so it only runs your tasks if it hasn't run them yet?
Im using .is_running() currently but somehow it just never listens
Also tried try/except but it threw error anyway did not even go to except
How do i set the boolean to false
If my bot restarts
self.started = False
Then i set it true after I start the bot?
after your timer starts
Hmm could potentially work
But what is wrong with this function it was imbuilt in library is there any exception?
hello how can i edit a slash command interaction twice
bot breaks every time i try to do it
I am trying to create boxes like this for bot replies, but I can't figure out what they are called to look it up in the docs.
they are called Embeds
they can have titles
thumbnails, footer text and more
also
AttributeError: '_MissingSentinel' object has no attribute 'request'
why i get this error?
async def Emoji_Init():
Server = await bot.fetch_guild("snow_flake_id")
Custom_Pos_Emoji = await Server.fetch_emoji(1014948125124853840)
Snap_Pos_Emoji = await Server.fetch_emoji(1014947848082706592)
Stretch_Pos_Emoji = await Server.fetch_emoji(1014953112835985428)
asyncio.run(Emoji_Init())
full error?
sure
Traceback (most recent call last):
File "/Users/##############/#################/#############/#############/Main.py", line 9, in <module>
Server = asyncio.run(bot.fetch_guild(863770714590412820))
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
return future.result()
File "/Users/###############/#################/################/venv/lib/python3.9/site-packages/discord/client.py", line 1339, in fetch_guild
data = await self.http.get_guild(guild_id, with_counts=with_counts)
File "/Users/###################/################/###############/venv/lib/python3.9/site-packages/discord/http.py", line 284, in request
async with self.__session.request(method, url, **kwargs) as response:
AttributeError: '_MissingSentinel' object has no attribute 'request'
your bot probably hasn't started yet
thanks a lot tho
also
how can i make it for the select menu to wait
and get the response
like the bot.wait_for()
i don't want to use async def callback
for other reasons
is there a event for getting guild premium update
figured it out
i don't think so
but u could make a some kind of timer
where each minute
the bot checks the server for any boosts
and if it finds a change by comparing the old value with the new
u do the event
alternatively and more better
is to check for the message if its a boost
bc welcomes and boosts tend to be message objects
@topaz ginkgo hope i tried to answered some techniques if it doesn't exist
interaction.edit_original_message
hey um
is it possible if i can send a modal
after i respond to a message
bc i get this error
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: InteractionResponded: This interaction has already been responded to before
you need an interaction (like a button) to send a modal
send a message, give it a button, then send the modal in the button callback
Why don't you send the modal first and then send the message
So send the message as the follow up
to kinda organise it
Oh, well I don't believe there's any other way to do it other than what jab said
Pretty much it has to be the response of some interaction, whether that be a slash command or a button or something else
this
SuccessEmbed = discord.Embed ( title = "Position Options", description = f"Please Select the Position System to Use for The Action You Wanna Try. Use ``quit`` or ``exit`` to Quit from the Photo Editor Input", color = discord.Color.teal())
SuccessEmbed.set_thumbnail(url = Logo)
SuccessEmbed.set_footer(text = "Select from the Box")
Select = discord.ui.Select(
min_values = 1,
max_values = 1,
placeholder = "Choose a Position System",
options = [
discord.SelectOption(label = "Snap Position", description = "Limited Positioning(9 Areas), Used When\nYou Need Accurate Positioning", emoji = Snap_Pos_Emoji, value = "snap"),
discord.SelectOption ( label = "Custom Position", description = "Custom Positioning Freely Move\nThe Object Anywhere at Any Position", emoji = Custom_Pos_Emoji, value = "custom"),
discord.SelectOption ( label = "Stretch Position", description = "Snap Positioning But Its Only\nFor Scaling Positions", emoji = Stretch_Pos_Emoji, value = "stretch" ),
]
)
View = discord.ui.View()
View.add_item(Select)
await ctx.respond(embed = SuccessEmbed, view = View)
def OptCheck(interaction):
return interaction.user == ctx.author and interaction.channel == ctx.channel
option: discord.Interaction = await bot.wait_for("interaction", check = OptCheck)
images = await Input(ctx, bot)
which is a dropdown menu
il make it to a class
help please
AttributeError: module 'discord' has no attribute 'ApplicationContext'
send your code
me?
yes
async def whitelist(ctx: discord.ApplicationContext,
user: discord.Option(discord.Member, "Member to whitelist.", required=True)):```
so just py async def whitelist(ctx, user: discord.Option(discord.Member, "Member to whitelist.", required=True)):?
Are you sure you have pycord installed?
Do pip freeze
And send the results
i have this
Send the entire thing
too long
this one
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In data.components: This field is required
gets triggered here
Your missing some field in a component
async def select_callback ( self, select, interaction: discord.Interaction, ctx=ctx, bot=bot, quality=quality):
if interaction.user == ctx.author and interaction.channel == ctx.channel:
class PositionModal ( discord.ui.Modal ) :
def __init__ ( self, *args, **kwargs ) -> None :
super ( ).__init__ ( *args, **kwargs )
if select.custom_id == "custom":
self.add_item(discord.ui.InputText(label = "Left Position / First X Position", style = discord.InputTextStyle.singleline, value = "x"))
self.add_item(discord.ui.InputText(label = "Top Position / First Y Position", style = discord.InputTextStyle.singleline, value = "y"))
self.add_item(discord.ui.InputText(label = "Right Position / Second X Position", style = discord.InputTextStyle.singleline, value = "x2"))
self.add_item(discord.ui.InputText(label = "Left Position / Second Y Position", style = discord.InputTextStyle.singleline, value = "y2"))
async def callback ( self, interaction: discord.Interaction, ctx = ctx, quality = quality) :
# Stuff
await interaction.response.send_modal(modal = PositionModal(title = "Position Modal"))
but don't get what im missing
can i send to DMs? It's very long
I used it once, then if I want to edit it again? What should I use
but here
same thing
is the entire interaction thing
Sure
class SelectView (discord.ui.View) :
@discord.ui.select ( # the decorator that lets you specify the properties of the select menu
min_values = 1,
max_values = 1,
placeholder = "Choose a Position System",
options = [
discord.SelectOption(label = "Snap Position", description = "Limited Positioning(9 Areas), Used When\nYou Need Accurate Positioning", emoji = Snap_Pos_Emoji, value = "snap"),
discord.SelectOption ( label = "Custom Position", description = "Custom Positioning Freely Move\nThe Object Anywhere at Any Position", emoji = Custom_Pos_Emoji, value = "custom"),
discord.SelectOption ( label = "Stretch Position", description = "Snap Positioning But Its Only\nFor Scaling Positions", emoji = Stretch_Pos_Emoji, value = "stretch" ),
]
)
Send your code
i sent it
?tag paste
this is for the top, and the other is the bottom
okok
I tried but it says interaction has been responded to before
class SelectView (discord.ui.View) :
@discord.ui.select ( # the decorator that lets you specify the properties of the select menu
min_values = 1,
max_values = 1,
placeholder = "Choose a Position System",
options = [
discord.SelectOption(label = "Snap Position", description = "Limited Positioning(9 Areas), Used When\nYou Need Accurate Positioning", emoji = Snap_Pos_Emoji, value = "snap"),
discord.SelectOption ( label = "Custom Position", description = "Custom Positioning Freely Move\nThe Object Anywhere at Any Position", emoji = Custom_Pos_Emoji, value = "custom"),
discord.SelectOption ( label = "Stretch Position", description = "Snap Positioning But Its Only\nFor Scaling Positions", emoji = Stretch_Pos_Emoji, value = "stretch" ),
]
)
async def select_callback ( self, select, interaction: discord.Interaction, ctx=ctx, bot=bot, quality=quality):
if interaction.user == ctx.author and interaction.channel == ctx.channel:
class PositionModal ( discord.ui.Modal ) :
def __init__ ( self, *args, **kwargs ) -> None :
super ( ).__init__ ( *args, **kwargs )
if select.custom_id == "custom":
self.add_item(discord.ui.InputText(label = "Left Position / First X Position", style = discord.InputTextStyle.singleline, value = "x"))
self.add_item(discord.ui.InputText(label = "Top Position / First Y Position", style = discord.InputTextStyle.singleline, value = "y"))
self.add_item(discord.ui.InputText(label = "Right Position / Second X Position", style = discord.InputTextStyle.singleline, value = "x2"))
self.add_item(discord.ui.InputText(label = "Left Position / Second Y Position", style = discord.InputTextStyle.singleline, value = "y2"))
async def callback ( self, interaction: discord.Interaction, ctx = ctx, quality = quality) :
# Stuff
await interaction.response.send_modal(modal = PositionModal(title = "Position Modal"))
send the code
@fervent cradle Type pip uninstall discord pip uninstall discord.py pip uninstall py-cord and pip install py-cord in the console
okay
@fervent cradle here's an example: https://github.com/jab416171/simple-discord-bot/blob/master/simplebot/cogs/simple.py#L36-L49
simplebot/cogs/simple.py lines 36 to 49
@slash_command(name="flip")
async def flip(self, ctx: discord.ApplicationContext):
"""flip a coin"""
number = random.randint(1, 2)
response = await ctx.respond("flipping -")
await asyncio.sleep(0.2)
await response.edit_original_message(content="flipping |")
await asyncio.sleep(0.2)
await response.edit_original_message(content="flipping -")
await asyncio.sleep(0.2)
await response.edit_original_message(content="flipping |")
await asyncio.sleep(0.2)
number = "heads" if number == 1 else "tails"
await response.edit_original_message(content=f"It's {number}")```
uh wait don't these 2 libraries conflict with each other
It's tails
Yeah, that's why you need to uninstall all of them and reinstall py-cord
In your pip freeze, it showed dpy and discord
oh nvm
also one question
why both libraries have to conflict?
Working now, thanks <333
Because they share some of their codebase but don't share some other stuff
yw
So that causes some stuff to work but other stuff to be overwritten when you install both
i mean there is hikari
which u could say its a fork
ig
I don't believe it is
But pretty much the incompatibility issue is shared with a lot of the forks that use the discord namespace
Hey, i have this command /add [trigger] [action] and then bypasses which are optional so you can set channels, roles etc but the code works when you don't set bypasses but you you don't set them it doesn't work any ideas why?
im stupid now ik why
does asset.read() only takes the first frame if its an gif?
Thanks 🙏 i was using interaction.response.edit_original_messsage lol
well that's not interaction.edit_original_message
I'm lost and kinda tired so if someone could help me with this.
class TicketClosedButtons(discord.ui.View):
def __init__(self):
super().__init__(timeout=None)
del_button = discord.ui.Button(label="Delete", discord.Interaction.custom_id="delete_ticket", style=discord.ButtonStyle.danger, emoji=":lock:")
trans_button = discord.ui.Button(label="Transcript", custom_id="transcript_ticket", style=discord.ButtonStyle.danger, emoji=":scroll:")
self.add_item(del_button)
self.add_item(trans_button)
async def button_callback(self, button, interaction):
support = discord.utils.get(interaction.guild.roles, name="Staff")
channel = client.get_channel(transchanid)
if button.label == "Delete":
embed=discord.Embed(color=0xff0000)
embed.add_field(name="Ticket Deletion", value="Ticked will be deleted in a few seconds.", inline=False)
embed.set_footer(text="Report bugs or suggestions with /bug or /suggest!")
await interaction.response.send_message(embed=embed)
await asyncio.sleep(5)
await interaction.channel.delete()
else:
transcript = await chat_exporter.export(interaction.channel)
transcript_file = discord.File(io.BytesIO(transcript.encode()), filename=f"{interaction.channel.name}.html")
await channel.send(file=transcript_file)
class TicketCommandButtons(discord.ui.View):
@discord.ui.button(label="Close", custom_id="close_ticket", style=discord.ButtonStyle.danger, emoji=":lock:") # the button has a custom_id set
async def button_callback(self, button, interaction):
support = discord.utils.get(interaction.guild.roles, name="Staff")
role = discord.utils.find(lambda r: r.name == 'Cult Members', interaction.guild.roles)
await interaction.channel.edit(overwrites={})
await interaction.channel.set_permissions(support, read_messages=True, send_messages=True)
embed=discord.Embed(color=0xffff00)
embed.add_field(name="Ticket Closed", value="Ticket has been closed. Save a transcript and/or close the ticket.", inline=False)
embed.set_footer(text="Report bugs or suggestions with /bug or /suggest!")
await interaction.response.send_message(embed=embed, view=TicketClosedButtons())```
I messed the code up and was using decorators then changed it for sme reason so now im here.
Im trying to make buttons to close and make a ticket transcript... heres what i have now. neither buttons function at all
hey, so I wondering if there is a way in SQL to join one table with multiple tables individual at once
table 1: id, date, reason
table 2: id, moderator, user
table 3: id, moderator, channel, amount
the result could be something like the one below I could imagine, but I have no idea how to achieve this
id, date, reason, moderator, user / none, channel / none, amount / none
I'm using group commands and Option() doesn't work anymore on them (and only on group commands, and they were working before)
?tag idw
Saying it doesn't work or asking what's wrong with this code? is not helpful for yourself or others.
Describe what you expect and/or tried (with your code), and what isn't going right.
Please provide any errors you get for optimal assistance.
@bot.group()
async def heat(ctx):
if ctx.invoked_subcommand is None:
await ctx.send("invalid syntax dumbass")
@heat.command()
async def add(usr: discord.Member, val, ctx):
embed = discord.Embed(title="Moderation Action", color=0xff0000)
embed.add_field(name=f"✅ {usr}'s heat has been increased to " + val,value="",inline=False)
await ctx.send("test")
I need help with subcommands, after i run it it gives me this AttributeError: 'str' object has no attribute 'send'
Ctx goes first
How are you defining your slash commands group?
locker = client.create_group("locker", "Locker related commands")
The command works but the options are gone without touching the code
They changed it recently ?
strictly speaking either will work
i think SlashCommandGroup is more commonly used in cogs
I tried it still does the same thing
Send your whole file
locker = client.create_group("locker", "Locker related commands")
@locker.command(guild_ids=myserver, name='view', description="Locker command")
async def lockerview(ctx: discord.ApplicationContext, user: Option(discord.User, default=None, required=False)):
await ctx.respond("Done")
Command working fine but the user argument stop working and that's the same for all the other groups commands
And it's working fine for normal commands
I said whole file. But ok. Are you in a cog?
No
The whole file can show us other code that may be causing issues with it
If you’re not going to send the whole file (without token) we won’t be able to help you. As the code you’re sending seems fine but other code in your file may effect it.
I don't understand why it could affect my command because i didn't update it since a week and even more and it stopped working like today
I’m not going to argue about this. Other code in your file may affect what you’re trying to do.
I'm lost and kinda tired so if someone could help me with this.
class TicketClosedButtons(discord.ui.View):
def __init__(self):
super().__init__(timeout=None)
del_button = discord.ui.Button(label="Delete", discord.Interaction.custom_id="delete_ticket", style=discord.ButtonStyle.danger, emoji=":lock:")
trans_button = discord.ui.Button(label="Transcript", custom_id="transcript_ticket", style=discord.ButtonStyle.danger, emoji=":scroll:")
self.add_item(del_button)
self.add_item(trans_button)
async def button_callback(self, button, interaction):
support = discord.utils.get(interaction.guild.roles, name="Staff")
channel = client.get_channel(transchanid)
if button.label == "Delete":
embed=discord.Embed(color=0xff0000)
embed.add_field(name="Ticket Deletion", value="Ticked will be deleted in a few seconds.", inline=False)
embed.set_footer(text="Report bugs or suggestions with /bug or /suggest!")
await interaction.response.send_message(embed=embed)
await asyncio.sleep(5)
await interaction.channel.delete()
else:
transcript = await chat_exporter.export(interaction.channel)
transcript_file = discord.File(io.BytesIO(transcript.encode()), filename=f"{interaction.channel.name}.html")
await channel.send(file=transcript_file)
class TicketCommandButtons(discord.ui.View):
@discord.ui.button(label="Close", custom_id="close_ticket", style=discord.ButtonStyle.danger, emoji=":lock:") # the button has a custom_id set
async def button_callback(self, button, interaction):
support = discord.utils.get(interaction.guild.roles, name="Staff")
role = discord.utils.find(lambda r: r.name == 'Cult Members', interaction.guild.roles)
await interaction.channel.edit(overwrites={})
await interaction.channel.set_permissions(support, read_messages=True, send_messages=True)
embed=discord.Embed(color=0xffff00)
embed.add_field(name="Ticket Closed", value="Ticket has been closed. Save a transcript and/or close the ticket.", inline=False)
embed.set_footer(text="Report bugs or suggestions with /bug or /suggest!")
await interaction.response.send_message(embed=embed, view=TicketClosedButtons())```
I messed the code up and was using decorators then changed it for sme reason so now im here.
Im trying to make buttons to close and make a ticket transcript... heres what i have now. neither buttons function at all
Why are you defining your buttons in the __init__ when doing them in the class?
You don’t need to define them in the __init__ because I think you’re overriding the buttons with the callback while doing that
^^
this error is still a thing
I did some search, i installed the latest pycord version (stable and alpha on github) and i got this error : AttributeError: type object '_MissingSentinel' has no attribute '_get_overridden_method' and in a few days i'm not the only one to have this error, i tried to install pull request and the last version on the github but the error is still here
2.1.1*?
How can I stop this error even when it send the embed?
use ctx.respond
not ctx.send
Thankyou
Howdy, folks, this might be a dumb question, but my brain is a bit shot today. I have a bot (bot 1) that sends a message to trigger another bot (bot 2) to update stats for an object. Bot 2 just swapped to using slash commands only, and I can't seem to get anything that Bot 1 sends to trigger bot 2. I read somewhere that slash commands are ignored by bots to protect against abuse, but I wasn't sure if that is still the case.
Or is there a way I can have bot 1 say /update and bot 2 is triggered? 
Im updating my commands to use slash commands, and when I did that, the command wouldn't send in the correct channel, it only sends it in the channel the command was sent it. How can I fix this?
@commands.slash_command(description="Create a new FAQ for the server.")#FAQ command
@commands.has_permissions(administrator=True)
async def faq(self, ctx):
def check(message):
return message.author == ctx.author and message.channel == ctx.channel
channel = self.client.get_channel(969562872399147048)
m1 = await ctx.respond('What is the title of this FAQ?')
title = await self.client.wait_for('message', check=check)
m2 = await ctx.respond('What is the answer for this FAQ?')
desc = await self.client.wait_for('message', check=check)
embed = discord.Embed(title=f"**__"+title.content+"__**", description="• "+desc.content, color=0x0099ff)
embed.set_footer(text='©️ CubePark Studios 2021')
messages = [m1,m2,title,desc]
await ctx.channel.send(embed=embed)
await ctx.delete(messages)```
look at your second to last line
yeah, I tried channel.send and that didnt work either
It did before updating it to slash commands
wdym "didn't work", what happened
I get errors
...like?
only if you happen to own bot 2, and can edit its source code, in which case you could make it communicate not over discord
then get_channel failed because either the bot didn't cache the channel or it doesn't exist
nothing to do with slash commands
but no there isnt a way for a bot to trigger a slash command, and they weren't supposed to be able to access other bots commands, but before it was left to the programmer to do that, now discord is forcing it
Crap. That's what I figured. I own Bot 1, and just had it calling /update name1 and then it triggered it. All good!
you can just mention the bot without needing message content
Im using this to get the channel channel = self.client.get_channel(969562872399147048)
^ there is also that, if bot 2 has mention prefixes available still
yes i can see, but what i'm saying is that it's returning None https://docs.pycord.dev/en/master/api.html#discord.Client.get_channel
The returned channel or None if not found.
I am unsure of how to tell. If I manually send the !update name1 nothing responds, so I am imagining that it does not?
are you sure the bot has access to that channel, or maybe you disabled the guild intent?
btw there's a built in handler for adding mentions as a prefix
ext.commands.when_mentioned_or(...) is one i've always used
Now the slash command doesn't even work, it just gets stuck on this
You need to actually respond to the interaction
How did you solved it
what intent allows the Member.add_roles func to be used?
because my bot has admin perms and has members intent enabled and its getting a Missing Permissions error when I try to use member.add_roles
I switched to 2.0.1 to solve this
the member/role may be above the bot role
ooh so i need to move my bots role to the top?
above the role you are trying to assign
ty
Here's the button roles example.
i would be @bot1 update name1
!update name1 will no longer work without message intents
Oh that's interesting, so in theory changing the message send to @bot1 update name1 with message intents ON might work? 😮
i'm pretty sure they said that bot will see any message's content if it was pinged in it
They did, yes
Oh, where did we see this?? Apologies I am catching up on updating all my crap with the updates. Been stupid busy recently lmao
#discord-api-updates #library-updates
Will have to give that a catch up read, and give it a try! I will report back in a bit, thanks guys!
No problem
Adding onto this, you can also use ext.commands.when_mentioned to set the prefix to when the bot is mentioned and nothing else
Well, that would be for if it is mentioning the bot I own correct?
I am using bot1 that I do own to call a command from bot2 that I don't own
well, was*
Yeah
Yeah so that would be the reverse of what I need haha, but I will still try the @ method and see if it works 😄
Oh I see
Bot1 is owned by me, that enters !update or /update now, which bot2 that I don't own responds to. 🙂
Think like, an auto bumper hahhaa
@bot2 update name not working
@bot2 /update name also not working.
Those tested on both my bot1, and from me personally and neither called anything. Hmmm.
how to invoke a slash subcommand?
works fine on one word slash commands
await ctx.invoke(self.bot.get_application_command('auction info'))
(5th repost)
Can you just call the method instead
Do you guys think Oracle Cloud hosting would be good to host my bot?
can you elaborate?
nvm, it worked, ty
how i can get user game activity?
bot printing: micsma-prod#6363 ()
for user in users:
u = await guild.fetch_member(user[0])
print(u, u.activities)
How to hide a slash command like somebots do
the slash command fades into light grey
my bot's slash commands are not showing how do i fix it? i have added the server id in debug_guilds
You have to enable the presence privileged intent via the Discord Developer Portal and your code
My bot is not registering any slash command,
it says this in discord.log file
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host discord.com:443 ssl:default [Temporary failure in name resolution]
is this normal ?
Bad internet connection
no, i am on a vps , its network connectivty is normal, the bot is online
i heard from ddevs that the bots wont be able to connect for sometime to their api, wanted to ask the maintainers of pycord, if they are aware with it
and have implemented the necessary implementations ?
Wdym?
ttps://discord.com/developers/docs/topics/gateway#invalid-session
This means that aiohttp couldn’t resolve the domain “discord.com” (ALWAYS internet connection issues)
but the bot does connect to api, it does not throw any error in console, i had to lookup the discord.log file, also the vps is online and connected
but it is able to connect to it and change the presence status
that wouldnt have been possible if there werre connection issues
Then IDK man
Have you tried just making the slash commands global? By not setting debug_guilds
You can’t really hide slash commands without setting permissions
And bots can’t really set permissions for application commands without a bearer token from an admin of the server
yeah i did but it's not showing in any servers
even tried with 2 different bots
@wild socket actually the connectivity issues might not be your fault
But it might be Discord’s fault
?
discord is dying rn apparently
in what way
I haven't had issues today
i hadn't too, but there is some according to others

Does anyone know if daki.cc is a legitimate hosting service? Also, if it isn't, should I (or could I) use Oracle Cloud?
never heard of that
Hey, you want to host your bot for free today and with a good uptime? Then you are exactly right with Daki, convince yourself today!
Wow, that embed reads super sketchy
"...convince yourself today!"
convince yourself or i will convince you myself
So do you think it's... gigalegit?
didn't use it
Also do you know of any way to use my token in a bot hosted on the internet without actually giving them my token?
Use mongodb
Loginto mongo db before you can even start your bot take the token from mongo db and store it in a variable then use it
Host a test bot whats gonna happen anyway to your test bot lol
Its not like it will charge u
Used it for production for 5 months, until my resources got removed and my account got locked, now I'm adding a card (but from Revolut so they can't charge me even if they wanted to)
It's good until they prioritize paying customers and remove your resources
Can someone help me?
TypeError: startswith first arg must be str or a tuple of str, not bytes
like I get the error from this
avatar="https://cdn.discordapp.com/attachments/1014095439831769138/1015214318150766702/tZgZvoZ.png"
nvm I fixed
you can use https://railway.app you get $5 free credits every month but they have a 500 hour execution limit you can remove that by linking a credit card or you can apply for github student and wait for the developers to release student integration for removing all of the limits and stuff
free hosting like daki, etc. always seem sketchy and not trustable, you can run a test bot tho and see how it goes for a while
File "c:\home\main.py", line 3, in <module>
from interactions_api import ManageTicket
File "c:\home\interactions_api.py", line 3, in <module>
from ticket_api import getTickets, setTickets, createTicket, deleteTicket, errorTicket
File "c:\home\ticket_api.py", line 3, in <module>
from src.api.interactions_api import ManageTicket
ImportError: cannot import name 'ManageTicket' from partially initialized module 'api' (most likely due to a circular import)``` Why does it come on suddenly and not go away?
circular import
You are importing something that’s defined in the current file
how can i only show slash commands if user has specific role?
You have to set this manually in the command permissions on your server settings, otherwsie it can be done with permissions by default
does anyone know if its possible to have a "multi-use" command, rather than duplicating code for /slash and @mention commands?
but permission doesnt use roles just perms
i know
you can do checks to see if the invoker has certain roles but it won't be hidden
so hidden just works with the integrations panel on the server right?
that or with default_permissions
What all can I use other than input text in modals?
not yet
sad
Do the Voice Activity or Read Message History permissions have any effect on bots?
Simple
not complex
i just attached that function to the on_ready
read message history stops them from fetching messages in a channel
voice activity I'm not sure but I've seen bots say it can stop them from sending voice
Umm but you that on_ready can be called multiple times
file = discord.File("data/images/profile_data.png", filename="profile_data.png")
await interaction.response.edit_message(content='', file=file, embed=embed, view=MyView())```
how to pass a file in this
file has some problem it doesnt work i am gettng some error
also it says it accepts files in paremeters
anyone welp?
define error
TypeError: edit_message() got an unexpected keyword argument 'file'
Does on_timeout trigger when you run view.stop()?
no
that's the same question
my brain didnt brain, edited
ive tried that it won’t work
then don't
what
yeah, no.
nigga what
Anyone know how to import the Discord.py module in VS Code? I've tried by using "import discord" and "import discord.py"
And I'm getting errors by using the terminal, ("pip install discord.py")
use the discord.py server. This is a pycord server
anysolution?
what error are you getting?
typeError: edit_message() got an unexpected keyword argument 'file'
tbh edit_message() has argument or parameter called file according to docs
is the edit_message() bugged or something?
what's inside interaction?
what version of pycord?
2.0.0b7
mate?
i am trying to download the latest version
ERROR: Cannot unpack file C:\Users\xxx\AppData\Local\Temp\pip-unpack-t41i9j54\pycord.git (downloaded from C:\Users\xxx\AppData\Local\Temp\pip-req-build-as9j85ye, content-type: text/html; charset=utf-8); cannot detect archive format
ERROR: Cannot determine archive format of C:\Users\xxx\AppData\Local\Temp\pip-req-build-as9j85ye
you should update to 2.1.1
i am trying to having some error as of now
what command did you run
also to make the slash commands global we just remove guild_ids=[788316124516974622,842085499946401812] from the cmd parameter right>
pip install https://github.com/Pycord-Development/pycord.git
Pycord, a maintained fork of discord.py, is a python wrapper for the Discord API - GitHub - Pycord-Development/pycord: Pycord, a maintained fork of discord.py, is a python wrapper for the Discord API
uh that's not how you update
?tag install
- Uninstall discord.py or any other forks of discord.py you might have with the namespace
discord.
python -m pip uninstall discord.py discord -y
2a. Install py-cord
python -m pip install py-cord
2b. Update py-cord
python pip install -U py-cord
Installing other builds:
Note: You need to have git installed. Use !git to find out how to install git.
Updating the module to Alpha (unstable):
pip install -U git+https://github.com/Pycord-Development/pycord
I mean don't really care
since i have the emojis thingy
but this sometiems doesnt work in hosting servers
like what the emojis will just refresh
then you should ask them for support 🤷
uuuh
yes rn it works in the latest version
could anyone help me?
don't ask to ask
# The Role names that the player has
rnames = [role.name for role in player.roles]
# The team role you want them to have
trole = discord.utils.get(ctx.guild.roles, name=team)
# Removing role and checking if they have any of the roles
[await player.remove_roles(ctx.guild.get_role(role)) for role in nateamids if any(rname in allteams for rname in rnames)]
await player.add_roles(discord.utils.get(ctx.guild.roles, name=team))
is there a faster way to check if a user has a role that matches one in a list and then remove is it?
I would just call remove role for every role
if they don't have it it just won't do anything
remove_roles takes multiple roles, hence roles 🙂
i have a problem here: https://discord.com/channels/881207955029110855/1015300016077799424, maybe anyone could help :'
Discord is the easiest way to communicate over voice, video, and text. Chat, hang out, and stay close with your friends and communities.
oh does it, can i send a list of role ids into it?
yeah
alr, thank you!
oh i can't send markdown
don't cross post
an unrelated question, but can i disable a button different from the one i interacted with?
sure, you just need to get that button and disable it
oh okay, my bad, thought i can since there's no rule about it
there is a rule about it.
- Have patience - Please be patient and don't expect help immediately. We are humans too, we have other things to do as well and can't always respond immediately. Stick to one channel and don't post the same question on multiple channels. Please don't ask for help in other channels if no one is responding in the one you have posted your question in.
ohhh, i'm really sorry didn't see that
hey, could someone teach me a good way to make localised names for my commands ?
Localizations are a way to make your bot more accessible to your users. Learn all about localizations now!
I tried putting every names for each languages in a separated file but I can't manage to come up with a good way to extract each name
yeah i've seen this but if possible i would prefer putting names in other files rather than all at the same place
then let's say you have a file localizations.py py commandnameidk = { "en-GB": "Hello", "fr": "Bonjour" }then you can import localizations
or something idk
Is there a way to see which user added the bot to the server?
so it's better to have a file for each command rather than a file for each language?
you could do a file for each language, but you'd have to make sure everything is mapped correctly and you'd have to form the correct format after
i tried doing that i've made this monstrosity (which probably doesn't work) :
def get_locales(category: str, *path):
locales = {}
for filename in os.listdir("locales"):
if os.path("locales/" + filename) and filename.endswith(".py"):
value = import_module(f"locales.{filename[:3]}.{category}")
for i in path:
value = value[i]
locales[filename[:3]] = value
so i guess i'll try you method instead
you're probably on the right track but i can't quite tell
I'm trying to catch the permission error of my bot not having the permission to send messages, but the type of error it returns is just Forbidden and not MissingPermissions which makes it hard to catch the specific missing permissions error because I can't access the missing_permissions attribute
I do not want to check whether the bot has permissions to send messages on every command
i tried passing a list of role ids into
remove_roles() but it returned 'list' object has no attribute 'id' so i did a list of roles instead and got the same result. when i put it in a for loop it works but is there no faster way?
im going through 32 roles
the reason it doesn't raise missingpermissions is because that's a special error used in the commands extension, while forbidden is an actual error from discord
(under error 403)
we can't really help you there, it assumes that the user knows the cause of the error and thus you should base your error message off of that
class ticketSelect(Select):
def __init__(self):
options=[
discord.SelectOption(label="Roblox Script", value='1'),
discord.SelectOption(label="Discord Bot", value='2'),
discord.SelectOption(label="Website", value='3'),
discord.SelectOption(label="Other", value='4'),
]
super().__init__(placeholder="Select an option.", options=options)
async def callback(select, interaction):
itd = # problem variable
What do I set as the value of itd to get the value parameter in the actual select?
select.values[0]
thank you 
Alright thanks, but what about my other question, can you answer that?
can you show an example of what the issue is?
@command(require_var_positional = True)
async def example(ctx, guilds: Greedy[Guild]):
pass
Does not throw an error when I don't provide any arguments
how do i get the display username of the user who interacts with a button/select?
display_name
NameError: name 'display_name' is not defined
interaction.user
ty
from the looks of it, an oversight when require_var_positional was first added; greedy isn't natively considered variadic and there's some other fun logic here so oops
i think the fix may be rather straighforward but i'm not quite sure so I'm not going to implement it, I recommend opening this as an issue on the github
needs some investigation in two methods for the most part
https://github.com/Pycord-Development/pycord/blob/master/discord/ext/commands/core.py#L584
https://github.com/Pycord-Development/pycord/blob/master/discord/ext/commands/core.py#L753
discord/ext/commands/core.py line 584
async def transform(self, ctx: Context, param: inspect.Parameter) -> Any:```
`discord/ext/commands/core.py` line 753
```py
async def _parse_arguments(self, ctx: Context) -> None:```
Alright thanks. I'll look into it
all good
as a current workaround you could just raise commands.MissingRequiredArgument(...) yourself if your guilds argument is empty
Yeah, that was what I was trying to avoid by using the keyword argument
But I guess I'll make something work.
Maybe I can edit something in the code myself as a workaround for now
so i have a command going wich is premium and i want to be able to give a user a role with the command is there an example i should follow or something?
here is what i have right now
@bot.slash_command(description="gives member premium" )
async def premium(ctx, user, password ):
if password != 'give me vip':
return
await ctx.respond()
Giving a user premium?
yes its a role i have in my server
Ah. Btw if you don't want other people to use the command, you can check if the user is you instead of using a password
member.add_role() is the method for giving roles to members
If you use type hinting in the parameters for the command, pycord will parse and find users for you, even if you only input the user id
So if you do user: Member in the parameter, the user variable will be a member object
You'll probably find that useful
Do you know what type hinting is?
not really no im new to this codeing stuff
Different programming languages have two kinds of typing systems
Static typing and dynamic typing
Static means that the programmer has to specify which types variables contain, and which types functions return
Dynamic typing languages infer the type automatically
*Dynamic-typed
Python is a dynamically typed programming language, which is why you never need to specify that your variable is going to hold an integer for example
However, there is a system in Python called type hinting, which is used to make keeping track of types easier. Python doesn't enforce the types, but it is an option for programmers to hint at which types are appropriate
num: int = 45 is an example
You never need to specify that it is an integer, but you can if you want to
I don't think they are listening
If you use this to specify which type the user parameter is in your command like I said before. Then Pycord will see that you are looking for a member, and will parse it for you.
That's the gist of it @wooden zenith
Okay thanks a lot @dawn berry
@commands.Cog.listener()
async def on_scheduled_event_update(self, before, after):
if before.status == discord.ScheduledEventStatus.scheduled and after.status == discord.ScheduledEventStatus.active:
async for subscriber in before.subscribers(limit=200):
try:
await subscriber.send(f"Hey {subscriber.name}, das Event ``{after.name}`` hat gerade angefangen!\n"
f"Komm doch gern vorbei!\n"
f"Event-Link: {after.url}")
except Exception as e:
print(e, traceback.format_exc())
pass
``` why does this send twice per user?
hello, i'm trying to follow the subclassing official guide but it throws me this error
NameError: name 'slash_command' is not defined
import discord
class Bot(discord.Bot):
async def on_ready(self):
print(
f"logged in as {self.user}"
)
@slash_command()
async def ping(self, ctx):
ctx.respond("Pong!")
from discord.commands import slash_command
ho okay thank you, is it normal that this isn't in the guide?
its the same in cogs
okay, thank you very much 🛐
how would I add a description to a slash command option (like the one below)
Add the description parameter into discord.Option
discord.Option(str, description="Description")
?
?tag tias
When my friend hosts bot on pterodactyl it has no module named discord but pycord is installed
Anyone else have this issue?
This.mist be why people use docker
you mean py-cord ?
Yes
File "/home/container/main.py", line 1, in <module>
from discord import Intents
ModuleNotFoundError: No module named 'discord'```
Requirement already satisfied: py-cord==2.1.1 in ./.local/lib/python3.10/site-packages (from -r requirements.txt (line 1)) (2.1.1)
show full requirements.txt?
py-cord==2.1.1
mcuuid==1.0.1
pymongo==4.2.0
requests==2.28.1
dnspython==2.2.1
How can I get the context of a newly created thread?
When I use thread = await message.create_thread(name=game_name, auto_archive_duration=60) it sets thread = game_name
wdym by context
if you mean message content then i set it to message.clean_content
Sorry, I'm pretty new with using this. I want to store the thing that refers to the thread so I can send messages to it later. I guess maybe context is the wrong word to use...
Are you just printing it out? The __str__ just returns the name
Just try await thread.send()
Oh, interesting! That was really throwing me off. I figured it would have printed out the object information
Thanks
I got it to work! Again, thanks
why does this occure tho i havent locked anything
like only i can use it no one else can
i havent wrote any code to lock it also
what is Jarvis?
its my discord bot
oh are you on the developer portal?
yes
i have also never seen that what is this?
what's the url?
cause it works nomrally on my test bot
can you show the whole screen in the screenshot
that looks like the slash command prompt not devportal
it kinda works on my account only i tried on the other account
it shows this
but that wasnt the case with test bot
oh it's the command window
are you an admin in the guild?
yes
oh hey
idk can't say im seeing that with my bots
what kinds of decorators do you have on your commands
oh nvm misunderstood
pycord version?
but as i said i have no problem in my test bot like in my test bot it was working for everyone publicaly
so what should be the problem here
is that happening in all guilds?
yes
can you actually use the commands if you type the name in, instead of clicking the bot?
might be solely a client issue
but that would trigger some other bot like vote and stuff
no you can still specify which bot
nope it doesnt work
its working on mobile
then yeah some weird client issue, don't think we can do much about it
update and restart your device
try the browser if you're using the app or vice versa
but its not about my device my users arent able to use it via pc they showed screenshot
you sure your commands are registering?
100% like in mobile it did register i kinda saw from my other account also in pc
from my account only
wdym kinda
my user which aparently was not able to use slash commands via pc was able to do that in mobile
i managed to find a single other person post a similar issue in ddevs like 12 hours ago, don't think there's a user solution for this
so this a bug?
i guess? don't know what the cause is but idk maybe it's temporary
have you tried restarting?
(the bot)
yeah idk then
maybe just sleep it off and it'll be fixed in the morning
ez
speaking of which it's 6am, bye
bye
I have coded afk command i want to add afk command with reason what should i do ?
@prisma flicker
@grizzled sentinel
#help-rules stop pinging people
Ok ok
Tell this bro
Lol
is it a slash command?
No prefix
/ command?
oh ok i got you,
Yaa
just add a parameter
like command(ctx, reason: str)
how to add guild roles selector in slash command?
In front of this i have to wrriten this
@tiny wagon
how to know if an error is Mission Permission or Unknown Ban
when printed type both are discord.errors.ApplicationCommandInvokeError
Hi, is there the possibility of restricting an application command to a role instead of restricting it to a permission?
i got discord.errors.HTTPException: 401 Unauthorized (error code: 50027): Invalid Webhook Token on ctx.followup.send().
it's probably because it had an extremely long process inside a command.
is there a timeout or smth for followup? or webhook?
u passed an invalid webhook url
it's just ctx.response.defer() and ctx.followup.send() so it shouldn't be wrong
and it works just fine if the process gets done quickly
i just want to know how long the webhook token stays valid
How does overwrites in await guild.create_text_channel work? I can't for the life of me figure it out
something like this maybe
overwrites = {
<role/member>: discord.PermissionOverwrite(view_channel = True, …),
…
}
await guild.create_text_channel(“channel-name”, overwrites = overwrites)
why does
@commands.check_any
not hide commands no matter what
I have owners = discord.SlashCommandGroup("owners", "Bot owner commands.", default_permission=False, default_member_permissions=None)
cmd_name = bot.get_application_command('vote')
await ApplicationContext.invoke(command=cmd_name)
TypeError: ApplicationContext.invoke() missing 2 required positional arguments: 'self' and 'command'
i don't understand why this error
import discord
from discord.ext import commands
from cogs.utils import *
from discord.ext.commands.errors import *
class Errors(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.Cog.listener()
async def on_command_error(self, ctx, err):
if err == CommandOnCooldown:
em = discord.Embed(color=discord.Colour.yellow(), description=f" You're being ratelimited! You can use `{ctx.prefix}{ctx.command}` again *in {humanize_time(seconds=round(err.retry_after))}*.")
return await ctx.reply(embed=em)```
for some reason `CommandOnCooldown` doesn't work here. am I using it wrong?
Aren't you supposed to use if isinstance(error, CommandOnCooldown)
oops
isn´t it (self, ctx, error)?
It doesn't rlly matter what you name the vars
k
Its just that the self, context, and error objects will be passed in
yeah it doesnt matter i just have another variable named error and didnt want it to override it.
oh
?
ApplicationContext needs a bot and interaction object
await ApplicationContext(bot, interaction).invoke(command)
what if i want to invoke it using a message there is no interaction in that
is there no usage attribute for slash command?
what?
i don’t think you can do that
so ig i need to invoke the normal message command then
yeah
like usage on prefix command
application context is usually passed through slash commands
so how to invoke normal message commands
cmd_name = bot.get_command('vote')
await Context.invoke(mesg, cmd_name)
like this ?
you need a context object for bot.invoke
is there any way to mention slash commands?
you can get it with await bot.get_context(message)
yeah with </command:id>
i see ty
right click on it after typing it in
there should be an option to copy its id
do you have developer mode turned on
m = await ctx.send("Vote here")
File "C:\Python310\lib\site-packages\discord\ext\commands\bot.py", line -1, in get_context
TypeError: can't send non-None value to a just-started coroutine
try right clicking the upper /ping
np
</ping:988395626049982554>
did you use await with get_context
no i did not
try it with it
okay works
nice
?tag idw
Saying it doesn't work or asking what's wrong with this code? is not helpful for yourself or others.
Describe what you expect and/or tried (with your code), and what isn't going right.
Please provide any errors you get for optimal assistance.
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: NotFound: 404 Not Found (error code: 10062): Unknown interaction
gimme a moment
yep
so I'm trynna send an image which is locally stored on my device
and the error and the code I have posted above^^
Can you send the whole method
so I have a status loop and after a few days or so I get this error: https://pastebin.com/raw/yvu4azeT
this is my code for the status loop:
https://pastebin.com/raw/RAUw4kur
discord probably disconnected you while you were trying to update presence
I'd just try/except it
k
@bot.command(description="Screenshot a website")
async def webshot(ctx, website:str):
async def ss(websites:str):
websites = website
browser = await launch()
page = await browser.newPage()
await page.goto(websites)
await page.screenshot({'path': 'website.png'})
await browser.close()
await ss(website)
embed = discord.Embed(title="Input website",description="Website screenshot",color=0xffffff)
file = discord.File("C:\\Users\\quant\\OneDrive\\Desktop\\cypherbot\\website.png", filename="website.png")
embed.set_image(url="attachment://website.png")
await ctx.respond(file=file, embed=embed)
os.remove('website.png')
sorry for the ping
what bot are you using? discord.Bot?
?tag client
discord.Client # just for events
discord.Bot # events + slash/user/msg commands
commands.Bot # above + prefixed commands
the second one
I use commands.Bot so I'm not sure what's going on
same
all things that start with get_
discord.utils.get_or_fetch is this what you are trying to say?
there's client.get_or_fetch_user for users specifically, otherwise discord.utils.get_or_fetch(obj, attr, default=None) (needs to be documented)
e.g. if i wanted to get or fetch a role from the guild inside a command, i'd do await discord.utils.get_or_fetch(ctx.guild, "role", role_id)
I wonder why that isn't documented 🤔
no particular reason https://github.com/Pycord-Development/pycord/blob/master/discord/utils.py#L478
discord/utils.py line 478
# TODO: Document this```
Lol
how do i access the choices of a slash command, eg
@bot.slash_command(name = "status", description = "Status")
async def status_command(ctx, object: discord.Option(str, "Object to check status", choices = ["server", "client", "web"])):
if object == choices[1]:
print("chosen server")
make it a variable outside of the method declaration
yeah
you just say choices = mychoices
and then if object == mychoices[1]:
or whatever
where does mychoices get defined
such as this?
mychoices = ["server", "client", "web"]
@bot.slash_command(name = "status", description = "Status")
async def truckersmp_server(ctx, object: discord.Option(str, "Object to check status", choices = mychoices)):
object_capitalized = object.capitalize()
embed.title = f"{object_capitalized} Status"
if object == mychoices[1]:
await ctx.respond("server")
elif object == mychoices[2]:
await ctx.respond("client")
else:
await ctx.respond("web")
?tag tias
how do i begin to convert a user using
discord.ext.commands.UserConverter
class discord.ext.commands.UserConverter(*args, **kwargs)
Converts to a User.
All lookups are via the global user cache.
The lookup strategy is as follows (in order):
Lookup by ID.
Lookup by mention.
Lookup by name#discrim
Lookup by name
Changed in version 1.5: Raise UserNotFound instead of generic BadArgument
Changed in version 1.6: This converter now lazily fetches users from the HTTP APIs if an ID is passed, and it’s not available in cache.
await convert(ctx, argument)
This function is a coroutine.
The method to override to do conversion logic.
If an error is found while converting, it is recommended to raise a CommandError derived exception as it will properly propagate to the error handlers.
Parameters
ctx (Context) – The invocation context that the argument is being used in.
argument (str) – The argument that is being converted.
Raises
.CommandError – A generic exception occurred when converting the argument.
.BadArgument – The converter failed to convert the argument.
Here's the converters example.
@limber bison ^
oh i didnt know that was a thing. tyvm
Hey, is it possible to add the Hide function to a Reply message?
how can i edit a already edited interaction response?
No, its only possible on interactions
ok, thx
Options in group command are still not working, even after tried a few updates of pycord
is there any reason why client.reload_extention(...) would run without error but not actually work?
pass store=false
thats only for client.load_extention()
is there no way to have more than 25 choises/auto complete things in a command option?
yes
sad
truly
maybe a selection menu? Or does that also have a 25 limit
read the docs, idk off the top of my head
*note: it used to work but now it dosnt
i know it dosnt, and its not just my code because i changed the response embed color and there was no change
25 is the limit what you can see
with autocomplete
but if you type the stuff it will autocomplete anything
idk why slash commands are not showing in my bot, can someone help
i'm using debug_guilds
re-invite your bot to said guilds. also, are there are errors?
i did reinvite, and no errors are shown.
normal commands work fine but slash commands are not shown
do you enable slash commands in your channel permissions?
also check if "use the legacy chat input" is turned off
does that turn off slate2?
yep
interesting
it is enabled
it literally doesn't show slash commands except basic chat ones lol
where is that option
under accessibility
it is off
it's basically the old chat from way back when chat input didn't have formatting previews
try removing debug_guilds
i can see other's bots slash commands but not mine
tried everything
1s
i removed some background tasks which also run when bot's online
okk
maybe pycord should say
WARNING: on_connect was overridden. Application Commands will not be synced.
WOW! it worked
THANKS
at least in the logs honestly
is there a way to add all servers the bot is in in slash commands Option or max can be just 25 choices?
Do it
before you said, i didn't even know you couldn't
may be because i never used it

but yes, what
said
i was rewriting my bot from dpy to pycord, didn't knew that 
definitely didn't spend 3 minutes photoshoping that

its mine
#352062534469156864
xd
</gigalegit-:352062534469156864> (raw: </gigalegit-:352062534469156864>)
omg it's a slash command
how can I create this?
?tag command-mention
No tag command-mention found.
?tags mention
slashcommandmention
?tag slashcommandmention
</full name:ID>
ok how does toolkit not use an autocomplete for that
make a PR then :)
wanted to ask Doruk😋 about that
Any idea why my bot isn't showing up on the integrations list for a specific server despite it showing up in other servers instantly? For some context, I'm using guild debug as there are only 3 servers the bot is in, so it's easy to specify and get instant slash command updates.
Audit Log also says the integration was made, just not showing up on the list
Just wondering if there is any particular benefit to using SlashCommandOptionType enums as they are a little longer and more messy-looking than just using Option() or just specifying the raw type (which also seems to work for the basic types like int, str, etc)?
What is the preferred/recommended way?
Nevermind... Just saw this: #guide message
How do i get the name of the command that had a error?
How do I get a users avatar url?
my current code:
# Join Logs
@client.event
async def on_member_join(member):
embed=discord.Embed()
embed.set_thumbnail(url=member.avatar_url)
embed.add_field(name=f"Join Logs", value=f"{member.mention} has joined the server.", inline=False)
channel = client.get_channel(logchanid)
await channel.send(embed=embed)
my error:
Ignoring exception in on_member_join
Traceback (most recent call last):
File "C:\Users\Ryanh\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\client.py", line 382, in _run_event
await coro(*args, **kwargs)
File "F:\[bots]\MyChemicalCult Bot\bot.py", line 547, in on_member_join
embed.set_thumbnail(url=member.avatar_url)
AttributeError: 'Member' object has no attribute 'avatar_url'```
I have intents enabled
Equivalent to :attr:`User.avatar````
i see
ty
@simple canopy
await coro(*args, **kwargs)
File "F:\[bots]\MyChemicalCult Bot\bot.py", line 547, in on_member_join
embed.set_thumbnail(url=member.avatar.url)
AttributeError: 'NoneType' object has no attribute 'url'
ye i found it
Hi guys. I have disabled members, presence, and message intents in bot code. Why discord still tips me above error? Can someone help, very worried T_T
can you show how you did it in your code
not messages, should be intents.message_content
...though that might not be the issue anyway, but worth a try
let me try,hope it works 
Nice, it works (I also updated the Pycord version -> 2.1.1)
but there is a breaking change
. Is there an alternative solution
it's breaking because that decorator doesn't work anymore due to discord changes
you can use internal check via discord.ext.commands.is_owner() decorator, but user/role/channel permissions on discord's end can only be done via guild settings > integrations
really appreciate !
Slash command error "unknown interaction" with error 404
Upon looking up SO I get to know that, it's because of some kinda time limit
So how do I extend this time limit
await ctx.defer()
im using prefixed commands and sending a command wont give the desired output nor does it give an error??? why is this happening?
do you use cogs?
I'm using the commands in my main file, i have a cogs folder but it's empty for now
ah then i dont know sorry
I am trying to import discord.app
But then in get an error that says
No module named 'discord.app'
Can anyone pls help me with this

