#Basic Pycord Help (Quick Questions Only)

1 messages · Page 17 of 1

meager mica
#

change it

cyan quail
#

hmm but that edit may break because you're sending an empty view

pallid token
#

For some reason shard 0 (of 9) of my bot keeps getting ratelimited

meager mica
cyan quail
meager mica
#

wait it is

#

im confused myself lol

cyan quail
#

and what is the exact error you're getting

pallid token
#

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
cyan quail
#

hmm

#

when is it occurring

pallid token
#

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

cyan quail
#

i wonder what happens if you disable intents again

#

you haven't been restarting repeatedly or anything?

pallid token
#

message or guild member intent?

cyan quail
#

oh right what intents do you have

#

forgot to ask

pallid token
#

Message content and guild members

cyan quail
#

just before continuing, how much do you rely on cache for members?

#

this shouldn't affect much but just checking

pallid token
#

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

cyan quail
#

inside where you call your bot class, can you set chunk_guilds_at_startup = False

#

and see if that improves anything

pallid token
#

Will do. My info command uses bot.users. Gets the length of the list

pallid token
cyan quail
#

the latter

pallid token
#

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

cyan quail
#

mmm prod

pallid token
#

so uh

#

No ratelimits yet

cyan quail
#

nice

pallid token
#

Nope. Not hitting any ratelimits

cyan quail
#

awesome, since on_ready wasn't firing you could assume it was due to trying to cache members from your 9k or so guilds

pallid token
#

Heh welp. That's not good FalseFacePalmLaugh

cyan quail
#

well havefun

pallid token
#

Thanks so much lol. You saved production 😆

pallid token
cyan quail
#

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.

calm plume
#

well as they say

#

u gotta get used to the traddeoffs

tiny wagon
#

how to invoke a slash subcommand?
works fine on one word slash commands
await ctx.invoke(self.bot.get_application_command('auction info'))

slender abyss
#
 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
shy crow
#

hey, what is the maximum timeout from bot.wait_for?

young bone
white wadi
#

what do you think is the safest place to store the token?

simple canopy
#

.env file

#

added to .gitignore

edgy dew
#

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

young bone
#

Bridge commands doesnt have a group

#

You can only do it with app_commands

edgy dew
#

Ah ok thanks

graceful mortar
#
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?
graceful mortar
# young bone 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

young bone
#

Wtf is that?

#

Do you have something else installed?

graceful mortar
#

no

amber shale
#

can i get list of error i can get in pycord? need to make a error handler

tiny wagon
#

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)

fervent cradle
#

anyone know how to get a python interpreter on mac?

rocky stump
#

why is my Member.status coming up as offline even though they're online

rocky stump
void iris
#

where do i put timeout=None in buttons/view because i dont want them to expire?

void iris
void iris
full basin
#

Yes

tiny wagon
#

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)

royal spindle
#

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?

simple canopy
royal spindle
#

I did

#

but it didn't register till now

#

Even tho its a slash command for specific guild_ids

simple canopy
#

i don't really see those kwargs you are providing in it

simple canopy
#

yea

royal spindle
#

brief and usage?

simple canopy
#

brief and usage

royal spindle
#

just for generalisation
I've used it in normal commands too

simple canopy
#

im not sure if those arguments are in slash commands

#

i think they are not present

royal spindle
#

they aren't used internally

#

just contains info for the cmd.

tiny wagon
#

check above my pblm

fervent cradle
#

🤔 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?

proud pagoda
fervent cradle
proud pagoda
#

You can also find examples on the github

fervent cradle
naive remnant
#

how can make my bot able to read txt files

full basin
#

Take a discord.Attachment and read it?

naive remnant
#

yes

#

but a filr.txt

#

not an image

#

use

rugged lantern
#

description*

naive remnant
rugged lantern
naive remnant
rugged lantern
slender abyss
#

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

full basin
#

You shouldn't do things on on_ready

pallid token
#

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.

prisma flicker
#

oh yours is abnormal though

pallid token
#

Ahh that's probably it. Thanks 🙂

prisma flicker
#

what host are you using?

pallid token
#

Oop

#

I'm using Hetzner's US location

#

Ashburn Virginia

prisma flicker
#

maybe reach out to them and see if there's been any network errors on your account?

pallid token
#

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?

prisma flicker
#

correct

prisma flicker
pallid token
#

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

prisma flicker
#

is it all on different shards?

loud holly
#

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?

prisma flicker
#

you can limit it based on discord permissions, yes

prisma flicker
pallid token
#

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

loud holly
prisma flicker
#

correct

loud holly
prisma flicker
#

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

loud holly
#

I'll have to manually had a check to it

prisma flicker
#

@commands.guild_only

pallid token
#

They all happen minutes apart from one another. Anywhere from 2-15.

prisma flicker
pallid token
#

What would be causing them to Disconnect?

#

You'd think a network error would just cause all the shards to Disconnect.

cyan quail
#

Random resumes are pretty normal and not something you need to worry about

cyan quail
pallid token
cyan quail
#

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

pallid token
#

Also huge appreciation to you too Jab for helping to work through it.

slender abyss
prisma flicker
slender abyss
#

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

slender abyss
#

If my bot restarts

prisma flicker
#

self.started = False

slender abyss
#

Then i set it true after I start the bot?

prisma flicker
#

after your timer starts

slender abyss
#

Hmm could potentially work

slender abyss
fervent cradle
#

hello how can i edit a slash command interaction twice

#

bot breaks every time i try to do it

rotund current
#

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.

calm plume
#

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())
round rivet
#

full error?

calm plume
#

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'
round rivet
#

your bot probably hasn't started yet

calm plume
#

oh

#

makes sense

#

bc i putted on top of the ready

#

since i wanna avoid using globals

calm plume
#

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

topaz ginkgo
#

is there a event for getting guild premium update

calm plume
#

figured it out

calm plume
#

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

prisma flicker
calm plume
#

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
prisma flicker
#

send a message, give it a button, then send the modal in the button callback

proud pagoda
#

Why don't you send the modal first and then send the message

#

So send the message as the follow up

calm plume
proud pagoda
#

Oh, well I don't believe there's any other way to do it other than what jab said

calm plume
#

well i got one interaction

#

before the message

proud pagoda
#

Pretty much it has to be the response of some interaction, whether that be a slash command or a button or something else

calm plume
#

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

fervent cradle
#

help please
AttributeError: module 'discord' has no attribute 'ApplicationContext'

solemn spire
#

send your code

fervent cradle
#

me?

solemn spire
#

yes

fervent cradle
#
async def whitelist(ctx: discord.ApplicationContext,
                    user: discord.Option(discord.Member, "Member to whitelist.", required=True)):```
solemn spire
#

you dont have to do this

#

just do ctx

fervent cradle
#

so just py async def whitelist(ctx, user: discord.Option(discord.Member, "Member to whitelist.", required=True)):?

proud pagoda
#

Do pip freeze

#

And send the results

fervent cradle
#

i have this

calm plume
#

got weird error

#

after subclassing

proud pagoda
fervent cradle
#

too long

calm plume
#

this one

#
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In data.components: This field is required
#

gets triggered here

proud pagoda
calm plume
#
        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"))
calm plume
fervent cradle
fervent cradle
calm plume
#

but here

calm plume
#

is the entire interaction thing

proud pagoda
calm plume
#
    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" ),
           ]
        )
proud pagoda
calm plume
prisma flicker
obtuse juncoBOT
calm plume
fervent cradle
#

okok

fervent cradle
calm plume
#
    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"))
proud pagoda
#

@fervent cradle Type pip uninstall discord pip uninstall discord.py pip uninstall py-cord and pip install py-cord in the console

fervent cradle
#

okay

prisma flicker
errant craneBOT
#

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}")```
calm plume
deft pantherBOT
#

It's tails

proud pagoda
#

In your pip freeze, it showed dpy and discord

calm plume
#

also one question

#

why both libraries have to conflict?

proud pagoda
#

Because they share some of their codebase but don't share some other stuff

proud pagoda
proud pagoda
calm plume
#

which u could say its a fork

#

ig

proud pagoda
#

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

fervent cradle
calm plume
#

im stupid now ik why

dry echo
#

does asset.read() only takes the first frame if its an gif?

fervent cradle
prisma flicker
worn void
#

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

finite flame
#

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

shadow stratus
#

I'm using group commands and Option() doesn't work anymore on them (and only on group commands, and they were working before)

full basin
#

?tag idw

obtuse juncoBOT
#

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.

shadow stratus
#

There is no errors

#

That's why i'm asking

#

If it's a common bug

surreal glade
#
@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'

full basin
#

Ctx goes first

full basin
shadow stratus
#

locker = client.create_group("locker", "Locker related commands")

#

The command works but the options are gone without touching the code

full basin
#

Slash commands group uses SlashCommandGroup

shadow stratus
#

They changed it recently ?

cyan quail
#

strictly speaking either will work

#

i think SlashCommandGroup is more commonly used in cogs

shadow stratus
rare ice
shadow stratus
# rare ice 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

rare ice
shadow stratus
#

No

#

And whole file is useless

#

only this part is useful

rare ice
#

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.

shadow stratus
rare ice
worn void
#

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
rare ice
#

You don’t need to define them in the __init__ because I think you’re overriding the buttons with the callback while doing that

shadow stratus
#

this error is still a thing

shadow stratus
rare ice
#

Try uninstalling and installing 2.0.1

#

pip install py-cord==2.0.1

young bone
rare ice
#

No

#

I use 2.0.1 and it seems to be pretty stable

red geyser
#

How can I stop this error even when it send the embed?

silver moat
#

not ctx.send

red geyser
#

Thankyou

fervent cradle
#

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? Hmm

red geyser
#

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)```
cyan quail
red geyser
#

yeah, I tried channel.send and that didnt work either

#

It did before updating it to slash commands

cyan quail
red geyser
#

I get errors

cyan quail
#

...like?

red geyser
kindred sail
cyan quail
#

then get_channel failed because either the bot didn't cache the channel or it doesn't exist

#

nothing to do with slash commands

kindred sail
#

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

fervent cradle
cyan quail
#

you can just mention the bot without needing message content

red geyser
kindred sail
#

^ there is also that, if bot 2 has mention prefixes available still

cyan quail
fervent cradle
cyan quail
#

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

red geyser
#

Now the slash command doesn't even work, it just gets stuck on this

rare ice
harsh dust
#

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

slender abyss
silver moat
harsh dust
#

ooh so i need to move my bots role to the top?

silver moat
#

above the role you are trying to assign

harsh dust
#

ty

errant craneBOT
#

Here's the button roles example.

kindred sail
#

!update name1 will no longer work without message intents

fervent cradle
simple canopy
#

i'm pretty sure they said that bot will see any message's content if it was pinged in it

lilac turret
#

They did, yes

fervent cradle
#

Oh, where did we see this?? Apologies I am catching up on updating all my crap with the updates. Been stupid busy recently lmao

lilac turret
#

#discord-api-updates #library-updates

fervent cradle
#

Will have to give that a catch up read, and give it a try! I will report back in a bit, thanks guys!

lilac turret
#

No problem

lilac turret
fervent cradle
#

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*

fervent cradle
# lilac turret 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 😄

lilac turret
#

Oh I see

fervent cradle
#

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.

tiny wagon
#

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)

prisma flicker
cyan flower
#

Do you guys think Oracle Cloud hosting would be good to host my bot?

tiny wagon
#

nvm, it worked, ty

teal mica
#

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)
fierce hollow
#

How to hide a slash command like somebots do

the slash command fades into light grey

fervent cradle
#

my bot's slash commands are not showing how do i fix it? i have added the server id in debug_guilds

lilac turret
wild socket
#

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 ?

lilac turret
#

Bad internet connection

wild socket
#

no, i am on a vps , its network connectivty is normal, the bot is online

lilac turret
#

Well the only explanation is bad internet connection

#

So ¯_(ツ)_/¯

wild socket
#

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 ?

wild socket
lilac turret
#

That’s not related at all

#

You would get a different error for that

lilac turret
wild socket
#

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

lilac turret
#

Then IDK man

lilac turret
lilac turret
fervent cradle
#

even tried with 2 different bots

lilac turret
#

@wild socket actually the connectivity issues might not be your fault

#

But it might be Discord’s fault

wild socket
#

?

simple canopy
#

discord is dying rn apparently

round rivet
#

in what way

simple canopy
#

pretty normal behaviour for discord i would say

round rivet
#

I haven't had issues today

simple canopy
#

i hadn't too, but there is some according to others

round rivet
#

meanwhile on embed generation

#

"We've root caused the issue"

simple canopy
cyan flower
#

Does anyone know if daki.cc is a legitimate hosting service? Also, if it isn't, should I (or could I) use Oracle Cloud?

cyan flower
#

Wow, that embed reads super sketchy

#

"...convince yourself today!"

simple canopy
#

convince yourself or i will convince you myself

cyan flower
#

So do you think it's... gigalegit?

simple canopy
#

not sure

#

seems unlegit

cyan flower
#

Like, token stealing unlegit?

#

Or what?

#

What could it do?

simple canopy
#

i just don't like free hosts

#

read about them idk

cyan flower
#

Yeah, me neither

#

What do you think about Oracle Free Tier?

simple canopy
#

didn't use it

cyan flower
#

Also do you know of any way to use my token in a bot hosted on the internet without actually giving them my token?

simple canopy
#

i don't think there is a way

#

how would you log in then

slender abyss
#

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

slender abyss
#

Its not like it will charge u

fervent cradle
#

It's good until they prioritize paying customers and remove your resources

fervent cradle
#

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

fervent cradle
# cyan flower https://daki.cc

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

Railway

Railway is an infrastructure platform where you can provision infrastructure, develop with that infrastructure locally, and then deploy to the cloud.

#

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

graceful mortar
#
  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?
full basin
#

circular import

rare ice
dry echo
#

how can i only show slash commands if user has specific role?

smoky forge
long moat
#

does anyone know if its possible to have a "multi-use" command, rather than duplicating code for /slash and @mention commands?

dry echo
smoky forge
#

i know

#

you can do checks to see if the invoker has certain roles but it won't be hidden

dry echo
#

so hidden just works with the integrations panel on the server right?

smoky forge
#

that or with default_permissions

proud mason
#

What all can I use other than input text in modals?

proud mason
#

sad

little hill
#

Do the Voice Activity or Read Message History permissions have any effect on bots?

calm plume
#

not complex

#

i just attached that function to the on_ready

round rivet
#

voice activity I'm not sure but I've seen bots say it can stop them from sending voice

little hill
#

👍

#

great thanks!

slender abyss
rugged iris
#
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?

rugged iris
round rivet
full basin
#

Does on_timeout trigger when you run view.stop()?

full basin
#

Would on_timeout trigger after i stopped the view

#

I assume it wont

silver moat
#

that's the same question

full basin
#

my brain didnt brain, edited

devout nimbus
#

how do you give your bot a mobile status on pycord?

#

example:

silver moat
devout nimbus
#

ive tried that it won’t work

silver moat
#

then don't

devout nimbus
#

what

silver moat
#

yeah, no.

devout nimbus
#

nigga what

half cargo
#

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")

silver moat
rugged iris
prisma flicker
rugged iris
#

tbh edit_message() has argument or parameter called file according to docs

rugged iris
tired notch
prisma flicker
rugged iris
#

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

prisma flicker
rugged iris
prisma flicker
#

what command did you run

rugged iris
rugged iris
prisma flicker
#

?tag install

obtuse juncoBOT
#
  1. Uninstall discord.py or any other forks of discord.py you might have with the namespace discord.
    python -m pip uninstall discord.py discord -y

2a. Install py-cord
python -m pip install py-cord

2b. Update py-cord
python pip install -U py-cord

Installing other builds:
Note: You need to have git installed. Use !git to find out how to install git.

Updating the module to Alpha (unstable):
pip install -U git+https://github.com/Pycord-Development/pycord

calm plume
#

since i have the emojis thingy

rugged iris
calm plume
#

like what the emojis will just refresh

prisma flicker
rugged iris
tired notch
#

could anyone help me?

prisma flicker
void fable
#
# 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?

prisma flicker
#

if they don't have it it just won't do anything

#

remove_roles takes multiple roles, hence roles 🙂

tired notch
void fable
#

oh does it, can i send a list of role ids into it?

prisma flicker
#

yeah

void fable
#

alr, thank you!

tired notch
#

oh i can't send markdown

void fable
#

an unrelated question, but can i disable a button different from the one i interacted with?

prisma flicker
#

sure, you just need to get that button and disable it

tired notch
prisma flicker
# tired notch oh okay, my bad, thought i can since there's no rule about it

there is a rule about it.

  1. 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.
tired notch
echo egret
#

hey, could someone teach me a good way to make localised names for my commands ?

cyan quail
echo egret
#

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

echo egret
cyan quail
#

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

little hill
#

Is there a way to see which user added the bot to the server?

cyan quail
#

don't think so

#

maybe audit log

echo egret
cyan quail
#

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

echo egret
#

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

cyan quail
#

you're probably on the right track but i can't quite tell

dawn berry
#

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

void fable
#

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

dawn berry
#

require_var_positional = True doesn't work when I use commands.Greedy

#

why?

cyan quail
#

(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

heavy ibex
#
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?

full basin
#

select.values[0]

heavy ibex
dawn berry
cyan quail
dawn berry
#
@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

heavy ibex
#

how do i get the display username of the user who interacts with a button/select?

full basin
#

display_name

heavy ibex
young bone
#

interaction.user

heavy ibex
#

ty

cyan quail
#

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

errant craneBOT
#

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:```
dawn berry
cyan quail
#

all good

#

as a current workaround you could just raise commands.MissingRequiredArgument(...) yourself if your guilds argument is empty

dawn berry
#

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

wooden zenith
#

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()

dawn berry
#

Giving a user premium?

wooden zenith
#

yes its a role i have in my server

dawn berry
#

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

wooden zenith
#

ik

#

i like having the password tho

dawn berry
#

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

wooden zenith
#

im confused

#

af @dawn berry

#

where do i put thaty in inside of my code

dawn berry
#

Do you know what type hinting is?

wooden zenith
#

not really no im new to this codeing stuff

dawn berry
#

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

silver moat
dawn berry
#

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

silver moat
dawn berry
#

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

wooden zenith
#

Okay thanks a lot @dawn berry

shy crow
#
    @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?
stable salmon
#

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!")
young bone
stable salmon
#

ho okay thank you, is it normal that this isn't in the guide?

young bone
#

its the same in cogs

stable salmon
#

okay, thank you very much 🛐

sweet tiger
#

how would I add a description to a slash command option (like the one below)

rare ice
sweet tiger
#
discord.Option(str, description="Description")

?

full basin
#

?tag tias

obtuse juncoBOT
meager mica
#

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

meager mica
#
  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)

silver moat
#

show full requirements.txt?

meager mica
#

py-cord==2.1.1
mcuuid==1.0.1
pymongo==4.2.0
requests==2.28.1
dnspython==2.2.1

humble vortex
#

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

meager mica
#

if you mean message content then i set it to message.clean_content

humble vortex
#

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...

full basin
#

A thread object is indeed returned when you create a thread

prisma flicker
#

Just try await thread.send()

humble vortex
#

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

rugged iris
#

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

prisma flicker
rugged iris
prisma flicker
#

oh are you on the developer portal?

rugged iris
#

yes

prisma flicker
#

interesting

#

I've never seen that screen

rugged iris
#

i have also never seen that what is this?

cyan quail
#

what's the url?

rugged iris
#

cause it works nomrally on my test bot

prisma flicker
#

can you show the whole screen in the screenshot

cyan quail
#

that looks like the slash command prompt not devportal

rugged iris
#

it shows this

#

but that wasnt the case with test bot

prisma flicker
#

oh it's the command window

cyan quail
#

are you an admin in the guild?

rugged iris
prisma flicker
#

oh hey

cyan quail
#

idk can't say im seeing that with my bots

prisma flicker
cyan quail
#

oh nvm misunderstood

cyan quail
#

pycord version?

rugged iris
#

2.1.1

prisma flicker
#

can you try using commands.Bot?

#

and @commands.slash_command

rugged iris
#

so what should be the problem here

cyan quail
#

is that happening in all guilds?

rugged iris
cyan quail
# rugged iris yes

can you actually use the commands if you type the name in, instead of clicking the bot?

#

might be solely a client issue

rugged iris
cyan quail
#

no you can still specify which bot

rugged iris
cyan quail
#

what about on mobile?

#

if you can test that

rugged iris
cyan quail
#

then yeah some weird client issue, don't think we can do much about it

prisma flicker
#

update and restart your device

#

try the browser if you're using the app or vice versa

rugged iris
prisma flicker
#

you sure your commands are registering?

rugged iris
#

from my account only

prisma flicker
#

wdym kinda

rugged iris
cyan quail
#

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

cyan quail
#

i guess? don't know what the cause is but idk maybe it's temporary

#

have you tried restarting?

#

(the bot)

rugged iris
#

nope it doesnt work

cyan quail
#

yeah idk then

#

maybe just sleep it off and it'll be fixed in the morning

#

ez

#

speaking of which it's 6am, bye

rugged iris
#

bye

fervent cradle
#

I have coded afk command i want to add afk command with reason what should i do ?

#

@prisma flicker

#

@grizzled sentinel

prisma flicker
fervent cradle
#

Ok ok

fervent cradle
tiny wagon
#

/ command?

fervent cradle
#

$ command is this

tiny wagon
fervent cradle
#

Yaa

tiny wagon
#

just add a parameter

#

like command(ctx, reason: str)

#

how to add guild roles selector in slash command?

fervent cradle
fervent cradle
#

@tiny wagon

amber shale
#

how to know if an error is Mission Permission or Unknown Ban

#

when printed type both are discord.errors.ApplicationCommandInvokeError

night warren
#

Hi, is there the possibility of restricting an application command to a role instead of restricting it to a permission?

bleak cloud
#

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?

fervent cradle
bleak cloud
#

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

heavy ibex
#

How does overwrites in await guild.create_text_channel work? I can't for the life of me figure it out

empty tree
fervent cradle
#

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)

spiral spruce
#

You can't just use None

#

You should pass a Permissions obj

slender abyss
#
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

rare ice
#
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"![Clock](https://cdn.discordapp.com/emojis/1000911443153146007.webp?size=128 "Clock") 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?
proud pagoda
rare ice
#

oops

young bone
#

isn´t it (self, ctx, error)?

proud pagoda
young bone
#

k

proud pagoda
#

Its just that the self, context, and error objects will be passed in

rare ice
young bone
#

oh

empty tree
#

await ApplicationContext(bot, interaction).invoke(command)

slender abyss
cerulean drum
#

is there no usage attribute for slash command?

empty tree
slender abyss
#

so ig i need to invoke the normal message command then

empty tree
#

yeah

cerulean drum
empty tree
#

application context is usually passed through slash commands

slender abyss
#
cmd_name = bot.get_command('vote')
await Context.invoke(mesg, cmd_name)

like this ?

empty tree
#

you need a context object for bot.invoke

amber shale
#

is there any way to mention slash commands?

empty tree
#

you can get it with await bot.get_context(message)

empty tree
amber shale
#

i mean not using code

slender abyss
empty tree
#

there should be an option to copy its id

amber shale
#

cant find any

empty tree
#

do you have developer mode turned on

amber shale
#

yes

#

559427364644192278, ur id

slender abyss
#
    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
empty tree
amber shale
#

oh

#

thanks 🙂

empty tree
#

np

amber shale
#

</ping:988395626049982554>

empty tree
slender abyss
#

no i did not

empty tree
#

try it with it

slender abyss
#

okay works

empty tree
#

nice

fervent cradle
#

is there anything wrong with this snippet?

prisma flicker
obtuse juncoBOT
#

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.

fervent cradle
#

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^^

prisma flicker
#

Can you send the whole method

rare ice
round rivet
#

discord probably disconnected you while you were trying to update presence

#

I'd just try/except it

rare ice
#

k

fervent cradle
# prisma flicker Can you send the whole method
@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

prisma flicker
fervent cradle
#

yeah

#

bot = discord.Bot(yadayada)

prisma flicker
#

?tag client

obtuse juncoBOT
#
discord.Client # just for events
discord.Bot # events + slash/user/msg commands
commands.Bot # above + prefixed commands
fervent cradle
#

the second one

prisma flicker
#

I use commands.Bot so I'm not sure what's going on

fervent cradle
#

oof

#

Hello what was that method which would try to get, if not in cache fetch?

silver moat
proud mason
cyan quail
#

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)

proud mason
#

I wonder why that isn't documented 🤔

cyan quail
errant craneBOT
#

discord/utils.py line 478

# TODO: Document this```
proud mason
#

Lol

alpine spear
#

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")
prisma flicker
#

make it a variable outside of the method declaration

alpine spear
#

choices?

#

even though its built-in to the command function declaration?

prisma flicker
#

yeah

#

you just say choices = mychoices

#

and then if object == mychoices[1]:

#

or whatever

alpine spear
#

where does mychoices get defined

prisma flicker
#

somewhere else

#

make it a variable outside of the method declaration

alpine spear
# prisma flicker make it a variable outside of the method declaration

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")
obtuse juncoBOT
limber bison
#

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.
errant craneBOT
#

Here's the converters example.

silver moat
#

@limber bison ^

limber bison
#

oh i didnt know that was a thing. tyvm

graceful mortar
#

Hey, is it possible to add the Hide function to a Reply message?

subtle garnet
#

how can i edit a already edited interaction response?

full basin
graceful mortar
#

ok, thx

shadow stratus
#

Options in group command are still not working, even after tried a few updates of pycord

lime lichen
#

is there any reason why client.reload_extention(...) would run without error but not actually work?

lime lichen
serene spindle
#

is there no way to have more than 25 choises/auto complete things in a command option?

lime lichen
#

yes

serene spindle
#

sad

lime lichen
#

truly

serene spindle
#

maybe a selection menu? Or does that also have a 25 limit

lime lichen
lime lichen
#

i know it dosnt, and its not just my code because i changed the response embed color and there was no change

young bone
#

with autocomplete

#

but if you type the stuff it will autocomplete anything

fervent cradle
#

idk why slash commands are not showing in my bot, can someone help

#

i'm using debug_guilds

silver moat
fervent cradle
#

normal commands work fine but slash commands are not shown

prisma flicker
#

do you enable slash commands in your channel permissions?

silver moat
#

also check if "use the legacy chat input" is turned off

prisma flicker
cyan quail
#

yep

prisma flicker
#

interesting

fervent cradle
silver moat
fervent cradle
silver moat
#

under accessibility

fervent cradle
#

it is off

cyan quail
#

it's basically the old chat from way back when chat input didn't have formatting previews

silver moat
fervent cradle
#

i can see other's bots slash commands but not mine

silver moat
#

and also show code

#

restarting your discord client/browser could also help

fervent cradle
#

tried everything

fervent cradle
#

i removed some background tasks which also run when bot's online

cyan quail
#

who in the CHRIST is still teaching people to override on_connect

#

remove that event

fervent cradle
#

okk

silver moat
fervent cradle
cyan quail
#

possibly

#

all good

fervent cradle
#

Thanks

#

i thought there's some problem in my bot lol

fervent cradle
#

is there a way to add all servers the bot is in in slash commands Option or max can be just 25 choices?

prisma flicker
simple canopy
#

may be because i never used it

#

but yes, what

#

said

silver moat
fervent cradle
silver moat
#

definitely didn't spend 3 minutes photoshoping that

simple canopy
young bone
#

time to send a random user id

#

352062534469156864

simple canopy
#

its mine

silver moat
#

#352062534469156864

young bone
#

xd

simple canopy
#

no

#

yes it is

silver moat
#

</gigalegit-:352062534469156864> (raw: </gigalegit-:352062534469156864>)

#

omg it's a slash command

silver moat
#

?tag command-mention

obtuse juncoBOT
#

dynoError No tag command-mention found.

silver moat
#

?tags mention

obtuse juncoBOT
#
Tags (1)

slashcommandmention

silver moat
#

?tag slashcommandmention

obtuse juncoBOT
#

</full name:ID>

errant craneBOT
#

Tag command mention created successfully.

#

</full name:ID>

cyan quail
#

ok how does toolkit not use an autocomplete for that

silver moat
simple canopy
severe comet
#

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

pallid token
#

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

subtle garnet
#

How do i get the name of the command that had a error?

worn void
#

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

errant craneBOT
#
Equivalent to :attr:`User.avatar````
simple canopy
#

its Asset

#

so member.avatar.url

#

not _url

#

it changed in 2.0.0a

worn void
#

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'
simple canopy
#

use display_avatar

#

user can have no avatar basically

worn void
#

ohh

#

so member.avatar.display_avatar?

worn void
#

ye i found it

oak elm
#

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

cyan quail
oak elm
cyan quail
# oak elm

not messages, should be intents.message_content

#

...though that might not be the issue anyway, but worth a try

oak elm
oak elm
#

but there is a breaking change FalseFacePalmLaugh . Is there an alternative solution

cyan quail
#

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

fervent cradle
#

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

silver moat
fervent cradle
#

And as argument I pass the time limit?

#

ctx.defer(15)

silver moat
#

no

#

it extends the time limit to 15 minutes

#

and displays Bot is thinking…

fervent cradle
#

ah

#

thanks

gilded barn
#

im using prefixed commands and sending a command wont give the desired output nor does it give an error??? why is this happening?

fading granite
#

do you use cogs?

gilded barn
fading granite
#

ah then i dont know sorry

fervent cradle
#

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

lean marten
#

How can I disable component interactions after a interaction?

#

🔥 🔥 🔥 🔥 🔥 🔥 🔥 🔥 🔥 🔥 🔥 🔥 🔥 🔥🔥 🔥 .