#Basic Pycord Help

1 messages · Page 40 of 1

fresh sierra
#

mine are boring only fix and test

shadow bear
#

Because I definitely wasn't working on prod

#

its a bot for like 10 people, its not that important

sage tendon
#

bruh

shadow bear
#

Push to remote -> remote builds docker image -> docker image is pulled locally -> restart -> test

#

couldn't be arsed grabbing a token for local dev

sage tendon
#

wtf

shadow bear
#

idk where my phone is so I can't get my 2fa code

sage tendon
#

that is omega cursed

shadow bear
#

I've done worse

#

if it ain't broke don't fix it

quartz umbra
#

Am I allowed to have async functions in a class?

#

and then just await those functions?

quartz umbra
# lofty parcel Yes?

and i can just await those and it'll just work like not having them in a class?

lofty parcel
#

What are you trying to do?

quartz umbra
#

i wanted to just tidy up some code

#

into a class

#

I'll paste the file

lofty parcel
#

Class methods can be async, yes.

quartz umbra
fresh sierra
#

but you will need ot use aenter and aexit if you want a class to be async

#

and init are not allowed for async class

quartz umbra
#

no init is allowed?

fresh sierra
#

in my memory you cant use init for an async class

lofty parcel
#

Async inits are possible just not like that

#

?tags init

limber wagonBOT
#

dynoInfo There are no tags that match your search.

lofty parcel
#

.tag asyncinit

sly karmaBOT
#

Add this to you class to allow async init-

    async def __new__(cls, *args, **kwargs):
        obj = super().__new__(cls)
        await obj.__init__(*args, **kwargs)
        return obj
quartz umbra
#

I just changed it from __init__ to init() and then just called that directly after a reference is made

#

is that alright?

quartz umbra
#

async def init(self, db_path: str = "database.db") -> aiosqlite.Connection:

sage tendon
#

i still wonder why its not supported natively tho
oversight imo

quartz umbra
#

I'm getting this error, no idea why: ```bash
data_handler = await data_handler.init()
^^^^^^^^^^^^
UnboundLocalError: cannot access local variable 'data_handler' where it is not associated with a value

lofty parcel
#

And you leave your async init as it was before

quartz umbra
#

i added it

lofty parcel
#

Show your new code

quartz umbra
#
class DataHandler:
    async def __new__(cls, *args, **kwargs):
        obj = super().__new__(cls)
        await obj.__init__(*args, **kwargs)
        return obj

    async def init(self, db_path: str = "database.db") -> aiosqlite.Connection:
  ...
sage tendon
#

bruh

lofty parcel
#

It is __init__

#

Not init

quartz umbra
#

oh bruh

#

you said keep the async init the same

lofty parcel
quartz umbra
#

sorry its working now (so far)

rough heron
#
await ctx.followup.send(
                "You can't do that!", ephemeral=True)

What is the best way to send a followup thats ephemeral? This obviously doesn't work.

lofty parcel
#

ctx.respond should handle followups and responses for you.

#

You shouldn't need anything else.

rough heron
#

I'll look into it, ty.

wary saffron
#

How can I make a command that can only be run by a user who ran a different command?

#

In this example, I need the user that ran /host_lie_to_me to be the only one who can run /cancel_lie_to_me

#

also the command descriptions don't show up idk why

tidal vessel
wary saffron
tidal vessel
wary saffron
#

Oh

tidal vessel
lapis dock
rough heron
errant trout
#
for i in range(5): await ctx.respond(str(i), ephemeral=bool(i%2))```
lapis dock
#

and did that change at some point or am I completely mis-remembering?

errant trout
#

yep, and always been possible !

#

so you have 15 minutes to do as many ephemeral responses as you want

little cobalt
#

Can I see your pip list and Python version?

#

I also see some problems with aiohttp

sinful juniper
wary saffron
#

Oh wait

#

Maybe I can update a variable

wary saffron
vital bramble
#

discord.Thread.add_user():

You must have ~Permissions.send_messages_in_threads to add a user to a public thread. If the thread is private and
invitable is False, then
~Permissions.manage_threads is required.

What permissions do I need, if the thread is private but invitable is True?

#

Oh I guess no permissions are needed in that case? Because everyone in the thread can invite other users, including the bot... Got it xD

sage tendon
fresh sierra
#

Is that normal that await bot.sync_commands([command], method="individual") doesnt raise any error while loading an invalide command while await bot.sync_commands() does ?

karmic river
#
  File "C:\Users\rahul\Downloads\Prix Bot\main.py", line 2, in <module>
    from discord.ext import commands
ImportError: cannot import name 'commands' from 'discord.ext' (unknown location)```
I have uninstalled discord.py and installed pycord 2.5.0 correctly but why is it not working???
karmic river
karmic river
# fresh sierra can you show ur pip list ?
aiosignal                1.3.1
async-timeout            3.0.1
asyncio                  3.4.3
attrs                    23.2.0
beautifulsoup4           4.12.3
blinker                  1.7.0
bs4                      0.0.2
certifi                  2024.2.2
cffi                     1.16.0
chardet                  3.0.4
charset-normalizer       3.3.2
click                    8.1.7
colorama                 0.4.6
DateTime                 5.5
discord-py-slash-command 3.0.3
discord-ui               5.1.6
ffmpeg                   1.4
ffmpeg-python            0.2.0
Flask                    3.0.2
frozenlist               1.4.1
future                   1.0.0
googletrans              3.0.0
h11                      0.9.0
h2                       3.2.0
hpack                    3.0.0
hstspreload              2024.4.1
httpcore                 0.9.1
httpx                    0.13.3
hyperframe               5.2.0
idna                     2.10
imageio-ffmpeg           0.4.9
itsdangerous             2.1.2
Jinja2                   3.1.3
MarkupSafe               2.1.5
multidict                6.0.5
numpy                    1.26.4
openai                   0.28.0
pip                      24.0
py-cord                  2.5.0
pycord                   0.1.1
pycparser                2.22
pyfiglet                 0.8.post1
PyNaCl                   1.5.0
pystyle                  2.9
python-dotenv            1.0.1
pytz                     2024.1
requests                 2.31.0
rfc3986                  1.5.0
setuptools               69.5.1
sniffio                  1.3.1
soupsieve                2.5
tqdm                     4.66.2
typing_extensions        4.10.0
urllib3                  2.2.1
Werkzeug                 3.0.1
yarl                     1.9.4
youtube-dl               2021.12.17
youtube-search-python    1.5.1
zope.interface           6.3```
Here all pips
#

idk why i have installed useless pips 🤡

sage tendon
#

packages*

#

pip is the package installer

fresh sierra
#

discord-py-slash-command 3.0.3
discord-ui

sage tendon
#

good job installing the wrong pycord and the right pycord at the same time lol

fresh sierra
#

discord-py-slash-command 3.0.3
discord-ui 5.1.6

karmic river
fresh sierra
#

try to remove this one

karmic river
sage tendon
#

and also uninstall both pycords, and reinstall the right one after

#

just to make sure everything is cleanly installed

karmic river
#

py-cord

#

??

sage tendon
#

yes

karmic river
# sage tendon yes

the bot started but not responding to my commands and not showing any errors on terminal

karmic river
# sage tendon yes
intents = discord.Intents.all()```
Are these intents enough to run the bot?
sage tendon
#

I don't think you understand python

karmic river
sage tendon
#

I know

sage tendon
karmic river
#

thats why getting errors

sage tendon
#

if you use all intents you also need to enable all in the developer dashboard

timid shuttleBOT
#

Heads up @karmic river! We've detected one or more tokens in your attachments!

  • Found token of 1239810411541430302 (Prix) in attachment main.py. You can regenerate it here.

Fyi: Each token might trigger a system message by discord, if it's valid.
Please avoid uploading tokens in future, even if they aren't valid anymore.

Stay Safe!

sage tendon
#

bruh

karmic river
#

💀

#

wait

sage tendon
#

regenerate your token now

karmic river
#

I think i should use .env

sage tendon
#

and obviously not synced to github

fresh sierra
lofty parcel
#

I was about to say that

sage tendon
#

wait did you put your bot on GitHub with the token lmao

karmic river
fresh sierra
#

so why are u doing that ?

fresh sierra
#

are you coding without thinking ?

sage tendon
#

chill out

karmic river
fresh sierra
#

no but like

fresh sierra
#

when you do something to improve

#

try to think

sage tendon
#

luma

fresh sierra
#

why am i doing that

#

or why etc etc

sage tendon
#

there's no need for this

fresh sierra
#

this will help you to improve this it will make u understand how does that work

sage tendon
#

you're basically telling them "I think you're stupid"
that doesn't really help

lofty parcel
#

I mean, Luma is right lmao, you won't learn if you code without thinking what you're typing

karmic river
fresh sierra
#

in which way im saying that he is stuping ?

sage tendon
fresh sierra
#

im saying that he should understand what he is doing to improve

sage tendon
#

If they don't know how the code they copied from somewhere works, or the programming language at all, it doesn't matter how much they think about it
they need to learn about it with tutorials or whatever

#

Lack of knowledge isn't to be confused with lack of thinking

fresh sierra
#

man like ur trying to do idk why but there is not need for that

#

im saying he should try to understand his code

#

that's all

sage tendon
#

this isn't helpful in any way

#

it's just rude

fresh sierra
#

for telling to someone you should try to understand what ur are doing ?????,

little cobalt
#

~~ @sage tendon you are a helper~~

fresh sierra
#

okay so lucifer continue to not understand anything about ur code

sage tendon
little cobalt
sage tendon
#

no

#

I cannot

fresh sierra
#

i am sorry but i dont understand why telling to someone he should understand his code to improve his rude

#

like explain me

sage tendon
#

because you're saying it in a very specific way that has a rude undertone

red mist
#

Could you two perhaps

#

just

sage tendon
#

fine by me

red mist
#

not discuss this here >.<

little cobalt
red mist
fresh sierra
#

@karmic river im sorry if you were thinking it was rude that was not my intention, what im trying to tell you is when you are putting a line try to understand the purpose of that, you can for exemple use comment like so :

intents = discord.Intents.default() # put intent by default
intents = discord.Intents.all() # activate all intents

Then it will help you to understand for exemple that there is no need to put intents by default since just after you are putting all

red mist
#

^^ also Luma is french, english is not his first language so saying something thats meant good and accidentally ends up "rude" if you look at it that way is just an accident.

sage tendon
#

it's also my second language

fresh sierra
#

my english still need some improvements

karmic river
red mist
#

I'll continue this discussion in#general tho, stick to help here.

fresh sierra
#

(without sending the token)

karmic river
fresh sierra
sage tendon
#

well, I / we still need your code and what you see in discord lol

karmic river
fresh sierra
karmic river
sage tendon
#

can you just show your code lol

karmic river
fresh sierra
#

?tag paste

limber wagonBOT
#

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

sage tendon
#

if you send the token again you win a prize

karmic river
fresh sierra
karmic river
sage tendon
#

can you please send it as a normal text message lol
I can't open that on mobile

fresh sierra
#

its too big

#

does the help is working or not ?

karmic river
sage tendon
karmic river
#

but this time it is not responding

#

to any command

fresh sierra
karmic river
fresh sierra
#

are you using the good prefix ?

little cobalt
#

lol

karmic river
sage tendon
#

with which scopes did you invite your bot?

karmic river
sage tendon
#

yea well that dodged my question lolw

when you made the invite link for your bot did you actually check the bot checkmark
I think that's actually the only necessary one but not sure rn

fresh sierra
#

does the on_ready is triggered ?

karmic river
sage tendon
#

you made an invite for the bot at some point

#

did you check the bot scope y/n

karmic river
sage tendon
#

does it have permissions?

karmic river
#

administrator cuz just testing the bot rn

fresh sierra
#

can you add an on_message to check if the bot can see the message typed by the user ?

#

dont forget to add the process

sage tendon
#

okay i could check your code now and holy HELL why do you have a billion imports

fresh sierra
#

.rftm process_message

fresh sierra
#

.rtfm process_message

sly karmaBOT
#

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

fresh sierra
#

.rtfm process_command

lofty parcel
sage tendon
#

remove all this

#

you dont have to use that

#

pycord handles that via the decorator

fresh sierra
#

and you should also consider cog

sage tendon
#

you are never calling the function

#

so the prefix is likely just gibberish / none

karmic river
sage tendon
#

you dont need like 90% of that code in general lmao
all the imports, all the add_commands..

karmic river
sage tendon
#

also the way that help command is done is so unbelievably messy lmao

#

you copied it from some template repo right?

sage tendon
#

and it might actually be the reason your commands dont work

karmic river
#

lol the bot is working with the on_message command

karmic river
vital bramble
#

How can I set the overwrites for @everyone, when using discord.Guild.create_voice_channel? What do I use as key in the dict?

sage tendon
#

the everyone role is a normal role with an ID, so i think you can just get that (somehow) and then put it there like any other role

vital bramble
#

ooh nice xD

#

thx

#

I guess it's also just the guild id, right?

sage tendon
#

?

#

wait wtf yes it is

#

i never noticed that

vital bramble
#

I think the id of everyone role is just the guild id

#

but is that reliable?

sage tendon
vital bramble
#

yeah. I was just thinking what if I just have the guild id, but if I can use the create channel method I already have the guild object xD

sage tendon
karmic river
#

it started working yayyyy

#

Thank you so much

#

for helping

sage tendon
#

np

fresh sierra
#

is there a big difference between on_connect and on_ready for the shard ? or should i use only one or the other, its for simple logging

vital bramble
quasi dune
#

Hey all, is there a way to know when a Member has completed their onboarding? I want to trigger a message once they've properly entered the server. Allegro_love

vital bramble
#

Does pycord update the position of all channels in cache, if I create, delete, move a channel?

sage tendon
#

it should, yes

sage tendon
#

like the actual actual onboarding with role select? I think that isn't possible

quasi dune
#

Bummer. That's kinda what I figured.

sage tendon
#

there is Member.pending but to this day i could not get a clear answer on what that means
I THINK it only checks if people agreed to the rules (if you set that up)

quasi dune
sage tendon
#

i never tested it with an alt yet so maybe try that (and tell me if you do)

quasi dune
#

I'll keep you posted!~

vital bramble
#

Well, you could listen to the role add event and if it's any of the roles from the onboarding use that as onboarding finished...

sage tendon
#

ok so

#

i have a command that also checks member.pending
and some people there have onboarding roles

#

so its not determined solely by the role selection

#

let me check smth

#

discord also says they agreed to the rules

#

so god knows why they're pending

#

maybe it also includes the verification level but not sure

quasi dune
vital bramble
#

or maybe they have not completed all the additional onboarding steps like say hello in..., go to this channel etc

sage tendon
#

well i just put my verif level to email-only and they are still all there so god knows what member.pending actually means

#

but from experience, a member that is pending is unable to chat, and a member that ISNT pending is always able to chat

quasi dune
#

Currently it sends a message after 60 seconds based on the roles the member has at that time.

vital bramble
quasi dune
#

I was just hoping for something a little more precise

#

^.^

sage tendon
quasi dune
sage tendon
#

yea no i already knew that before lol
but thats literally all i know about it still

#

i wish it was clearly documented

quasi dune
#

Sameeee

sage tendon
#

you actually gave me an idea

#

currently, I'm waiting 20s after join to send my welcome message (for bot kick reasons)
but i could actually wait for a member update that changes pending

fresh sierra
quasi dune
sage tendon
quasi dune
#

Yay, I helped ^.^ lol

sage tendon
#

okay... apparently pending doesnt rely on onboarding at all
just tested my new thingy and the pending flag changed before they selected any roles

#

(unless i messed smth else up)
Ill tell you when i know

errant trout
#

pending is for the rules section, not roles/channel selection

sage tendon
#

but doesnt that come after the roles and channels?

#

i'm 99.99% sure that is the order
roles > rules

#

and i have mandatory roles, so, it cant be that someone has no roles but isnt pending

fresh sierra
sage tendon
#

yea i'm doing that
by len(member.roles) though, i have like 70 onboarding roles

vital bramble
#

Can I use the discord.ui.button decorator to add a button with dynamic properties (label, custom id, etc.) to a view?

I don't want to define a whole class for it, so I thought maybe I can just use the decorator in the view init. Does that work?

errant trout
#

(Button, not button)

vital bramble
#

No. I mean button xD

errant trout
#

no

vital bramble
#

That's the decorator

errant trout
#

oh wait

#

just do self.button_callback_name.attribute = ... in your init

#

like self.button.custom_id or whatever

vital bramble
#

that does work?

errant trout
#

yeah

#

because init runs last

vital bramble
#

yeah but I want to use the same callback for two different buttons...

errant trout
#

...

vital bramble
#

without writing it twice ofc xD

errant trout
#

then make the buttons manually instead of using the decorator

vital bramble
#

By subclassing you mean?

errant trout
#

no

#

button = Button(...)
button.callback = self.callback

#

or alternatively you can define on_interaction in your view as a callback for all items

#

that's probably the wrong name

#

it's interaction_check

vital bramble
#

oh that's nice. Totally forgot about that

vital bramble
#

How would I register a persistent View only for a certain message? I have a view that I want to be persistent but it holds message specific data so I can't use it for every interaction but only for one message each. Would it be enough to use Bot.add_view with the message_id parameter set? I don't really understand what they mean with "The message ID that the view is attached to. This is currently used to refresh the view's state during message update events. If not given then message update events are not propagated for the view."

sage tendon
#

db i suppose

vital bramble
#

I want to avoid that. But I think Bot.add_view works the way I need it to.

sage tendon
#

well, what data are we talking about

vital bramble
vital bramble
#

Basically who clicked what button

cedar snow
#

I'm just now learning the cogs system, but cant find anything about SlashCommandGroups within cogs, should the be their own cog, own extention?

rugged lodgeBOT
#

Here's the slash cog groups example.

cedar snow
#

thank you my friend

wary saffron
#

How does the cog know what I wrote in the LiarGame class?

tidal vessel
wary saffron
#

I don't know how to explain it

#

For example... how do I get it to recognize the class? Does that make sense?

tidal vessel
#

🤔

wary saffron
#

I don't know

tidal vessel
wary saffron
#

Also the description you told me to put into the bot command gives me a syntax error

lofty parcel
#

This is why you need to learn python. No offense.

hoary cradle
#

is there a way to do something like this?

await ctx.defer()

if something is True:
  await ctx.respond('true', ephemeral = True)

await ctx.respond('bla...')

sage tendon
#

no

#

The defer dictates whether the response can be ephemeral or not

hoary cradle
#

can i do something in reverse? or use ctx.send for the last message

sage tendon
#

if the condition check for whether it should be ephemeral or not doesn't take too long, do it before the defer

hoary cradle
#

how much time do i have to defer?

#

seems like im like 2 or 3 seconds away from being able to fit it in

sage tendon
#

3 seconds

hoary cradle
#

oof, can't fit it in then, is it better to just delete the message and ctx.send after?

sage tendon
#

whatever works for you

#

multiple ways to solve this

sinful juniper
high pilot
#

sometimes when i edit the embed on button click. the embed message disappears

high pilot
#
await interaction.message.edit(embed=embed, view=self,attachments=[])
#

embed.set_image(url="attachment://plot.png")

fresh sierra
#

because you are here replacing the emebd with embed=embed

high pilot
#

embed = interaction.message.embeds[0]

fresh sierra
#

ur message only have 1 embed ?

high pilot
#

yes

#

its like sometimes when people click placed bet the image vanishes

#

all the other things work

#

and thats just some random times

fresh sierra
#

if that can help you, im doing like that :

    file = discord.File("Resources/Images/xpIMAGE.png", filename="card.png")
    embed.set_image(url="attachment://card.png")
    await interaction.message.edit(embed=embed, view=self, file=file)
high pilot
#

the file is a bytesio file generated when the bot first posts the embed so i am not saving the file

fresh sierra
#

i dont have any other solution

high pilot
#
 chart = discord.File(data_stream,filename="plot.png")
            return chart
#

i use it already

fresh sierra
high pilot
#

seperate function

#

u mean this , file=file?

#

i cant really get this file as it is not saved in

#

how do i even ddefine file = discord.File("Resources/Images/xpIMAGE.png", filename="card.png")

#

this

#

Resources/Images/xpIMAGE.png file is not saved like this

#

if i were to save files i might need 1tb of space lol

fresh sierra
#

i dont remeber where in my bot but let me take a look

#

here i did :

#
            captcha_code = ''.join(random.choices(string.ascii_letters + string.digits, k=6))
            image = ImageCaptcha(width=280, height=90)
            data = image.generate(captcha_code)
            file = discord.File(data, "captcha.png")
            embed = discord.Embed(title=welcome.captcha.title, description=welcome.captcha.description)
            embed.set_image(url='attachment://captcha.png')
            await new_channel.send(content=member.mention,embed=embed, file=file)
red mist
#

Because your connection gets closed for some reason.

I do know that discord tends to pause and resume sessions in the background which is normal (except for when you're spamming the discord API) but you could probably get a lot more info by implementing an event log by using the logging module.

sinful juniper
red mist
#

Yeah- try the logging module :>

#

It could be that some task or some of your code which is constantly checking something or updating nonstop crashes on a client pause- and cannot live with a few second pause.

Or you're spamming the API somewhere and discord rate limits you :P

#

Again- logging module is the way to go- it'll also show you if you're making too many requests.

#

Or posts- whatever

vital bramble
#

What is the __cancel_callback method in discord.Modal for? It doesn't seem to have any purpose...

#

shouldn't it be called in the discord.Modal.stop method?

fresh sierra
vital bramble
#

It's never used anywhere... That's what I find strange.

fresh sierra
#

because its an internal methode, user have no point to use it

#

its used in the _start_listening_from_store function

vital bramble
#

I know that it's not supposed to be used by the user. But it does not even get used internally. So it's basically useless. And I'm wondering why it's there.

fresh sierra
#

its used internally

vital bramble
fresh sierra
#

in the _start_listening_from_store

vital bramble
#

with used I mean called

fresh sierra
vital bramble
#

That's from discord.ui.View not discord.ui.Modal

fresh sierra
#

when a view is stop its used to remove everything iguess

vital bramble
#

I'm talking about discord.ui.Modal!

fresh sierra
#

yeah mb

#

i guess they just copy the cancel callback from the view to the modal

vital bramble
#

I guess too... But it could actually serve a purpose if it were implemented...

fresh sierra
#

and since we cant stop a modal, it's useless

sage tendon
#

i think thats intended to be the callback for when the user cancels a modal

fresh sierra
#

nope cancel is useless

#

i checked on dpy, the cancel is used only for the view too

vital bramble
vital bramble
fresh sierra
#

how can you remove a modal ?

#

you can remove a view but a modal i dont know how

vital bramble
#

It can be removed from the internal modal store. But it can only be removed per user not per modal.

#

that's probably why they didn't implement it because when the timeout happens it's (currently) not possible to know which user the modal is for.

sinful juniper
fresh sierra
#

its just logging

sinful juniper
fresh sierra
#

are you hosting ur bot on a computer or an host

fresh sierra
red mist
#

Or couldn't connect- / tries to connect but fails

sinful juniper
#

okay

fresh sierra
#

yeah i didnt read correctly

fresh sierra
#

i think the issue is simply ur wifi/ host has some issue and disconnect nothing dangerous, logging can help

fresh sierra
#

is that possible to disable the logging info from pycord while using it for urself ?

#

i want to use logger.info() in my code but i dont want to get every message from pycord about the info, i really dont think that possible but we never know

#

(i dont want to remove completly the logging from pycord because of the warning etc)

sleek mauve
#

Can I get the message ID if I clicked the button?

little cobalt
sleek mauve
little cobalt
sleek mauve
high pilot
fresh sierra
#

It will be more easy because I’m lost rn so it’s a little bit hard to help u

vital bramble
#

I can't defer an interaction and then send a modal, can I?

shell radish
#

no

vital bramble
shell radish
#

L /s

vital bramble
#

L?

#

I know /s but L is new to me xD

edgy nest
vital bramble
# edgy nest loser

Thx. I just received the notification for this message and was a bit irritated why you would call me loser xD

edgy nest
#

merp!

wild prairie
#

Using a slash command group inside a cog seems to break the parameter list and considers ctx as a Discord slash command parameter.

grotto_translate = bot.create_group("grotto_translate", "Grotto Translation Commands")

class Grottos(commands.Cog):
    @grotto_translate.command(name="english", description="Translate a Grotto")
    async def grotto_translate_english(self, ctx, ...):

How can I fix this?

shell radish
#

that's not how you make a scg in a cog

rugged lodgeBOT
#

Here's the slash cog groups example.

wild prairie
wild prairie
shell radish
#

because if it says that then it's wrong

wild prairie
#

Doesn't mention anything about cogs

shell radish
#

yeah because it doesn't work in cogs

wild prairie
#

Well then it should mention that

shell radish
#

k

wild prairie
# shell radish k

If you don't have the power to change that, don't be snarky, instead point me to where I can make a suggestion

wild prairie
#

Unless using a group created with bot.create_group outside of the cog is the crucial detail?

cloud bloom
#

what does this mean

#

I changed the folder that my cog was in to a subfolder

#

and also changed the path

#

and it prints in the file's setup function

shell radish
#

do all other commands work?

cloud bloom
#

so far

shell radish
#

was the bot invited correctly

cloud bloom
#

ooooo

#

something interesting

#

I have a print statement when it syncs commands

#

but it doesn't print

#

wat does that mean

#

nvm it prints now

#

that's so weird

#

WHOA

#

ok I figured it out

#

I had to REFRESH and then click instead of press enter to run the slash command

#

heh sorry

#

& ty

shell radish
#

:o

cloud bloom
#

heisenburger

lapis dock
# cloud bloom what does this mean

I think this happens when the integration is updated while the discord client is "accessing it". IE you have the command typed in the text bot and than restart the bot than press enter. I might be wrong tho

cloud bloom
wild prairie
dreamy prawn
#

Im using an f-string spread over multiple lines for my bots response. Is there a way to stop the response being tabbed in like can be seen in forst screenshot?

cloud bloom
#

those tabs are characters in the actual f string

#

what you could do instead is .replace(" ", "")

#

which would remove all sequences of four spaces

dreamy prawn
#

Thank you! That did it.

cloud bloom
#

oop sorry for ping

dreamy prawn
#

its fine 🙂

stray pasture
#

I am looking to host my discord bot on a cloud service (looking for 4 Gb of RAM). I found that OVH looks like a great option (very cheap). I was wondering if anybody used it before, because when checking comments on internet a lot of people are saying their Ip are in a lot of blacklists. Would it work to host discord bot ?

cloud bloom
#

but

#

are bad ips a problem for a discord bot?

stray pasture
#

I will go take a look at sparkedhost !

wary wyvern
#

How can I add my commands inside of the bot class?

class TicketsBot(commands.Bot):
    def __init__(self):
        super().__init__(
            help_command=None,
            command_prefix='+',
            intents=discord.Intents.all()
        )

    async def on_ready(self):
        print(f'Successfully logged in as {self.user}')
cloud bloom
#

but if you do that, you can probably just see how the decorator adds the command and do that in __init__ for a function that you make inside the class

#

found it

self.add_application_command(result)
#
  def add_application_command(self, command: ApplicationCommand) -> None:
        """Adds a :class:`.ApplicationCommand` into the internal list of commands.

        This is usually not called, instead the :meth:`command` or
        other shortcut decorators are used instead.

        .. versionadded:: 2.0

        Parameters
        ----------
        command: :class:`.ApplicationCommand`
            The command to add.
        """```
wary wyvern
#

Cool;
Thanks.

sage tendon
#

why is the correct question

#

there is no point

rugged lodgeBOT
#

Here's the slash cog example.

fresh sierra
tidal vessel
#

Guys, can someone help me with an example of how to use the checks parameter of the SlashCommandGroup class?

tidal vessel
fresh sierra
#
example = discord.SlashCommandGroup(name="example", default_member_permissions=discord.Permissions(administrator=True))
tidal vessel
errant trout
#

(Note that admins can change this permission !)

tidal vessel
errant trout
#

If you are using default_member_permissions, yes that's how it works

#

It will hide it if the user can't use it

#

Server admins can change the required permissions; on the other hand, checks is a list of internal checks that are always enforced, but they do not change visibility on discord

tidal vessel
fast glade
#

Can I edit an interaction's response given only the interaction ID as an integer, and not the full interaction object?

errant trout
#

you could probably edit it if you have the channel and message id

fast glade
#

Would it be possible if I saved the token alongside the ID?

errant trout
#

how long after are you trying to edit

fresh sierra
#

if you mean interaction reponse from the ctx.repond; only way is to do ctx.interaction.original_responset() and edit that

fast glade
#

Trying to see if I can edit previously sent messages in a user bot where I don't have direct access to messages

#

Though I'm aware that interactions have a short timeout period it should be fine for my purposes

errant trout
#

no chance

#

eh

fresh sierra
#

why would you not have access to it ?

#

cant u use the channel history ?

errant trout
#

because in the context of interactions, bots can respond in channels/guilds they don't have access to

fast glade
#

It is yes

fresh sierra
errant trout
#

then just store the interaction object itself? surely your bot will be alive during that time

fresh sierra
#

never knew that

fresh sierra
fast glade
fast glade
#

Was curious if there was a quicker solution to avoid that :P

fresh sierra
errant trout
fresh sierra
#

bot cant edit message if there have no access to the channel?

errant trout
fresh sierra
#

ok

errant trout
fresh sierra
#

for what usecase do you need a user to run a command where the bot has no access to then edit it after ?

errant trout
#

well just for general followups, as long as it's within 15 mins it's not too unusual

#

the "bot doesn't have access" context is completely irrelevant, because this is not uncommon with interactions - they're built on strict rules where they can act freely in that context

#

with the release of user commands, this will be even more common

cloud bloom
#

for the most part though with app commands context is fixed right?

#

unless it interacts with the rest of the server if it's a mod bot or something

cloud bloom
errant trout
#

right

cloud bloom
#

but text commands the bot might have problems because it won't even be able to respond at all and you won't know if it can respond

errant trout
#

which is why they aren't encouraged

cloud bloom
#

yeeeep

errant trout
#

for what

fresh sierra
#

i dont really see when we need to do that

#

for why he is trying to do his thing

cloud bloom
errant trout
#

you're starting to sound more like toothy Ultimately i don't know how their bot is structured, but literally just

  1. Respond to command
  2. Do something in the background for like, 10 mins?
  3. Update the same response
sage tendon
#

wow thx

errant trout
#

:)

fresh sierra
#

no like im trying to underrstand the usecase lmao

sage tendon
#

but i have a reason, namely, the xy problem

fresh sierra
#

like i learbned thing like that

fresh sierra
#

it wasnt meaning to be like is useless

#

its more like if i underestand why i might need it later for something

errant trout
cloud bloom
#

you could defer it and pass the interaction to whatever different class you use

#

that'd work right

fresh sierra
cloud bloom
#

OR save the channel ID

#

wait...

#

oh I see the problem now

errant trout
#

discord gives you 15 minutes to do whatever you want with an interaction token

cloud bloom
#

so you want to respond to something that you don't have access to after 15 mins but the command might take more an 15 mins

#

I see!

errant trout
#

well for this user, it's under 15 minutes so it's a valid question

fresh sierra
#

no but i mean his command was not for a channel that he doesnt have access at the begining, its just in case it doesnt have access that he wants to do that if i understand

fresh sierra
#

now i understand

errant trout
fresh sierra
#

i was thinking the point of his command was to be run in a channel where he doesnt have access to it

#

yes i understand now

#

i should implemenrte somethjing like that too when i need to edit after

#

sorry again if you were thinking i was saying it was useless, i was just trying to understand ;)

errant trout
#

nah it's fine LOL

cloud bloom
#

who

errant trout
cloud bloom
#

ig people switching over

#

which makes senese

#

sense*

fresh sierra
#

if the bot doesnt have admin it is useful

cloud bloom
#

eh

#

if you have text commands

errant trout
#

and people making dedicated bots/commands for user contexts, where the bot has access to even less data

fresh sierra
#

text commands = prefix command ?

cloud bloom
#

what are dedicated bots

#

and dedicated commands

errant trout
#

before bots could run commands in channels they don't have access to, now they can run in guilds they don't have access to

cloud bloom
#

WHAT

#

wait wait wait

#

wait wait wait wait

#

how

errant trout
#

...user commands have existed for a month now

fresh sierra
cloud bloom
errant trout
cloud bloom
#

hooooww

errant trout
#

(not merged yet since it's still a "preview" feature)

cloud bloom
#

no waaaay

#

wait so how does that work

#

are you just able to run the bot wherever

#

but only you can see it

#

which makes sense

sage tendon
#

for now

cloud bloom
#

oooooooooooooooooooooo

#

hooollllyyyy craaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaap

sage tendon
#

its not ephemeral in servers <200 members right now

cloud bloom
#

BUT STILL

#

that's amazin

errant trout
sage tendon
#

yea ok true

cloud bloom
sage tendon
#

not
ephemeral
(by default)

devout glacier
#

might there be a thing like discord.Attachment but instead of just uploading 1 attachment you can upload bunch?

#

in slash commands

edgy nest
#

nope

quartz umbra
#

Hi, How do some bots have commands with 2 words? Is that possible with py cord, I know obv underscore, but there's like /prune messages with a space. How do you define that?

shell radish
#

slash command groups

rugged lodgeBOT
#

Here's the slash groups example.

#

Here's the slash cog groups example.

quartz umbra
#

thanks for that. probably bit too elaborate for what my implementation though

sage tendon
#

it's really not hard, it's one line of code at best

red mist
#

Ehhhhhh- trust me- if you try hard enough you can have a very complicated core architecture.

My command groups for example are being self generated based on my folder structure.

sage tendon
#

Yes, but I like to adhere to KISS

#

I will never understand these whole command builders and shit, I don't see the point

red mist
#

what

sage tendon
#

what

little cobalt
deft kestrel
#

is there a server size limit of when the on_presence_update events stops working?

quartz umbra
#

Hi. Is there any way to retrieve a user's avatar to a form which Pillow can understand? Ideally I don't want to be downloading it and saving to the filesystem if possible. Thank you

#

nvm, i think Image.read(io.BytesIO(await user.avatar.read())) should work, right?

fresh sierra
fresh sierra
fresh sierra
little cobalt
fresh sierra
#

Yes for the decorator

little cobalt
#

And for a description you have to add every time a description=""

fresh sierra
#

I don’t need to do that I have a function for when the bot start it automatically add each name description and localization and choices

#

So like you put a decorator and it put the description from file ?

little cobalt
#

My own decorator for it

#

Its the best way do to it at your own so you gonna learn from it

fresh sierra
#

So ur decorator put name description for options etc

#

I think the best way is to do a fonction before the bot start to itinerare into the pending command to add all of those for u don’t even have to put the decorator before each command

#

I will have to learn how to subclass application context also

little cobalt
red mist
# fresh sierra Can you elaborate on how it work ?, like it automatically create a group based o...

I'm using pycord-multicog extension;

using that decorator

@add_to_group(get_current_folder()) above my normal slash command
it just adds the command to the command group based on where the cog is located in the dir (in what folder);

note I have a cog for every command;

and the get_current_folder() function just does what it says;

import os, inspect

def get_current_folder(stack: int = 2):
    """
    Returns the name of the current folder a file is in.

    Returns
    -------
    :class:`str` The name of the current folder.
    """

    return str(os.path.basename(get_current_path(stack)))

def get_current_path(stack: int = 1):
    return os.path.dirname(os.path.abspath(inspect.stack()[stack].filename))

It gets the current folder where the file that executes the function is located in.

GitHub

Pycord extension for splitting command groups into multiple cogs - Dorukyum/pycord-multicog

fresh sierra
#

rn im doing somehting like that

#

i have the init where all the group are created

#

and then folder are sub subgroup

red mist
#

about the same.

fresh sierra
#

i have a suggestion

#

idk if that possible

#

but instead of putting the same decorator for each command

#

cant you at the begining make a function that will do that for each command ?

#

here how look my commands

lofty parcel
fresh sierra
sage tendon
fresh sierra
#

he does if i understood :
@slash command
@decorator

for then he doesnt need to put name options etc, which is a good idea because i will be too lazy to do each time name=, description=, name_localization=, description_localization=

#

are they really people who does that for each ?

sage tendon
#

I never use name= or description=

sage tendon
fresh sierra
# sage tendon but then where do you put them

personally i dont i have a function in my setup_hook that put all those attribute. But if i understand zervy does like that :

@config
@slash_command()
async def (self, ctx: discord.applicationContext, member: discord.Member) etc etc
#

and he doesnt use the decorator since the @config put name description etc, even if i dont know how he can do for choice or more than 1 not required without decorator

arctic oar
#

With the pycord paginator is it possible to have the embeds for each page get created per page change

#

I would like to fetch data from the database and present it

little cobalt
fresh sierra
#

Because rn with my thing I can do all of that except multiple required None, default and autocomplete

vital bramble
#

I'm too lazy to test it: What error do I get, if I try to use discord.Interaction.edit_original_response() on an interaction that I have not responded to?

#

I tested it anyways. Seems to be a NotFound.

vital bramble
#

Why does discord.Interaction.edit_original_response() on a component interaction edit the message the component was attached to but in a slash command interaction it edits the response or throws an error?

vital bramble
#

Considering the following code:

print(await interaction.original_response())
print(interaction.message)
print((await interaction.original_response()) == interaction.message)

Why do I get this output?

<InteractionMessage id=1246171041382797398 channel=<TextChannel id=1117427672683917403 name='help' position=13 nsfw=False category_id=1117427563107721226 news=False> type=<MessageType.application_command: 20> author=<Member id=925830334547910686 name='Testimesti' discriminator='4483' bot=True nick=None guild=<Guild id=717770840221024422 name='The Archive' shard_id=0 chunked=True member_count=14>> flags=<MessageFlags value=0>>

<Message id=1246171041382797398 channel=<TextChannel id=1117427672683917403 name='help' position=13 nsfw=False category_id=1117427563107721226 news=False> type=<MessageType.application_command: 20> author=<Member id=925830334547910686 name='Testimesti' discriminator='4483' bot=True nick=None guild=<Guild id=717770840221024422 name='The Archive' shard_id=0 chunked=True member_count=14>> flags=<MessageFlags value=0>>

False

InteractionMessage and Message have the same id and thus should compare equal. But they don't. Why?

#

this is the __eq__ method of both of them:

def __eq__(self, other: object) -> bool:
    return isinstance(other, self.__class__) and other.id == self.id
#

Oh and that's exactly the problem.
It checks the class too. Is that intended?

I guess, whoever wrote that didn't consider that self.__class__ doesn't refer to EqualityComparable but to the actual object...

class EqualityComparable:
    __slots__ = ()

    id: int

    def __eq__(self, other: object) -> bool:
        return isinstance(other, self.__class__) and other.id == self.id

    def __ne__(self, other: object) -> bool:
        return not self.__eq__(other)
quartz umbra
#

Hi, if I have an Image object in Pillow, how can I convert it into an EmbedMedia object, or is it necessary for me to save it?

red mist
#

I cant explain

#

Wait-

#

Oh- that's a lot of blackmark. I hope this won't be seen as flooded text

fresh sierra
#

Why so many black mark lmaoo. But I think I understood

red mist
#

Oh nvm

#

It got deleted

fresh sierra
#

Like if for example if you have a folder in a folder

red mist
#

Euhhh

fresh sierra
#

So it need to check the first folder read all file and then check for the other folder inside of the first one ?

red mist
#

Wait I'm stupid I should just share a link to it facepalm

errant trout
red mist
#

what.

#

Uhhhhhhhhhh

#

When you call get_current_folder(), it looks two levels up the call stack by default:The first level is the call to get_current_folder itself.The second level is the caller of the function that called get_current_folder.When you call get_current_path(), it looks one level up the call stack by default:The first level is the call to get_current_path.This allows you to dynamically determine the directory or folder name based on where the function was called from, which can be particularly useful for logging, debugging, or handling file paths in scripts and modules.

#

It just looks 2 levels up >.>

quartz umbra
#

Just encountered the weirdest error in my opinion:py discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction
I'm not sure if this is a once off thing or what. The code is py ctx.respond(embed=embed)

#

in a bot command

little cobalt
#

do you use anything like requests?

#

also try to defer the command

wintry pawn
#

I get this error for some reason

  File "/usr/local/lib/python3.10/dist-packages/discord/ext/bridge/__init__.py", line 26, in <module>
    from .bot import *
  File "/usr/local/lib/python3.10/dist-packages/discord/ext/bridge/bot.py", line 29, in <module>
    from discord.interactions import Interaction
ModuleNotFoundError: No module named 'discord.interactions'```

How do I fix this?
Bot was working before
little cobalt
wintry pawn
# little cobalt Can you show the pip list pls
----------------------- ----------------
aiohttp                 3.8.4
aiosignal               1.3.1
aiosqlite               0.19.0
async-timeout           4.0.2
attrs                   23.2.0
Automat                 20.2.0
Babel                   2.8.0
bcrypt                  3.2.0
blinker                 1.4
certifi                 2020.6.20
chardet                 4.0.0
charset-normalizer      3.1.0
click                   8.0.3
colorama                0.4.4
command-not-found       0.3
configobj               5.0.6
constantly              15.1.0
croniter                2.0.5
cryptography            3.4.8
dbus-python             1.2.18
discord-py-interactions 5.12.1
discord-typings         0.8.0
distro                  1.7.0
distro-info             1.1+ubuntu0.1
dnspython               2.6.1
emoji                   2.12.1
ffmpeg-python           0.2.0
frozenlist              1.3.3
future                  1.0.0
httplib2                0.20.2
hyperlink               21.0.0
idna                    3.3```
little cobalt
#

is that the full list?

wintry pawn
#

yep

little cobalt
wintry pawn
#

pycord

#

huh

#

for some reason it's not there

little cobalt
#

than why is it not at the list?

#

also what is that?

wintry pawn
#

idk, tbh, that was from the last botmaker

#

tried to install, got this:

Requirement already satisfied: ffmpeg-python>=0.2.0 in /usr/local/lib/python3.10/dist-packages (from pycord) (0.2.0)
Requirement already satisfied: numpy in /usr/local/lib/python3.10/dist-packages (from pycord) (1.26.4)
Requirement already satisfied: imageio-ffmpeg>=0.4.2 in /usr/local/lib/python3.10/dist-packages (from pycord) (0.5.0)
Requirement already satisfied: future in /usr/local/lib/python3.10/dist-packages (from ffmpeg-python>=0.2.0->pycord) (1.0.0)
Requirement already satisfied: setuptools in /usr/lib/python3/dist-packages (from imageio-ffmpeg>=0.4.2->pycord) (59.6.0)```
#

so it's there but... it's not there?

lapis dock
#

pycord != py-cord
You need to have py-cord

wintry pawn
#

fuck

lapis dock
#

uninstall these like zervy said too

discord-py-interactions 5.12.1
discord-typings         0.8.0
shell radish
#

you should probably uninstall like everything

lapis dock
#

And you probably are installing them in the wrong place if it says its installed but not showing up

shell radish
#

except for pip

lapis dock
#

Are you using a venv?

wintry pawn
#

nope, previous bot guy wasn't even using fucking git

little cobalt
#

Im also not really using git

lapis dock
#

Probably best to start a venv. Than the packages will install to the right place

wintry pawn
#

well, they didn't use any version controll at all

little cobalt
#
pip freeze > pip.txt
pip uninstall -r pip.txt

@wintry pawn

wintry pawn
#

done

#

now what?

little cobalt
#

install py-cord

wintry pawn
#

finnally

#

thank you so much

sage tendon
#

is there really no command to uninstall everything

shell radish
sage tendon
#

no

#

but
pip uninstall --all
why not?

deft kestrel
#
                use_soundboard=True,

how it's called this permission?

errant trout
forest tulip
#

how to add

fresh sierra
#

It’d automatic

#

U can’t do anything about that

forest tulip
#

saddo

rain dune
#

is there any inbuilt function, which can convert multiple embeds to paginator directly?

grizzled loom
fresh sierra
#

And then pass them

#

embeds = []
Embeds.append(embed) * 10
pages=embeds

#

Like si

grizzled loom
#

here is how i did it, with a subclass but otherwise its the same:

        paginator = MyPaginator(
            pages=embeds, show_disabled=False, author_check=True, disable_on_timeout=True, timeout=300
        )

        await paginator.respond(interaction=ctx.interaction)

"embeds" is a list with several embends in it

rain dune
#

alright thanks

grizzled loom
#

welcome

rain dune
errant trout
#

(10 embeds per any message)

rain dune
#

ohk thanks

rain dune
lapis dock
#

what do you mean by optimally? It can put 1 embed per page if thats what you mean

deft kestrel
#

Does anyone have a base strucutre of everythingf embeds can include?

little cobalt
deft kestrel
#

which docs are you refering to?

shell radish
#

.embeds

shell radish
#

@deft kestrel ^

deft kestrel
#

thank u

rain dune
# errant trout wdym

i mean like i will pass the whole list, and it will make the pages of 10-10 and rest elements in another page automatically and then send

errant trout
#

Just look up how to chunk lists in Python

#

Then make a page object for each set of embeds

#

Note that even with the 10 embed limit, all text must be under 6000 characters per message

rain dune
#

alright thanks

#

ill do it

green kernel
#

Hello

#

How long does it normally take for a guild-only slash command to register?

#

Added a new one and it's not registering as it usually is

sage tendon
#

instantaneously

#

restart discord to see it

green kernel
#

o ok

#

'nother question, how do I do that "bot is thinking..." thing?

sage tendon
#

await ctx.defer()

#

only do that when you need it tho

green kernel
sage tendon
#

respond

green kernel
#

ty

weary meteor
#

thunderinmc@bots:~/listingbot$ python3 bot.py
Traceback (most recent call last):
File "/home/thunderinmc/listingbot/bot.py", line 8, in <module>
from views.account_owner import AccOwnerView
File "/home/thunderinmc/listingbot/views/account_owner.py", line 3, in <module>
from discord.ui import Button, View
File "/home/thunderinmc/.pyenv/versions/3.10.7/lib/python3.10/site-packages/discord/ui/init.py", line 11, in <module>
from .button import *
File "/home/thunderinmc/.pyenv/versions/3.10.7/lib/python3.10/site-packages/discord/ui/button.py", line 32, in <module>
from ..components import Button as ButtonComponent
File "/home/thunderinmc/.pyenv/versions/3.10.7/lib/python3.10/site-packages/discord/components.py", line 30, in <module>
from .enums import ButtonStyle, ChannelType, ComponentType, InputTextStyle, try_enum
ModuleNotFoundError: No module named 'discord.enums'

any ideas guys?

#

i slapped this on a vps and it very much not willing to run

lofty parcel
forest tulip
#

its possible to make 2 select menus in 1line?

#

like buttons with rows

#

like that

#

all what i got its my bestxd

sage tendon
#

you can't make select menus side by side

winter moss
#

i've a interaction code,
Even tho I haven't set ephemeral=True it still doesn't show to others.

little cobalt
winter moss
# little cobalt Can you show some of the code?

Oh don't mind my bad there I missed it in another file,

Anyways, Another Issue I am facing is that options are limited to 25, isn;t there a way to increase the limit or a better approach to it?

little cobalt
#

which options?

#

select menu options?

winter moss
#

Select Options

#

Yes

little cobalt
#

choices? at slash commands?

winter moss
#

Select Choices / options, isn't that same?

#

What ever the dropdown is

little cobalt
#

one is a select options for a select menu and the other one is at slash commands

little cobalt
#

dropdown got a limit of 25 sadly and you cannot increase it

#

do you use a str menu?

winter moss
#

nope, I didnt define such thing

little cobalt
#

so you just did ui.Select?

winter moss
#

Although am just using them to show strings so naturally i should be going for string type by the ring of it. It increases the limit?

little cobalt
#

the normal ones got a limit of 25

#

but there are also channel and user ones

winter moss
#

Whats the limit for string one

little cobalt
winter moss
#

I read somewhere that its 40 for string ones?

errant trout
#

(you can only specify string anyway; the others are automatic)

granite pier
#

hey, anyone noticed missing avatars while not using cache?

granite pier
#

i mean user/members display_avatar is like blank sometimes

#

(outdated, 404)

deft kestrel
#

I know this isnt pycord related but pythong isnt pythoning right now, basically i have the bot token set in an Enviroment

#

i can read it from all python files

#

but it doesnt work on 1 specific one

#

even though it read it the same way as the other ones:

granite pier
#
from os import getenv
from dotenv import load_dotenv

load_dotenv(override=True)
...
deft kestrel
#

forgot to mention that i set it

sage tendon
#

what

deft kestrel
#

Like i get the token from the database wit ha function

#

set it an an enviroment variable and then read it back liket hat

sage tendon
#

...why

deft kestrel
#

because i want to use the token between different python files for various discord requests

granite pier
#

dont store token in db

#

just use .env file

#

or set it in system env variables

deft kestrel
#

Yeal lemme store 60000 bot tokens in a env file

sage tendon
#

If you have 60000 bot tokens you're doing it wrong

granite pier
#

or abusing PepeLaugh

deft kestrel
#

Just look at my profile conections

sage tendon
#

best way is still just config.py

bot1 = token
bot2 = token
etc

sage tendon
deft kestrel
#

So people know im not an imposter

#

basically i launch my bot in a docker container which gets the token from the database. reading BOT_TOKEN from the ENVIROMENT (NOT .ENV) works fine on 3/4 files

#

but it doesnt on that one specific one

fresh sierra
deft kestrel
#

So i dont have to read it 4 different times

fresh sierra
#

fetchall from the database
for token in tokens :
do your thing

#

why not just store it as a variable ?

deft kestrel
#

because i have 4 different files

fresh sierra
#

from ... import token

deft kestrel
#

thats a thing?

fresh sierra
#

that's basic python

#

from ur file import the var

deft kestrel
#

bruh i thought that only worked for functions

fresh sierra
#

and it will import it from the file

#

it works for everything

deft kestrel
#

the more you know

fresh sierra
#

?

#

you still have some issue ?

deft kestrel
#

that was it

fresh sierra
#

so now everything is working fine ?

deft kestrel
#

yeah i have to fix some parts of the code to use that from ... import tt

fresh sierra
#

good luck then

sage tendon
#

or just import your config file and then config.token lol

#

so many ways to do it

granite pier
granite pier
fresh sierra
fresh sierra
#

member.color that a thing ?

fresh sierra
#

i dont understand what is member.color

granite pier
granite pier
#

haha

fresh sierra
#

oooo

granite pier
fresh sierra
sage tendon
#

I'll be real I think I had a similar issue now that I think of it

granite pier
fresh sierra
#

also do you have this issue using user and not member ?

granite pier
sage tendon
#

I pass display avatars to an API
and the past days it's been broken a couple of times
I thought it was the API, but it might have just been discord not working then

granite pier
#

but i pref to ask

fresh sierra
#

discord is a lot broken lately

little cobalt
granite pier
sage tendon
fresh sierra
#

yesterdaty it was not possible to add some bot

granite pier
fresh sierra
#

can you give me l'id of the member where you cant get the avatar ?

granite pier
#

i mean its missing sometimes

#

so e.g. when someone change avatar

fresh sierra
#

just to try if i have the same issue for that member

granite pier
#

not missing but invalid *

granite pier
#

cause they work after hard bot restart

#

so i was wondering if its not issue related to lib also

sage tendon
#

possible

granite pier
#

ill add some debug for it

#

and mby ill find some issues haha

#

avatar in logs was valid

#

i mean url

deft kestrel
#

How do I set the presence to 'watching me' using pycord

granite pier
sage tendon
deft kestrel
sage tendon
#

that is literally everything lol

lapis dock
#

its a kwarg for the bot constructor

deft kestrel
granite pier
sage tendon
deft kestrel
#
async def on_ready():
    print(f"WORKING AS {bot.user}")
    discord.Bot(activity=Activity(type=ActivityType.watching, name="you"))
    await main() ``` ??
sage tendon
#

lol

lapis dock
#

it should go in your existing bot constructor

#

dont make a new one

sage tendon
#

you can set / change it in on_ready

but there's no point if its supposed to be static

fresh sierra
#

if you want to make it change in the on_ready you should use :

#

await bot.change_presence(activity=activity)

granite pier
#

it seems that discord embed breaks after setting a newly changed avatar/banner etc.

glossy latch
#

how can i add try my command in the bot profile ?

lofty parcel
#

You don't

#

It's set by discord only to verified apps

glossy latch
#

ah okey

#

thx sir!

deft kestrel
sage tendon
#

then change it when you want

deft kestrel
#

how do i have it just anytwhere in the code

#

and always changing

lofty parcel
#

You have to create a task.

#

And iterate over your predefined activities.

deft kestrel
sage tendon
deft kestrel
#

oh cool

half terrace
#

Okay, so I wanted to have a single command that is prefix only (not a slash command) and there are 2 problems

  1. bot.command() still creates slash command
  2. if the function does not use .respond(), but .send() then discord shows message that the app is not responding
bot = discord.Bot(command_prefix='?', intents=intents)
        
@bot.command(name='debug', description='debug stuff etc.')
@commands.has_role(RoleId.admin)
async def debug(ctx: discord.ApplicationContext):
    await ctx.send('test')

this should be prefix command, but it's not + shows up (and works) as a slash one

edgy nest
#

you need to use commands.Bot for prefix commands

half terrace
#

ohhh, will try, thanks

little cobalt
half terrace
#

yup, during migrating (from discord.py) I changed it to discord.Bot as it said in one tutorial (guide.pycord.dev) but changing it back fixed everything, thanks