#Basic Pycord Help

1 messages · Page 38 of 1

upper flint
#

If it does this by itself, why not? Saved a file, waited 2 seconds while it restarted and voila

errant trout
#

idk if you'd really want to restart everytime but eh whatever, i mean ultimately it depends on your setup? how you detect the file changes, beyond that ending the process and having a command to start it again doesn't seem impossible

upper flint
#

Right now I'm trying to use pymon for this

#

Just thought anyone had experience with this kind of problem

errant trout
#

py-mon looks pretty good too

fresh sierra
#

if you are using github, you can do a loop that when the git is not up to date it updated it and restart ur bot

#

you can also just reload cog or use the function importlib.reload to reload a file that is not from a cog

upper flint
#

This way, repo will flood with a lot of commits with 1-2 changed lines

#

It's ok though, I already did what I planned to

#

I ended up using watchdog for monitoring file changes. I binded my dev directory with src directory in docker and now it works like a charm. Every update is almost instant, no need to do anything at all

fresh sierra
#

yes

#

but like

#

if every time you edit a file its restart

#

it will do a lot of restart no ?

upper flint
#

Yes, indeed

fresh sierra
#

Consider looking for a better option without ur bot restarting if you plan to have a bot public, (more user mean it will take way more time to reach the on_ready like 30min)

upper flint
#

No, I don't use it for production. Of course my main container is always up and running w/o constant restarts

#

I have a separate bot instance in which I develop and test my code. It's on it's own isolated server so no one except me has access to it

#

So there are no problems with command propagation

fresh sierra
#

perfect so

#

if that can help you

#

im using a command /update that make the bot up to date and restart it

fresh sierra
#

Why does guild doesnt have any attribute guild attribute fetch_role while it has every other fetch ?

edgy nest
#

because you can't fetch a single role

sage tendon
#

should be possible imo

fresh sierra
edgy nest
#

because you literally can't

#

it's impossible to fetch just one

#

it's all or none

fresh sierra
#

like discord doesnt allow it

edgy nest
#

yes

fresh sierra
#

that kinda stupid

#

like if you have an id of the role

#

so you have to fetch all the role to then itinerate in it to find the corresponding id

edgy nest
#

just fetch all and filter

fresh sierra
#

im using the method guild._fetch_role

#

but yeah if not i will have to use the fetch_all and filter

edgy nest
fresh sierra
#

what intput_type should i use for an message_id ?

#

should i use float and then convert to int or someone has a better way to deal with that

sage tendon
#

string

#

and then do int(message_id_string)

fresh sierra
#

string works thanks

fresh sierra
#

How can i use paginator to put 2 embed in each page ?

#
        for result in results:
            id, embed_data = result
            embed = discord.Embed.from_dict(eval(embed_data))
            id_embed = discord.Embed(title=str(id))
            embeds.append(embed, id_embed)
        paginator = pages.Paginator(pages=embeds, timeout=None)
#

like something like that

lofty parcel
granite pier
fresh sierra
#

thanks dark

fresh sierra
edgy nest
#

use the json lib

fresh sierra
#

eval works too ;)

#

and less code

granite pier
fresh sierra
#

why ?

granite pier
#
import json

embed = discord.Embed.from_dict(json.loads(embed_data))
#

same length, just 1 more import

edgy nest
granite pier
#

yeah

#

an attacker could use it

fresh sierra
#

i dont really see a world where they can

edgy nest
#

youre living in it

fresh sierra
#

tell me if im wrong

sage tendon
#

you are wrong

edgy nest
#

you're wrong

fresh sierra
#

wait lmaoo

#

the embed_data is just the embed.to_dict, how can the eval of that can do something ?

granite pier
#

what is embed_data

#

how do you get/define it

fresh sierra
#

its an embed.to_dict()

#

that its store in my database

#

like how can he used that to attack my bot

sage tendon
#

embed content :)

fresh sierra
#

its an str

#

eval an str doesnt execute code no ?

granite pier
#

it does

#

you can use e.g. eval("1+2")

fresh sierra
#

i will try

granite pier
fresh sierra
#

still give me the same

#

but yeah if i only eval 1+2 its does 3 thanks for make me learn that

#
code = eval(str({'fields': [], 'type': 'rich', 'title': '1+2'}))
print(code)
# outpout = {'fields': [], 'type': 'rich', 'title': '1+2'}
#

i dont think that eval can be used by an attacker since its a str(json) like that, but if someone knows an exploit where the eval can work feel free to ping me

granite pier
#

overall eval is used to evaluate code

fresh sierra
#

and with json.load i havean error:

import json

code = json.load(str({'fields': [], 'type': 'rich', 'title': '1+2'}))
print(code)
# AttributeError: 'str' object has no attribute 'read'
granite pier
#

not load

#

load accept file

fresh sierra
# granite pier loads
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)
sage tendon
#

make it double quotes

fresh sierra
#

well i cant

#

(without having to do a replace everytime to replace ' to ")

sage tendon
#

just change it in that one line lol what

fresh sierra
#

that how discord return the embed.to_dict

edgy nest
#

tada

#

it's running code and caused a syntax error

fresh sierra
#

thanks ;)

#

can you send me the text ?

#

i like to try thing

#

but even the user cant really do that

edgy nest
#

{'test': 'test'}; print("a");#'}

fresh sierra
#
{"fields": [], "type": "rich", "title": "1+2"}
#

he can only edit the 1+2

edgy nest
#

i terminated the dict early and added code after

#

same concept as SQL injection

fresh sierra
#

i will try it rn

edgy nest
#

or you could just change 2 lines of code and use a standard library for parsing json

#

eval is also just bad practice

#

if you're using eval you're doing something wrong

granite pier
fresh sierra
#

however i got an error

granite pier
#

i have an idea

edgy nest
fresh sierra
#

how should i dump it ?

edgy nest
#

you can't just cast a dict to string

#

use json.dumps

fresh sierra
#

i tried ur exploit

#

seems like it doesnt change anything

fresh sierra
edgy nest
#

is that base64

fresh sierra
#
code = eval(str({'fields': [], 'type': 'rich', 'title': '{\'test\': \'test\'}; print("a");#\'}'}))
print(code)
# outpout {'fields': [], 'type': 'rich', 'title': '{\'test\': \'test\'}; print("a");#\'}'}
#

its the timestamp convert into base64

#

to then be able to load the embed

fresh sierra
granite pier
fresh sierra
#

yes better safe than sorry

granite pier
#

mostly someone with try with closing quotes like plun above

#

also u can use unicode in eval

deft kestrel
#

What permissions are required to send messages in channels?
Checking using can_send returns True but send throws a Forbidden 50013 exception. This behaviour happens in production

sage tendon
#

send_messages lol

#

and i think also view channel

deft kestrel
#

The bot has that permission but it still throws Forbidden

#

I added a check before the call for this permission but it didn't work

#

and yes I made it check for the channel, not the server

round heart
#

Does it have the View Channels permission on the target channel? Frustratingly, that's a requirement in order for it to be able to send a message.

deft kestrel
#

this is what it looks like rn

#

still throws an exception right under when I call send on the channel

#

there shouldn't be any line ending issues as I have git configured to convert to Unix

#

and the bot server runs Debian 12 which I updated 2 hours ago so there shouldn't be an issue

sage tendon
#

is it only for that channel or any channel

deft kestrel
deft kestrel
#

might try out with different discord permission settings

sage tendon
#

check the permission overrides for that channel, maybe something is weird

#

and also try viewing the server as the bot role

fresh sierra
#

does the bot has the good scope ?

#

or that doesnt matter

sage tendon
#

also fyi you can use delete_after=5 in the send() to schedule deletion automatically

fresh sierra
#

can we saw the channel_perms definition ?

deft kestrel
#

how do I convert Member instance to User instance or is that the same thing essentially

fresh sierra
#

even if normally that doesnt change anything the channel.can_send should check that also

fresh sierra
#

user is not member

deft kestrel
#

oh ok

#

so I can ignore the warning

sage tendon
#

there is member.user i think but you usually never need that because member has everything user has

sage tendon
deft kestrel
sage tendon
#

i think thats just a typehint error, permissions for a user make no sense

fresh sierra
deft kestrel
#

I think the check for overrides may have patched the bug, I'll check in a while, meanwhile I'll implement proper logging

fresh sierra
#

why are you using can_send() and check if it has the perm ?

#

like just use can_send()

deft kestrel
fresh sierra
#

if it does that

#

i think you should open an issue on github

deft kestrel
#

I don't think can_send() checks permission overwrites

fresh sierra
#

i will check the code

fresh sierra
#

it does

#
            if not getattr(channel.permissions_for(channel.guild.me), permission):
                return False
#

but maybe

#

your bot just have any permission in the whole guild

#

and not only in the channel

#

(even if the can_send should handle that)

sage tendon
#

you could also print the exception text, maybe it has some info

stray pasture
#

When I rerun a slash command it sometime give me NOT found error

#

The first time I run the slash command it works. After I do the up arrow on keyboard to redo the same command. When I do that, I get error on bot. An embed is still sent, but it is a wrong one ...

#

Here I I run the command for the first time (no errors):

#

after I run it a few time, it start crashing and sending wrong embed:

sage tendon
#

show the code

stray pasture
#

for the show, all I am going is creating a paginator, and after

#

await paginator_server.respond(ctx.interaction, ephemeral=ephemeral)

#

Maybe it is new version, it never done that before. That code has been working for more than a year

stray pasture
# sage tendon show the code
    @SHOW_GROUP.command(guild_ids=guildIds, name="member", description="Show all the individual, global and recurrent timed role of a member")
    @option(
        "role",
        description="The member which roles will be show",
        type=Member
    )
    @option(
        "ephemeral",
        description="If the bot respond as ephemeral",
        type=bool,
        default=True
    )
    async def show_timed_role_of_member(self, ctx: ApplicationContext, member: Member, ephemeral: bool):
        await self._show_timed_role_of_member(ctx, member, ephemeral=ephemeral)
little cobalt
stray pasture
# little cobalt change the name "role" to "member"

sorry sent the wrong command.

    @SHOW_GROUP.command(guild_ids=guildIds, name="me", description="Show all the individual, global and recurrent timed role of you")
    @option(
        "ephemeral",
        description="If the bot respond as ephemeral",
        type=bool,
        default=True
    )
    async def show_timed_role_of_me(self, ctx: ApplicationContext, ephemeral: bool):
        await self._show_timed_role_of_member(ctx, ctx.author, ephemeral=ephemeral)
sage tendon
#

yea idk tbh, something about the interaction already being used or something
Im too tired for this today

stray pasture
#

I put the wrong name there, it is not suppose to work

#

but is does

sage tendon
#

diff command

stray pasture
sage tendon
#

oh

stray pasture
#

But appart from that, I get the bad Request on all slash commands

#

if I redo them with up arrow

#

Even with slash command that have no code changes.

nova epoch
#

Any support for user-installable apps with Py-cord Stable yet?

lofty parcel
#

But wont be merged until discord takes it out of preview

nova epoch
#

Ahhhhhhhhh~
Not me here trying to make a user-installable app...
I've got the guild-install side of it all working, but I'm waiting on what is likely v2.6 to allow user apps 😭

little cobalt
errant trout
#

The current PR is stable unless discord changes anything

#

At the moment they're making up their mind on permissions

#

So if you wanna use it just install the branch as per the pr's instructions

nova epoch
#

Do we know if there's an ETA for when Discord releases user apps officially or when Pycord is supporting with user apps?

errant trout
#

Nope, at minimum when discord takes it out of "preview"

#

They typically don't give specific timelines on this stuff though

nova epoch
#

Typical Discord. I'm convinced that their business model aims to piss off developers as much as possible-

sage tendon
#

but the profit is rising wdym

errant trout
#

Eh ultimately this is a pretty significant feature with a lot of implications so they have to take their time on it

#

Seeing the progress on it it shouldn't be too long, and it's still functional as far as we're concerned so using the early PR isn't particularly dangerous at this stage

nova epoch
#

I'm not overly against using the PR, I'm just weiging my options:

  • Get an early start on developing my app and hoping that Discord don't change it too much; or
  • Wait for ages and pray Discord release it to stable soon, but possibly risk months of lost time.
errant trout
#

At this stage there really isn't a lot they CAN change, but if there are any major changes it'll be clear in the pr

#

As always, it's "possible" but weighing out everything they've put out so far it's unlikely

nova epoch
#

I'm tempted to just say f*ck it and pray Discord don't screw it up too much

#

One pip command later...

errant trout
#

I'd just say go for it, if there's any issues leave a comment on the pr or feel free to ask here

#

Also you can preview the docs for it if you go down to the actions and find readthedocs

nova epoch
#

I think I'm just going to blame Discord if there's any issues because Py-cord is too good to be making errors. Then again, I see Discord just using the "it's in preview" for any issues that come up so that says alot.

Managed to find the docs while looking for the PR, not sure how though...

little cobalt
#

@errant trout can you take a look at #1241170479834988706 , Im to tired and I want to go sleep now

errant trout
#

In a Sec

#

I love my phone

little cobalt
#

xd

nova epoch
obsidian blaze
#

Is it possible for a bot to send a voice message? (Not sending a .mp3 file)

shell radish
#

no

obsidian blaze
#

Any thoughts on how I can send an audio recording so it shows on mobile as well?

lofty parcel
#

i was about to say that lmfao

stray pasture
obsidian blaze
errant trout
#

yeah pretty silly that the app can't play audio files

deft kestrel
#

i dont really know how but this keeps on erroring ```py
await memeber.add_roles(discord.Role(1239192685022023771), reason="test", atomic=True)

shell radish
#

it should just be discord.Object(1239192685022023771)

stable yarrow
#

What's atomic arg?

grizzled loom
# deft kestrel

can you show me your code, starting with how the command is made, up to this permission check part you just posted, please

deft kestrel
#

from top to bottom:
main.py cog definition
on_message listener in leveling.py
getting channel perms and overrides
and then ✨Le code spaghetti✨

#

if I remove the channel_overrides check it starts throwing errors

#

but I think it won't send messages anywhere unless the permissions are overridden as the channel overrides are None

grizzled loom
#

whats the error you're getting?

fresh sierra
#

?tag paste

limber wagonBOT
#

Please copy and paste your code here. This makes it easier for everyone helping you.

fresh sierra
#

Including the error, it will be easier for us

errant trout
# deft kestrel

do not bother with can_send and overwrites_for, just use permissions_for

#

can_send is meant to take the objects you're trying to send, but it should be noted that it doesn't actually check the view_channel permission

sage tendon
#

that's an oversight I'd say

#

if can_send returns true you should absolutely be able to send

serene goblet
#

Can I have 2 dropdown menu's on the same row of an interaction. I have 5 rows in the following setup

  1. 3 buttons
  2. disabled button with info text
  3. dropdown 1
  4. dropdown 2
  5. confirm button
    and I would like to add a second dropdown on the same row as the 1st dropdown, is that possible at all or will I need to re-order stuff
fresh sierra
lofty parcel
#

You cant.

#

Dropdowns use a full row.

#

I believe its 5 items per row, dropdowns use 5.

serene goblet
#

Ah ok, makes sense

serene goblet
#

Can you sned multiple followup messages to interactions? Say I have an interaction which will take a while to process so I defer it and then want to send a followup once the response is partially complete, can I then send another followup when it;s finished?

serene goblet
#

okay, but can I do 2 followups?

lofty parcel
#

.tias

sly karmaBOT
sage tendon
#

why would you need 2 followups is the first question that comes to mind

fresh sierra
#

To answer 2 times to an interaction ?

sage tendon
#

why?

fresh sierra
#

Why not lmao It depend in his code, for example you answer 1 time to ask them to send a message, and answer again afer the bot.wait for

sage tendon
#

2 followups are just clutter, i do not see any use case for that

errant trout
#

toothy please i beg of you, and i mean no offense, learn that people have use cases beyond what you personally use

#

multiple messages in a single command isn't strange by any stretch of the imagination

sage tendon
#

no but like, you can edit the message, or just use a send, or anything

#

and i mean i did ask them why, but luma decided i needed the answer from them

#

i dont know why

errant trout
#

regular bots can use followups and send interchangibly, but in many instances when commands are limited to interactions bots won't be able to use ctx.send

#

editing is pretty neat, but there's also cases where you don't necessarily want to overwrite the original message

fresh sierra
sage tendon
#

yea but now i have 2 answers from 2 people who aren't the person that actually holds the info :>

errant trout
#

i mean, i'm not speaking for them; i'm just speaking in general

sage tendon
#

yea ik but like lol

errant trout
#

"why would you need 2 followups" just sounded a little silly to me

sage tendon
#

yea, because i rarely come across even a single followup in the many bots i use

fresh sierra
#

The fact that everytime u don’t use something u say yeah but why the heck use that

#

Is disappointing

shell radish
#

deferred responses are followups

sage tendon
fresh sierra
#

I give up with u toothy

sage tendon
#

i'm not saying "oh you are so stupid for 2 followups"

fresh sierra
#

U ask me why too

sage tendon
#

quit twisting the words i write

fresh sierra
#

And then u say why luma answer me

sage tendon
#

to my very initial question
i want to know from THEM not you

shell radish
sage tendon
#

should just add /srs behind everything i write here

fresh sierra
#

Doesn’t seem clear that ur not asking that to everyone but only to him

sage tendon
#

"you"

#

this is pointless, lets just stop

fresh sierra
#

Well yeah you mean him when you never talk about him and when the 2 last message where not from him

#

I’m sorry to not read ur mind…

broken pivot
#

How can I create a prefix and a slash command at the same time? discord.py have method hybrid_command, is there an analog to this in pycord?

shell radish
#

bridge commands

fresh sierra
shadow bear
#

how do I add a bridge command without putting it in a cog?

#

decorating it normally doesn't work, and idk if im supposed to add_command or add_application_command lol

shadow bear
#
@bridge.bridge_command()
async def ping(ctx: bridge.Context):
    """Checks the latency between the bot and discord."""
    t = f"WebSocket: `{round(ctx.bot.latency * 1000)}ms`"
    await ctx.respond(t, ephemeral=True)
#

this doesn't get added to the bot since its in the runtime file and not a module

#

Hold on

#

I'm thick, @bot.bridge_command

#

idk why my intellisense didn't show me that existed when I tried it lol

rain dune
#

how can i get discord.Member object from userid and vise-versa

vital bramble
#

discord just did!? Am I dreaming?

rain dune
#

whats that VScode theme, it looks cool

sage tendon
shadow bear
#

Does bot.run fully close the event loop before returning? or can I still use the loop afterward

shadow bear
#

I was using the wrong decorator

rain dune
sharp sleet
#
@bot.event
async def on_message(ctx):
    open(f"{ctx.channel.id}_log.txt", 'a').write(ctx.author+": "+ctx.message+"\n")

on_message does not appear to be working unless the bot sends a message, user messages are not causing it to run

brazen estuary
errant trout
brazen estuary
# errant trout you dont have the message_content intent
# --- BOT ---
intents = discord.Intents.all()
intents.message_content = True
intents.members = True
client = discord.Client(intents=intents)
bot = Bot(command_prefix='&', intents = intents)
``` that's what i thought too so i checked and turns out we do
errant trout
#

are you sure it isn't just erroring

sage tendon
#

you already request all intents lol, no need to overwrite

#

I know the issue I think

errant trout
#

on_message takes message, not ctx; as such, ctx.message is actually message.message and errors

sage tendon
#

you're using bot.event on a bridge or prefix bot for on_message

#

doesn't that make it not process anything

errant trout
#

well that's in terms of commands yeah

#

but they never said commands were the issue

sharp sleet
#

ima make a thread

errant trout
#

unless it is, in which case yeah you need to process them

sage tendon
#

yea true just wanted to bring that up if it becomes an issue

sharp sleet
#

dont want to spam this channel

#

ill post the whole code

errant trout
#

whatever works

sharp sleet
deft kestrel
#

ok wtf, it says it has permissions above but still throws missing permissions error?

#

Source: (Lines 128 to 139)

sage tendon
#

view the channel as the bot role and see if you can send a message

deft kestrel
#

I don't have access to the server

#

I don't even know what server this is happening on

rain dune
#
    order_group = SlashCommandGroup(
        name="order", 
        description="Manage Everything related to order",
        checks=[
            commands.has_permissions(administrator=True)
        ],
        guild_ids=[974347594866237461]
    )

why commands.has_permissions(administrator=True) dont work for slash command groups

errant trout
rain dune
#

yeah

errant trout
#

you should use default_permissions

rain dune
#

.rtfm default_permissions

sly karmaBOT
rain dune
#

alright

errant trout
#

default_permissions is the decorator version

sage tendon
manic glen
#

does reset_cooldown() will reset cooldown for all user or for current user ?

errant trout
#

whatever bucket you selected

#

in other words, it completely resets it

manic glen
#

I'm using user
is there any way to reset for a particular user.

sage tendon
#

then reset_cooldown would reset it for that particular user in the current interaction id guess

#

or do you wanna reset it for someone else

manic glen
#

for that particular user

nova epoch
#

Looking for a little advice, not specifically Pycord but this seems to be a good place to ask.
I'm making a bot that can be both installed to a User & to a Guild. When storing data from these commands, would it be best to have 2 DBs - one for users & one for guilds or 1 DB for both methods to share?
TIA

sage tendon
#

one DB, two tables

nova epoch
#

That's what I meant by 2 DBs - whoops 😭
Thanks though

sage tendon
#

(thats how i'd do it)

fresh sierra
#

i will do that

sage tendon
#

i mean ultimately it depends on what you wanna save

fresh sierra
#

depend on your preference and code ig

nova epoch
#

That's not quite how this bot would work. When installed to a user, commands only work in a DM channel. When installed to a guild, you can only use the setup commands in a channel in that guild.
It makes sense to me at least.

In terms of what I'm storing, I'm essentially making a message tags bot, similar to Dyno/Carl ?tag commands. It's just going to be data for the tag name, tag content and who owns the tag (member or guild id).

Not too sure how exactly I'm going to do this yet but any suggestions would be appreciated.

sage tendon
#

I mean yea, you could make one boolean column "guild", and then an "ID" column that saves either the guild or the user ID
or you seperate it into two tables, might be a bit cleaner

#

i would seperate it personally

fresh sierra
#

well you can do for your table :
guild_id
member
name
content

if its in guild you save also the guild_id, if not you put None for guild id.

so if user app select * where member = ... and guild select * where guild_id =

#

depend on ur preference

#

i personally prefer not having 2 tables that will do the same thing just for user app and normal app

nova epoch
#

I'm tempted to make 2 different tables, just not too sure exactly how I want to do it yet. Trying to figure out the logistics of what needs to be stored for each type of interaction (user/guild) and how to separate these methods, tempting to use 2d classes:

class db:
  # blah blah
  class user_install:
      # put all the user_install methods here
  class guild_install:
      # put the guild_install methods here```
Also trying to figure out with a little testing if `iscord.IntegrationType` is data that's passed with an interaction or not, trying to use ```py
if discord.IntegrationType == 0:  #guild
if discord.IntegrationType == 1:  #user```
sage tendon
#

id just check if its a DM or not since you said its DM for user, and channel for guild install

rain dune
#

.rtfm get_user

rain dune
#

is any better way to send DM to a user whos only userID is know to me? rather than get_user

nova epoch
sage tendon
sage tendon
#

so i wont be much help lol

nova epoch
sage tendon
#

yea, i mean the discord-side of things is simple enough really, you just need to make sure to address the proper DB functions (e.g. tag_save_user vs. tag_save_guild)

#

DB schema should also be simple enough for both tables
Just User / Guild ID | tag name | content i suppose

rain dune
#

alright

nova epoch
sage tendon
#

Yea that's why I'd do two tables

#

yea that was what i was suggesting, imo the cleanest way

nova epoch
#

Yeah, I'll consult some of my friends and see if they can give me a hand with this db stuff, not too sure how much it'll help but there's only one way to find out.
Thanks for the help :)

sage tendon
#

np

#

Just start with something, that'll get you most of the way there
you can always change stuff later

nova epoch
#

Was the plan, just going to see what happens.
Worst case scenario, I have to start the DB stuff again 🤷

sage tendon
#

meh if you just do two tables with the schema I said I don't see much need to change that

nova epoch
#

Neither, just going to hope my friends can give me a hand - some of them have been doing dbs for many years so hopefully all will be okay :p

sage tendon
#

yea it'll be fine

nova epoch
sage tendon
#

never used something like that, no idea

#

I'd just duplicate the functions for the dB access in the dB class, once for guild and once for users
but maybe that works better but yea

nova epoch
#

Yeah I have no idea what's better - I'll just do some experimenting and see what works I guess

sage tendon
#

yea that'll probably show what's better (or if it doesn't really matter)

lofty hedge
#
Ignoring exception in on_connect
Traceback (most recent call last):
  File "/home/container/.local/lib/python3.10/site-packages/discord/client.py", line 400, in _run_event
    await coro(*args, **kwargs)
  File "/home/container/.local/lib/python3.10/site-packages/discord/bot.py", line 1178, in on_connect
    await self.sync_commands()
  File "/home/container/.local/lib/python3.10/site-packages/discord/bot.py", line 754, in sync_commands
    app_cmds = await self.register_commands(
  File "/home/container/.local/lib/python3.10/site-packages/discord/bot.py", line 531, in register_commands
    prefetched_commands = await self._bot.http.get_guild_commands(
  File "/home/container/.local/lib/python3.10/site-packages/discord/http.py", line 367, in request
    raise Forbidden(response, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access``` i get this error randomly and im not entirely sure what's its being caused by, does anyone have any ideas? the bot has like 20k lines of code in total so hard to debnug
sage tendon
#

On startup or during runtime

lofty hedge
#

both. it gets thrown before on_ready is fired. and sometimes when the bot is running randomly

nova epoch
sage tendon
#

Yea sounds good

#

that, or if you really wanna restrict it, manage server

nova epoch
#

I feel like that's too strict. Might make it configurable in the future (maybe add compatibility for a guild to specify a role) but I think that's too much work to put into the first release. I'll put it on timeline for the v1.1 update :)

sage tendon
sage tendon
nova epoch
#

Yeah I'll just experiment and see what works

sage tendon
#

If you wanna make it configurable definitely use that decorator, don't try to make that yourself
way more work and everyone can still see the command

lofty hedge
sage tendon
#

yea judging by the error there seems to be an issue getting a guild's commands

rain dune
#
    user_member = commands.Bot.get_or_fetch_user(data['user_id'])
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Client.get_or_fetch_user() missing 1 required positional argument: 'id'

why this error is occuring

sage tendon
#

read the error

rain dune
#

the first one is self,

sage tendon
#

wait
that's.. not how it works lmao

nova epoch
#

.rtfm get_or_fetch_user

sage tendon
#

you need to use your actual bot object

#

don't call it from the bot class

errant trout
#

one of the servers you've specified has de-authorized or kicked the bot

sage tendon
errant trout
#

settings > integrations > remove app

sage tendon
#

but that also kicks the bot no?

nova epoch
#

Doesn't that just kick the bot?

errant trout
#

yes, but it's also possible to have a bot without the commands scope

#

in which case it isn't authorized

sage tendon
#

ic

errant trout
#

(discord put some effort into preventing this but eh some edge cases exist)

lofty hedge
#

im only specifying two guilds, using guild_ids both the bot have access too / i use the commands in both servers

errant trout
#

you're 100% sure there's no stray guild ids? because that error is only possible with an invalid one

lofty hedge
#

oh wait youre definitely right thats my apology. i forgot, that in the second server i only have the "Beta" bot not the main bot in it

errant trout
#

rip

lofty hedge
#

i wont be able to properly test until i restart the main bot, so probably within next day. But thank you.

#

its where i was using a slash command group

#

and specified two guilds, one of them the main bot doesnt have access too.

lethal loom
#

hi, what are the limit for embed title and description

sage tendon
#

2000 combined for the entire embed i believe, not sure if there are specific limits for the title etc

echo wraith
#
  • Embed title is limited to 256 characters
  • Embed description is limited to 4096 characters
  • An embed can contain a maximum of 25 fields
  • A field name/title is limited to 256 character and the value of the field is limited to 1024 characters
  • Embed footer is limited to 2048 characters
  • Embed author name is limited to 256 characters
  • The total of characters allowed in an embed is 6000
    https://www.pythondiscord.com/pages/guides/python-guides/discord-embed-limits/
sage tendon
#

as always, reading the docs >>>>

#

6000? wtf

echo wraith
sage tendon
#

they changed that at some point then

#

i firmly remember it being 2000 for the entire embed at one point

echo wraith
#

The official doc actually

nova epoch
#
import discord, logging, os, aiosqlite, asyncio

async with aiosqlite.connect('tags.db') as db:
        table = f'tags_{ctx.guild.id}' if ctx.guild else f'tags_{ctx.author.id}'
        await db.execute(f'''
            CREATE TABLE IF NOT EXISTS {table} (
                name TEXT UNIQUE NOT NULL,
                content TEXT NOT NULL
            )
        ''')
        try:
            await db.execute(f'INSERT INTO {table} (name, content) VALUES (?, ?)', (name, content))
            await db.commit()
            await ctx.respond(f'Tag "{name}" created successfully!')
        except aiosqlite.IntegrityError:
            await ctx.respond(f'Tag "{name}" already exists.')
lapis dock
lapis dock
#

if they run tag as a user command it would be a user id?

fresh sierra
lapis dock
#

I was recomending 2 tables. What it looks like they are doing now is a new table for every guild and every user id

#

table = f'tags_{ctx.guild.id}' if ctx.guild else f'tags_{ctx.author.id}'

fresh sierra
#

oooo i see now srry i didnt understand that

swift egret
#

hey there
So I have an existing /ban command that logs the ban into a log channel and I would also like to log bans that are issued directly with discord interface so I thought about using the the event "on_member_ban" but it seems there isn't a direct way to retrieve the reason nor the author who did the ban.
Maybe there's a better way to do this, any ideas?

lofty hedge
lapis dock
swift egret
lapis dock
#

yeah, probably

swift egret
#

according to the docs the target is the user who got banned

lapis dock
#

strange

#

can you show that section of your code

swift egret
#

getting this when printing entry
<AuditLogEntry id=XXX action=AuditLogAction.ban user=<Member id=XXX name='js7457' global_name='JS7457' bot=False nick='XXX' guild=<Guild id=XXX name='XXX' shard_id=0 chunked=True member_count=8753>>>

#

the member id is mine and there's no info on the target

little cobalt
#

can you try the raw one?

swift egret
#

sure

lapis dock
#

As the user is not cached It returns None. You will have to get the ID and convert it to a user manually

swift egret
#

@little cobalt @lapis dock I can indeed get the target id using the raw event

#

thank you

#

however I do not understand the cache thing

#

what is that about?

rain dune
#
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction

whenever i am running any command, i am getting this error.
but if i like run the same command twice, the command runs perfectly ol

#

why is it happening i have deferred also

#

using

await ctx.response.defer()
lapis dock
# swift egret however I do not understand the cache thing

If your bot stores all of the information about every user, guild, channel, etc it can see it would use up massive amounts of memory. So it only stores the information of the first X of all of those categories. When the bot receives a members information is "deletes" the most out of date information it has to make room.

lapis dock
rain dune
#
    order_group = SlashCommandGroup(
        name="order", 
        description="Manage Everything related to order",
        guild_ids=[1241794451958136993,1236055846308286637],
        default_member_permissions=discord.Permissions(administrator=True)
    )
    @order_group.command(description="Create an order")
    async def create(
        self,
        ctx,
        name: Option(str, "Enter name of the order", required=True), # type: ignore
        user: Option(discord.Member, "Mention the user you want to send", required=True), # type: ignore
        time: Option(str, "Enter the Delivery time", required=True) # type: ignore
    ):
        await ctx.response.defer()
                ...
#

yeap

#

i have defer every command like this

#

on the top

swift egret
#

there haven't been any other audits between the tests

lapis dock
#

When you restart the bot user cache is generally not filled. So your alt is not known by the bot. Discord does not give the information of a banned user on the ban event (which is why we use cache to get user info). You could try running one of your bots commands on your alt before banning and it would probably not be None

swift egret
#

but I suppose the best way is to go with the raw event for my case?

lapis dock
lapis dock
rain dune
# lapis dock specifically what line in your callback is this error from?

for every slashcommands in the group

The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/home/container/.local/lib/python3.12/site-packages/discord/bot.py", line 1130, in invoke_application_command
    await ctx.command.invoke(ctx)
  File "/home/container/.local/lib/python3.12/site-packages/discord/commands/core.py", line 376, in invoke
    await injected(ctx)
  File "/home/container/.local/lib/python3.12/site-packages/discord/commands/core.py", line 131, in wrapped
    ret = await coro(arg)
          ^^^^^^^^^^^^^^^
  File "/home/container/.local/lib/python3.12/site-packages/discord/commands/core.py", line 1370, in _invoke
    await command.invoke(ctx)
  File "/home/container/.local/lib/python3.12/site-packages/discord/commands/core.py", line 376, in invoke
    await injected(ctx)
  File "/home/container/.local/lib/python3.12/site-packages/discord/commands/core.py", line 139, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: NotFound: 404 Not Found (error code: 10062): Unknown interaction
swift egret
fresh sierra
#

u already used it

rain dune
#

yeap

fresh sierra
#

can you show us that command ?

rain dune
#

?tag paste

limber wagonBOT
#

Please copy and paste your code here. This makes it easier for everyone helping you.

rain dune
#

wait

rain dune
swift egret
lofty parcel
lofty parcel
swift egret
#

thank you !

fresh sierra
#

that have this issue ?

rain dune
fresh sierra
#

empty view can be the issue

rain dune
#

lemme try wait

lapis dock
rain dune
# lapis dock go even further up in the traceback. There is one more section above this
ignoring exception in command order complete:
Traceback (most recent call last):
  File "/home/container/.local/lib/python3.12/site-packages/discord/commands/core.py", line 131, in wrapped
    ret = await coro(arg)
          ^^^^^^^^^^^^^^^
  File "/home/container/.local/lib/python3.12/site-packages/discord/commands/core.py", line 1009, in _invoke
    await self.callback(self.cog, ctx, **kwargs)
  File "/home/container/commands/order_manage.py", line 149, in complete
    await ctx.response.defer()
  File "/home/container/.local/lib/python3.12/site-packages/discord/interactions.py", line 748, in defer
    await self._locked_response(
  File "/home/container/.local/lib/python3.12/site-packages/discord/interactions.py", line 1243, in _locked_response
    await coro
  File "/home/container/.local/lib/python3.12/site-packages/discord/webhook/async_.py", line 220, 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 "/home/container/.local/lib/python3.12/site-packages/discord/bot.py", line 1130, in invoke_application_command
    await ctx.command.invoke(ctx)
  File "/home/container/.local/lib/python3.12/site-packages/discord/commands/core.py", line 376, in invoke
    await injected(ctx)
  File "/home/container/.local/lib/python3.12/site-packages/discord/commands/core.py", line 131, in wrapped
    ret = await coro(arg)
          ^^^^^^^^^^^^^^^
  File "/home/container/.local/lib/python3.12/site-packages/discord/commands/core.py", line 1370, in _invoke
    await command.invoke(ctx)
  File "/home/container/.local/lib/python3.12/site-packages/discord/commands/core.py", line 376, in invoke
    await injected(ctx)
  File "/home/container/.local/lib/python3.12/site-packages/discord/commands/core.py", line 139, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: NotFound: 404 Not Found (error code: 10062): Unknown interaction
fresh sierra
#

strange that its the defer that cause this issue

lapis dock
#

is your host really slow? The problem is it takes more than 3 seconds for your bot to respond even with the defer

rain dune
lapis dock
#

ok, that is very weird. Glad it works now

sage tendon
#

you're making a new db for every user lmao

#

You need ONE sqlite file
Everything else you do with SQL inside of that sqlite file
One sqlite file = one entire DB

nova epoch
lapis dock
#

I still see a reason to split it up with 1 table having user tags and one table having guild tags incase you want to add functionality to one in the future but not the other. That is up to you however

sage tendon
#

yea, thats also what i suggested to them earlier

weary meteor
#
    async def callback(self, interaction: Interaction):
        channel = interaction.channel
        seller_id = channel.topic
        seller = discord.utils.get(interaction.guild.members, id=seller_id)
        tickets_cat = discord.utils.get(interaction.guild.categories, id=1234319572706791424)
        print(seller_id)
        print(tickets_cat)
        ow = {
            interaction.user: discord.PermissionOverwrite(read_messages=True, send_messages=True, view_channel=True, read_message_history=True),
            seller: discord.PermissionOverwrite(read_messages=True, send_messages=True, view_channel=True, read_message_history=True),
            interaction.guild.default_role: discord.PermissionOverwrite(read_messages=False, view_channel=False)
        }
        ticket_channel = await interaction.guild.create_text_channel(name=f"{interaction.user.name}-account-buy", category=tickets_cat, overwrites=ow)
        print(ticket_channel)
        await ticket_channel.send(f"Added {interaction.user.mention} as Buyer and {seller.mention} as Seller.")
        await interaction.respond(f"Created your ticket <#{ticket_channel.id}>")```
I get this error when clicking the button:
#
768682559634538566
TICKETS
Ignoring exception in view <AccountBuyView timeout=None children=1> for item <AccountBuy style=<ButtonStyle.success: 3> url=None disabled=False label='Buy' emoji=None row=None>:
Traceback (most recent call last):
  File "C:\Users\Acer\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\ui\view.py", line 426, in _scheduled_task
    await item.callback(interaction)
  File "C:\Users\Acer\PycharmProjects\lcmp-bot\views\account_buy.py", line 32, in callback
    ticket_channel = await interaction.guild.create_text_channel(name=f"{interaction.user.name}-account-buy", category=tickets_cat, overwrites=ow)
  File "C:\Users\Acer\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\guild.py", line 1217, in create_text_channel
    data = await self._create_channel(
  File "C:\Users\Acer\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\guild.py", line 1096, in _create_channel
    "id": target.id,
AttributeError: 'NoneType' object has no attribute 'id'
#

printing the tickets category prints out the name so why cant it create the channel

weary meteor
#

yeah real helpful, it found the category so why is it nonetype

#

huh?

little cobalt
#

so

#

if its None the bot might cannot see the category

#

what are your bot intents?

sage tendon
weary meteor
weary meteor
#

so im lost as to how its none

sage tendon
#

view the server as the bot role and see if it can see it first of all

weary meteor
#

okay

sage tendon
#

also, it might simply not be cached (for some reason), so try get_or_fetch instead

weary meteor
#

how would i access the bot object inside my view tho, should i pass it in as an arg

rugged lodgeBOT
sage tendon
#

discord.utils.get_or_fetch

weary meteor
#

ah okay

#

and yes the bot can see the category

shell radish
#

yeah just fetch it

weary meteor
shell radish
#

"channel"

weary meteor
#

tickets_cat = discord.utils.get_or_fetch(interaction.guild, id=1234319572706791424, attr="channel")
something like this?

#

whoops i removed .categories

shell radish
weary meteor
#

oh

shell radish
#

all CategoryChannel objects are GuildChannel objects so it should be a channel

sage tendon
#

yea i was also a bit confused by that, but shouldn't that still work?

shell radish
weary meteor
sage tendon
#

ah

shell radish
#

and besides, categories returns an array

shell radish
weary meteor
#

yeah still gave me the same error

#
Ignoring exception in view <AccountBuyView timeout=None children=1> for item <AccountBuy style=<ButtonStyle.success: 3> url=None disabled=False label='Buy' emoji=None row=None>:
Traceback (most recent call last):
  File "C:\Users\Acer\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\ui\view.py", line 426, in _scheduled_task
    await item.callback(interaction)
  File "C:\Users\Acer\PycharmProjects\lcmp-bot\views\account_buy.py", line 33, in callback
    ticket_channel = await interaction.guild.create_text_channel(name=f"{interaction.user.name}-account-buy", category=tickets_cat, overwrites=ow)
  File "C:\Users\Acer\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\guild.py", line 1217, in create_text_channel
    data = await self._create_channel(
  File "C:\Users\Acer\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\guild.py", line 1096, in _create_channel
    "id": target.id,
AttributeError: 'NoneType' object has no attribute 'id'
768682559634538566
TICKETS
<class 'discord.channel.CategoryChannel'>```
shell radish
#

oh wait you didn't await the coro

weary meteor
#

i did

shell radish
#

but that should be a different error

#

ok

weary meteor
#

i saw the error and added it myself

sage tendon
#

this is probably jank but can't you just do ticket_cat = discord.Object(id= category ID)

shell radish
weary meteor
#

nope still throws the same error

errant trout
sage tendon
errant trout
#
        seller_id = channel.topic
        seller = discord.utils.get(interaction.guild.members, id=seller_id)```this 100% returns None
#

and breaks the entire overwrites

weary meteor
#
{<Member id=768682559634538566 name='thunderins2' global_name='thunderins' bot=False nick=None guild=<Guild id=1234305926702432277 name='Banana Marketplaace' shard_id=0 chunked=True member_count=20>>: <discord.permissions.PermissionOverwrite object at 0x00000186DF5179D0>, None: <discord.permissions.PermissionOverwrite object at 0x00000186DF5A4460>, <Role id=1234305926702432277 name='@everyone'>: <discord.permissions.PermissionOverwrite object at 0x00000186DF5A4280>}
#

ah hey

weary meteor
#

ur right

#

LOL

errant trout
#

because channel.topic is a string

weary meteor
#

yep

errant trout
#

convert it to int and use interaction.guild.get_member

sage tendon
#

right

weary meteor
#

it freakin fixed it

#

thank you nelo

errant trout
#

allgood

upper flint
#

How to ping a server event?

errant trout
#

uhhh

#

elaborate?

sage tendon
#

Don't think that's possible if you mean an inline ping like #general

#

you can only send the share url and that'll show the event embed

upper flint
#

Alright, thanks

wild prairie
#

Is there a way to take custom emoji inputs in a Modal InputText without entering the full name with ID (copied from escaping the emoji)?

wild prairie
little cobalt
#

Idk if you can do it with copy and paste

fresh sierra
#

Why does pycord doesn’t have a setup_hook like discord.py ( if I understand what is it is something that run prior to the bot.run) that will be useful for the load_extension etc or does it already exist something similar

shell radish
#

there isn't any implicit need for it. It's not like discord.py where load_extensions is asynchronous

fresh sierra
#

Well ur right

#

Can still be useful but it’s not that important as in dpy since load extension are asynchous

#

(I forgot that in dpy it’s async)

frail ocean
#
Traceback (most recent call last):

  File "/data/main.py", line 373, in <module>

    client.run('Token')

  File "/usr/local/lib/python3.10/site-packages/discord/client.py", line 766, in run

    return future.result()

  File "/usr/local/lib/python3.10/site-packages/discord/client.py", line 745, in runner

    await self.start(*args, **kwargs)

  File "/usr/local/lib/python3.10/site-packages/discord/client.py", line 709, in start

    await self.connect(reconnect=reconnect)

  File "/usr/local/lib/python3.10/site-packages/discord/shard.py", line 475, in connect

    raise item.error

  File "/usr/local/lib/python3.10/site-packages/discord/shard.py", line 180, in worker

    await self.ws.poll_event()

  File "/usr/local/lib/python3.10/site-packages/discord/gateway.py", line 603, in poll_event

    await self.received_message(msg.data)

  File "/usr/local/lib/python3.10/site-packages/discord/gateway.py", line 555, in received_message

    func(data)

  File "/usr/local/lib/python3.10/site-packages/discord/state.py", line 818, in parse_interaction_create

    interaction = Interaction(data=data, state=self)

  File "/usr/local/lib/python3.10/site-packages/discord/interactions.py", line 171, in __init__

    self._from_data(data)

  File "/usr/local/lib/python3.10/site-packages/discord/interactions.py", line 201, in _from_data

    self._guild = Guild(data=self._guild_data, state=self)

NameError: name 'Guild' is not defined. Did you mean: 'guild'?```
#

What does this error mean

frail ocean
errant trout
#

error?

errant trout
#

then you aren't on master

sly karmaBOT
#

pip install git+https://github.com/Pycord-Development/pycord

frail ocean
errant trout
frail ocean
errant trout
#

It imported stuff wrong and there's some other minor issues on 2.5

rare marlin
#
An error occurred: 'SelectOption' object has no attribute 'append'


k_options = discord.SelectOption(label="Ticket", emoji="🎫")


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

    @discord.ui.select(
        custom_id="bro_i_dont_know",
        placeholder="👆 | CLICK ME!",
        options=keks,
    )
    async def ticket_select_callback(self, select, interaction):
        if "Ticket" in select.values:
            labels = [option.label for option in select.options]
            print(f"Labels: {labels}")
            k_options.append_option(k_options)
        else:
            select.disabled = True
            await interaction.response.edit_message(view=self)



my command  @ticket.command(description="Add a ticket option")
    async def select(self, ctx, name: str, emoji: str):
        global my_option_count
        await ctx.defer(ephemeral=True)
        ticket_message = await db.get_message(ctx.guild.id)
        if ticket_message:
            try:
                if await db.name_exists(ctx.guild.id, name):
                    await ctx.respond("This name is already in use. Please choose a different name.", ephemeral=True)
                    return
                if my_option_count >= 5:
                    await ctx.respond(
                        "You have reached the maximum number of options (5). Please remove an option before adding a new one.",
                        ephemeral=True)
                    return

                message = await ctx.channel.fetch_message(ticket_message)
                view = CreateTicketSelect(k_options)
                k_options.append(discord.SelectOption(label=name, emoji=emoji))
                view.add_item(k_options)
                await message.edit(view=view)
                await ctx.respond("The option was added successfully.", ephemeral=True)
                my_option_count += 1
            except Exception as e:
                await ctx.respond(f"An error occurred: {e}", ephemeral=True)
            print(name)

            await db.add_option(ctx.guild.id, name)
        else:
            await ctx.respond(f"The ticket message was not found. Please {self.bot.get_cmd('ticket setup')} First!", ephemeral=True, delete_after=10)```
errant trout
#

and down there below your CreateTicketSelect view k_options.append(discord.SelectOption(label=name, emoji=emoji))

#

it seems k_options should be a list or you want select.append_option

rare marlin
errant trout
#

what are you trying to do

rare marlin
errant trout
#

...i'm struggling to see how k_options is meant to work ```py

            view = CreateTicketSelect(k_options)
            k_options.append(discord.SelectOption(label=name, emoji=emoji))
            view.add_item(k_options)
- Why is `CreateTicketSelect` taking `k_options` when it's meant to be a guild id?
- you use `k_options.append` as if it's meant to be a list, but then on that 3rd line you use `add_item` - which is it?
#

it feels to me that you don't know what's happening in your own code

frail ocean
#

But on other bots from me it wont happen

errant trout
#

Because it doesn't affect every bot

sage tendon
#

But what is the condition that makes it fail

#

thats what ive been wondering too

frail ocean
#

Idk

errant trout
gray sun
#

Can someone tell me how I can fix this error, I get it all the time and I don't know how to fix it

TypeError: expected Item not <class 'discord.ext.commands.bot.Bot'>```
errant trout
#

full traceback

gray sun
errant trout
#

what is the full error in your console

gray sun
# errant trout what is the full error in your console
Ignoring exception in modal <command.ticketview.TicketModal object at 0x0000021B051E3D10>:
Traceback (most recent call last):
  File "C:\Program Files\Python311\Lib\site-packages\discord\ui\modal.py", line 341, in dispatch
    await value.callback(interaction)
  File "c:\Users\faust\OneDrive\Bureau\Bot-Discord\command\ticketview.py", line 33, in callback
    await ticketchannel.send(f'Ticket créé par {interaction.user.mention} pour la raison suivante : {reason}', view=CloseTicketView(self.bot))
                                                                                                                     ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Python311\Lib\site-packages\discord\ui\view.py", line 184, in init
    self.additem(item)
  File "C:\Program Files\Python311\Lib\site-packages\discord\ui\view.py", line 291, in add_item
    raise TypeError(f"expected Item not {item.__class!r}")
TypeError: expected Item not <class 'discord.ext.commands.bot.Bot'>```
errant trout
#

ok, so what are you doing in CloseTicketView

gray sun
errant trout
#

ok, but you're also using add_item on bot

#

which is wrong

gray sun
errant trout
#

somewhere in CloseTicketView.__init__, probably

#

probably super? i bet you have something like ```py
class CloseTicketView(View):

def __init__(self, *args, **kwargs):
    super().__init__(*args, **kwargs)```
errant trout
#

can you show your full init

gray sun
errant trout
sage tendon
#

just make a screenshot of the class with your init in it

errant trout
#

eh

#

restart your bot? lol

edgy nest
#

press ctrl+s

errant trout
#

that too

austere plank
#

How can buttons / components be used in locked threads?

gray sun
edgy nest
edgy nest
gray sun
austere plank
errant trout
#

if it's locked then you can't interact at all in the thread

austere plank
#

Aight ✅

#

Thought there is a way

#

So i can just reopen it by command or discord default by right clicking the thread

errant trout
#

indeed, unlocking it works

#

though considering that mods can talk in a locked thread, perhaps the UX for that should be improved

austere plank
#

yeah pretty weird i thought one of the ticket bots out there have it like that but looks like i thought wrong lol

#

Or maybe the message with the component have to be sent after the thread was closed idk have to try it. rn im doing it for the inital message

errant trout
#

nah it doesn't work for new messages either, despite the fact that the bot can send messages at all

austere plank
#

ok thx then i can spare that time

errant trout
#

kinda feels like an oversight if anything

gray sun
#

Why Have I that error now :

AttributeError: module 'discord' has no attribute 'ui'

errant trout
#

reinstall py-cord

sage tendon
wild prairie
#

Is there a way to make a slash command group be clickable in a message? I can have standard slash commands be clickable via </name:id> but I'd like a way to be able to click a slash command group for it to show all the sub-commands

errant trout
wild prairie
errant trout
#

you can automate it easier by iterating through commands and using command.mention

#

even better if they have descriptions set already so you don't have to write them out again

#

or perhaps for groups, consider making use of components/paginator to display them

wild prairie
#

Yeah, but I want to keep certain ones out and it's easier for me to do this. I was thinking of switching that in the future

errant trout
#

fairfair

wild prairie
#

Can I use bridge commands for command groups?

errant trout
wild prairie
# errant trout there's bridge_group

awesome. I just realized I'd need to add a crap ton of code to now account for the required parameters that aren't necessarily passed, so i'm sticking with slash commands haha

#

(i only found out bridge commands was a thing about 10 minutes ago)

errant trout
#

yeah not always ideal

tidal vessel
#

Guys, a question, is the timeout attribute of a .View object reset after each interaction?

tidal vessel
frail ocean
#

Is there a way to get the lib + version in a command?

grizzled loom
frail ocean
#

This show the complete list?

grizzled loom
#

its like giving the line into a terminal

#

there might be a better way to do it. that's just the first thing that came to mind when reading your question

errant trout
#

If you mean for other libraries then it may vary, __version__ is a recommended implementation by PEP8 but it's not guaranteed to be present

#

In which case perhaps the pip command would be better

frail ocean
errant trout
#

it'll show some longer string like 2.5.1

#

even though it doesn't exist

south smelt
#

i have a really dumb question
what does vc = ctx.voice_client do exactly
(it was from an older guide i think, and it says "define our voice client")
but i don't exactly understand how it works

sage tendon
#

its just to get quicker access to ctx.voice_client

#

by saving it to a short variable

south smelt
#

i mean like

#

the ctx part

sage tendon
#

what about it

south smelt
#

i'm trying to make it so that i don't have to run a command
and it would just automatically connect to a specific voice channel

sage tendon
#

on startup?

south smelt
#

and... i guess i'm just too dumb

#

yes

sage tendon
#

well, then you'd need a set voice channel for every server, or if you only have your bot in one server, hardcode it into your on_ready

south smelt
#

i only need it in one server
but i don't know how to specify the voice channel

#

is it just get_channel?

sage tendon
#

yes

south smelt
#

oh

#

thank you

red mist
#

You can do circular imports even though its generally not recommended, just import the variable exactly then when you need it, inside a function for example.

Because if you import it directly at the beginning, it's loaded for the entire cog and when you then try to import something from that cog back into your main.py then it says circular import, except for when you import only a specific part of your cog, a function or a variable when you need it.

fresh sierra
#

It was because the variable was only on the on_ready, and there was no reason tu be rhere

red mist
#

Honestly didn't read further because chat didn't load 🐔

arctic oar
#

Is it possible to run a asynchronous function within a regular function and have it run via asyncio?

@property
def balance(self) -> int:
    """ Returns the balance of the user
    """
    async def fetch_balance() -> int:
      ...

    # TODO: can i run fetch_balance async here?
granite pier
#

loop.run_until_complete(fetch_balance())

#

but it's better to already do async functions to get/set rather try to do it in property

sage tendon
#

what's stopping you from making the balance function async

little cobalt
sly karmaBOT
# granite pier `@property`

You can run blocking code (such as PIL/Pillow) in an executor to run it in a separate thread: ```py
def my_blocking_func(*args):
...

@bot.command()
async def test_command(ctx):
ret = await bot.loop.run_in_executor(my_blocking_func, 'put', 'args', 'here')``` See the python documentation for more info.

little cobalt
#

Else remove the property

deft kestrel
#

how to get discord profile pic from ctx?

little cobalt
swift egret
#

hey there!
I have an existing join log, made a while back and recently the member mention doesn't show the name of the user anymore

#

example of someone leaving the server

#

when I click on the mention it says I do not have access

sage tendon
#

completely normal, that has always been the case

#

mentions in embeds do not resolve if the mentioned user isn't in the client cache

swift egret
sage tendon
#

ping them in the message

#

or wait

#

i think they did recently do some changes where even that isnt possible anymore, but not sure

#

try it out

#

Make an alt, join with it, leave with it, restart your main discord, and see if the ping resolves if you put the ping in the message content

clear bolt
#

import discord not working?

sage tendon
#

run pip list in a cmd and show the output

clear bolt
#

discord is there, but when running my bot i get the error ModuleNotFoundError: No module named 'discord'

sage tendon
#

no, show the output

clear bolt
sage tendon
#

that is not pycord

#

uninstall whatever that is and run pip install py-cord

clear bolt
#

oh wait

#

maybe that why

errant trout
sage tendon
clear bolt
sage tendon
#

restart your IDE and try again

clear bolt
#

okay well see my issue tho is running the bot because i have ```py
import discord

#

in the python code

sage tendon
#

yea, thats correct

clear bolt
#

and its just not found

sage tendon
#

do you have a venv?

clear bolt
#

no

#

i dont think so

sage tendon
#

show the files and folders in your project (within vscode if possible)

clear bolt
#

oh is that why i cant find the discord library

sage tendon
#

like the structure

clear bolt
#

alr

sage tendon
#

65 problems

#

damn

clear bolt
#

see i've just been copying my old code from replit and its shitting itself

clear bolt
sage tendon
#

but you dont have a .venv file/folder in your structure right? those are all?

errant trout
#

eh just work through it, probably nothing major

sage tendon
clear bolt
sage tendon
# clear bolt correct

open your terminal in your IDE (it should default to the venv) and run pip install py-cord again

clear bolt
#

oki

#

done

#

does replit just have all the libraries just there?

sage tendon
#

id imagine it has the most used ones there

clear bolt
#

ohh

sage tendon
#

i just wonder how they differentiate between e.g. pycord and discord

#

thats why i dont use repl.it, it kinda shit

clear bolt
#

i found that out trying to migrate after 3 years 😭

#

i think the last time i seriously touched this code was like 2 years ago

sage tendon
#

VPS, thats all you need
Few euros a month and no worries

clear bolt
#

or just run it off my pc

sage tendon
#

24/7? nah

clear bolt
#

its on 24/7 anyways

sage tendon
clear bolt
#

well i run my minecraft server usually 24/7 too

#

so

#

why not a bot too 💀

#

anyways how do i get these libraries

sage tendon
#

?

clear bolt
#

like the discord library

sage tendon
#

pip install
lol

clear bolt
#

ik 💀

#

but it refuses to work in the code

sage tendon
#

still not?

#

can you show the console output when you run your bot

clear bolt
sage tendon
#

do you run it from inside vsc or normal cmd

clear bolt
#

vsc

sage tendon
#

try a normal cmd

clear bolt
#

its been too long since i've ran anything, can i get a quick refresher on what to do

sage tendon
#

and make sure to install pycord there too to make sure

clear bolt
#

nop

#

this is why i quit 😭

sage tendon
#

?

clear bolt
#

i quit python a few years ago

errant trout
#

can you do python -m pip list

clear bolt
errant trout
#

nope, different command

clear bolt
#

same output tho

errant trout
#

including py-cord?

clear bolt
#

yup

errant trout
#

and python main.py doesn't work...? wth did you do

clear bolt
#

i have no clue

#
import discord 
``` just doesnt work
errant trout
#

what if you type python, then in the console that shows up type import discord

clear bolt
#

doesnt exist 😭

errant trout
#

then how about python -m pip install -U py-cord

clear bolt
#

requirement already satisfied

#

💀

sage tendon
#

man

#

what

clear bolt
#

yeah

errant trout
#

can you show a screenshot of the console output from all those commands

clear bolt
#

😭

#

which ones specificlly

errant trout
#

all :)

#

however much is feesible, i suppose

clear bolt
#

very slow upload speed

sage tendon
#

also go to your python path here and check the lib > site packages folder

clear bolt
errant trout
#

did you never actually run python main.py...?

#

(also you'll need to uninstall discord and discord.py, but that's for later)

sage tendon
#

all things i already said -w-

errant trout
#

wow no way

sage tendon
#

also, you still did it wrong

#

you have to type python > ENTER > then try import discord

clear bolt
sage tendon
#

show.

clear bolt
sage tendon
#

type
import discord

#

bruh

clear bolt
#

i did

#

no work

sage tendon
#

screenshot

#

this is all you need to do

clear bolt
#

no feedback

sage tendon
#

yea okay

#

now do exit()

and from that very same cmd, navigate to your bot directory and run python main.py

clear bolt
#

i forgor how 😭

sage tendon
#

cd

clear bolt
#

oh ty

#

nope

#

ARGGG

sage tendon
#

screenshot

clear bolt
#

wait

#

if its a venv issue imma kms

#

FUCK ME DUDE

#

IT WAS THE STUPID FUCKING VERSION

#

IT DIDNT LIKE THE OFFICIAL PYTHON VERSION, IT LIKED THE MICROSOFT BETTER

#

YOU GOTTA BE FUCKING JOKING

sage tendon
#

bruh

clear bolt
#
  File "C:\Users\hudso\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\discord\commands\context.py", line 271, in ApplicationContext
    @discord.utils.copy_doc(Interaction.respond)
                            ^^^^^^^^^^^^^^^^^^^
AttributeError: type object 'Interaction' has no attribute 'respond'. Did you mean: 'response'?
PS C:\Users\hudso\Downloads\Super Awesome Bot> & C:/Users/hudso/AppData/Local/Microsoft/WindowsApps/python3.12.exe "c:/Users/hudso/Downloads/Super Awesome Bot/main.py"
Traceback (most recent call last):
  File "c:\Users\hudso\Downloads\Super Awesome Bot\main.py", line 22, in <module>
    import discord.commands
  File "C:\Users\hudso\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\discord\commands\__init__.py", line 26, in <module>
    from .context import *
  File "C:\Users\hudso\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\discord\commands\context.py", line 69, in <module>
    class ApplicationContext(discord.abc.Messageable):
  File "C:\Users\hudso\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\discord\commands\context.py", line 271, in ApplicationContext
    @discord.utils.copy_doc(Interaction.respond)
                            ^^^^^^^^^^^^^^^^^^^
AttributeError: type object 'Interaction' has no attribute 'respond'. Did you mean: 'response'?
PS C:\Users\hudso\Downloads\Super Awesome Bot> 
#

cant find the issue

#

like whats causing it

sage tendon
#

that file path tells me its still the windows store version

clear bolt
#

yeahhh

sage tendon
#

stop using that, people only ever have issues with that crap

clear bolt
#

thats what fixed my issue tho

sage tendon
#

oh, what?

#

yea then your python install is just cooked

clear bolt
#

fug

sage tendon
#

and you ONLY have this version of python installed now right

clear bolt
#

in a bit, i gotta drive home

frail ocean
#

How can i set a regex in automod

sage tendon
rare marlin
#

error py An error occurred: 'TutorialSelect' object has no attribute 'append' mein code ```py
@ticket.command(description="Add a ticket option")
async def select(self, ctx, name: str, emoji: str):
global my_option_count
await ctx.defer(ephemeral=True)
ticket_message = await db.get_message(ctx.guild.id)
if ticket_message:
try:
if await db.name_exists(ctx.guild.id, name):
await ctx.respond("This name is already in use. Please choose a different name.", ephemeral=True)
return
if my_option_count >= 5:
await ctx.respond(
"You have reached the maximum number of options (5). Please remove an option before adding a new one.",
ephemeral=True)
return
select = TutorialSelect()
select.append(discord.SelectOption(label=name, emoji=emoji))
await ctx.respond("The option was added successfully.", ephemeral=True)
my_option_count += 1
except Exception as e:
await ctx.respond(f"An error occurred: {e}", ephemeral=True)
print(name)

        await db.add_option(ctx.guild.id, name)
    else:
        await ctx.respond(f"The ticket message was not found. Please {self.bot.get_cmd('ticket setup')} First!", ephemeral=True, delete_after=10)``` meine class ```py

class TutorialSelect(discord.ui.Select):
def init(self):
super().init(
min_values=1,
max_values=1,
placeholder="Triff eine Auswahl",
options=t_options
)

async def callback(self, select, interaction):
    if "Ticket" in select.values:
        labels = [option.label for option in select.options]
        select.append_option(t_options)
        await interaction.response.edit_message(view=self)```
sage tendon
#

read the error

#

you are trying to use .append on your own class

#

that makes no sense

#

Besides, i dont think what you're doing would work anyway but not sure

rare marlin
#

i have fix

vital bramble
#

How would I pass labels and values to the autocomplete, instead of just values (or labels?)? Is the only way using OptionChoices or can I also just use dicts?

sage tendon
#

you cant, thats not how autocomplete works
yes, you need optionchoices

shadow bear
#

Can sub-application-commands have their own default_permissions?

sage tendon
#

i think i did do that once, one second

edgy nest
#

you just have to use optionchoices

sage tendon
#

yea i just looked it back up, i confused it with smth else

#

yea

#

my bad

shadow bear
#

I'll just have to make a subgroup with the perms

#

wait is that a thing?

#

or are perms down to the root

edgy nest
#

root only

shadow bear
#

omg

#

this platform infuriates me sometimes

edgy nest
#

you can always add your own checks

shadow bear
#

I'll just enforce them traditionally

#

yea

sage tendon
#

whats the command and the subcommands in question

#

like why do you need just one / more subcommands restricted

shadow bear
vital bramble
edgy nest
#

i believe so

edgy nest
#

it's probably fairly easy to convert that though

sage tendon
vital bramble
#

yeah it is

sage tendon
#

only takes a list of str or optionchoices

edgy nest
#

if you want to pr it I would approve

sage tendon
#

like all the admin cmds

shadow bear
#

I do have that, but /settings is more a meta-thing (e.g. configuring prefix, log channels, etc). grouping it under /sr clearly indicates that its specifically for the self-roles system

#

its fine though, i'm just requiring manage_roles, nobody will care

sage tendon
#

/settings sr add
shrug

shadow bear
#

I doubt anyone changes slash command permissions from their defaults anyway

shadow bear
sage tendon
#

Most don't, some do

shadow bear
#

I'll play about with some testing

shadow bear
#

manage_roles is generally a sensible requirement for... managing roles, lol

sage tendon
#

yea

shadow bear
#

Oh that's just reminded me

#

can options be dynamic?

#

or will I have to use autocomplete and validate

sage tendon
#

Options are static

shadow bear
#

I want per-guild options

#

ah yikes alright

#

thought so

#

thanks :)

red mist
#

I think it depends on what your options contain- autocomplete for channel selection for example can be different on every guild, no?

limber terrace
#

so i tested stuff for my new help command and comes to the point where the bot throws me the following error:
help.py konnte nicht geladen werden. [Extension 'commands.help' raised an error: ClientException: Too many arguments passed to the options kwarg.]

my next question, only two Options for one command allowed? :O

#
    @slash_command(name="help", description="When you know, you know (WIP)",
        options=[
                Option(
                    input_type=str, 
                    name="options", 
                    description="What type of commands you want to see", 
                    choices=[
                        OptionChoice(name="User Commands", value="user"),
                        OptionChoice(name="Slash Commands", value="slash"),
                        OptionChoice(name="Message Commands", value="message"),
                        OptionChoice(name="Slash Command Groups", value="group")
                    ], 
                    required=False
                    ),
                Option(
                    imput_type=str,
                    name="group", 
                    description="Specific group you want to see",
                    required=False
                    ),  
                Option(
                    input_type=str, 
                    name="command", 
                    description="Specific command you want to see", 
                    required=False
                    )
                ]
        )```
or....
#

wait....

#

alright nvm, got it

#

missed one varible in the definition head

silk oriole
#

does pycord support that feature some bots have where like, it responds with a different name and pfp than the bot actually has?

#

idk how to actually describe it

red mist
#

webhooks?

silk oriole
#

thank you :3

limber terrace
#

Cosmetic question:

embed.description=f"Description: `{command.description}`\n" \
                 f"Usage:       `{command.name} {', '.join([f'<{i.name}>' for i in command.options])}`\n" \
                 f"Type:        `{type(command).__name__}`"

how to accomplish this ^^^^

#

the picture is the output and i dont wanna have to use cheat chars xD

#

random ideas appreciated

edgy nest
#

codeblock the entire thing

#

tab characters

#

two seperate fields

sage tendon
#

doesnt that code, do that?

limber terrace