#Basic Pycord Help

1 messages · Page 33 of 1

civic quiver
#

to set it equal to the usercolor var and not the color var, bc the role was named after usercolor

lapis dock
#

do you have a bare except? IE except: with nothing between the except and the :

civic quiver
#

No, i have discord forbidden and HTTPException

lapis dock
#

👍

hybrid tinsel
#

whats the limit for changing voice channel names?

sage tendon
#

10 minutes

#

per channel

hybrid tinsel
#

thank you!

gaunt vale
#

Oh yea natsu_facepalm That arrangement wasn't the first thing on my mind while figuring it out. Thank you

By the way is it an short way to disable the buttons when it's used when editing the message?

sage tendon
#

self.disable_all_items

#

that disables all buttons

gaunt vale
#

When editing I think the view gets sent again, so guessing put disable as last part?

sage tendon
#

try it and see

wanton bramble
#

My bot won't run- I copypasted the starter from the guide, but it throws an error

AttributeError: module 'discord' has no attribute 'Bot'
sage tendon
#

show your pip list

wanton bramble
#
Package       Version
------------- -------
aiohttp       3.9.5
aiosignal     1.3.1
attrs         23.2.0
frozenlist    1.4.1
idna          3.7
load-dotenv   0.1.0
multidict     6.0.5
pip           24.0
py-cord       2.5.0
python-dotenv 1.0.1
yarl          1.9.4
sage tendon
#

hm

#

venv?

wanton bramble
#

Yes- Python 3.12.3, however also doesn't work outside of it

sage tendon
#

is that the pip list from inside your venv?

wanton bramble
#

Yes.

sage tendon
#

did you try reinstalling?

wanton bramble
#

Not inside of it no, but I have outside of it

sage tendon
#

well try reinstalling it in the venv

lapis dock
#

first restart your IDE'

wanton bramble
wanton bramble
#

Still not working.

lapis dock
#

same error?

wanton bramble
#

Yes.

lapis dock
#

right after import discord add print(discord.__version__)

wanton bramble
#

I get a new error:

AttributeError: module 'discord' has no attribute '__version__'
lofty parcel
#

Well, thats new. Kek

little cobalt
lapis dock
wanton bramble
#
Package       Version
------------- -------
aiohttp       3.9.5
aiosignal     1.3.1
attrs         23.2.0
frozenlist    1.4.1
idna          3.7
load-dotenv   0.1.0
multidict     6.0.5
pip           24.0
py-cord       2.5.0
python-dotenv 1.0.1
yarl          1.9.4
little cobalt
#

oh nvm xd

sage tendon
#

can you go into your venv > lib > site packages > discord and show whats in there

wanton bramble
#

Quite a bit in there- do you want a dir or a screenshot or two?

sage tendon
#

just show some stuff, no need to show everything

wanton bramble
#

Alright.

lapis dock
#

Do you have any files or folders that you created named discord?

sage tendon
wanton bramble
#

Yeah- it's odd.

sage tendon
#

can you show your project files

wanton bramble
lapis dock
#
import discord
import os.path
print(os.path.abspath(discord))
print(os.path.abspath(discord.__file__))

can you run this

#

take out any personal info in the file path before sending btw

wanton bramble
#

No, it crashes-

NameError: name 'my_module' is not defined
lapis dock
#

forgot to edit it to discord you can copy paste the above again

wanton bramble
#

Alright.

#

Still crashes-

  File "<frozen ntpath>", line 599, in abspath
  File "<frozen ntpath>", line 566, in normpath
TypeError: expected str, bytes or os.PathLike object, not module
lapis dock
#

ok get rid of the first print statement than.

wanton bramble
#

Same happens.

lapis dock
#

ok, try just the first printstatement not the second

wanton bramble
#

Same error.

lapis dock
#

try

import discord
print(discord.__path__)
sage tendon
#

tf lol

wanton bramble
#
_NamespacePath(['C:\\Users\\[REDACTED]\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python312\\site-packages\\discord'])
sage tendon
#

wtf is that folder name

wanton bramble
#

I'm using the Microsoft store version of Python.

lapis dock
#

I dont know how but microsoft broke thier version of python

wanton bramble
#

I can swap it out for the python.org version- I have both.

lapis dock
wanton bramble
#

It appears to install globally.

sage tendon
#

well, even so, does it work with the normal python?

wanton bramble
#

I'll test it again.

lapis dock
#

you probably need to activate your venv before installing

#

if it is installing globally

wanton bramble
#

I have activated my venv

#

And no, it does not work.

sage tendon
#

do you run your bot via the IDE or just via the cmd btw

lapis dock
#

in the terminal as well?
(.venv) PS [Path to project folder]> pip install py-cord?

wanton bramble
sage tendon
wanton bramble
#

Ah.

#

What does?

sage tendon
#

Usually you run it via the IDE because your IDE handles the venv

wanton bramble
#

How do I do that? (VSC)

lapis dock
#

You can look up how I'm sure. I have never done that though

sage tendon
#

yea no clue with vsc either

#

but im confused that it even imports without erroring then

lapis dock
#

I don't use VSC but if you look up how to set up a python venv in VSC you will find something

wanton bramble
#

Hold on I found a run button

#

It works now!

lapis dock
#

🎉

wanton bramble
#

Hi again! Does anyone know how I can add an optional argument to a / command? Guide doesn't seem to mention it.

sage tendon
#

required=False

wanton bramble
#

Thank you!

#

Does that also work with sub commands?

sage tendon
#

of course

wanton bramble
#

How do I provide it? Syntax looks a little different.

sage tendon
#

?

#

just in the option like normal

wanton bramble
#

How? The guide shows subcommands as looking like this

math = discord.SlashCommandGroup("math", "Math related commands")

@math.command()
async def add(ctx, num1: int, num2: int):

How do I set required on it?

sage tendon
#

well, use the option decorator or the option typehint lol

#

like you do with other commands too (i hope)

wanton bramble
#

This is my first command

sage tendon
#

under math.command, put @discord.option(name="num1", type=int, required=False)
and the same for your other option

#

thats how you explicitly make options

wanton bramble
#

So like
Do I put it in

@math.command()
async def add():
   @discord.option(name="num1", type=int, required=False)
sage tendon
#

under math.command

#

not in the function header

#

and you leave the rest as it is

wanton bramble
#
@math.command(@discord.option(args))
async def add:
   pass
sage tendon
#

UNDER

#

not in

#

and again, you leave the rest as it is

#

you just removed half your function header lol

wanton bramble
#
@math.command()
@discord.option(...)
async def add():
   pass
sage tendon
#

leave the function header as it was before

#

dont change the parameters of it

#
@math.command()
@discord.option(...)
async def add(ctx, num1: int, num2: int):
   ...
#

like that

#

and then you need another option decorator for the other option

#

doing it this way also makes the typehint in the function header optional and really just to help yourself

wanton bramble
#

Is num1 the option (discord.option(...))?

sage tendon
#

Options pick the parameter they bind to via the name parameter (usually)

wanton bramble
#

So if I name my option asdf and then add

async def add(ctx, asdf: int)

asdf is the option?

sage tendon
#

yea

wanton bramble
#

Thank you!

#

How can I handle the case where my argument is undefined?

sage tendon
#

wdym undefined

wanton bramble
#

Not supplied.

sage tendon
#

by default None is passed

wanton bramble
#

So

if asdf == None:
   pass
else:
   pass
sage tendon
#

you can just do if asdf

#

but yes

wanton bramble
#

Thank you.

high pilot
#

just wanted to know if 2 discord.ext.tasks loops are run simultanously or one after the other

sage tendon
#

its async, so, kinda both

high pilot
#

actually running heavy tasks in both so cant really have much delay as then the results wont be perfect

#

but thanks will give it a go and see

sage tendon
#

as long as it uses no blocking code

high pilot
#

meaning?

#

ah

#

no worries i think no blocking code just heavy queries andstuff ongoing

sage tendon
#

as long as its async :)

#

not async = blocking

high pilot
#

like lets say inside the tasks i run non async functions

#

still blocking?

sage tendon
#

yes.

high pilot
#

so to convert to async just right async def or need to change the code?

sage tendon
#

do you do db queries or API requests?

high pilot
#

i do api requests through requests.get atm

sage tendon
#

use aiohttp

high pilot
#

okay will see to that

#

thanks

weary meteor
#

how can i create a command that restarts the bots? like /restart stops it and starts the entire bot again as if i were running my bot file

sage tendon
#

why do you need to restart your bot so often that it needs a command

weary meteor
#

its for config changes, im using a json file and i have commands to update it but i need to restart the bot each time for it actually reflect those changes

sage tendon
#

what are you updating that needs a restart

weary meteor
#

the json file..?

#

as i said, its to update my config in the bot

shell radish
#

you can definitely update configs without restart

sage tendon
#

just read the json file again lol

wanton bramble
sage tendon
#

literally did?

#

they asked just fine

wanton bramble
#

fuck wrong link

#

Help rules-

This is not a server that will write code for you (AKA spoon-feeding.) We will offer help but questions like "How to make a warn command?" will not be answered.

sage tendon
#

meh

wanton bramble
#

granted i did the same earlie-

sage tendon
#

they were more asking for a way to restart the bot because there's no bot.restart

sonic onyx
#

When someone sends #channel, that carries the channel id right?

sage tendon
#

yes

#

p sure

#

try it i mean

#

might just be # channel

edgy nest
wanton bramble
sonic onyx
#

ah. So if I want the bot to get a channel id from a response, getting it from a channel mention would be most useful I'm guessing

sage tendon
#

slash command?

sonic onyx
#

Yes basically I'm testing a command that allows me to use the bot to post text to another channel

sage tendon
#

you can use discord.TextChannel as option

sonic onyx
#

so I would run the command, it would prompt me to mention the channel, then it would read the message for a channel id if its a channel mention(?)

#

at least that's how I see the first part working

sage tendon
#

no

#

you just make the channel a normal option like any other

#

itll even list the channels of the server

#

and then you select that and the parameter will be the channel already, no id or anything

sonic onyx
#

Is there like an example of this?

#

I don't really understand what you mean exactly

sage tendon
#

just make an option and use discord.TextChannel as the input type

#

or if you don't explicity use discord.Option you can just typehint the parameter as discord.TextChannel

sonic onyx
#

so would a channel mention be an appropriate discord.TextChannel input?

sage tendon
#

that's not how that input type works

#

try it out

sonic onyx
#

Ok

lean garnet
#

Anyone know why the status of this (certified) bot don't load after 5 mins, while it load instant on a test bot ?

#

I just switched to pycord, on discord.py it took like 5 mins to load (idk why), now it dont load anymore

sage tendon
#

sharded?

lean garnet
#

2 shards

#

with AutoShardedBot

sage tendon
#

might be the reason then, not sure tho

lean garnet
#

it will take more time or just don't load ?

sage tendon
#

shrug someone else might know

lean garnet
#

ok ty

#

it loaded after 0h 12m 57s

sage tendon
#

is the status change in your on ready or in your bot definition

lean garnet
#

should I moove it ?

sage tendon
#

just set it in your bot definition

lean garnet
#

how ? Do you have an example ?

#

my bot definition is : bot = commands.AutoShardedBot(intents=intents, command_prefix="Cl", shard_count=2)

sage tendon
#

just copy the activity= part over to the bot definition

#

you dont have to set a shard count btw

lean garnet
#

my bot has 700 servers so if i don't set it, it will have 1 shard

sage tendon
#

You cant even shard until 1000 for all i know

lean garnet
#

it works

#

idk

#

but how can I put the status o the bot definition ? I dont get it

sage tendon
#

show changeStatus()

#

why lol

lean garnet
lean garnet
sage tendon
#

yea just copy this over to your bot definition and replace "stream" with the actual discord.Streaming

lean garnet
#

like that ?

sage tendon
#

no.

lean garnet
#

fine c_catyes_972

wanton bramble
#

Please don't send screenshots of code. Copy/paste ot amd wrap it in
```py
# Your code goes here
```

sage tendon
#

discord.Bot(...status=discord.Status.online, activity=discord.Streaming(random.choice(status), url=....))

lean garnet
#

deleted, this clogs the chat

sage tendon
#

this just clogs the chat now

#

You joined today and are already minimodding, and its a bit annoying

lean garnet
sage tendon
#

yea

lean garnet
#

thanks !

#

i will try

shell radish
sage tendon
#

?

shell radish
#

you see the random.choice(status)?

sage tendon
#

yea?

shell radish
#

the intention is for it to change every 10 seconds

lean garnet
shell radish
#

but toothy is suggesting for you to remove changeStatus

shell radish
#

and even if that isn't the case, you are just getting an extra request

sage tendon
#

They want the status to be there once the bot starts
This achieves that

shell radish
#

so does the latter

sage tendon
#

i have no idea what the problem is

lean garnet
#

So now my bot definition is bot = commands.AutoShardedBot(intents=intents, command_prefix="Cl", shard_count=2, status=discord.Status.online, activity=discord.Streaming(random.choice(status), url="https://www.twitch.tv/potentielsaumon"))

And I have this error :
TypeError: Streaming.init() takes 1 positional argument but 2 positional arguments (and 1 keyword-only argument) were given

rugged lodgeBOT
sage tendon
#

i forgot the name=

#

put that before the random.choice

shell radish
#

@sage tendon i'm not sure what you are trying to achieve

sage tendon
lean garnet
#

yess thanks it works

shell radish
sage tendon
lofty parcel
#

Why would you want to set a status when you instance the bot

#

Squid is right

sage tendon
#

Read, up

lean garnet
#

my certified bot (idk why the beta don't) takes time to display the status

lofty parcel
#

You can just let the task do it

sage tendon
#

my god

shell radish
#

it is the same internally

sage tendon
#

they said at the very start it takes like 12 minutes for it to reach on ready

shell radish
lofty parcel
shell radish
#

if this works and change_presence doesn't then there's something wrong with discord/the lib

lean garnet
#

nvm it works

#

thanks Toothy

sage tendon
#

np

#

and squid, according to the docs, acvities passed via the bot definition start immediately upon logging in

#

and evidently it seems to work

shell radish
#

yes, but for some other reason it does not

lofty parcel
#

It does work. I've used it

shell radish
#

you solved the surface problem, but not the internal problem

sage tendon
#

Previously they only set the status in their on ready

#

which takes time

#

to reach

#

the onready

#

so it takes time to set the status initially

#

there is no problem anywhere but with their long bot startup which isnt a problem but unavoidable most likely

shell radish
#

but now the presence won't change until the bot has loaded

#

this is still an issue

sage tendon
#

i literally dont see what the issue is

shell radish
#

the intention of changeStatus is to change every 10 seconds, but this will not happen until on_ready. you haven't solved everything

sage tendon
#

Better than starting the task before on ready imo

shell radish
#

i don't see the issue of starting the task before on_ready

lean garnet
#

until on_ready

#

then it will rotate

#

but that's still better than a just online bot with no status

shell radish
#

presence should have nothing to do with cache so on_connect should still work

lean garnet
#

yes maybe, I didn't use the on_connect event

lean garnet
#

so here's what i did :

#
@bot.event
async def on_connect():
    await changeStatus()
#

and it works

#

thank you everyone

#

i never used the on connect event

sage tendon
#

this is on discord.SlashCommandGroup
Any reason why it shouldn't be created manually? I've always done it like this and have never had issues

#

and wtf is the functional interface

shell radish
#

because application commands

lean garnet
#

you sure ? It worked

shell radish
#

no, there's other issues

#

just trust

lean garnet
#

ok

#

so,

@bot.listen()
async def on_connect():
    await changeStatus()

shell radish
#

yeah

#

it's updating too right?

#

(i'm not sure because usually you start tasks with <task_name>.start())

sage tendon
sage tendon
#

and the functional interface means bot.create_group?

shell radish
#

not sure

lean garnet
#

i think yes

sage tendon
# shell radish not sure

cant even do that in a cog unless im dumb, because you cant access self unless in a function (or im too tired rn)

lean garnet
#

hm I don't see it update

#

I will change the delay

shell radish
#

you should use changeStatus.start(), too.

#

instead of await changeStatus()

lean garnet
#

@bot.listen()
async def on_connect():
await changeStatus.start()

#

ok

#

yes now i see it update

#

thanks

#

It works but I have this error on the console :

Ignoring exception in on_connect
RuntimeError: Task is already launched and is not completed.

#

(it don't affect the bot but why ?)

sage tendon
#

make sure you aren't launching changeStatus anywhere else

wanton bramble
#

How can I add a description to a subcommand?

sage tendon
wanton bramble
#

@group.command() ?

sage tendon
#

yea

wanton bramble
#

so

@group.command(description="Pycord is cool")
sage tendon
#

you can also be very fancy and instead do it by doing this

async def function(ctx,...):
    """ Description here """
wanton bramble
#

Thanks!

#

How can I access the bot from a cog?

sage tendon
#

self.bot

lapis dock
#

cogs take bot as an argument
so if you do

def __init__(self, bot):
  self.bot = bot

and the setup function correctly it will work

wanton bramble
#

My IDE is saying that self is undefined

lapis dock
sage tendon
lapis dock
#

could be indentation

wanton bramble
#

Doesn't seem to be

sage tendon
#

haha
yea
i had that same issue like 10m ago

#

thats why i simply used SlashCommandGroup when i first made my bot i guess

wanton bramble
sage tendon
#

SlashCommandGroup() :3

wanton bramble
#

doesn't that need self.bot too?

sage tendon
#

no

#

discord.Slash..

rugged lodgeBOT
#

Here's the slash cog groups example.

lapis dock
#

This might help

sage tendon
#

wow so even tho the docs say "dont use slashcommandgroup() manually" the examples still do

edgy nest
#

well then go fix it

sage tendon
#

nuh uh

#

complaining is less effort and more fun

#

and i mean its fine like this ig, i just cant imagine many people not using cogs

cerulean lake
#

@edgy nest ignore ping

cerulean lake
#

Wait nvm I'm fucking stupid ugh

#

Smh my head

weary meteor
#

okay yeah i need a way for a full restart of the bot, like in my main.py file, i need to restart the entire python script but i have no clue as to how i should go abt this

grizzled loom
sly karmaBOT
# weary meteor okay yeah i need a way for a full restart of the bot, like in my main.py file, i...

The only good way to restart your bot is to shut it down and have your process manager handle it. You can shutdown your bot by running Bot.close().

Do use

  • Run your bot in a process manager such as:
  • Systemd
  • Openrc (Gentoo, Devuan)
  • Runit (Void Linux)
  • Supervisord
  • Upstart (Old Ubuntu)
  • Docker
  • Manually reboot it

Do not use

  • A bash loop (it can eat your C-c by rapidly spawning python and if your bot fails it won't stop it from constantly failing)
  • subprocess.call (you will eat your memory up by not letting your old processes die)
  • os.exec
    Tag Credit: discord.py server
lapis dock
#

A good starting point

weary meteor
#

well yes but i still dont know how to use nay of that or how to go abt starting lmao

#

i saw this tag before but, as i said, im not sure how im supposed to do it

sick thorn
#
  @discord.ui.select(
      placeholder="Pick Your Modal",
      min_values=1,
      max_values=1,
      options=[
          discord.SelectOption(
              label="First Modal", description="Shows the first modal"
          ),
          discord.SelectOption(
              label="Second Modal", description="Shows the second modal"
          ),
      ],
  )
  async def select_callback(self, select: discord.ui.Select, interaction: discord.Interaction):
    await interaction.response.edit_message(view=self)

hi, In @discord.ui.select can I keep selected value after user select an option? Currently, after select an option, select box will be back to placeholder, not keep selected value

shell radish
#

if you respond, yes

boreal sky
#

How the heck is it possible for entry.target to be None?

sage tendon
#

?

#

oh

#

print the entire entry and see

boreal sky
#
<AuditLogEntry id=1231845452564004964 action=AuditLogAction.ban user=<Member id=313950673932779520 name='Gary' discriminator='6941' bot=True nick=None guild=<Guild id=1156330712060936312 name="Cypheriel's Epic Server" shard_id=0 chunked=True member_count=50>>>
sick thorn
little cobalt
sick thorn
sage tendon
boreal sky
#

so, yes, I'm sure

sage tendon
#

hm

grizzled loom
rugged lodgeBOT
#

Here's the link example.

frail ocean
#

Yes I know

#

So I only make string

#

Can btw someone tell me how I check in a command if a server has subscribed to a bot

sage tendon
#

p sure that's not possible

sage tendon
#

you have so many questions regarding premium and boosts and bot premium lol

#

what are you building

lofty parcel
#

Whats hard about reading the docs we already provided, trying to understand something and experiment to see if that way you understood it works?

frail ocean
frail ocean
lofty parcel
#

Read the docs

#

Try to find out

#

Come back with code and specific questions

viral snow
#

hey did you solve it btw? I am facing the same issue, the command is working perfectly for me and the people I know but some users are reporting the issue "The application did not respond"

viral snow
lofty parcel
#

Let me have a look.

ancient cosmos
# viral snow hey did you solve it btw? I am facing the same issue, the command is working per...

Yeah, I did solve it. Combination of errors on my end and on the user's end.

I had just recently found that I was screwing up the kwargs for the @commands.slash_command decorator, and was doing ids = [guild IDs here] instead of the correct kwarg, guild_ids = [guild IDs here], so it wasn't actually restricting the guilds where the command could be used.

So I had just fixed that and restarted the bot, right before the issue occurred. However, the user was trying to use the bot in a server that I never intended for it to be used in (which is why I was trying to filter the guild IDs in the first place). This caused some very weird results.

It looks like Discord was still letting the user "use" the command, because Discord hadn't purged the command from that server's usable commands list - but when the user "used" the command, it just black-holed the interaction because I had since told Discord that it wasn't usable in that server.

So the user thought everything was working correctly but my bot just wasn't responding, whereas I thought everything was working correctly, but I never even got anything from Discord for his interaction. Very confusing.

I asked the user to ctrl+R his Discord client, and that solved the problem, since he was no longer seeing my command in the server it wasn't supposed to be in. He then tried to use the command in the correct server, and it worked correctly.

#

(I did go ahead and swap to a deferred flow, though, since it didn't really hurt anything to do that.)

viral snow
frail ocean
#

Is there a way for bridge commands to have the command as a slash command in a group but also as a normal command in no group?

frail ocean
lofty parcel
frail ocean
#

Yeah but how

#

There are only 3 events

lofty parcel
#

What else do you need?...

sage tendon
frail ocean
lofty parcel
frail ocean
#

As slash command i want to have /moderation ban
As message command !ban

sage tendon
#

why?
Because having 2 commands that is the same command is pointless

frail ocean
lofty parcel
#

Welcome to the magic of creating your own decorators for your specific needs

sage tendon
frail ocean
sage tendon
#

uh, yes

frail ocean
#

Better idea

#

/ban and !ban

sage tendon
#

google

lofty parcel
lofty parcel
#

That's literally how you create a decorator

#

If you were expecting me to literally spoon-feed you with the whole code for your check, you're wrong

frail ocean
#

Code:

i!jsk py
test = discord.Entitlement(guild_id=1131636325880184854)
await ctx.send(test)```
Error:
```py
Traceback (most recent call last):
  File "/data/cogs/eval.py", line 75, in _eval
    ret = await func()
  File "<string>", line 2, in func
TypeError: Entitlement.__init__() got an unexpected keyword argument 'guild_id'

lofty parcel
#

The fuck is that supposed to be

frail ocean
#

I want to fetch one

lofty parcel
#

discord.Member and discord.Guild have their own method to create test entitlements

sage tendon
#

you never create that yourself

lofty parcel
#

And an entitlement isn't just a simple guild ID, plus what toothy said

frail ocean
lofty parcel
#

OK, fetch your entitlements, keep track of them look if the guild is in there and return the appropriate response

#

What's hard about that

fresh sierra
#

U asked that

#

More than 20 times

frail ocean
fresh sierra
#

And we replied to u

frail ocean
#

Thanks 😄

fresh sierra
#

More than 20 times

sage tendon
#

the search bar is your friend

#

use it

lofty parcel
#

You really can't solve stuff on your own

fresh sierra
#

He knows…

frail ocean
#

How much is that lol

discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In content: Must be 2000 or fewer in length.```
fresh sierra
#

🤡

sage tendon
lofty parcel
#

This man is allergic to providing context about his stuff

frail ocean
#

Thanks guys

sage tendon
fresh sierra
#

And u told me stfu lmaooo

#

That guy can’t be real

lofty parcel
#

Oh, believe it. Its right in front of you.

lofty parcel
fresh sierra
#

🤡

frail ocean
#

And if ends_at is before today's date, is it canceled?

sage tendon
#

i think that isn't possible

#

because if it ended, it doesnt exist anymore, meaning you cant fetch it

#

I do have to ask tho, Dark, what would you ever need to create a test entitlement for

frail ocean
#
... ends_at=2024-03-26 ...```
lofty parcel
#

Yes. It is expired.

#

The api returns all active and expired entitlements.

sage tendon
#

so basically in a few years itll be a gigantic list? or do they ever disappear

lofty parcel
#

You can exclude expired

#

But pycord doesn't have that option

frail ocean
#

ok

frail ocean
#

@sage tendonU said to me I should use timeot_for.
If i use this instead timeot i get this error:

    datetime.datetime.now(datetime.timezone.utc) + duration, reason=reason
TypeError: unsupported operand type(s) for +: 'datetime.datetime' and 'datetime.datetime'```
lofty parcel
#

now ask in English

#

And provide code

frail ocean
#

I changed member.timeout to member.timeout_for and the error cone

lofty parcel
#

timeout_for only receives a timedelta object

frail ocean
lofty parcel
#

It is what you must provide to it

#

If you read the docs, you shoulve found out

frail ocean
#
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In communication_disabled_until: Invalid communication disabled timestamp```
What means that?
#

(27 Days Work)

#

@lofty parcel^^

lofty parcel
#

The max is 28 days.

frail ocean
#

return timedelta(days=time_val)

#

28 doesnt work

lofty parcel
#

¯_(ツ)_/¯

frail ocean
#

whats wrong

lofty parcel
#

Discord or your code or the library.

frail ocean
#

Or 1 min

#

Or smth like that

lofty parcel
#

Yes?... tiemdelta takes days, hours, minutes, seconds and milliseconds

frail ocean
#

Let me try

#

Still doesnt work lol

sage tendon
#

i genuinely dont see what it matters for

#

a 27 day timeout will see most people leave anyway

edgy nest
#

enough to where it think it's more than 28

lofty parcel
#

^ it's a you issue. works fine for me.

frail ocean
#

I removed one second

#

It works

sage tendon
frail ocean
#

0,5 Seconds

#

Lol

#

How many slash command groups are max?

sage tendon
#

dont think there's a max for those specifically

frail ocean
#

is there a way to get how long a member is timed out with member.timed_out

lofty parcel
#

.rtfm communication_disabled_until

sly karmaBOT
sage tendon
#

fabio

#

in all honesty

#

use the fucking docs

#

90% of your questions are just "who can put my words into the docs"

lofty parcel
#

this made me laugh

sage tendon
#

good because its laughable

fresh sierra
#

A group is like a command

sage tendon
#

thats why i said specifically

#

because the normal limit applies

fresh sierra
#

So 100 groups, 25 subgroups

#

So 2500

#

Against 62500 for everything

#

(Sub sub group doesn’t exist)

frail ocean
sage tendon
frail ocean
sage tendon
#

man your lack of knowledge of the library would suggest you dont know anything about that

lofty parcel
#

Isn't it 100 global plus 100 per guild?

sage tendon
#

200 per day registered anyway

#

thats a seperate one tho

#

so you need like months for 62500

#

which is nonsnse

fresh sierra
fresh sierra
#

.tags slashlimit

sly karmaBOT
#
Nziie's Utilities
Tags (51-100)
  1. gif_avatar
  2. foo
  3. name-conventions
  4. sqli
  5. timestampgenerator
  6. xy
  7. local-file
  8. discord.app
  9. snowflake
  10. docs
  11. orjson
  12. get_x
  13. subcommands
  14. um-cmds
  15. bridge
  16. cmd-limits
  17. virtualembed
  18. specialchannelmentions
  19. username
  20. cross-post
  21. developermode
  22. asset
  23. message content
  24. tokens
  25. nohello
  26. examples
  27. 429
  28. mongodb
  29. objects
  30. woc
  31. official
  32. timer
  33. install github
  34. announcement-channel-options
  35. swasvid
  36. ephemeral
  37. rie
  38. usernames
  39. invite regex
  40. nziie-examples
  41. gateway
  42. applicationcommands-registration-delay
  43. exception
  44. inline-fields
  45. update
  46. bitwise
  47. gather
  48. option
  49. solved
  50. get-help
fresh sierra
#

.cmd-limits

sly karmaBOT
#

You can have 100 commands, and each command can have up to 25 sub-command groups. Each sub-command group can have up to 25 sub-commands.

100 x 25 x 25 = 62.5k

Of course, "slash commands can have a maximum of 4000 characters for combined name, description, and value properties for each command and its subcommands and groups", so you're not likely to hit that 62.5k command limit

This can be doubled again with guild commands

sage tendon
#

well, then i confused that with the 200 commands registered per day liimit

fresh sierra
fresh sierra
grizzled loom
#

sorry, was already answered. should read first

grizzled loom
sage tendon
#

its all premium commands

frail ocean
#

No i made a long coding break and try to get back in it but sometimes its harder than i thought xD

sage tendon
#

doc search

#

use it

frail ocean
#

Yeah but how should i know the premium stuff and communication_disabled_until

sage tendon
#

the search?

#

mutes are obviously part of a member
so you go to "member" and start looking

frail ocean
#

If i search timeout_until i doesnt find it

frail ocean
#

Yes

#

Didnt know that

#

Anyways good night!

red mist
#

gn

nova epoch
#

I feel really dumb to be asking this and this probably isnt the best description of what I'm looking for so apologies:
How can I create pre-selectable options for an argument in an interaction (slash) command? I've tried using the argument options as seen by arg3 in this amazing example: py @bot.command(name='command', description='This is a commmand!') async def command(ctx, arg1: int, arg2: str, arg3: str in ['a', 'b', 'c']): but I cannot get that to work, nor can I find anything on the internet (hell, I even went to ChatGPT)>
Any pointers would be appreciated!

sage tendon
#

i'd always recommend explicitly doing options via the options decorator

#

like this

@bot.command(name='command', description='This is a commmand!')
@discord.option(name="arg1", input_type=int)
@discord.option(name="arg2", input_type=str)
@discord.option(name="arg3", input_type=str, choices=["a", "b"])
async def command(ctx, arg1, arg2, arg3):
#

string is the default so you can also omit that if you want

nova epoch
#

I'll put it into context and maybe it'll make a little more sense:
I'm trying to make a /color <col> command in which users can set the color their profile shows as in the server (done with roles), and I cannot for the life of me make a list that people can select from for the col argument.

#

I've tried stuff like discord.Role but then it lets people select any role and that just causes a whole host of other issues & errors

sage tendon
#

yea, uses choices like in my example

nova epoch
#

Sounds good, is there a way to assign an ID or etc to each value to read what they choose or is it just done with the string?

sage tendon
#

yes, but thats a bit verbose
you need discord.OptionChoice for that, which allows you to show a name in the UI, and then the value is whatever you want it to be

nova epoch
#

I'll take a look at the docs and see what it's like, thanks so much.
Just an update on the server malarchy from the other day: I scrapped it and it's now a public server :)

sage tendon
#

so it'd be

choices=[discord.OptionChoice("purple", value="#42171")...]
#

ideally you import OptionChoice directly because that gets really long, and you probably need to use linebreaks

nova epoch
#

I use a lot of linebreaks anyways as it just keeps my code structure all nice, shouldn't think that will be too much of an issue but will have a look :)

#

Thanks for the links though, should make this a whole ton easier 😅

nova epoch
lilac veldt
#

why am i seeing this

C:\Users\darkp\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\client.py:753: RuntimeWarning: coroutine 'Client.run.<locals>.runner' was never awaited
  future = asyncio.ensure_future(runner(), loop=loop)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Traceback (most recent call last):
  File "C:\Users\darkp\Downloads\Not stupid AI\Bot.py", line 33, in <module>
    bot.run("...")
  File "C:\Users\darkp\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\client.py", line 754, in run
    future.add_done_callback(stop_loop_on_completion)
    ^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'add_done_callback'
#

clean install btw

sage tendon
#

which pycord version

lilac veldt
#

2.5.0

#

Requirement already satisfied: py-cord==2.5.0

sage tendon
#

future = asyncio.ensure_future(runner(), loop=loop)
is this in your c ode?

lilac veldt
#

no, it's from the client.py script of the module

sage tendon
#

show your code

lilac veldt
#

my code is just client.run()

sage tendon
#

any reason you use client instead of bot?

lilac veldt
#

bot.run

#

was looking at old code

sage tendon
lilac veldt
#
import discord
from discord.ext import commands
import json

from main import AIModel

# AI
Model = AIModel()

# Bot
intents = discord.Intents.default()
intents.messages = True
bot = commands.Bot(command_prefix="!", intents=intents)

@bot.event
async def on_ready():
    print(f'Logged in')

@bot.event
async def on_message(message):
    if message.author == bot.user:
        return

    if bot.user.mentioned_in(message):     
        await Model.ask(message.content)

    if message.reference and message.reference.cached_message:
        if message.reference.cached_message.author == bot.user:
            await Model.ask(message.content)

    await bot.process_commands(message)

bot.run("...")
sage tendon
#

did you actually put a token in your run

lilac veldt
#

yes

#

i'm 99.999% sure it's valid but i'll try remaking it incase

#

nope same error

sage tendon
#

did it work before or is htis your first try

lilac veldt
#

i'm reusing the code from something else where it worked fine

sage tendon
#

can you do print(discord.__version__)

lilac veldt
#
2.5.0
C:\Users\darkp\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\client.py:753: RuntimeWarning: coroutine 'Client.run.<locals>.runner' was never awaited
  future = asyncio.ensure_future(runner(), loop=loop)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Traceback (most recent call last):
  File "C:\Users\darkp\Downloads\Not stupid AI\Bot.py", line 35, in <module>
    bot.run("")
  File "C:\Users\darkp\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\client.py", line 754, in run
    future.add_done_callback(stop_loop_on_completion)
    ^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'add_done_callback'
sage tendon
#

hm

lilac veldt
#

i can try commenting that line out in the pycord code

sage tendon
#

no

#

yea i dont know tbh, looks fine to me

lilac veldt
#

yeah bot didnt start

sage tendon
#

can you show your pip list

lilac veldt
sage tendon
#

shrug really no clue

lilac veldt
#

future is None

#

so maybe an asyncio issue

sage tendon
#

try calling your file bot.py lowercase
doubt thatll help but cant hurt to try

lilac veldt
#

nah

#

i think my asyncio is corrupted

#

i tried discord.py and it has another weird asyncio error

sage tendon
#

dont install both at once

shell radish
#

try re-installing python then

lilac veldt
#

i removed pycord to be sure

#

will do that

sage tendon
#

are you by any chance using the microsoft store version

lilac veldt
#

no

#

3.11.7

sage tendon
#

use 3.12 if theres no reason not to

lilac veldt
#

i think that screwed python even more

#
PS C:\Users\darkp\Downloads\Not stupid AI> pip list
Fatal error in launcher: Unable to create process using '"C:\Users\darkp\AppData\Local\Programs\Python\Python311\python.exe"  "C:\Users\darkp\AppData\Local\Programs\Python\Python311\Scripts\pip.exe" list': The system cannot find the file specified.
sage tendon
#

lol

#

python -m pip list

lilac veldt
#

ah yeah i probably have to fix path

#

allow me to reinstall all of my packages

#

ok that fixed it nice

#

thanks

#

love you python

nova epoch
#

Anyone happen to have any advice for avoiding rate limits during startup? Getting at least 3 per startup (they look like this): 2024-04-22 23:10:45:DEBUG:discord.http: A rate limit bucket has been exhausted (bucket: None:1229906624613842994:/applications/{application_id}/guilds/{guild_id}/commands, retry: 59.818). and it's stopping anything working for a solid 30 seconds to a minute. Bot is only in one server with 3 commands...

sage tendon
#

did you change a command a lot?

nova epoch
#

Nope, added 3 of the command options like you suggested to the /color command and that was it. It does it every startup too, and I have absolutely no idea why.

sage tendon
#

Will probably be gone tomorrow or so
ratelimits can be weird

nova epoch
#

Yeah but it's hella annoying and stopping me from using the bot for literal minutes at a time-

fresh sierra
#

Is that possible to answer an interaction without sending anything ?

#

i tried interaction.reponse.pong but it didnt wokr

ivory beacon
#

Are there any restrictions preventing me from tracking a message that's only 30 minutes old?

#

something like that

#

Is it because messages that are only 30 minutes old don't trigger the on_message_edit() function?

fresh sierra
#

did u restart ur bot between those ?

#

maybe that trigger only for cache message(im not sure about that)

ivory beacon
fresh sierra
ivory beacon
#

waiting for mod reply

fresh sierra
#

maybe its just not that important to save everyhing

ivory beacon
fresh sierra
#

i check the code and

#

there is a maxium of message by the client

ivory beacon
#

Okay, not everything, but anything.

fresh sierra
#

so you can either use on_raw_message_edit

ivory beacon
#

umm wait

fresh sierra
#

or increase the max_messages <Client>

ivory beacon
sage tendon
ivory beacon
sage tendon
#

that's literally "saving everything"

ivory beacon
#

*Okay, not everything, but anything.

fresh sierra
#

so i guess

#

bot = discord.Bot(max_message=...)

#

yyep excatly

#

its by default to 1000

ivory beacon
#

this message

#

I don't need to track all messages, just this specific type. I hope that's clear.

sage tendon
#

then just save it

fresh sierra
#

u can use the on_raw_edit

#

and then check

ivory beacon
fresh sierra
#

but you cant increase the limit only for this one

ivory beacon
ivory beacon
sage tendon
#

your cache will.eventually.explode

fresh sierra
ivory beacon
fresh sierra
ivory beacon
#

If the message is not found in the internal message cache, then these events will not be called
okh

#

yeah i am reading all doc

ivory beacon
fresh sierra
ivory beacon
fresh sierra
#

i think

ivory beacon
#

this will clear a cache ? huh ?

#

ty again 😁

fresh sierra
#

nope

fresh sierra
#

i check again and no

#

but restart it will clear the cache

ivory beacon
#

ty

fresh sierra
#

u can still do bot.cached_messages = None, bot.cached_channel = None but i dont think that a good idea

fresh sierra
#

seems that i find 2 bugs

#

first the one with the interaction.message, and also when a message is edit, even if we dont touch the view, the view parameters will be updated to the last one

#

explanation :

    @tasks.loop(seconds=1)
    async def snake_update(self):
        for game in snake_games:
                embed = discord.Embed(title=translator.fun.snake.embed.title)
                try:
                    await game.message.edit(embed=embed)
                except discord.NotFound:
                    snake_games.remove(game)

the view is set for each command like that :
await ctx.respond(embed=embed, view=Fun_Snake_View(self.bot, translator, ctx.author.id))
that mean that the author_id should not change for the same user, however if another user run the command, the old author_id will be replace by the new one when the message will be edit

#

(i will do futher test to test that)

deft kestrel
#

how i can use a command that mantion another command?

rapid jackal
#

our bot works perfectly fine and I don't have any problems with doubled messages, but then there is this one function for my Bot I implemented that for some reasons send the lost embed before the won embed even I enterd the right answer (its a quiz and if I enter the right answer I get the wrong anwer embed and directly after that the right answer embed)

this is the function:

right_input_user = await self.create_quiz(thread, gameid)
    
            em = discord.Embed(description=f'<@{right_input_user}> answered the question right!', color=self.none_color)
             
            if p1.id == int(right_input_user):
                await thread.send(embed=em) 
                actual_position -= 1
                
            elif p2.id == int(right_input_user):
                await thread.send(embed=em) 
                actual_position += 1

and the create_quiz function:

        with open('json/quiz.json', 'r') as f:
            quiz_data: dict = json.load(f)
            

            
        random_question = random.choice(list(quiz_data.keys()))
        answer = quiz_data[random_question]
        
        em_question = discord.Embed(description=random_question, color=self.none_color)
        
        em_false_answer = discord.Embed(description=f'wrong answer! Try again', color=self.none_color)
        await thread.send(embed=em_question, view=SkipQuestionButton(self.bot, thread, gameId))

        def check(m):
            return m.channel.id == thread.id and m.author != self.bot.user

        while True:
            message: discord.Message = await self.bot.wait_for('message', check=check)
            if message.content.lower() == answer.lower():
                return message.author.id

            else:
                if message.content.lower() == answer.lower():
                    return message.author.id
                await message.reply(embed=em_false_answer)
sage tendon
#

while true..

rapid jackal
sage tendon
#

didn't read it yet because I'm not on pc but usually it's best to avoid that

rapid jackal
#

oh I see, because of the while True the bot isn't just waiting until the message is there, but performs the line again and again so it is possible that the bot gives me mulitple responses based on the line the interpreter currently is in the while. Am I right?

sly ember
#

can someone help me fix that

sage tendon
#

self doesnt have pool

#

quite clear

sage tendon
#

debugger preferrably in this case

fresh sierra
#

you can just remove it

#

wait_for will handle that

#

or you want the bot to check for each message ?

rapid jackal
#

but then the user can only guess the right answer one time.

#

like when the guess is wrong the bot don't wait for another guess message

fresh sierra
#

in that case while true can be an option

fresh sierra
rapid jackal
#

yes

fresh sierra
#
            if message.content.lower() == answer.lower():
                return message.author.id

            else:
                if message.content.lower() == answer.lower():
                    return message.author.id
                await message.reply(embed=em_false_answer)
#

first what the point of that ?

#

if else if

#

like if the first time is false, the second it will be also

#
            if message.content.lower() == answer.lower():
                return message.author.id
            await message.reply(embed=em_false_answer)
#

i will check for the error let me 5s

rapid jackal
fresh sierra
#

for i can check that ?

rapid jackal
rapid jackal
fresh sierra
rapid jackal
fresh sierra
#

ping me when ur here

rapid jackal
rapid jackal
fresh sierra
#

but

#

i think i know

#

when the bot answer

#

it trigger the while true

#

that then send from embed

#

maybe

#

or not

#

i will check with ur code

sage tendon
#

use prints or the debugger of your IDE to see the flow of execution

cursive zealot
#

Hey I have a quick question: I'm retrieving messages with my bot and I use message.content to get the string version of it. However, when someone is mentionned it appears like this in the str: <@user_id>.
In the doc I saw you can get all the mentions of the message with message.mentions, and I would like to replace the <@id> with the display name of the mentionned person.
My first idea was to use regex and to replace it with the display name of the corresponding user, but i would like to know if there's a built in way (I tried system_content but it's the same thing).

Thanks 😄

sage tendon
#

this might help you get all the IDs, and then you can probably get_or_fetch the users in question by the IDs that raw_mentions returns, and replace the mentions with the fetched user's name

fresh sierra
#

that split will check for the <@ and then the last > to replace it

#

but use a regex will be more easy

fresh sierra
#

to get the mention

#

and then get the member, take the display name and do a replace

sage tendon
#

hm yea prolly easier

#

wonder why raw_mentions even exists still then

fresh sierra
#
        for member in message.mentions:
            message.content.replace(member.mention, member.display_name)
#

something like that

cursive zealot
#

Ok thanks I'll try something like this !

sage tendon
#

i found a better way @cursive zealot

#

message.clean_content

fresh sierra
#

yes but this put name and not display_name

sage tendon
#

no idea what name it puts there
Guess they'll tell us if they try that
docs dont specify it

cursive zealot
#

I'll try it thanks

sage tendon
#

it should be display_name if the text is correct, because "...mentions are transformed into the way the client shows it..."

fresh sierra
#

you can use use_nicknames = true

cursive zealot
#

it puts the display name so it's perfect

fresh sierra
#

yep use_nicknames is by default true

deft kestrel
fresh sierra
#

but its in ur option, input_type is not correc

deft kestrel
sage tendon
#

i dont think that's the correct line

deft kestrel
#

there is not line in the error

fresh sierra
#

its only choice no ?

sage tendon
deft kestrel
fresh sierra
#

its ctx: discord.ApplicationContext

#

not discord.Interaction

deft kestrel
sage tendon
deft kestrel
fresh sierra
sage tendon
#

yea, that has nothing to do with it not working lol

fresh sierra
#

.tag blackstick

sly karmaBOT
#

Tag not found.

fresh sierra
#

.tag code

sly karmaBOT
#

Please put your code in a code block:
```py
Here is your Code
```

That makes reading code in Discord a lot easier:

print("This is an example.")
fresh sierra
#

use that pls

deft kestrel
#

sure

#

i fixed it thanks

fresh sierra
deft kestrel
sly ember
#

no errors and only the first 2 prints are getting printed

sage tendon
#

what even are these kwargs in your slash command decorator

#

and, well, add more prints then, if only those 2 are printing

#

make sure everything is not null

red mist
#

Honestly I dont even see why his total seconds wouldnt even get printed.

sage tendon
#

most likely because the options are strings (?)

red mist
#

if its 0 by standard it would just multiply by 0 and then add another 0 which should just return 0 per default.

sage tendon
#
  1. remove these, those do not do anything for a slash command decorator
red mist
#

how / where are they strings?

sage tendon
#
  1. make your options explicit via discord.Option or the @discord.option decorator
sage tendon
sage tendon
#

and so string * int would likely 💥

red mist
#

yeah but it would still print an error into the console xD

sage tendon
#

not if their error handling is crazy

red mist
#

You mean that basically every error gets ignored

#

in their handler

sage tendon
#

shrug we'll never know if they dont respond but it seems likely given what they said

deft kestrel
#

how i can put the member count in a button label?

little cobalt
#

and take a look at the examples and get creative

red mist
lofty parcel
#

Hint

#

.rtfm Guild.members

sly karmaBOT
nova epoch
nova epoch
#

^That's probably better to use for if you want to mention it within your bot's code, I was more on about typing it out 😭

#

I find it incredible how you guys just have thesee links to-hand :p

sage tendon
#

i dont

#

i use the doc search

#

something 90% of people here seem incapable of

nova epoch
#

Well I know how to use it, it's just incredible how quickly you go from a question to having multiple links to various doc pages

little cobalt
#

would it be against the TOS if you log all the messages with the on_message event.
BUT I mentioned it with a verify button that they confirm it that the messages is getting collected from a bot?

sage tendon
#

There's probably somewhat of a data privacy concern there if you keep them long term

#

but im not a lawyer, and im not sure if the ToS is specific on that

#

for what purpose anyway

deft kestrel
nova epoch
nova epoch
sage tendon
#

more reliable

sage tendon
nova epoch
sage tendon
#

thats why i am here to mercilessly correct mistakes if i see some :)

nova epoch
#

I rate it :p

nova epoch
#

I did put no, the policy was just a suggestion. 👏 user trust 👏

little cobalt
#

but I still would mention it and that they have to press a button to accept it that the messages would get collected

deft kestrel
#

Application Command raised an exception: TypeError: Object of type function is not JSON serializable

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

    async def _get_member_count():
        members_count = await getMembers()
        return "You are the " + members_count + " th Member!"

    @discord.ui.button(label=_get_member_count, style=discord.ButtonStyle.green, custom_id="Now members", disabled=True)
    async def welcomeMassage(self, button: discord.ui.Button):
        members_count = await getMembers(GUILD_ID)
        button.label = f"You are the {members_count}th Member!"
        
#

command:

nova epoch
deft kestrel
sage tendon
#

yea well and what line is that

nova epoch
#

The file is 63 lines, that doesn't help-

little cobalt
#

button without interaction?

deft kestrel
#

oh

sage tendon
#

also you will most definitely need to defer that command because you are running like a billion db operations ever time

nova epoch
#

Still applies.
I'd also suggest using the discord.Bot.get_application_command().mention feature in your code rather than mention strings.

sage tendon
#

get_application_command*

sage tendon
#

also, no, you need to use the existing bot object

#

you cant use discord.Bot

deft kestrel
sage tendon
#

self.bot usually

nova epoch
sage tendon
#

still

lofty parcel
deft kestrel
#

i made it 😀

lofty parcel
#

Wasn't a compliment but ok

lofty parcel
lofty parcel
#

You can't randomly slap a function into the label, that's not how it works.

#

That's why it throws the "not serializable error".

deft kestrel
sage tendon
#

view

#

look at the guide on views

deft kestrel
#

ok

fresh sierra
deft kestrel
fresh sierra
lofty parcel
deft kestrel
#

oh ok

fresh sierra
#

Looking at code on mobile is an absolute mess

deft kestrel
lofty parcel
fresh sierra
fresh sierra
#

And edit the message to replace the view

deft kestrel
deft kestrel
#

i am with cog

fresh sierra
#

Every command or group in different file

#

More clean than everything in one file

lofty parcel
#

That view is useless, you're doing an extra step for something you can achieve with 1 step.

fresh sierra
#

What is he trying to do ?

#

No put button with the number of member on it ?

lofty parcel
#

A disabled button which just displays the member count

#

I highly assume it's for a welcome message.

fresh sierra
#

So why use a callback ?

lofty parcel
#

They don't need it.

fresh sierra
#

And not just add a view with the label as the number

lofty parcel
#

I already provided an answer.

fresh sierra
#

I understand now

#

I was thinking it was for an verify button

#

That also display the number of member

round heart
little cobalt
#

just send a small and simple message

round heart
# little cobalt just send a small and simple message

There are times where you don’t want to. For instance, I have a response with an Embed, and UI elements (buttons/dropdowns) that update that . I don’t need to send confirmations for that

(Granted I think this workflow was updated to edit_original_message or something, but at the time I don’t think it was available)

Anyway, point is that there are situations where a separate message response is not needed

red mist
#

Is it possible to have a sub command like so;

/help info
returns info

While also having
/help
returns help

red mist
red mist
#

Erg okay

little cobalt
red mist
#

Like dyno and carlbot log?

little cobalt
#

A lot of stuff

sage tendon
#

bro's CCP

little cobalt
#

CCP?

little cobalt
red mist
#

Chinese Communist Party

#

Because you log everything

#

not to mention that could also be german during 1930's

sage tendon
#

or the 60-80s

red mist
# little cobalt A lot of stuff

Well I have never accepted any confirmation of dyno or carlbot which allows them to document everything I do see type write join whatever. So I'm guessing it's fine, however making some kind of notice that you log everything is a good ethical practice.

little cobalt
#

I dont trust the people from the big bots

red mist
#

For the record I said guessing. This does not mean I am sure.

#

You're not allowed to use it without their consent or as allowed by Law, which I'm guessing GDPR makes it difficult for you.

little cobalt
#

That is why you have to mention it and all the other stuff like that they need an option to be able to remove there stored messages and other things

red mist
#

Now- I am guessing as big bots have own policies as well; they would state somewhere that if you as a server admin enable logging features of the bot, you have to be within the ToS and juristic restrictions.

Because if you wouldn't they'd just state that you chose to enable this option making you liable and not them.

#

however if they store your messages even after disabling the logging features and they state they don't keep such information but they do- then it's their mistake for making their bot so shitty that stuff still gets stored on the database.

#

So if you're going to make such a bot- and enable it on your server- make sure to have a privacy policy somewhere.

deft kestrel
#

cogs.verify_v2 could not be loaded. [Extension 'cogs.verify_v2' raised an error: AttributeError: 'property' object has no attribute 'name']

pls help me i am stack on this error for a lot of time

sage tendon
#

which line is that error from

deft kestrel
#

i dont know that the problem

sage tendon
#

No, read the traceback

#

i dont think you sent the right code even

deft kestrel
#

right

#

wait

#

this is the right one

sage tendon
#

you dont have ctx in your slash command

deft kestrel
#

wait

sage tendon
#

and this has to be discord.Role

#

and you never respond anything to the slash command

deft kestrel
#

i did some changes and its now saying
cogs.verify_v2 could not be loaded. [Extension 'cogs.verify_v2' has no 'setup' function.]

sage tendon
#

well, it has no setup function at the bottom

#

make it have one

deft kestrel
#

i am fucking hateing myself right now

fresh sierra
rare marlin
#
class Ticket(ezcord.Cog, emoji="🎫"):
    def __init__(self, bot):
        self.bot = bot
        self.ticket_owner = None

    @ezcord.Cog.listener()
    async def on_ready(self):
        self.bot.add_view(TicketRole(self.channel_name, self.logs_channel_name, self.ticket_feedback))
        self.bot.add_view(TicketView())
        self.bot.add_view(CreateTicketSelect())
        self.bot.add_view(QuestionsButton(self.ticket_owner))
``` ```py
[ERROR] Error while sending error report to webhook. Please check if the URL is correct.
[ERROR] Error in event on_ready 
Traceback (most recent call last):
  File "C:\Users\Dark_Angel\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 400, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\Dark_Angel\Desktop\Jinx-Bot\cogs\ticket.py", line 94, in on_ready
    self.bot.add_view(TicketRole(self.channel_name, self.logs_channel_name, self.ticket_feedback))
AttributeError: 'Ticket' object has no attribute 'channel_name'```
lofty parcel
rare marlin
fresh sierra
#

Because there are no self.channel_name define

lofty parcel
# rare marlin

Pycord is already easy enough.you shouldn't need an extension

rare marlin
# fresh sierra The error come from ur class ticketrole
class TicketRole(discord.ui.View):
    def __init__(self, channel_name, logs_channel_name, ticket_feedback):
        super().__init__(timeout=None)
        self.channel_name = channel_name
        self.logs_channel_name = logs_channel_name
        self.ticket_feedback = ticket_feedback

    @discord.ui.role_select(placeholder="Wähle Rollen aus", min_values=1, max_values=1, custom_id="role")
    async def role_callback(self, select, interaction):
        try:
            teamrole_id = select.values[0].id  # Access values from the select object
            await db.set_teamrole(interaction.guild.id, teamrole_id)
            selected_role = interaction.guild.get_role(teamrole_id)
            role_mention = selected_role.mention if selected_role else "Unknown Role"
            embed = discord.Embed(
                title="🎫 Ticket System Setup",
                description="Welcome to the ticket system setup. Follow the instructions below to configure your ticket system.",
                color=discord.Color.dark_green()
            )
            embed.add_field(name="🔘Open Tickets",
                            value="``{category_name}``",
                            inline=False)
            embed.add_field(name="🎫 Ticket Channel ", value=f"``{self.channel_name}``", inline=False)
            embed.add_field(name="📜 Log Channel", value=f"``{self.logs_channel_name}``", inline=False)
            embed.add_field(name="⭐ Ticket Feedback", value=f"``{self.ticket_feedback}``", inline=False)
            embed.add_field(name="Great! Now you can select roles that should have access to tickets.",
                            value=f"The following roles can access tickets: {role_mention}\nClick on Continue afterward.",
                            inline=False)
            await interaction.response.edit_message(embed=embed)
        except Exception as e:
            print(f"Error setting teamrole: {e}")
``` her is my ticket role
fresh sierra
#

Check for that

grizzled loom
# rare marlin

The problem with most extensions, regardless if it's for pycord, some sql, or something else entirely is they tend to dumb down things. they become easy to use and its easier to do entry level things, saving time, brain cells and frustration.

Sounds good right? That's mainly what they are build for.

There is however two sides to any coin;
As soon as you try to modify what you have or build something unique you have no idea about the basics going on underneath your extensions. not only can't you do it without learning all the things you avoided with the additional wrapper but it'll hit you with twice the frustration.
first with the usual frustration that comes with learning those basics then the additional frustration that ships with modification or building sth. unique or case specific.

Don't get me wrong on the "frustration" thing. I think learning is mostly rewarding and fun, in my mind that frustration thing is just a normal part of it.

sage tendon
#

you also risk those becoming abandoned soon, and then you have code that's only partly compatible with the original library and you need to rewrite parts of it to native syntax of the original library

#

it's overall a bad deal imo

grizzled loom
#

This = 🎯

sage tendon
#

and I'll be honest, the only part of py-cord I'd consider due for a remake are views
and that's already planned
everything else is so straightforward AND well documented

deft kestrel
#

own vc activity in pycord when

sage tendon
#

pycord is for bots

#

activities are about as far away from bots as you can imagine

#

so, never

deft kestrel
#

but theres no lib for activities in py 😦