#Basic Pycord Help (Quick Questions Only)

1 messages · Page 86 of 1

fervent cradle
#

404 in slash command? u mean it didnt reply?

willow kiln
#

this works(in a method)

#

okay i moved it to the top of the method and it works 🤷

#

now im just wondering this

clear vault
#

@grizzled sentinel are u here?

open cove
#

how do i add max length and min length to modal (im stupid and cant find it on docs)

open cove
#

what

#

i want to set it to like 20

#

for max

full basin
#

max_lenght=20?..

open cove
#

oh sh im dumb

#

why am i like this

young bone
#

You should start to use google and read the stuff

open cove
fervent cradle
#

how can i convert this time into a utc timezone discord can process for local time for everyone? 2023-06-24 21:40:13.519874 ive used .timestamp() but that shows 2 hours ago the timestamp is stored without a timezone so in utc

fervent cradle
#

that just converts it to the timestamp format

#

i do that rn with just the timestamp and it shows as 2 hours ago

fervent cradle
grizzled sentinel
#

Can you show the entire function from this code. The only reasons I could see this happening is you never exit the ClientSession. Also explain the purpose of this function. I dont think you generally need to make direct calls with aiohttp in py-cord unless you are trying to get something else.

grizzled sentinel
#

Is that your code that you posted in the message or internal pycord code?

clear vault
grizzled sentinel
#
async with aiohttp.ClientSession() as session:
    try:
        commanduse = discord.Webhook.from_url

Did you write this code or did you find it in pycords files?

grizzled sentinel
fervent cradle
#

well not really no, i cant recreate the db

young bone
fervent cradle
#

no, the time stored is in utc, always, for me right now its 12 am, and utc is 10pm and the bot sends it as if it was 10pm

#

i need to somehow turn it locale independent

grizzled sentinel
#

So you want it to be displayed in UTC?

fervent cradle
#

i want discord to handle the timezone for me, like u do with discord.utils.utcnow() u get the locale independent time

grizzled sentinel
#

So when you say

the bot sends it as if it was 10pm
Do you mean 10pm for you (8pm UTC)

young bone
#
import datetime

now = datetime.datetime.now()
utc = datetime.datetime.utcnow()
hours = now - utc
time = utc + hours
print(time.strftime("%d.%m.%Y, %H:%M:%S"))
```I do it like that
#

But I dont really know if there is a better way @fervent cradle

rough roseBOT
#
Evaluation Result

24.06.2023, 22:12:35

Return Code

0

young bone
#

oof, there is now also utc xd

fervent cradle
#

i managed to fix it, turns out my timezone was not being set after all

weak violet
young bone
grizzled sentinel
#

[Solved] This error is discord side correct? Nothing I did wrong bot side?

#

Or is that the models version of "interaction did not respond"

#

Nevermind, Im not responding

zealous bear
#

404 NOT FOUND Madasf

#

WHY

#

I don't understand. My network connection is fine. My CPU is fine. I don't know what the hell is causing this to happen.

zealous bear
#

I'm defering all commands

#

/ping JUST FAILED HOW

#

the code for that command could not be simpler

#
@bot.slash_command(server_id = server, name = "ping", description = "returns pong")
async def ping(ctx):
    await ctx.defer()
    await ctx.respond("pong!")
fervent cradle
#

is the on_member_join event broken?
all events work but on_member_join dont work on me

young bone
#

Do you have intents?

zealous bear
#

elp

tidal narwhal
#

i used to be able to do bot = discord.Bot() but now it doesnt work?

#

and now slash commands dont work either???

young bone
zealous bear
#

elp!!

weak violet
#

How i can send a message with interaction like a ctx.send? withouth the "respond" ?

zealous bear
# zealous bear

Can anyone help me with this? It's not a network issue. Could it be a code issue?

zealous bear
#

defering just makes sense if i'm having the interactions fail

weak violet
#

remove it and try it without that

zealous bear
#

doesn't help

weak violet
#

you are self hosting it?

zealous bear
#

yes but it is not a network issue i have very low ping

#

I don't know how to fix this and i've been trying for days

weak violet
#

Hmm, you are using the bot in multiples servers?

#

like for using server_id

zealous bear
weak violet
zealous bear
#

its almost like random

weak violet
#

honestly i dont have any idea why is failling or lagging, is just a simple 3 line comand that responde "pong"

zealous bear
#

RIGHT??

#

I CAN'T FIGURE IT OUT AND LIKE ALL OF MY COMMANDS RANDOMLY FAIL

weak violet
#

you only have the py-cord lib installed?

#

or u have multiple version of it?

zealous bear
#

aiohttp 3.8.4
aiosignal 1.3.1
aiosqlite 0.19.0
async-timeout 4.0.2
attrs 23.1.0
autocorrect 2.6.1
boto3 1.26.140
botocore 1.29.140
cachetools 5.3.1
certifi 2023.5.7
charset-normalizer 3.1.0
components 1.2.8
discord 2.3.0
discord.py 2.3.0
distlib 0.3.6
ffmpeg-python 0.2.0
filelock 3.12.0
frozenlist 1.3.3
future 0.18.3
google-api-core 2.11.0
google-api-python-client 2.88.0
google-auth 2.19.0
google-auth-httplib2 0.1.0
google-cloud-language 2.9.1
googleapis-common-protos 1.59.0
grpcio 1.54.2
grpcio-status 1.54.2
httplib2 0.22.0
humanize 4.6.0
idna 3.4
imageio-ffmpeg 0.4.8
iniconfig 2.0.0
jmespath 1.0.1
multidict 6.0.4
nodejs 0.1.1
numpy 1.24.3
optional-django 0.1.0
packaging 23.1
pip 23.1.2
platformdirs 3.5.1
pluggy 1.0.0
proto-plus 1.22.2
protobuf 4.23.2
py-cord 2.4.1
pyasn1 0.5.0
pyasn1-modules 0.3.0
pycryptodome 3.18.0
pyparsing 3.0.9
pyspellchecker 0.7.2
pytest 7.3.1
python-dateutil 2.8.2
python-twitch-client 0.7.1
requests 2.31.0
rsa 4.9
s3transfer 0.6.1
secret 0.8
setuptools 67.8.0
six 1.16.0
tabulate 0.9.0
twitchAPI 3.11.0
typing_extensions 4.5.0
uritemplate 4.1.1
urllib3 1.26.16
virtualenv 20.23.0
wheel 0.40.0
wordninja 2.0.0
yarl 1.9.2

weak violet
#

uninstall discord.py, discord and py-cord and just install py-cord

#

and try it

zealous bear
#

how does it keep getting there

weak violet
#

maybe something else install it

zealous bear
#

alright how the fuck do i get rid of this

#

because it shows up every time i open terminal

weak violet
#

try to run the command that say in the third line

opal flax
#
Traceback (most recent call last):
  File "/home/adit/Coding/Bot/Discord/ditttt-bot/commands/normal/mods.py", line 30, in addrole
    await member.add_roles(*role, reason=f'add role by {ctx.author} | {reason}')
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: discord.member.Member.add_roles() argument after * must be an iterable, not Role``` why can this be like this? ```py
@commands.command()
    async def addrole(self, ctx, role: discord.Role, member: discord.Member, *, reason):
        try:
            await member.add_roles(*role, reason=f'add role by {ctx.author} | {reason}')
        except:
            traceback.print_exc()
        else:
            await ctx.send(
                embed=discord.Embed(
                    description=f"managed to add role {member.mention}".title(),
                    color=ctx.author.color,
                )
            )```
zealous bear
#

not install it or whatever

weak violet
zealous bear
#

uninstalled everything and reinstalled

#

we'll see

weak violet
#

kk

zealous bear
#

but i don't trust it hehHehCry

weak violet
#

lmao

#

its working now?

zealous bear
#

yes it seems to be working, no commands have failed

#

yet i'm getting that error message in my terminal

zealous bear
#

im about to just give up on bots man

weak violet
#

whats the error in console?

zealous bear
# weak violet whats the error in console?

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/discord/client.py", line 378, in _run_event
await coro(*args, **kwargs)
File "/Users/jef/Desktop/employee.py", line 658, in on_application_command_error
raise error
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/discord/bot.py", line 1114, in invoke_application_command
await ctx.command.invoke(ctx)
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/discord/commands/core.py", line 375, in invoke
await injected(ctx)
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/discord/commands/core.py", line 132, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: NotFound: 404 Not Found (error code: 10062): Unknown interaction

#

but its happening even when the actual commands aren't failing

zealous bear
zealous bear
#

reason was because i had two instances of the bot running 😂

#

what command handler should i be using for that error?

#

so that it sends a message telling the user to rerun the command

#
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/discord/commands/core.py", line 124, in wrapped
    ret = await coro(arg)
          ^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/discord/commands/core.py", line 982, in _invoke
    await self.callback(ctx, **kwargs)
  File "/Users/jef/Desktop/employee.py", line 466, in join
    await ctx.respond(f"{ctx.author.mention} has joined the PvP battle!")
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/discord/commands/context.py", line 282, in respond
    return await self.interaction.response.send_message(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/discord/interactions.py", line 825, in send_message
    await self._locked_response(
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/discord/interactions.py", line 1090, in _locked_response
    await coro
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/discord/webhook/async_.py", line 219, in request
    raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/discord/client.py", line 378, in _run_event
    await coro(*args, **kwargs)
  File "/Users/jef/Desktop/employee.py", line 656, in on_application_command_error
    raise error
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/discord/bot.py", line 1114, in invoke_application_command
    await ctx.command.invoke(ctx)
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/discord/commands/core.py", line 375, in invoke
    await injected(ctx)
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/discord/commands/core.py", line 132, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: NotFound: 404 Not Found (error code: 10062): Unknown interaction```
#

That is the typical error that I get when one of my slash commands fail

#

if anyone could help me i would appreciate that so much 😭

#

I need The Bob to help me

#

if i ping him i'll probably get banned though

silver moat
#

try using python 3.10?

zealous bear
silver moat
#

potientially?

zealous bear
#

😭

zealous bear
zealous bear
#

i've even searched through many of the #969574202413838426 posts similar to mine

silver moat
#

I only use 3.10 because some of my packages don’t support 3.11 yet.

zealous bear
# zealous bear also wondering this
@bot.event
async def on_command_error(ctx, error):
    if isinstance(error, commands.errors.CommandInvokeError) and isinstance(error.original, discord.errors.NotFound):
        await ctx.send("I'm sorry, this command failed. Please run it again.", ephemeral=True)
#

currently

#

and it doesn't work

silver moat
#

it should be on_application_command_error

zealous bear
#

Ah

#

Thanks

#

I really need to sleep so I will try downgrading tmr

somber pelican
#

The user will probably know to use the command again

river void
#

I cant edit

#

wait im an idiot

#

After:

author: Member | User = user
#

What specific things would I have to complete for this change to be accepted? I am brand new to contributing to other projects like this on GitHub and I dont want to waste other peoples time with trial and error trying to get it right

spring hare
#

What change?

river void
#

Litterally just adding typehinting to the author

spring hare
#

Isn't author is already typehinted?

river void
#

no

spring hare
#

Where?

river void
#

Line 212 in context.py in commands

spring hare
river void
#

i'm so confused

#

wait

#

Figured it out

spring hare
#

I think user is already typehinted so additional typehinting is not needed

spring hare
#

Yup, user is already typehinted

river void
#

The reason that I am trying to add typehinting is without it pycharm kinda just doesn't recognise that the author is an instance of Member or User and throws all kinds of errors when I add proper doccumentation.

#

I'l get screenshots to show what I mean

#
"""
    The trade command for the bot. Allows users to trade with other users.

    Args:
        ctx (ApplicationContext): The context of the command
        user (User): The user to trade with
        item (int): The item to trade
        amount (int): The amount of the item to trade
        cost (int): The payment for the trade
    """
#

And if I add typehinting to author the warning disapears

#

And without typehinting code complete does not work at all

spring hare
#

Hm... Odd

river void
#

Yeah, I added the correct typehinting to it locally and it completely fixes the issue.

#

I don't see this breaking anything and while it may be a little verbose it does make the code more readable (especially for new contributors like me).

alpine spear
#

ignore

river void
#

Anyways how on earth would I actually get this change included?

river void
#

what

alpine spear
#

i'm trying load cogs to my main program, but i'm having some issues along the way
the picture is the lines i use to load the extension, and i'm using the filename as i'm meant to. i've correctly used setup to load the cog in the bot file as well

silver moat
# river void what

you can do something like

assert isinstance(ctx.author, discord.Member)
alpine spear
spiral spruce
river void
#

I have already fixed it on my local copy of the package just by changing one line to author: Member | User = user

spiral spruce
#

if it ends with bot.py, remove the .py and load it

alpine spear
spiral spruce
#

remove the .py

#

python does the rest

#

I mean, to import from a file called bot.py, you do import bot

#

not import bot.py

#

so the name of the module becomes bot

alpine spear
#

is there another method to check for the whole name of the file? i'm not familiar with listdir and what it returns

alpine spear
spiral spruce
#

sure

silver moat
spiral spruce
#

if the file has that import, you can use |

#

else you can add it yourself

clear vault
drowsy hound
#

Thanks

solemn idol
drowsy hound
#

is it against terms of use to save all messages received in a database?

grizzled sentinel
# clear vault I wrote it

Can you show the function that it is in. The code above and below that bit of code that your wrote.

fervent cradle
#

how can I wait for a message in a callback? (I'm subclassing) bec. bot.wait_for("message") don't work

grizzled sentinel
#

Did you use a check? A message sent anywhere would trigger the wait_for to stop waiting

grizzled sentinel
#

Try adding a check that only returns true if it is in the same channel and/or author. Or whatever you need

fervent cradle
#

now I have one, but I still can't use the bot attribute, because I'm in a subclass

#

the problem is that I'm in a button callback in a view class and in there I don't have a bot object

#

you know what I mean?

fervent cradle
# grizzled sentinel Try adding a check that only returns true if it is in the same channel and/or au...

here is the code:

class ManagePersonalView(discord.ui.View):
    def __init__(self, team, logo, players):
        super().__init__(timeout=None)
        self.team = team
        self.logo = logo
        self.players = players

    @discord.ui.button(label='Traden', custom_id='player_trading', style=discord.ButtonStyle.blurple, emoji='🤝')
    async def player_trading_callback(self, button, interaction):
        em = discord.Embed(title='Spielerliste wird Generiert...' , color=discord.Color.red())
        await interaction.response.edit_message(embed=em, view=None)
        pages = []
        description = ''

        for index, player in enumerate(self.players):
            description += f"{index + 1}. {player}\n"

            if (index + 1) % 10 == 0:
                embed = discord.Embed(title='Spielerliste', description=description, color=discord.Color.green())
                pages.append(Page(embeds=[embed]))
                description = ''

        if description != '':
            embed = discord.Embed(title='Spielerliste', description=description, color=discord.Color.green())
            pages.append(Page(embeds=[embed]))

        print(pages)
        paginator = Paginator(pages=pages)
        paginator.custom_view = NewTradingPlayerView(self.players)
        paginator.remove_button("first")
        paginator.remove_button("last")
        await paginator.respond(interaction, ephemeral=True)

        def check(message):
            return message.author == interaction.user and message.channel == interaction.channel and message.content.isnumeric()

        user_input = await bot.wait_for(event='message', check=check, timeout=60)
        print(user_input.content)
grizzled sentinel
#

The way I am seeing is you will have to pass bot when creating the view. Im looking if there is another way to access it.

winter condorBOT
proud mason
#

That?

#

That's the bot object

fervent cradle
#

Thanks

hearty gorge
#

Hello, I have a small bot working that edit_message with a unique embed depending on which Select Menu option is clicked via a callback (menu and embed are in the same message). However, after clicking an option in the menu the visible selection clears. Is there a way to keep the selection visible after an edit?

fervent cradle
#
msg =  await interaction.response.send_message(embed=emb)

as I understood right msg is the interaction object, right?

but how can I geht the discord.Message object of the interaction message?

proud mason
#

.rtfm interaction.original_response

winter condorBOT
proud mason
#

Await it btw

fervent cradle
#
Ignoring exception in view <ManagePersonalView timeout=None children=4> for item <Button style=<ButtonStyle.primary: 1> url=None disabled=False label='Traden' emoji=<PartialEmoji animated=False name='🤝' id=None> row=None>:
Traceback (most recent call last):
  File "C:\Users\Pro 8\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\ui\view.py", line 414, in _scheduled_task
    await item.callback(interaction)
  File "C:\Users\Pro 8\Documents\Programmieren\Discord Bots\ZZGamesucht\football-minigame\cogs\management.py", line 481, in player_trading_callback
    await paginator.edit(await interaction.original_response())
  File "C:\Users\Pro 8\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\ext\pages\pagination.py", line 1073, in edit
    self.message = await message.edit(
                         ^^^^^^^^^^^^^
TypeError: InteractionMessage.edit() got an unexpected keyword argument 'suppress'
grizzled sentinel
#

Can you show the entire file that

async with aiohttp.ClientSession() as session:
    try:
        commanduse = discord.Webhook.from_url

Is in

grizzled sentinel
clear vault
#

The entire file? Why

fervent cradle
clear vault
#

I guess it’s a file error or smth

grizzled sentinel
clear vault
grizzled sentinel
grizzled sentinel
grizzled sentinel
clear vault
#

I‘ll send u a little bit later. I’m not at home rn

grizzled sentinel
#

Actually I think I found what you would need to do.

msg = await interaction.original_response()
msg = await msg.channel.fetch_message(msg.id)
#

Om said they are fixxing it.

fervent cradle
grizzled sentinel
#

Yeah, should be stable enough for most things rn

fervent cradle
#

Ok

drowsy hound
#

how do I add a discord.ui.Select to a Modal?

young bone
drowsy hound
#

:( can I add anything than an InputText?

young bone
#

At the moment no

#

Only string InputText

drowsy hound
#

ok

#

thanks

grizzled sentinel
#

You can add long/short input text (blobpain modal update when)

drowsy hound
#

I wanted to make an "annonymous: yes/no" selector, but... maybe some day haha

grizzled sentinel
# drowsy hound I wanted to make an "annonymous: yes/no" selector, but... maybe some day haha

This is my code for a t/f selector in a model :(

__init__

self.add_item(
            discord.ui.InputText(
                label="Required", required=True, max_length=1, placeholder="\"t\" (true) or \"f\" (false)"
            )
        )

callback

if self.children[1].value.lower() == "t":
    req = True
elif self.children[1].value.lower() == "f":
    req = False
else:
    return await interaction.response.send_message(embed=await ef.fail("Required Needs To Be Either \"t\" (True) Or \"f\"(False)"), ephemeral=True
            )
drowsy hound
#

that's a nice workaround. Kinda idiot-proof, I'll try it out, thanks

gleaming vortex
#

i have on question to ask:
my bot have about 280 commands
and i put them in the cogs
but... i unregister the all commands
and i restart the bot
and i didn't see the commands in the server app commands
(i restart the bot 2 days ago)

drowsy hound
#

How do I get the user's avatar_url? This way is not working. embed.set_footer(text=f"Done", icon_url=interaction.user.avatar_url)

grizzled sentinel
gleaming vortex
#

didn't get any error

grizzled sentinel
drowsy hound
willow kiln
#

uhhh so my interaction/button code kinda loops or something and i have no idea why, i tried pass at the end but it doesnt work
start is the method/command im calling

gleaming vortex
#

and i checked. the cogs are loaded

grizzled sentinel
willow kiln
#

it keeps going

#

closed the bot cuz you know..

grizzled sentinel
#

Do you override anything like on_interaction?

grizzled sentinel
willow kiln
grizzled sentinel
grizzled sentinel
willow kiln
#

its a test server with only me and a co dev in it, so i highly doubt they are messing with me. only version of it is running in visual studio, will try restarting tho

winter condorBOT
#

Checklist for Application Commands Not Showing Up:
• Does your bot have the application.commands scope?
• Are you loading cogs before on_ready and on_connect?
• Is on_connect not overridden?
• Did you update to the newest version of py-cord (tag: install)?
• Is User Settings > Accessibility > Chat Input > Use legacy chat input turned off?
• Did you share your code and errors?
• Do you still have libraries that conflict with the discord namespace (e.g. discord.py)?

grizzled sentinel
#

@gleaming vortex ^

gleaming vortex
#

OK

grizzled sentinel
drowsy hound
#

can a slash command have choices? e.g.: a field that can take only 2 values, "yes" or "no"

willow kiln
#

sounds like you want a bool

drowsy hound
#

not a bool, just constrained options, like "red", "green" or "blue"

fervent cradle
#

I have a problem. I updated to Development Version of Pycord and I have a paginator with a select menu. But when I select something in the menu nothing happens. Even the callback function don't get executed why?

this is a code snipped of the view class:

class NewTradingPlayerView(discord.ui.View):
    def __init__(self, players):
        super().__init__(timeout=None)
        self.players = players

    options = [
        discord.SelectOption(label='Alle', value='all'),
        discord.SelectOption(label='Sturm', value='sturm'),
        discord.SelectOption(label='Mittelfeld', value='mittelfeld'),
        discord.SelectOption(label='Abwehr', value='abwehr'),
        discord.SelectOption(label='Torwart', value='torwart')
    ]

    @discord.ui.select(placeholder='Filter', custom_id='select_player_filter', options=options)
    async def select_filter_callback(self, select, interaction):
        emb = discord.Embed(title='Spielerliste', color=discord.Color.green())
        pages = []
        description = ''
        print("Select")

and this is a code snipped of the code where I send the paginator:

        paginator = Paginator(pages=pages)
        paginator.custom_view = NewTradingPlayerView(self.players)
        paginator.remove_button("first")
        paginator.remove_button("last")

        print("Embeds")
        print(pages[0].embeds[0].description)
#

I don't get any errors and discord just said that the interaction was failed

grizzled sentinel
drowsy hound
grizzled sentinel
#
async def create(self, ctx, name: discord.Option(str, description="The Name For This Survey", max_length=64, required=True)):

This is a option. It allows you to modify how each argument in the slash command works. There is a kwarg called choices that you can pass a list to.

#

.rtfm discord.Option

zealous bear
willow kiln
#

other, hopefulyl easier question, anyone experienced with custom discord presence? so far had Playing ... but want to do smth custom

somber pelican
zealous bear
trim cipher
#

hi! I came back to discord bot development after a long time. I had a discord bot which worked fine and I used the same code for a new bot. as soon as I ran the bot, it showed me this error. anyone has any idea why did this happen and how could I fix it? I never got this issue anytime before.

grizzled sentinel
# drowsy hound nope. Isn't that for optional input?

This is a option that uses choices (sorry for spacing)

Option(str, description="How Should The Results Be Grouped",
                choices=[
                    discord.OptionChoice("By Template", "0"),
                    discord.OptionChoice("By Instance", "1"),
                    discord.OptionChoice("By User", "2"),
                ],
                required=False,
                default="0",
            )
drowsy hound
#

ohhh ok, i get it now

grizzled sentinel
gleaming vortex
trim cipher
grizzled sentinel
trim cipher
#

it has applications.commands scope and i have not installed discord.py or any other lib

grizzled sentinel
#

I meant that for someone else but i guess it is relevent to you as well 🙃

trim cipher
#

oh

gleaming vortex
fervent cradle
#

Yeah

grizzled sentinel
grizzled sentinel
trim cipher
gleaming vortex
#

that confused me

#

and i not have the way to fix it

#

cry

grizzled sentinel
#

could you show the file that has bot.run()

grizzled sentinel
#

I want to see how you load your cogs

gleaming vortex
#

ok wait me

gleaming vortex
# grizzled sentinel I want to see how you load your cogs
COG_FILE_COMMAND_LIST = [
    "group-command",
    "slash-command",
    "message-command"
]
cogs_count = 0
for i in COG_FILE_COMMAND_LIST:
    for filename in os.listdir(f"./Cogs/commands/{i}"):
        if filename.endswith('.py'):
            bot.load_extension(f"Cogs.commands.{i}.{filename[:-3]}")
            print(f"【INFO】-【COG-commands】- 已載入【count: {cogs_count}】【{filename[:-3]}】")
            cogs_count += 1
grizzled sentinel
#

2 More things, try restarting your discord. (It is possible it is a visual bug in the discord client)
Try starting the bot without any cogs loaded. Than start it agian with the cogs loaded.

fervent cradle
#

I also had the problem one time. I kicked the bot out of my guild and reinvited it. If that don't work, try to reset my token. That also worked for me

proud mason
#

And I've also made a pr to avoid fetching the message

#

Oh wait just realised that was an old message

gleaming vortex
fervent cradle
fervent cradle
proud mason
trim cipher
proud mason
fervent cradle
grizzled sentinel
# trim cipher welp!

The bot does not have permission to create slash command in one of the guilds it is in. Ensure your bot is still in all of the guilds that you specify a guild_id for

trim cipher
#

ohhk

gleaming vortex
gleaming vortex
#

QAQ

grizzled sentinel
gleaming vortex
#

ok .w.

proud mason
#

You could force a sync by calling await bot.sync_commands() inside a prefix cmd

gleaming vortex
#

it works !!!!

#

thank you for your help: @proud mason @grizzled sentinel
thanks a lot

grizzled sentinel
#

👍

fervent cradle
#

bro how can i make that an embed has a random color??

proud mason
#

.rtfm colour.rand

winter condorBOT
proud mason
#

That

fervent cradle
#

hmm

proud mason
#

Call the function

fervent cradle
#

?

proud mason
#

colour=discord.Colour.random()

Add the ()

fervent cradle
#

bruh

#

my bad

#

thx

proud mason
#

Np

fervent cradle
#

.rtfm member author url

fervent cradle
#

.rtfm member author icon

proud mason
#

#app-commands or #883236900171816970 please

fervent cradle
#

okay

#

sorry

proud mason
#

No worries

fervent cradle
#

help?

proud mason
#

?tag intents

obtuse juncoBOT
#

https://docs.pycord.dev/en/master/intents.html
https://discord.com/developers/docs/topics/gateway#gateway-intents

import discord
from discord.ext import commands

# Get specific intents for fine control
intents = discord.Intents()
intents.emojis = True
intents.guilds = True
intents.messages = True  # Required for prefix commands!
...
# Get all non-priveliged intents; this excludes presences, members and message_content 
intents = discord.Intents.default()

# Set priveliged intents: these must be enabled on dev portal
intents.members = True
intents.presences = True
intents.message_content = True  # Required for prefix commands >= 2.0.0b5

# Get all intents; all intents must be enabled on dev portal.
intents = discord.Intents.all()

# Apply intents when creating your bot
bot = commands.bot(prefix="?", intents=intents)
Discord Developer Portal

Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.

proud mason
#

You need message content intents

fervent cradle
#

i have it on

#

bruh

#

on an other bot i have this intents only and it works too

#

but on this bot not

proud mason
#

How do you pass the intents?

fervent cradle
#

and it dont work anyway

solemn idol
#

try only doing the default intents and then the other intents you put below the top line

fervent cradle
#
@client.event
async def on_message(message):
    if message.channel.id == int(get_config("Feedback_Channel")):
        if message.author.bot == True:
            pass
        else:
            embed = discord.Embed(title="\✨ New Feedback", description=f"{message.content}", color=discord.Colour.random())
            embed.set_author(name="Pure Services", icon_url="https://colin.isfucking.pro/7tApHe.gif")
            embed.set_footer(text=f"Feedback from {message.author.name}", icon_url="https://colin.isfucking.pro/7tApHe.gif")
            embed.set_thumbnail(url=message.author.avatar.url)
            await message.delete()
            await message.channel.send(embed=embed)```
coarse spire
fervent cradle
#

yes

solemn idol
#

hmm

coarse spire
#

so something like: client = discord.Bot(intents=intents)?

fervent cradle
#

yes

#

bruh mb

coarse spire
#

hmm

solemn idol
#

?

#

what

#

did you or did you not?

fervent cradle
#

it works now

#

i did not befroe

solemn idol
#

thinkCat ... and why?

fervent cradle
#

forgot

solemn idol
#

🥹

fervent cradle
clear vault
#

@grizzled sentinel May i ask why u need the code

zealous bear
#
@bot.listen()
async def on_application_command_error(ctx: discord.ApplicationContext, error: discord.NotFound):

    if isinstance(error, discord.ApplicationCommandInvokeError):
        await ctx.respond("I'm sorry, this command failed. Please run it again.", ephemeral=True)
    else:
        raise error
#

Does anyone know to make this work

#

for the 404 interaction not found error

somber pelican
#

itll only execute if both of those conditions are true

#

should be applicationcommandinvokeerror

zealous bear
#

looking better?

somber pelican
#

yeah

#

oh my i got upvoted how flattering :O

proud mason
#

it might actually be discord.ApplicationCommandInvokeError

zealous bear
#

W

proud mason
#

oh it works?

#

.rtfm ApplicationCommandInvokeError

proud mason
#

yea

zealous bear
#

i'll try that

#

now i need to sit and wait for one of my commands to fail! KermitSatisfiedStare

#

won't take long at all

proud mason
#

error: discord.NotFound uh

zealous bear
#

im still so pissed off by this happening all the time PepeDespairge

zealous bear
#

hold on hold on hold on
if my commands fail the first time someone uses them if nobody uses them for a while
the solution is to have people constantly using my commands!

zealous bear
#

HOW CAN THAT COMMAND FAIL

#

ITS THE SIMPLEST CODE EVER

proud mason
#

it should be Exception

zealous bear
#

error: Exception.NotFound?

proud mason
#

error: Exception because that function is called for any error

#

not just discord.NotFound

zealous bear
#

OH

#

okay

zealous bear
#
@bot.listen()
async def on_application_command_error(ctx: discord.ApplicationContext, error: Exception):

    if isinstance(error, discord.ApplicationCommandInvokeError):
        await ctx.respond("I'm sorry, this command failed. Please run it again.", ephemeral=True)
    else:
        raise error
#

discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: NotFound: 404 Not Found (error code: 10062): Unknown interaction

zealous bear
#

Do you have any clue what could keep bringing discord.py into my system

#

I am not pip installing it

#

Okay well this happened when i didn't have discord.py installed

cyan quail
#

if it's not firing the error handler then the error didn't originate from a command

#

more specifically, the random NotFound on interactions likely can be neither caught nor responded to

zealous bear
#

from happening

zealous bear
#

most of the time they happen the first time that i run an interaction after a couple minute period of not running an interaction

cyan quail
#

if you're consistently getting notfound then that's a structural problem with your code that you should aim to fix

zealous bear
#

it should fix?]

cyan quail
#

well no, by structual i mean that you're not dealing with interactions properly which causes issues

#

all interactions have to be responded to (or deferred) within 3 seconds, and interaction tokens only last for 15 minutes (for followup etc.)

zealous bear
#

could you explain the proper way?

zealous bear
#

none of that applies (i think)

#

and yet it fails

cyan quail
#

you sure there's no network issues?

zealous bear
#

i have like 23 ping

#

and good solid internet

cyan quail
#

well ping is cool and all, but consistency is more relevant here

zealous bear
#

yes, my internet is consistent

cyan quail
#

you don't have any extra listeners for interactions? any potentially blocking code?

zealous bear
#

i don't think there is blocking code

#

i'm not using requests

#

my only @bot.event(s) are on_ready and on_shutdown

cyan quail
#

....fwiw, on_shutdown doesn't exist

zealous bear
#

meh okay that's fine

cyan quail
#

hmm

zealous bear
#

its not causing the problems

#

its been happening way before i added a non existent event PepeLaughing

#
@bot.event
async def on_shutdown():
    print('Shutting down...')
    save_task_states()
    await bot.close()

KEKW

cyan quail
#

i mean if it was a lib issue it would have been stamped out long ago, only you'd be able to narrow it down

zealous bear
#

it's extremely infuriating

zealous bear
#

i would offer to send my code but it is 1000 lines of stuff and that is just not fun for you

fervent cradle
#

@proud mason ur PR is done now?

zealous bear
#

elp

fervent cradle
#
        m = await ctx.interaction.original_response()
        msg = await m.channel.fetch_message(m.id)``` so instead of fetching it i can pass in just m
solemn idol
young bone
fervent cradle
#

yes but i dont need to do the extra steps

#

wait no

#

cant i just directly assign the m variable to await ctx.respond

zealous bear
willow kiln
#

does anyone know what interaction is below the surface here? cuz i for some reason cant use ctx.respond in one specific method but also cant put interaction in its args as else it would just be picked up/required in the / command

young bone
#

Interaction

zealous bear
#

@cyan quail did anything come to mind on what my issue is or should I ask someone else

proud mason
trim condor
#

how are people doing end-to-end tests with their discord bots? i’ve tried even just testing at the command level, but the decorators change things in weird ways that’s hard to reason about (e.g. you can’t just run the function for a slash command in a test, because you get an error about self being a _MissingSentinel object)

zealous bear
#

and install 3.10?

uncut current
#

really quick question, why does am I not allowed naming my command ban but I am allowed to name it "test"

Traceback (most recent call last):
  File "F:\NigDiscord\main.py", line 34, in <module>
    @client.slash_command(name = "ban", description = "bans a user that is not on this server")
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "F:\NigDiscord\venv\Lib\site-packages\discord\bot.py", line 931, in decorator
    self.add_application_command(result)
  File "F:\NigDiscord\venv\Lib\site-packages\discord\bot.py", line 127, in add_application_command
    command._set_cog(None)
  File "F:\NigDiscord\venv\Lib\site-packages\discord\commands\core.py", line 603, in _set_cog
    self.cog = cog
    ^^^^^^^^
  File "F:\NigDiscord\venv\Lib\site-packages\discord\commands\core.py", line 830, in cog
    self._validate_parameters()
  File "F:\NigDiscord\venv\Lib\site-packages\discord\commands\core.py", line 708, in _validate_parameters
    self.options: list[Option] = self._parse_options(params)
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "F:\NigDiscord\venv\Lib\site-packages\discord\commands\core.py", line 768, in _parse_options
    _validate_names(option)
  File "F:\NigDiscord\venv\Lib\site-packages\discord\commands\core.py", line 157, in _validate_names
    validate_chat_input_name(obj.name)
  File "F:\NigDiscord\venv\Lib\site-packages\discord\commands\core.py", line 1875, in validate_chat_input_name
    raise error
discord.errors.ValidationError: Command names and options must follow the regex \"^[-_\w\d\u0901-\u097D\u0E00-\u0E7F]{1,32}$\". For more information, see https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-naming. Received "User ID"
full basin
#

What's your pycord version

zealous bear
#

hmmm

trim condor
# full basin What's your pycord version

i’m on 2.4.1 - this is when I’m running it from a unit test though, if that changes things. so I’m calling from my test a function that is decorated with @commands.slash_command in a cog

young bone
#

That is the py-cord version

trim condor
#

I was asked what the pycord version was?

#

🤔

young bone
#

Python

trim condor
#

I’m 3.10.6 for python

young bone
#

Do you have any other version installed?

zealous bear
#

aw man are those not avaliable on 3.10?

trim condor
#

ah no you’re confusing me with someone else, or I confused you 😂

#

I’m the one with the testing thing, talking to @full basin, @jef is asking about something python version related 😂

zealous bear
#

yes

#

i downgraded to 3.10 because @squ1d.dev suggested it

#

now i'm getting those cute errors

spring hare
#

redownload packages/libs?

zealous bear
spring hare
#

Are you sure, you are using right venv?

zealous bear
#

i have no venv

spring hare
#

tf?

zealous bear
#

tehe

spring hare
trim condor
#

get a venv for the love of god please 🙂

zealous bear
zealous bear
spring hare
#

please, use venv

#

That's why you have these errors

trim condor
#

python -m venv venv && source venv/bin/activate && pip install -r requirements.txt && pip show py-cord

spring hare
#

shadow wizard money gang

zealous bear
#

should i uninstall like all the global shit

trim condor
#

dont worry about that, it’ll override when your venv works

zealous bear
trim condor
#

you just run this at a terminal. not sure what you mean by naming it, like the directory where the binaries and pkgs are stored? if so, it’s the second “venv” argument

zealous bear
#

i'll just look up how to do it so i dont fuck up

#

thank you though Heart

trim condor
#

yeah venv will set you straight!

zealous bear
#

well maybe it will magically fix my errors but i doubt it

#

its good to have anyway :)

zealous bear
#

that should do it right?

#

like if i run that in the VSC terminal when i'm inside my bot's folder @trim condor ?

proud mason
#

Also, windows or Mac/Linux?

zealous bear
#

Mac

#

M1 chip

#

(dont know if thats relevant)

proud mason
#

Sepcific the python version when using pip

zealous bear
#

okey

proud mason
#

python3.10 -m pip install ...

proud mason
zealous bear
zealous bear
proud mason
#

What python3 points to. It could be 3.11

spring hare
proud mason
#

Run python -V

zealous bear
zealous bear
proud mason
proud mason
zealous bear
#

Python3 -V

#

gets me Python 3.10.0

#

because you have to use python3 on mac

#

as the command

proud mason
#

That's a pretty old 3.10 version tbh

zealous bear
#

@squ1d.dev

#

Suggested it

proud mason
#

And what does python3.10 -V return

zealous bear
proud mason
#

I mean use 3.10.8 or later

zealous bear
#

i should just use the most recent i don't think downgrading will help

#

whats the most recent like "supported" version

proud mason
#

3.11.4 or 3.10.12

zealous bear
#

okay ill do 3.11.4

proud mason
#

Was there a reason why squid asked you to downgrade

zealous bear
#

interactions constantly failing

proud mason
#

Oh right that issue

zealous bear
#

so what's the command for the venv? i'm on 3.11.4 now, and want to name the venv for this bot "employeenv"

zealous bear
#

maybe a proper venv will help it

proud mason
#

Ig

zealous bear
#

RAHHH

#

Here's how you can setup a virtual environment in Visual Studio Code for Python.

▶ Master the Python language in less than a month:
https://www.udemy.com/course/the-complete-guide-to-mastering-modern-python/?referralCode=CC9D7387F065F70EBC23

▶ Follow me on Instagram:
https://www.instagram.com/indentlyreels

▶ Join the chat on Discord:
https:/...

▶ Play video
#

im watching this shit

#

and i combined that with what jroes suggested

#

python3 -m employeenv .venv && pip install -r requirements.txt && pip show py-cord

#

and ended up with that hehHehCry

#

shoot

#

how do i delete a venv

#

@trim condor

#

hey so i have a venv now

#

but

#
-ERROR: Could not open requirements file: [Errno 2] No such file or directory: 'requirements.text'
#

did i need to make a requirements.txt file or something?

#

elp meh

#

i should just do it manually!

#

done

#

should i be creating a virtual enviroment for all of my bots?

silver moat
#

it's a good practice to do so for all projects

zealous bear
#

hi okay

zealous bear
silver moat
#

idk what pm2 is

zealous bear
#

okay ignore that part

#

how do i run something in a venv

silver moat
#

lemme make sure: I have an answer, but not 100% sure

zealous bear
#

okey!

silver moat
#

yeah should just be venv/bin/python

zealous bear
silver moat
#

uninstall discord, discord.py and just install py-cord

zealous bear
#

okkk

zealous bear
#

aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host discord.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)')]

now there's this bruh

#

i've gotten it before

silver moat
zealous bear
#

ye hold on i remember how to fix

#

its mac specific

silver moat
#

Under application

#

there's Python 3.10

#

then open "Install Certificates.command"

zealous bear
#

yep

#

i did it and am still getting the error?

#

should i restart my mac

silver moat
#

maybe

trim condor
#

@zealous bear to delete your venv just rm -rf venv

#

oh sorry I’m late, just catching up

zealous bear
#

what the hell

#

does it have to do with my venv?

#

full traceback

#

thank you @silver moat , how did you get the token?

silver moat
#

it was in the traceback

zealous bear
#

shoot

#

oh man it was

#
    return future.result()
  File "/Users/jef/Desktop/EmployeeBot/.employeenv/lib/python3.10/site-packages/discord/client.py", line 696, in runner
    await self.start(*args, **kwargs)
  File "/Users/jef/Desktop/EmployeeBot/.employeenv/lib/python3.10/site-packages/discord/client.py", line 659, in start
    await self.login(token)
  File "/Users/jef/Desktop/EmployeeBot/.employeenv/lib/python3.10/site-packages/discord/client.py", line 515, in login
    data = await self.http.static_login(token.strip())
  File "/Users/jef/Desktop/EmployeeBot/.employeenv/lib/python3.10/site-packages/discord/http.py", line 418, in static_login
    data = await self.request(Route("GET", "/users/@me"))
  File "/Users/jef/Desktop/EmployeeBot/.employeenv/lib/python3.10/site-packages/discord/http.py", line 283, in request
    async with self.__session.request(
  File "/Users/jef/Desktop/EmployeeBot/.employeenv/lib/python3.10/site-packages/aiohttp/client.py", line 1141, in __aenter__
    self._resp = await self._coro
  File "/Users/jef/Desktop/EmployeeBot/.employeenv/lib/python3.10/site-packages/aiohttp/client.py", line 536, in _request
    conn = await self._connector.connect(
  File "/Users/jef/Desktop/EmployeeBot/.employeenv/lib/python3.10/site-packages/aiohttp/connector.py", line 540, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "/Users/jef/Desktop/EmployeeBot/.employeenv/lib/python3.10/site-packages/aiohttp/connector.py", line 901, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
  File "/Users/jef/Desktop/EmployeeBot/.employeenv/lib/python3.10/site-packages/aiohttp/connector.py", line 1206, in _create_direct_connection
    raise last_exc
  File "/Users/jef/Desktop/EmployeeBot/.employeenv/lib/python3.10/site-packages/aiohttp/connector.py", line 1175, in _create_direct_connection
    transp, proto = await self._wrap_create_connection(
  File "/Users/jef/Desktop/EmployeeBot/.employeenv/lib/python3.10/site-packages/aiohttp/connector.py", line 982, in _wrap_create_connection
    raise ClientConnectorCertificateError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host discord.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)')]```
#

ait that's better

#

no clue why that's happening

young bone
#

oh you get the SSL Error

zealous bear
#

yeah and i tried running the Install Certificates.command

#

didn't work

#

elp

silver moat
zealous bear
#

oooh okey

zealous bear
#

fixed it

#

thanks squid

silver moat
#

i didn’t do anything but yay

zealous bear
#

this server should integrate a thank you system

#

where you can thank people and it keeps track of who has the most thanks and there are rewards

#
@bot.listen()
async def on_application_command_error(ctx: discord.ApplicationContext, error: Exception):

    if isinstance(error, discord.ApplicationCommandInvokeError):
        await ctx.respond("I'm sorry, this command failed. Please run it again.", ephemeral=True)
    else:
        raise error
#

this still doesn't work PepeSadge

#

and my interactions are still failing PepeSadge

#

and i'm even in a virtual enviroment PepeSadge

#

and this is my pip list PepeSadge

#

aiohttp 3.8.4
aiosignal 1.3.1
aiosqlite 0.19.0
async-timeout 4.0.2
attrs 23.1.0
charset-normalizer 3.1.0
frozenlist 1.3.3
humanize 4.6.0
idna 3.4
multidict 6.0.4
pip 23.1.2
py-cord 2.4.1
setuptools 65.5.0
yarl 1.9.2

#

So there's no reason PepeSadge

sly comet
#

My bot has been working perfectly fine until some time recently, when I barely updated the code. Now it won't go online without any errors. Any quick ideas for solutions, or would I have to look deeper into the code?

zealous bear
sly comet
#

Oh yeah, there isn't any error

#

It just won't go online

naive remnant
#

how can i make my bot see if the command channel is full of webhooks or not ?

naive remnant
halcyon gorge
#

is auto_archive_duration close the post? because I have that enabled but it's not closing the post after the duration

river void
#

I am completely stumped

#

So i'm trying to create a dropdown menu that has a user's inventory in it

#

and i cannot for the life of me figure out how to actually get the user's inventory

#

code below for reference (it is nowhere near functional so just ignore it's incompleteness)

class MonetaryTradeUI(discord.ui.View):

    def __init__(self, config: Config, inventory_system: Inventories, user_initiating: Member | User, user_receiving: Member | User,
                 timeout: int = 60):
        super().__init__(timeout=timeout)
        self.config = config

        self.logger = create_logger("MonetaryTradeUI", "MonetartTradeUI", "monetary_trade_ui",
                                    level=self.config.logging_level)

        self.inventory_system = inventory_system
        self.user_initiating = user_initiating
        self.user_receiving = user_receiving

        try:
            self._user_receiving_inventory = self.inventory_system.get_user_inventory(self.user_receiving)
        except UserHasNoInventoryError:
            self.inventory_system.add_user_inventory(self.user_receiving.id)
            self._user_receiving_inventory = self.inventory_system.get_user_inventory(self.user_receiving)

        global user_receiving_inventory
        user_receiving_inventory = self._user_receiving_inventory
        self.logger.debug(f"User receiving inventory: {user_receiving_inventory}")

        setattr(__class__, "user_receiving_inventory", self._user_receiving_inventory)

    @staticmethod
    def test():
        return getattr(__class__, "user_receiving_inventory")

    global user_receiving_inventory

    @discord.ui.select(
        placeholder="Select the item you want",
        min_values=1,
        max_values=1,
        custom_id="select_item",
        options=user_receiving_inventory
    )
    async def select_item(self, select: discord.ui.Select, interaction: discord.Interaction):
        """
        Select menu for selecting the item to trade.
        """
        pass
#

how on earth would i get the user's inventory in the function decorator?

halcyon gorge
weak violet
weak violet
#

kk ty

elfin dagger
#

is there any way to make embed fields go downwards only instead of to the side

silver moat
#

or something like that

#

.rtfm embed.add_field

winter condorBOT
silver moat
#

yup

elfin dagger
#

oh beautiful tyvm

fervent cradle
fervent cradle
#

also i noticed that ctx.respond has been moved to interaction.respond that means i should also pass in interaction instead of ctx? or should i just keep using ctx since its a property

silver moat
proud mason
# fervent cradle ctx as in m = await ctx.respond or something or what am i able@to pass in now

earlier, you were doing

await ctx.respond("Hi")
m = await ctx.interaction.original_response()
msg = await ctx..channel.fetch_message(m.id)
await paginator.edit(m)

rn on master branch, my 1st pr got merged. so you can save 1 step

await ctx.respond("Hi")
m = await ctx.interaction.original_response()
await paginator.edit(m)

in a couple of days, my 2nd would get merged, allowing you to just do

await ctx.respond("Hi")
await paginator.edit(ctx)
#

🙃

#

ill try to get my pr merged today

#

||hopefully somebody tests it||

fervent cradle
maiden nexus
fervent cradle
#

in async def on_message(message):

how do i react to it?

proud mason
#

.rtfm message.add_reac

fervent cradle
#

how can I change the button appereance from a paginator? in default there are the two blue buttons, one red and one green and one gray button. I want to change the color of the red and the green button and change their lable to an emoji. How can I do it?

fervent cradle
proud mason
#

you specify the name of the type

#

.rtfm paginatorbutton

proud mason
#

also check the init of Paginator

#

.rtfm Paginator

proud mason
#

pass custom buttons to it

fervent cradle
#

oh I see

#

thanks

fervent cradle
#

how do i get discord bots guild perms?

proud mason
winter condorBOT
proud mason
#

.rtfm member.guild_per

winter condorBOT
proud mason
#

@fervent cradle ^

fervent cradle
#

i tried that it doesnt work

proud mason
#

hmm

#

try channel.permmissions_for

#

.rtfm channel.perm

proud mason
#

it is more accurate

maiden nexus
# proud mason it is more accurate

Hey do you remember telling me to use asyncio.run_coroutine_threadsafe() for my issue?

It works fine if I just want to send a simple message but if lets say the message contains a view, after you click the button the reply is very slow.. do you think I can do anything to make it faster?

proud mason
#

thats why i didnt reply

maiden nexus
#

ah

#

hmm alr

#

sorry for disturbing

proud mason
#

its weird tbh. the asyncio.run_coroutine_threadsafe() shouldnt make the button slower

maiden nexus
#

it makes no sense

proud mason
#

delete an interaction? wdym?

#

interaction itself cant be deleted. do you want to delete the response sent to the interaction?

#

then see interaction.delete_original_response

#

.rtfm interaction.delete_original_response

winter condorBOT
fervent cradle
silver moat
#

no, that's what ctx is for

fervent cradle
#

right

silver moat
#

hmm maybe component context? nah that would be breaking...

naive remnant
#

how can i make my bot see if the command channel is full of webhooks or not ?

silver moat
#

then check if that number is 25 (or something like that I forgot the exact number)

true panther
#

Do I need some additional intent other than guilds for bot.get_guild() to work? It returns None even though I'm 100000% sure I pass the correct id.

young bone
#

Also what are your intents?

true panther
young bone
#

try it with fetch_guild

true panther
#

I can't because I need it in __init__ Dogesmile

clear vault
#

@silver moat can u maybe help me please? #1122591787203174441

fervent cradle
#

@young bone r u any good with docker by chance

young bone
fervent cradle
#

ah u seemed really smart damn it

young bone
#

lol

#

If you want a clean code?

young bone
#

You could edit the message and add view=None to it

#

It would get auto deleted after some time

#
await asyncio.sleep(5)
message = await ctx.interaction.original_response()
await message.delete()

works fine for me

proud mason
#

.rtfm interaction.delete_orig

young bone
#

or that

#

;3

proud mason
#

Mhm

proud mason
true panther
#

¯_(ツ)_/¯

proud mason
#

Bear in mind that on ready could be called multiple times

quiet ocean
#

~~How to get the display name for a user that doesn't have a server specific display name (has global display name)?

discord.Member.display_name is returning username when no server specific display name is set
discord.Member.nick is returning none when no server specific display name is set~~
Nvm, updating to dev version

drowsy hound
#

I am making some querys through the django ORM from the bot and I'm getting some exceptions suggesting to use sync_to_async or threads. Is there any good practice here? Any advice?

proud mason
#

Depends on you. Tortoise is a new library so it has a few bugs here and there

drowsy hound
proud mason
drowsy hound
proud mason
#

np 👍

signal sandal
#
    player = self.client.lavalink.player_manager.get(member.guild.id)
AttributeError: 'NoneType' object has no attribute 'player_manager'
``` how should i attack this
signal sandal
#

heres the thign i understand that but until the bot caches users this will be an error

meager heron
#

If I have an ApplicationContext, how can I tell if it was a user command, message command, or slash command?

I see that I can access ctx.command.type, which gives 1 for slash command, but it gives a 2 for both a user command and a message command. Is there any way of differentiating the two?

#

(Other than simply isinstance(ctx.command, UserCommand)

meager heron
#

No

#

Oh, huh, I just ran it again and got a 3 on a message command. Maybe I messed something up when I first tested

meager heron
#

Sweet, simple enough

true pewter
#

Is there a library to translate commands in various languages?

silver moat
#

it worked at one point, but not sure

true pewter
silver moat
#

that's the only one I know

fervent cradle
#

how can I get the label of the paginator page_indicator button?

proud mason
fervent cradle
#

thanks

proud mason
#

Use .label on it

fervent cradle
#

is that right?

#

I'm disabling the "first" and the "last" button in the paginator

proud mason
#

But the 3rd item still shouldn't be out of range

#

Can you print paginator.children

fervent cradle
#

I found the problem

#

I tried to get the childrens before sending the paginator

fervent cradle
#

whats the max time a user can be timed out for?

solemn idol
fervent cradle
#

thank u

silver moat
#

7 days?

fervent cradle
#

oh

#

then which one

#

hmm

#

Q: What are the time limits I can put on time out?

A: You can choose between 60 seconds, 5 minutes, 10 minutes, 1 hour, 1 day, or 1 week

i guess 7 days is max then

solemn idol
#

wth I thought bots could go till a month

#

normal moderation can only do for 1 week

fervent cradle
#

where have u seen that?

silver moat
solemn idol
full basin
#

Why not trying and see

rare garnet
#

anyone has any idea how to run a task only once when the client runs

solemn idol
rare garnet
#

if you're talking about on_connect i think its a dumb idea

solemn idol
#

on_ready works too

#

but it depends on what you're trying to do

full basin
#

Or make the task wait until the bot is ready?

rare garnet
#

trying to create posts in forums and send messages

rare garnet
#

but tasks need looping right

solemn idol
#

.-.

solemn idol
knotty surge
#

Can anyone point me torwards the information for discord pop ups?

solemn idol
#

you can also make it so that you make x = 0 and you run the task only once when x = 0 and in the task itself you make x = 1 so that it only runs once.

#

if you wanna take the idiotic way :)

full basin
#

If you set a time, it'll loop every x time you set

solemn idol
rare garnet
#

makes sense thanks both of you!!

solemn idol
#

👍

rare garnet
#

this exists and now i look stupid...

solemn idol
#

uh oh I did not know that was a thing

#

the lol

proud mason
#

Using basic event loop methods

silver moat
rare garnet
proud mason
# rare garnet i.e.?

Smth like

bot = ...

async def my_function():
  await bot.wait_until_ready() # optional. Depends on what you want to do in this function

  # do stuff here 

bot.loop.create_task(my_function()) # will only run once bot.run is called 

bot.run()
proud mason
rare garnet
#

thanks!

proud mason
#

Mhm I've started to use it quite often lol

knotty surge
#

How would I go about adding a updating dropdown to my modal? I can't seem to find out anything about it. Any help would be great -

class MyModal(discord.ui.Modal):
    def __init__(self, *args, **kwargs) -> None:
        super().__init__(*args, **kwargs)

        self.add_item(discord.ui.InputText(label="Short Input"))
        self.add_item(discord.ui.InputText(label="Long Input", style=discord.InputTextStyle.long))

    async def callback(self, interaction: discord.Interaction):
        embed = discord.Embed(title="Modal Results")
        embed.add_field(name="Name", value=self.children[0].value)
        embed.add_field(name="Collar", value=self.children[1].value)
        embed.add_field(name="Faction", value=self.children[1].value)
        await interaction.response.send_message(embeds=[embed])
knotty surge
#

Or chat commands I am presuming, as you can add onto a slash command's options I believe

silver moat
#

depends on what you mean by updating dropdown

knotty surge
#

So

#

I would like to create a command which would add to the options -

Original List shown in slash command - ["Peach", "Orange"]
After running other slash command - ["Peach", "Orange", "Apple"]

silver moat
#

so dynamic?

knotty surge
#

Yes

errant craneBOT
#

Here's the slash autocomplete example.

knotty surge
#

So adding to colours in real time

silver moat
#

sure

livid wolf
#

I forgot what the line was for @option where you pick from a list

livid wolf
#

Yes, that

errant craneBOT
#

Here's the slash options example.

maiden nexus
# silver moat sure

Uhm sorry to disturb you but could you check my thread #1122598154009841674 ? I've asked people before on this issue but they don't seem to know the fix for this...

livid wolf
maiden nexus
#

so maybe you could help..

livid wolf
#

let me look

livid wolf
#

Its not showing up with options

silver moat
livid wolf
#

I have a command that looks like

def returnCommandList() -> list:
  with open('commands.txt', 'r') as file:
    content = file.readlines()
    commands = []
    for index, line in enumerate(content):
      cline = line.split('cmd: ')
      if cline == '':
        commands.append(cline[1])
  return commands

@bot.command(description="Get help on a certain command")
@option("command", description="Command you need help with.", choices=returnCommandList())
async def find(ctx, command: str):
  resp = find_command(command.lower())
  if resp['found'] == True:
    embed = discord.Embed(title=f"Command:\n{command}", color=discord.Colour.green())
    embed.add_field(name='Description:', value=resp['desc'], inline=True)
    embed.set_footer(text="Brought by the /find command")
    await ctx.respond(embed=embed)
  else:
    embed = discord.Embed(title="Command not found", color=discord.Colour.red())
    embed.add_field(name="Error", value=f"Command {command} was not found.")
    await ctx.respond(embed=embed, ephemeral=True)

How would I use the @option into the command??

young bone
livid wolf
#

the bot what?

young bone
#

you use choices

livid wolf
#

the function returns a list

young bone
#

yea

#

but you have to restart the bot to add new stuff to the list

#

Also the limit are 25 items

livid wolf
#

oh

#

I got 29 items

young bone
#

yea

#

that is not gonna work than

#

you have to use autocomplete

livid wolf
#

And how would I use autocomplete?

errant craneBOT
#

Here's the slash autocomplete example.

livid wolf
#

Thanks

warm tendon
#

@pulsar narwhal
that's why several people mentioned $PATH.
its needed so you can run python anywhere and not just in the place the installation happend.

you can add it later but its easier to simply un and re-install python and tick the box for $PATH during install.

then the not found message wont show up anymore.

silver moat
#

it depends on your OS

warm tendon
pulsar narwhal
#

(No offense to any library) Is discord.js taking more RAM or Pycord?

silver moat
young bone
pulsar narwhal
silver moat
#

you picked python, performance shouldn't be an issue

silver moat
pulsar narwhal
warm tendon
silver moat
#

note that pycord isn't a beginner library.

young bone
pulsar narwhal
silver moat
pulsar narwhal
silver moat
pulsar narwhal
warm tendon
young bone
pulsar narwhal
#

Sever count is very less btw

silver moat
#

if one server has like 40000

#

¯_(ツ)_/¯

pulsar narwhal
warm tendon
# pulsar narwhal Dayum

i can give you a few easy lines to count members with the on ready event (so its only done when your bot starts up/reconnects) if you like.

pulsar narwhal
warm tendon
#

alright

pulsar narwhal
#

(In js)

#

Not py

warm tendon
pulsar narwhal
silver moat
pulsar narwhal
#

Is advertising allowed here?

warm tendon
#

Sounds like a good idea. Enjoy, python learning is awsome :]

pulsar narwhal
silver moat
#

but after learning javascript, javascript is indeed shit

warm tendon
silver moat
pulsar narwhal
pulsar narwhal
silver moat
pulsar narwhal
silver moat
#

kinda getting off-topic here. Are you done with your queries?

warm tendon
fervent cradle
#

d.py documentation:

until (Optional[Union[datetime.timedelta, datetime.datetime]]) – If this is a datetime.timedelta then it represents the amount of time the member should be timed out for. If this is a datetime.datetime then it’s when the member’s timeout should expire. If None is passed then the timeout is removed. Note that the API only allows for timeouts up to 28 days.``` so the max is 28 days.
trim condor
#

anyone know if I can put any old view into a Paginator Page? not sure why / how views are related to embeds, but I thought there might be some interchangeability. not seeing anything obvious though

#

oh sweet, just read through the code and found this in the Page docstrings: custom_view: Optional[:class:discord.ui.View] The custom view shown when the page is visible. Overrides the custom_view` attribute of the main paginator.11pm

young bone
#

Pls dont crosspost

left flame
fervent cradle
#
  File "C:\Users\jan\.virtualenvs\src-UVICV5iw\Lib\site-packages\discord\commands\core.py", line 139, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: Forbidden: 403 Forbidden (error code: 50013): Missing Permissions``` im getting this error and the embed description is not being set in my error handler?

```py
    elif isinstance(error, discord.errors.Forbidden):
        embed.description = "I don't have sufficient permissions to complete this action!"```
proud mason
#

.rtfm applicationcommandinvokeerror.original

winter condorBOT
#

Target not found, try again and make sure to check your spelling.

proud mason
#

.rtfm applicationcommandinvokeerror

proud mason
#

It should have an original attribute

fervent cradle
#

i dont get it

proud mason
#

I'll show an example

#

One sec

#
if isinstance(error, ApplicationCommandInvokeError):
  if isinstance(error.original, Forbidden):
    ...
#

Smth like that

fervent cradle
#

or are there like more error messages to forbidden or something?

#
    elif isinstance(error, discord.errors.Forbidden):
        if isinstance(error.original, discord.errors.Forbidden):
            embed.description = "I don't have sufficient permissions to complete this action!"``` basically like this huh
proud mason
#

Other wise looks good

fervent cradle
#

oh yeah

proud mason
#

More error messages?

fervent cradle
#

like why does it need to be nested, why cant i just check for discord.errors.Forbidden directly

#

and are there any more cases where i need to watch out for this?

proud mason
fervent cradle
#

basically any error that has discord.errors.something like NotFound

#

commands.MissingPermissions probably doesnt need it

#

probably dont even need that one tbh

#

just in case tho

#

nvm i dont need to use those with slash commands

errant craneBOT
winter condorBOT
#

Target not found, try again and make sure to check your spelling.

fervent cradle
#

@proud mason now this is what my error handler looks like

    elif isinstance(error, discord.ApplicationCommandInvokeError):
        if isinstance(error.original, discord.errors.Forbidden):
            embed.description = "I don't have sufficient permissions to complete this action!"
    elif isinstance(error, discord.errors.NotFound):
        embed.description = "The requested option was not found!"
    elif isinstance(error, gdshortener.GDGenericError):
        embed.description = "Custom short URL already exists or is not at least 5 characters long!"

    else:
        embed.description = "Something went wrong"```, but now when i have an unhandled error, the description doesnt change to "something went wrong" ?
candid coral
#

Is it better to make one database for all user data or spread the data across different databases?

fervent cradle
#

depends on what data

#

if u have like whitelists or something, then u can just add a column with a boolean to the user

candid coral
fervent cradle
#

thats a broad statement

#

just numbers ull update? list of numbers?

candid coral
#

I plan to make a complex economy with multiple currencies and capital

#

I want to know what is the best way to store such information

fervent cradle
#

okay then for like users and balance and bank could be all 3 different tables but they could be set up as relations

candid coral
#

Thank you

fervent cradle
#

maybe inventory and shop could be related as well to see how many of each a user owns

#

im planning on making an economy system myself, just dont have enough time lol

prisma flicker
#

and you don't handle the cse where it's discord.ApplicationCommandInvokeError but not Forbidden

fervent cradle
#

i fixed it, i had to add another else statement and i added Forbidden into it