#Basic Pycord Help

1 messages · Page 52 of 1

fresh sierra
#

so its because of pillow ig

shadow sigil
#

and not using pillow anywhere that "should" be running while idle

fresh sierra
#

.tag rie

sly karmaBOT
#

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

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

fresh sierra
#

just in case, if you still have the other issue send the file with the link i gave u and i will take a look

shadow sigil
#

also, for the record

#

i have changed nothing regarding pillow usage between this not happening and now

fresh sierra
#

might not be this but you still should use the rie

#

try that just in case

shadow sigil
#

top file is the main one

fresh sierra
shadow sigil
#

yes

#

this happens with me doing nothing besides writing python fractalrhomb.py in the console

fresh sierra
#

does fractalthorns_api is async ?

shadow sigil
#

uh
what?

fresh sierra
#

i think those kind of thing :
fractalthorns_api.purge_cache(cache)
might be blocking the bot

#

yeah might be that

#

everything is using requests

#

which is blocking, so ig the request to the api block ur whole bot

shadow sigil
#

fyi, you're looking at old code

#

for one, i'm not using requests

fresh sierra
#

i dont have the fractalthorns_api in the thing u sent me

#

but since no fractalthorns_api are awaited

#

i think it can be the issue

shadow sigil
#

i'm gonna test a thing

#

hmm
i can just make the following comment
if i change it to

def main() -> None:
    parse_arguments()

    try:
        asyncio.run(frg.bot_data.load(frg.BOT_DATA_PATH))
    except Exception:
        discord_logger.exception("Could not load bot data.")

    #async with aiohttp.ClientSession() as session:
        #frg.session = session

    bot.load_extension("cogs.fractalthorns")

    token = getenv("DISCORD_BOT_TOKEN")
    bot.run(token)


if __name__ == "__main__":
    main()
```it doesn't give me heartbeat blocked warnings anymore
fresh sierra
#

also for you know, asyncio.run is blocking

#

so using asyncio.run might block ur bot

#

and so give u the hearthbeat

shadow sigil
#

ok
literally just adding an async with bot: before the await bot.start stopped the error

obsidian blaze
#

A little confused with the new guild commad/user command app install system. Before 2.6 I used ad = SlashCommandGroup("admin", "Admin controls for the bot", guild_ids=[xx]) to lock to a guild. But not they won't show up at all. So how do you do it now?

shadow sigil
#

how can i split long messages in a way that wouldn't mess up markdown formatting?

tidal vessel
obsidian blaze
stoic patio
#

when a member only has one mutual server with a bot and then gets kicked, and has had no previous interaction with the bot before (e.g., dms), do they get uncached?

stoic patio
#

also how do bots like carlbot processes a bunch of channel overwrite updates at once if those events are sent individually?

real glacier
#

hi, how subcommand works already read the doc but not so sure where to start

sage tendon
#

if you use cogs, manually create a SlashCommandGroup, then do
@groupname.command()

and from there on its like any other command

real glacier
#

oh

#

do i have to implement both main file and cogs file?

sage tendon
#

I think how to do slash groups in cogs isn't on the guide
if you don't use cogs, there is definitely a guide on groups

rugged lodgeBOT
#

Here's the slash cog groups example.

echo wraith
#

There's the example

real glacier
#

alrr

sage tendon
#

oh there is

#

oh an example yea

real glacier
#

ok working now thanks

real glacier
sage tendon
#

@discord.slash_command()

#

it's all in the guide, read it

real glacier
#

ok i figured it out

oblique sable
#

Hey guys, any idea? The settings one doesnt appear

sage tendon
#

restart discord

oblique sable
#

ah okay

#

thanks 😭

real glacier
#

ok so how do i get classes returned ThinkO_O

shell radish
#

what

real glacier
#

bad explanation, i mean like

sage tendon
#

that arguably explains it even less

#

do you mean stuff like return discord.Guild as a class or what

real glacier
#

i want to pull the class callback

sage tendon
#

can you please explain what you want to do in a full sentence or two

real glacier
#

oh

#

im trying to do custom context using class

sage tendon
#

so like a custom ctx for commands? im still so confused

real glacier
#

yes

#

prob from my bad explanation

sage tendon
#

well for that you can just subclass ApplicationContext
but not sure though how you populate / actually pass that into the commands, never did that
maybe someone else knows

real glacier
#

alrr

rugged lodgeBOT
#

Here's the custom context example.

echo wraith
#

Custom context is very useful

sage tendon
#

#general message this can happen because py-cord (the install name of the package) doesnt match discord, the import name

#

if it works, dont worry about it

#

but if you did pip install discord, thats not pycord

limpid marten
#

i followed the pycord installation process

little cobalt
#

Can you show the pip list pls

sage tendon
#

If everything works you can ignore those warnings
I also get them in pycharm, it's correct that they show up, tho annoying

limpid marten
#

i yet again switched muahaha

sage tendon
#

switched what

limpid marten
#

to vscode

sage tendon
#

i mean, it doesnt matter lol

#

the warning showing up is correct

little cobalt
limpid marten
#

its quite long so i gotta make it a txt file probably

sage tendon
#

if its longer than fits in a discord message you are long overdue for using venvs

limpid marten
sage tendon
#

aaand wrong

limpid marten
#

WHY IS IT THERE

sage tendon
#

you dont have pycord installed at all

little cobalt
limpid marten
sage tendon
#

you didnt

limpid marten
#

i did

sage tendon
limpid marten
#

but WHY

sage tendon
#

because yo udidnt install it

limpid marten
#

i hate u, random person on stackoverflow

sage tendon
sage tendon
limpid marten
sage tendon
#

no need to trust random idiots from probably 4y ago on stacky

limpid marten
#

wellllll

#

so i GOTTA follow the stackoverflow gods who had the same problem as me

sage tendon
#

oh my god i last saw that when someone tried using python on a chromebook

#

the horrors

limpid marten
#

its making me suicidal

sage tendon
#

did you try apt install python3-py-cord like it says

limpid marten
#

i think

#

lemme try again

little cobalt
#

and you said its Linux Mint?

sage tendon
#

mint is debian based

little cobalt
#

and?

limpid marten
sage tendon
#

in case you mean it saying debian-based in the error text

little cobalt
#

lol

sage tendon
# limpid marten

well, then did you follow the rest of the text and make a venv?

limpid marten
#

oops

sage tendon
limpid marten
#

yeah hold on

sage tendon
#

people not reading errors is the worst pandemic to strike programmerkind

limpid marten
#

i read it

sage tendon
#

but?

little cobalt
#

that is not how you install the stuff....

sage tendon
#

zervy

#

yes, it is
else there wouldnt be a literal text step by step guide on how to do it when you try the normal way

#

idk what kind of messy install they have that that happens, but they do

#

tho tbfh the chromebook person that happened to didnt succeed either in the end so shrug

limpid marten
#

yeah imma just code on windows then

#

and do everything else on linux

#

the way its absolutely NOT Intended

#

they call me mr. opposite

sage tendon
#

i mean, you didnt exactly do what it says

little cobalt
acoustic zodiac
#

I have an embet with buttons and logic And I want to update the embet in another file 1 picture when entering the voice channel send this message to the chat and the one who is first, that is, foz change the captain and choose your timemate 2 pictures and after the button the button changes the embet and deletes the buttons, and I want to connect another file where there will be other buttons, and it will be possible to add new buttons and change the embet, if you need a code, I can support

sage tendon
#

stay in one place

#

@acoustic zodiac

round heart
#

It's been 6 minutes. Nobody gets help in 6 minutes.

acoustic zodiac
round heart
#

No, he means you already have an active Post that hasn't even had time to get noticed by people who could help

acoustic zodiac
round heart
#

That would make it difficult to apply any changes people may suggest.

acoustic zodiac
#

Ok friend

limpid marten
#

i fixed my problem

#

i literally just had to pip install through the vscode terminal

sage tendon
#

bruh

limpid marten
#

i have no idea why it didnt work through the terminal

little cobalt
#

lol

sage tendon
#

"linux is so easy and makes sense"

little cobalt
#

It is easy to use xd

sage tendon
#

cleeeeearly

little cobalt
sage tendon
#

whats wrong with trying to pip from the terminal?

#

clearly it didnt work as they showed

little cobalt
#

I was using Linux for half a year without any experience

#

And it was pretty nice to use

rugged lodgeBOT
#

Here's the cooldown example.

broken pivot
#

why does role.members literally return nothing

sage tendon
#

is the bot role above that role?

#

do you have members intents?

#

and maybe you also need manage roles

#

but the docs dont say anything about that

stoic patio
#

are member_remove and member_ban the only two events associated with members leaving a server

sage tendon
#

think so, there isn't really anything else

stoic patio
#

i see

broken pivot
broken pivot
sage tendon
#

just as a counter-check, you can print member.roles right

shell radish
#

it can be printed

broken pivot
sage tendon
#

hm but not sure then, and im too tired to think harder about this

shell radish
sage tendon
#

all good

deft kestrel
#

how to make the command only for the owner of the bot?

little cobalt
#

with is_owner()

deft kestrel
#

thanks

stoic patio
#

how can i check if my bot has a dm with a certain member

sage tendon
#

cant check rn but it hink there's Member.history

stoic patio
#

oh wait i found it

#

member.dm_channel

obsidian blaze
#

How do you register slash command groups to a certain command? Is it done through the command or the slash command group?

rugged lodgeBOT
#

Here's the slash cog groups example.

obsidian blaze
# little cobalt ^

Oops I missed my main part lol. How do I register to a certain guild. not sure why i wrote command lol

little cobalt
#

guild_ids=[]

obsidian blaze
#

ad = SlashCommandGroup("admin", "Admin controls for the bot", guild_ids=[x]) So like this? I did this and nothing is showing up in the server which is how i did it before the update

little cobalt
#

mhm

obsidian blaze
#

Weird I am having no luck with that. Nothing seems to register in that server.

little cobalt
#

try it by adding it directly to the commands and not the group

sage tendon
#

it has to be on the group

sage tendon
obsidian blaze
sage tendon
#

yea because you can't pass guild ids to individual command group commands

obsidian blaze
#

Right okay hmmmm

#

All other commands register just fine, I think its something in 2.6 as the previous version worked just fine when I registered the guild id in the slash command group

flat tapir
#

maybe a stupid question or unrelated to the library but im streaming an audio file through discord and it plays it through my laptop first before it plays it on the bot, is this normal with pycord? or is it the other library

shadow sigil
#

is it possible to tell if a "the application did not respond" error has occurred or no

limpid marten
sage tendon
shut fox
#

guys, what is it space and how to fix it? (pycharm)

sage tendon
#

git blame thingy mb?

#

but uh thats not really pycord related lolw

#

right click the grey area at the top and it should tell you what it is

sage tendon
#

wait no i think that is the annotations tab lol

#

right click this other grey part up here, should let you close it

sage tendon
#

no

#

the top grey thing above the dark grey are

shut fox
sage tendon
#

no, below that lol

#

the middle grey thing

shut fox
sage tendon
#

oh, hm

#

yea then idk lol

fresh sierra
#

Why does this does not give the same number ?

len(list(self.bot.entitlements(limit=None, exclude_ended=False).flatten()) => 199 while

obsidian blaze
#

Any ways to send a audio message as a voice message in discord so it can be seen on mobile?

lofty parcel
#

Not possible as far as I am aware.

little cobalt
#

Does someone know why this is not added as "persistent"?

#

I added the View also with "add_view()

sage tendon
little cobalt
#

after the bot restart

sage tendon
#

your view doesn't have a custom id

#

I'm p sure the view itself needs one

little cobalt
#

do you see any custom id?

sage tendon
#

man idk

little cobalt
#

you add the custome id to the button

lofty parcel
little cobalt
lofty parcel
#

Oh kek

#

When are you doing it

little cobalt
#

ok I got it

#

I have to load it all at the main file I see

#

with @client.listen()

fresh sierra
#

I don’t think it’s because of that

#

Cos im adding the add_view in cog and different file

#

Only thing that’s im not using is a subclass of button

little cobalt
#

Its working fine at the main file but not at the cog

fresh sierra
#

Can u try putting it inside the cog

#

And not using a subclass of button v?

#

like do button = …

lofty parcel
#

Are you sure the cog is being loaded then

#

Or that the listener actually runs

#

I do load my views on a cog listener too and I got no issues

little cobalt
fresh sierra
lofty parcel
#

Oh, no

fresh sierra
#

Might be that then

#

I will try tomorrow

stoic patio
#

if i wanna send a bunch of embeds at once, is the max char limit of 6k supposed to be a limit of the total chars in all of the embeds?

shell radish
#

per embed iirc

stoic patio
#

for some reason it seems like it's total

errant trout
#

definitely total

#

discord sure as hell aint letting you send 60k chars in a message

echo wraith
echo wraith
lofty parcel
echo wraith
opal swan
#

how it works ?

sage tendon
#

what exactly do you want to do

opal swan
#

but it's write I need to make that in parameter

opal swan
#

can we fetch a voice channel ?

#

.rtfm fetch_voice

sly karmaBOT
#

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

sage tendon
#

of course

opal swan
#

i'm right ?

grizzled loom
# opal swan await bot.fetch_channel

naah
you get first, only when you receive None you fetch
else you'll float api calls and, depending on scale, could face disconnect due to too many api calls.

opal swan
#
# idk why it didn't work... lemme send the traceback

if ctx.message.attachments[0]:
        await ctx.guild.create_custom_emoji(name=str(ctx.message.attachments[0].filename.split(".")[0]), image=await ctx.message.attachments[0].read(), roles=list(ctx.guild.default_role))
        
#

(and yes I read the doc but why this error in name parameter)

lofty parcel
#

The name you're passing is not valid for the library

opal swan
#

bruh

#

alr

#

nice it work

errant trout
#

also if you're only using default_role, just don't bother passing roles at all

opal swan
#

I modify my code so now it's clean

#

I do a for ... in ctx.message.attachments:

#

and so we can create multiple emojis

verbal torrent
#

is there a way to do every emojy from the bot in an embed?

sage tendon
#

sure

#

why not

verbal torrent
# sage tendon why not

do you know, how to get the emojys? i tried it with self.bot.emojis but this are only the emojys from the server, where the bot is

sage tendon
#

app emojis aren't in pycord yet

echo wraith
verbal torrent
#

oh ok. but thanks

#

for the info

opal swan
sage tendon
#

i dont know? lol
ask them

verbal torrent
opal swan
loud kayak
#

how do i fix this ide error?

little cobalt
shell radish
loud kayak
sage tendon
#

you won't regret it, trust me

#

also, what

loud kayak
# sage tendon also, what

i added the under score just in case I use anything for status_group and dont want to have to change a ton of decorators

loud kayak
sage tendon
#

just because you're used to it doesn't mean its better
and it gets rid of the warning

#

and really, its a minimal change

echo wraith
#

It's funny because the decorator LITTERALLY hijacks the function signature typehints

fresh sierra
grim estuary
#

Hello! Is there a possibility that the bot will skip discord.on_voice_channel_status_update? Maybe a temporary loss of connection or something like that

shell radish
#

yes

oblique sable
#

hey guys, i basically got a flask api where an endpoint is supposed to remove a role/add a role to some user, what is the best way to do that?

#

should i switch to quart?

#

i tried having a list of users, and in my on_ready() function to check each time a memebr gets added to that list to add/remove a role, but after like 5-6 hours, the bot starts glitching, doesnt find the role etc

lofty parcel
shell radish
oblique sable
#

okay ill switch to that directly

lofty parcel
oblique sable
#

is it okay if i run the bot this way?

#

then simply have my endpoints under that, and starting the flask app normally?

mint solar
#

yo, how do I check if message has mentions

lofty parcel
stoic patio
#

if a discord bot disconnects and then reconnects, and i have asyncpg.Pool() objects, do i need to close them explicitly

mint solar
#

How do I get the user ID from list of mentioned user

#

ahh just how do I convert the str into user property

errant trout
proven valley
#

if I installed pycord before uninstalling discord.py, do I need to uninstall both then reinstall pycord for it to work? cuz VS code is saying it's not recognizing it.

errant trout
#

reinstall py-cord

proven valley
#

gotcha, thanks

mint solar
#

So I didn't use the mentions one, but I have this code, it split messages and the first item is user mention, I just want to convert the mention from string into user objects, but I've been struggling with that.

    @command()
    async def verify(self, ctx, *, msg):
        main_ally = ['58-K', '58-D', '58-B']
        cmd = msg.split(', ')
        user = cmd[0]
        nickname = cmd[1]
        ally = cmd[2]
        member = cmd[3]
fresh sierra
#

@command()
async def verify(self, ctx: commands.Context, user: discord.User, nickname: str, ally: …, member: discord.Member ?

mint solar
#

err

#

I'll just do slashcommand

mint solar
#

okay so why doesn't it show the command when I type slash

little cobalt
#

How do you load the cogs?

mint solar
#

like this

#
if __name__ == "__main__":
    for cog in listdir('./cogs'):
        if cog.endswith('.py') == True:
            bot.load_extension(f'cogs.{cog[:-3]}')```
little cobalt
#

That looks fine

#

Refresh your client with ctrl + r

granite pier
#

you can just use if cog.endswith('.py'):

mint solar
#

I've also close and reopen the client

#

this is the code

#

btw why is the slash command different in guide

mint solar
#

Fixed, had to reinvite with application.command scope

opal swan
#

idk if ur understand

proven valley
#

cog

import discord
from discord.ext import commands


class MM(commands.Cog):
    def __init__(self,bot):
        self.bot = bot

    mm = discord.SlashCommandGroup("mm","test")


    @mm.command(name="1v1")
    async def mm1v1(self, ctx):
        await ctx.respond("test")

async def setup(bot):
    await bot.add_cog(MM(bot))```

main

import discord
from dotenv import load_dotenv
import os
from discord.ext import commands
import asyncio
import aiosqlite
bot= commands.Bot(command_prefix="!",intents=discord.Intents.all())

load_dotenv(".env")
TOKEN: str = os.getenv("DISCORDTOKEN")

@bot.event
async def on_ready():
print("Bot Ready!")

async def Load():
cogs_list = ['mmq']
cogs_loaded = 0
for cogs in cogs_list:
bot.load_extension(f'cogs.{cogs}')
cogs_loaded =+ 1
print(f'Cogs loaded: {cogs_loaded}')

async def main():
async with bot:
await Load()
await bot.start(TOKEN)

asyncio.run(main())```

#

anyone know what's wrong here?

#

the command isn't working.

sage tendon
#

what "isnt working"

little cobalt
#

like a async def func. at the cog ;3

proven valley
#

the app command won't show up in my server

little cobalt
proven valley
#

py-cord

sage tendon
#

restart discord

little cobalt
#

remove the async and await

sage tendon
#

oh, lol

little cobalt
#

;3

sage tendon
#

yea your IDE shouldve warned you about that

proven valley
#

How come you're not supposed to do that? I'm not very familiar with the async and await stuff

sage tendon
#

well, you just arent lol

#

thats sync stuff

proven valley
#

got it, thank you.

sage tendon
#

check out the guide if you're not familiar

proven valley
#

Okay, thanks

oblique sable
#

hey guys, how's that possible?

#

member.roles doesnt contain the Tester role even though its there

#

is this the proper way to get it?

little cobalt
oblique sable
#

just a dict containing either "id" either "username"

#

i dont think issue could be from there, its just providing them

#

and if i restart the bot, then it gets the roles good for the first time, then not anymore, like it caches them or something

little cobalt
#

Keep in mind that people can change the user name

#

so you would add the wrong thing to a user

oblique sable
#

yup sure

#

but i dont undetrstand why member.roles doesnt get the right roles

#

only the first time

#

just like it caches them

#

i have a loop running on the on_ready function

little cobalt
#

why?

sage tendon
little cobalt
#

on_ready can runs multiply times while running your bot

sage tendon
#

can*

oblique sable
#

wdym? cant i have a code keep running there?

#

why?

#

i didnt know that

little cobalt
#

I kinda competently removed on_ready at my bots

sage tendon
#

just use tasks

#

they're meant for that

little cobalt
#

^

oblique sable
#

ah okay thanks, ill check that out

fresh sierra
#

You should copy the to_add_roles to not get this error

oblique sable
#

not really in that case, since im only removing the current element

opal swan
#
@bot.command()
async def memberconvert(ctx, member : Union[str, discord.Member, int]):
    if not isinstance(member, discord.Member):
        class myconverter():
            def __init__(self):
                pass
            async def converter():
                member = await commands.MemberConverter.convert(self, ctx=ctx, argument=member)
        myconverter().converter                
            
    await ctx.reply(content=member.mention)        
 
#

yo guys why it raise that

sage tendon
#

discord.Member catches member IDs too, there's no need to use a union

#

just do member: discord.Member

#

itll work and convert

#

and i dont even wanna know why you are defining a class inside of a command

opal swan
sage tendon
#

yea because its not a static method

#

you have to instantiate it to use convert()

sage tendon
opal swan
#

ok i'm gonna test it rn

#
@bot.command()
async def memberconvert(ctx, member : discord.Member):
    member = await commands.MemberConverter.convert(ctx=ctx, argument=member)
            
    await ctx.reply(content=member.mention)        
 ``` that's weird
#

traceback :

sage tendon
#

dont convert it.

#

the library does it for you.

opal swan
#

fr ?

#

tyyy

#

it work

#

I doesn't know this before

#

nice

opal swan
#

pls help what is state parameter

sage tendon
#

wtf even is a widget lol

#

what are you doing

opal swan
#

don't say in the doc what is state

sage tendon
#

befor,e you said widget :)

opal swan
#

ye but now I'm trying a new thing

sage tendon
opal swan
#

state ?

sage tendon
#

you dont create assets manually ever im p sure

opal swan
#

😢

#

ye but I need to open a link and read the content

sage tendon
#

again, what do you even wanna do

sage tendon
opal swan
sage tendon
#

why not use aiohttp lol

opal swan
#

bcs aiohttp didn't send a format like .jpg or smthing like that

#

so my code is wront

#

wront

#

wrong

sage tendon
#

does the link end with a file ending

opal swan
#

nah it end with the emoji id

sage tendon
#

ah

#

yea idk then

opal swan
#

😭

#

alr ty also

opal swan
opal swan
#

https://cdn.discordapp.com/emojis/{emoji_id}.gif

#

or .jpg

shell radish
#

glad it works

stoic patio
#

self.bot._connection.clear() theoretically shouldn't clear the bot's user object right?

stoic patio
errant trout
#

that'll only happen if you do stuff before on_ready is complete

stoic patio
#

cuz i get this

errant trout
#

i can see why this is happening, but you appear to be the first person to ever hit this error in the many years of that line existing

stoic patio
#

and why does it happen?

errant trout
#

because user is none, but that event wouldn't fire before on_ready

stoic patio
#

but why does that come directly from the bot.run line?

errant trout
#

any error that kills the bot would come from run because that's how the loop works

stoic patio
#

oh lol

stoic patio
#

if that event isn't supposed to fire before the bot's ready?

errant trout
#

it's not that "it's not supposed to", it literally can't receive other events until ready has fired

stoic patio
#

like that's what i mean

#

then how likely is it that it's something beyond my control?

stoic patio
errant trout
#

i can't really tell, like i said above literally no one has ever seen this error (from what i can tell) in the 9 or so years that it's checked for self.user.id, so my assumption is that it's something on your end but i wouldn't really know what

#

(i.e. if this had ever been a problem before, it would have been patched years ago - otherwise it'd be odd for there to be no null check for self.user)

#

quite frankly patching it is the matter of a few characters, but understanding why it's like that is more important for both you and the library itself

stoic patio
#

and if i print self.bot.user after self.bot._connection.clear(), it should be None right

errant trout
#

well, yeah

#

...you aren't calling clear normally, are you?

stoic patio
errant trout
#

ok well

#

why

stoic patio
#

cuz i had a weird memory issue

#

and wanted to clear stuff upon disconnect

errant trout
#

you're just nuking your entire cache and it won't refill then 💀

stoic patio
#

oh 💀

errant trout
#

literally ```py
def clear(self, *, views: bool = True) -> None:
self.user: ClientUser | None = None
self._users: dict[int, User] = {}
self._emojis: dict[int, Emoji] = {}
self._stickers: dict[int, GuildSticker] = {}
self._guilds: dict[int, Guild] = {}
self._polls: dict[int, Guild] = {}
if views:
self._view_store: ViewStore = ViewStore(self)
self._modal_store: ModalStore = ModalStore(self)
self._voice_clients: dict[int, VoiceClient] = {}
self._private_channels: OrderedDict[int, PrivateChannel] = OrderedDict()
# extra dict to look up private channels by user id
self._private_channels_by_user: dict[int, DMChannel] = {}
if self.max_messages is not None:
self._messages: Deque[Message] | None = deque(maxlen=self.max_messages)
else:
self._messages: Deque[Message] | None = None

stoic patio
#

OH SHOOT

#

lol i just saw

errant trout
#

if you're gonna use undocumented stuff, at least read the source

stoic patio
#

ok

#

i used .clear() on the on_disconnect event

opal swan
#

is discord.ext.commands.Bot.get_emoji need the bot be in the guild to get it or ?

echo wraith
#

.tag get

sly karmaBOT
#

Tag not found.

Did you mean...
get_x

echo wraith
#

.tag get_x

sly karmaBOT
#

Any function that starts with get_ in Py-cord is retrieving the related object from your bots cache. If the object is not in the bots cache the get_ method will return None. Because of this behavior you should check if the get_x method is None and if it is use the fetch_x method.

Why Is Using fetch_ Without Using get_ First Bad?
The fetch_ method makes a call to the discord API. This API call is unneeded if you already have the information. It will also make your command take longer because it will have to send and than wait for a response from the discord API. It will also contribute to the discord APIs global rate limit of 50 requests per second.

What Is Cache?
The cache is a temporary storage inside your bot. It holds many objects from members to messages. When you restart your bot the cache will be empty. When the cache is full it will delete older objects to make space for the new objects.

opal swan
#

.rtfm fetch_emoji

sly karmaBOT
opal swan
#

bruh

echo wraith
opal swan
#

😢

echo wraith
shut fox
#

how to delete bot's message with button?

opal swan
shut fox
opal swan
#

np

hazy turret
#

Can anyone tell me how I can test this cog with pytest?
I always have problems with ctx

test_testfunc - TypeError: Test.testfunc() missing 1 required positional argument: 'ctx'```
```py

import discord
from discord.ext import commands

from config import BOTCOLOR


class Test(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

    @commands.command(name="test")
    @commands.has_permissions(administrator=True)
    async def testfunc(self, ctx):
        embed = discord.Embed(
            title="Test",
            description="""Test""",
            color=BOTCOLOR,
        )

        await ctx.send(embed=embed)


def setup(bot):
    bot.add_cog(Test(bot))
@pytest.fixture
def bot():
    return MagicMock(spec=commands.Bot)


@pytest.fixture
def cog(bot):
    return Test(bot)


@pytest.mark.asyncio
async def test_testfunc(cog, mocker):
    # Mock the context
    ctx = AsyncMock()
    ctx.send = AsyncMock()

    # Mock the permissions check
    mocker.patch("discord.ext.commands.has_permissions", return_value=True)

    # Call the command
    await cog.testfunc.__call__(ctx)

    # Assert that ctx.send was called once
    ctx.send.assert_called_once()

    # Get the call arguments
    call_args = ctx.send.call_args[1]

    # Assert that an embed was sent
    assert "embed" in call_args

    # Check the embed properties
    embed = call_args["embed"]
    assert isinstance(embed, Embed)
    assert embed.title == "Test"
    assert embed.description == "Test"
    assert embed.color.value == BOTCOLOR

def test_setup(bot):
    setup(bot)
    bot.add_cog.assert_called_once()```
sage tendon
#

I'll be real, test automation is just unnecessary for discord bots

echo wraith
#

never is

#

being able to check that you didn't break anything

#

I can't count how many times tests saved me

#

as well as type enforcement

hazy turret
# echo wraith honestly it ain't

If I also pass self as a mock, I can run the test.
Is that the right way?

@pytest.mark.asyncio
async def test_testfunc(cog):
    # Mock the context
    self = MagicMock()
    ctx = AsyncMock()
    ctx.send = AsyncMock()

    # Call the command properly
    await cog.testfunc(self, ctx)  # Directly call testfunc with ctx

    # Assert that ctx.send was called once
    ctx.send.assert_called_once()

    # Get the call arguments
    call_args = ctx.send.call_args[1]

    # Assert that an embed was sent
    assert "embed" in call_args

    # Check the embed properties
    embed = call_args["embed"]
    assert isinstance(embed, Embed)
    assert embed.title == "Test"
    assert embed.description == "Test"
    assert embed.color.value == BOTCOLOR```
echo wraith
hazy turret
echo wraith
#

wait no

#

it has been abandoned unfortunately

sage tendon
#

because it's unnecessary

echo wraith
sage tendon
#

No.
Bots are so simple compared to big programs that unit testing automatically is more work than just testing stuff once manually, unless you reach sizes like dyno

errant trout
#

Then to use them, just hit the copy markdown button

chrome plover
#

so I use pfps in some of my commands, when the user has recently changed a pfp I'm getting this error

An error occurred:
Traceback (most recent call last):
  File "/root/Project Valor/bot_files/cogs/Dueling.py", line 14761, in enter_depth
    data1 = BytesIO(await ctx.author.display_avatar.with_format("png").read())
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/Project Valor/venv/lib/python3.11/site-packages/discord/asset.py", line 76, in read
    return await self._state.http.get_from_cdn(self.url)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/Project Valor/venv/lib/python3.11/site-packages/discord/http.py", line 397, in get_from_cdn
    raise NotFound(resp, "asset not found")
discord.errors.NotFound: 404 Not Found (error code: 0): asset not found

before I used to just use ctx.author.display_avatar but I read that if I added .with_format it might fix the issue. Its a weird thing it doesn't happen always but sometimes many users report it at the same time otherwise its never an issue

chrome plover
#

no I don't

#

just use default intents

errant trout
#

that's why; if a member updates their avatar, the bot can't detect it

chrome plover
#

hmm

#

I see

errant trout
#

to get around this, you can just fetch the member/user

#

(because fetching doesn't require intents)

chrome plover
#

instead of ctx.author

sage tendon
errant trout
#

probably

#

but in case they can't for some reason, they have to fetch

#

ideally if you can, just enable all intents lol

chrome plover
#

I'll need approval from discord

errant trout
#

then fetch instead

chrome plover
#

ok

errant trout
#

guild.fetch_member will have both their server-specific display_avatar and global avatar

deft kestrel
#

how to put a tag in thread? (forum)

errant trout
deft kestrel
errant trout
#

use forumchannel.get_tag with its id, then use thread.edit and pass applied_tags as a list

#

should probably make it more convenient in future versions

flat wind
#

Hello, is it possible for a bot to check if a message content is triggered by automod rules before sending the message ?
I own a translation bot, and in a server, some users are using it to send racial slurs using the slash command to translate. The bots seems to be bypassing the automod rules so I am searching if there is any way I can check all automod rules of the server, and if I get a match with my message and the automod rule, then I don't send the message.

rugged lodgeBOT
echo wraith
#

maybe

deft kestrel
echo wraith
#

no forget that nvm

deft kestrel
#

thread.close?

errant trout
#

Use thread.edit

#

Just check docs for the args

rugged lodgeBOT
echo wraith
#

mb thread

#

but yea

#

use edit

flat wind
# echo wraith maybe

I don't see any coroutine or event that I can call to check the message content I am going to send before sending it. Even after my message is sent

echo wraith
flat wind
sage tendon
#

It's not an easy thing to do that's for sure

echo wraith
#

yeah

sage tendon
#

you'd have to manually recreate all the blocked words and regexes

#

honestly just punish the users that abuse the bots being able to bypass automod
much simpler

flat wind
sage tendon
#

The only thing discord doesn't support in regex for all I know is lookback and lookahead

#

else you can do anything

flat wind
#

okay, so I just have to use the re module to check each regex. How do I see the content and the type of each automod rule ?

sage tendon
#

if you really wanna go into that rabbit hole, check the Guild class for the automodrules getter, idk what it's called exactly

errant trout
#

you can fetch the rules yes

flat wind
sage tendon
#

good luck

flat wind
#

after brainfuck language for sure

sage tendon
#

at least you don't have to create any new rules

errant trout
#

Guild.fetch_auto_moderation_rules returns a list of AutoModRule
AutoModRule has an attribute trigger_metadata, which has further attributes keyword_filter and regex_patterns

#

just read up on everything carefully and it should be easy to manage

flat wind
opal swan
#

PartialEmoji represent discord base emojis or no ?

sage tendon
#

oh, i know

#

it's probably the built in filters

flat wind
sage tendon
#

e.g. "commonly flagged words"

#

all these are built in and will most likely cause the ...
Also yet another discord bug, the icons are fucking tiny..

proven valley
#

is there a way to make it so that when I send multiple of the same view I can have distinct IDs to each one? or when the call back happens I can send a value back to where the view was called?

sage tendon
#

there's View.wait() that lets you wait for an action to be taken in a view
but you can just handle whatever you need in the view's callback

proven valley
#

I need it so that the views can be related to each other, so that if someone clicks on a button it will put something in a list and use it later.

#

I don't know how to do that with just the callback

echo wraith
#

that will be unique

#

store it in a database or something

flat wind
sage tendon
#

no

flat wind
#

okay fine !!

opal swan
#
@bot.command()
async def getusers(ctx, *, member : str):
    members = member.split(",")
    
    for membe in members:
        membe = int(membe)
        membre = await bot.fetch_user(membe)
        await membre.send("Test by koryai sry...")
    
opal swan
sage tendon
#

but why are you getting members as str

#

use discord.Member as the option, only then do you get actual member objects

opal swan
#

bcs I need to do a list

#

and iterate it

sage tendon
#

yea ok but change it to discord.Member lol

flat wind
# sage tendon if you really wanna go into that rabbit hole, check the Guild class for the auto...

Here it is. not that difficult

        for rule in automod_rules:
            if (type(rule.trigger_metadata.keyword_filter) == list) and (any(AutoModActionType.block_message == action.type for action in rule.actions)) and (not ban_word) :
                for keyword in rule.trigger_metadata.keyword_filter :
                    if fnmatch(Traduction.text, keyword) :
                        ban_word = True
                        
            if (type(rule.trigger_metadata.regex_patterns) == list) and (not ban_word) :
                for keyword in rule.trigger_metadata.regex_patterns :
                    pattern = flpc.compile(keyword)
                    if flpc.fmatch(pattern, Traduction.text) :
                        ban_word = True

            if (type(rule.trigger_metadata.allow_list) == list) and (ban_word) :
                for keyword in rule.trigger_metadata.allow_list :
                    if fnmatch(Traduction.text, keyword) :
                        ban_word = False
                        break
opal swan
#

Retrieves a User based on their ID. You do not have to share any guilds with the user to get this information, however many operations do require that you do.

sage tendon
#

also, if you wanna use it on people you dont share a server with, you cant DM those anyway

opal swan
#

alr

#

tysm for the information

fresh sierra
#

you know that you can pass multiple user attribute

#

like do +getusers @fresh sierra @fresh sierra @fresh sierra @opal swan @opal swan

#

like so

fresh sierra
#

and it will give you the user object for all member

#

no

opal swan
#

but I wanna like do

fresh sierra
#
  • discord.User takes also an id arg
opal swan
#

send a user id (he is not in the guild) and the bot send the msg

fresh sierra
#

like do +getusers 1118670495466934274 1118670495466934274

#

so this would also work

fresh sierra
#

even if there are not inside the guild

#

cos its discord.User

#

users are not related to guild

opal swan
#

idk

sage tendon
#

Luma

#

they cant DM them

fresh sierra
#

and ?

sage tendon
#

you're just repeating what i said while missing the point

fresh sierra
#

ooo its to dm them

#

but anyways

#

my thing is more to make him learn something

sage tendon
#

i already said what you said

fresh sierra
#

*, member : str): -> can be edit to discord.User and using something else it will try to catch all user that u passed inside

fresh sierra
sage tendon
#

which is what i already said, just with discord.Member, which is better if they wanna use it on someone already in the guild

opal swan
opal swan
#

bcs discord.User is based on ctx.guild

sage tendon
#

no

fresh sierra
#

where did u talk about it

sage tendon
#

it isnt

fresh sierra
#

ctx, users: commands.Greedy[discord.User]

sage tendon
fresh sierra
sage tendon
#

you literally are

fresh sierra
#

cos that will only work for 1 user

fresh sierra
opal swan
#

don't worry guys it was just a test

fresh sierra
opal swan
#

a command test

fresh sierra
#

its more to make u learn a new thing

#

not related directly to that command

#
@bot.command()
async def slap(ctx, members: commands.Greedy[discord.Member], *, reason='no reason'):
    slapped = ", ".join(x.name for x in members)
    await ctx.send(f'{slapped} just got slapped for {reason}')
opal swan
fresh sierra
#

this make that u can do
+slap @fresh sierra @opal swan reason

#

and it will find all member, so you dont need to fetch them

#

and u dont need to do one member per one member

opal swan
fresh sierra
#

mb then

fresh sierra
fresh sierra
opal swan
#

how work parameter "size" about discord.Asset.with_size

sage tendon
#

it's just the size in pixels

opal swan
#

oh

#

nice

#

await member.banner.read().with_size(size=40)

#

is it work ?

fresh sierra
#

try it and see

opal swan
#

ok let's go

#

it's done

fresh sierra
#

but dont really understand what is the issue here

opal swan
#

with_size don't work

#

and i'm stupid

#

I write .read

#

and I don't need it

fresh sierra
#

with size should work

#

im using it

opal swan
#

alr

opal swan
#

idk why but it doesn't work ofc

#

always me

#

....

fresh sierra
#

im using it like so :

png_avatar_url = user.display_avatar.with_format("png").with_size(2048).url
opal swan
#

....

#

wth I doing :
member.banner.with_size(40)

sage tendon
#

40 is extremely small

#

do 256 at least

fresh sierra
#

try adding .url at the end maybe

opal swan
#

256 ok nice

sage tendon
#

4096 for max quality

opal swan
#

16 minimum

proven valley
proven valley
#

Within the callback function to pass something to where the view is called, 4 views sent out to 4 pepe at once they all have to agree and I want to track who agreed and who didn't

fresh sierra
#

and then u choose to accept and not

#

if u want to track based on user

stoic patio
#

which event gets fired when TextChannel.delete_messages() is called?

errant trout
#

if multiple messages are deleted at once, on_bulk_message_delete

proven valley
proven valley
#

okay, thank you

proven valley
#

also would there be a way to make it so that if one user clicks cancel it will cancel the whole interaction, because right now what I'm encountering is there will be 3 view.waits() and it will have to wait for all of them to proceed to further logic

errant trout
#

that ultimately depends on how you implement it

#

e.g. store all references to the views in a list, then loop through and stop them all if someone cancels

real glacier
#

how do i prevent random choice keeps given the same output unless i restart the bot but still given the same thing again and again

shell radish
#

you're probably doing the random wrong, then

#

could you share your code?

real glacier
#
    item = ["item1", "item2" "item3", "item4", "item5", "item6", "item7"]
    random.seed[7]
    itn = random.choices(item, k=10)
    return itn[0]```
shell radish
#

i mean, you literally set a random seed

real glacier
#

i just try every possible way, still happens even without seed

shell radish
#

i don't understand random.choices

#

why not random.choice

#

you just want to return a random item in the array item right?

real glacier
#

mhm!

shell radish
#
def getitemname():
    item = ["item1", "item2" "item3", "item4", "item5", "item6", "item7"]
    itn = random.choice(item)
    return itn

should do what you want

real glacier
shell radish
#

where/how is the function being called

real glacier
#

inside class

shell radish
#

i'm also assuming that there's actually a comma between "item2" and "item3" right? and the code you shared was simply a typo?

real glacier
#

yes

shell radish
real glacier
#

one sec

#
    r1 = Rarity()
    rr = r1.rr1 #result each rarity pull from class #1
    ricon = r1.rrc1 # pulling rarity icon emoji from class #1 shortcut(ricon = rarityicon)
    with open(f"cards/{getitemname()}.json") as jf:
        data = json.load(jf)
        lower_name = getitemname()
        jc_name = data["NAME"]
        jc_quote = data["QUOTE"]
        jc_game = data["GAME"]
        jc_element = data["ELEMENT"]
        jc_thumbnail = data["THUMBNAIL"]
        jc_title = data["TYPE"][0]["STANDARDS"][0][f"RARITY{rr}"]["TITLE"]
        jc_tier = data["TYPE"][0]["STANDARDS"][0][f"RARITY{rr}"]["TIER"]
        jc_credit = data["TYPE"][0]["STANDARDS"][0][f"RARITY{rr}"]["CREDIT"]
        jc_era = data["TYPE"][0]["STANDARDS"][0][f"RARITY{rr}"]["ERA"]
        jc_card = data["TYPE"][0]["STANDARDS"][0][f"RARITY{rr}"]["CARD"]```
#

getitemname()

shell radish
#

did you set the seed anywhere

real glacier
#

nope

shell radish
#

should the file name and lower_name be the same?

real glacier
#

yes

shell radish
#

what do you actually have as getitemname()

real glacier
#

but somehow it keeps 'item6' every cmd i execute

shell radish
#

Is your computer's clock frozen somehow?

real glacier
#

no, why

shell radish
#

well, python uses system time to calculate random numbers

real glacier
#

wdym

shell radish
#

how is it actually defined

real glacier
#

like the output?

#

it defined as string

#

a = getitemname() print(a) will return string from array

shell radish
#

you don't have random.seed anywhere in your code?

real glacier
#

yes i confirm

shell radish
real glacier
#

alr ToT

deft kestrel
#

How to create a command that can be used only in guilds and not in private chat

opal swan
opal swan
#

:

#
@bot.command()
@commands.guild_only()
async def ...(ctx): 
  ...
deft kestrel
opal swan
opal swan
#

just add @commands.guild_only()

mellow pebble
#

how to use bridge commands in cogs ?

opal swan
mellow pebble
#

i got it thanks

#

and waht about the groups

#

is it possible to create one for bidge ?

deft kestrel
mellow pebble
#

got that too thanks

opal swan
#

I never rlly use slash_command

opal swan
#

I forgot how to do this command so don't trashtalk me pls 😭

@bot.command()
async def bingo(ctx, channel : discord.TextChannel):
    numero = random.randint(1, 100)
    
    await ctx.reply(f"Bingo commencé : \n**Numero**\n{numero}")
    
    
    def check(m):
        return m.channel == channel and msg.content.isdigit()
        
    while True:
        try:
            msg = await bot.wait_for('message', check=check, timeout=800)  
        except:
            return
             
        
        if msg:
            if int(msg.content) == numero:
                await msg.reply("> Bravo, Tu as trouvé !")                
                return
#

0 traceback

#

it's weird

errant trout
#

Your try-except probably eats it

#

Or you don't have message content intent

opal swan
#

🤔

#

@errant trout yoooo

opal swan
errant trout
#

Oh

#

Just change the isdigit line to m.content

opal swan
#

alr

#

ty

opal swan
lofty parcel
sacred gale
#

i need help

await message.edit(embed=embed2)```this is returning an error:
#

discord.app_commands.errors.CommandInvokeError: Command 'ping' raised an exception: AttributeError: 'NoneType' object has no attribute 'edit'

opal swan
sacred gale
#

discord.app_commands.errors.CommandInvokeError: Command 'ping' raised an exception: AttributeError: 'Interaction' object has no attribute 'send'

#

but they are similar

opal swan
sacred gale
#

here is the full command ``` @app_commands.command(name="ping", description="test")
async def ping(self, ctx):

    file = discord.File("./bot_dc/assets/loading.gif", filename="loading.gif")
    waitForConfirmationsEmbed = discord.Embed(title="Waiting for confirmations", description=f"Waiting for confirmations with `a` This may take a while.")
    waitForConfirmationsEmbed.set_thumbnail(url="attachment://loading.gif")

    waitForConfirmationsMessage = await ctx.send(file=file, embed=waitForConfirmationsEmbed)
    await waitForConfirmationsMessage.edit(embed=embed1)```
little cobalt
opal swan
#

message = await ctx.channel.send

little cobalt
#

app_commands are not from py-cord

opal swan
#

imo

sacred gale
#

ok

#

1 sec

opal swan
sacred gale
#

it worked, thanks guys

opal swan
summer knot
#

I want to put the "unmute all:" field next to "mute all:" but I have tried changing the inlines of the fields without success, basically I want the fields below to be shown like the second image, or is it impossible to do it that way?

summer knot
summer knot
opal swan
summer knot
opal swan
#

and last field did u do inline = False

#

?

summer knot
#

and it still shows like the picture

#

just in case I restart the bot

opal swan
#

docs said nothing about it....

summer knot
summer knot
opal swan
little cobalt
little cobalt
#

I actually like it how it is currently

#

you should let it like that

#

and at the mobile version its gonna be whole different soooo xd

summer knot
summer knot
little cobalt
#

you really should let it like that

opal swan
#

imo it's bcs u have a lot of character for disable inline

opal swan
summer knot
#

and seeing it from this my tablet is right

opal swan
#

alr good

#

👍

summer knot
#

I'll have to leave it like this

opal swan
summer knot
#

but at least the staff liked it

opal swan
#

nah I'm not meaning that

little cobalt
opal swan
#

ur words in ``

summer knot
#
+ hi
- hi
opal swan
#

nice

#

tt

#

ty

#

for the information

summer knot
#

well on mobile devices in general

opal swan
#

I know bcs i'm on mobile here

#

And I didn't see the comor

#

color

little cobalt
#

you mean that right?

opal swan
summer knot
summer knot
opal swan
#

ty

summer knot
proven valley
lofty parcel
lofty parcel
little cobalt
#

k

real glacier
#

how to edit message using button?

little cobalt
opal swan
little cobalt
#

The interaction message, a message from a text channel?

opal swan
#

await interaction.message.edit("test")

little cobalt
real glacier
little cobalt
opal swan
#

idk if we say that in english

little cobalt
#

For edit you have to add content=

opal swan
opal swan
little cobalt
#

If its a str

opal swan
#

bcs me I edited message embed with my command embed

#

and it's like 1 month I don't use edit in interaction type button

real glacier
#

ok thank u both of u

opal swan
#

👍

opal swan
real glacier
#

alrr

real glacier
sage tendon
opal swan
#

urembed = discord.Embed ofc

proven valley
#

is there a way to make it so that paramters of app command are optional, and if you can make it so only people with certain perms can view certain options?

sage tendon
#

optional yes, locked to permissions no

lofty parcel
#

You could technically use autocomplete to return options based on the user... but idk

sage tendon
#

mehhh quite hacky

proven valley
#

should I use the decerator for the options or the .options type hinting?

#

is there any benefit to one over the other?

sage tendon
#

decorator is much cleaner

#

and the typehint way is kinda hacky really

proven valley
#

alright, thank you.

errant trout
#

ultimately it's personal preference GuraSquintSmol

sage tendon
#

in user-code its much cleaner

proven valley
#

anyone knoe why my options with discord.Member are not working but my options with int is working? is there something specific I got to do?

sage tendon
#

define "not working"

proven valley
#

the description set for the int is working, while the description and required option are not working correctly for the ones where I have discord.Member I don't know if that has anything to do with it or if something is wrong with my code.

#

this is the code

errant trout
#

eh

#

longshot, but remove the types from your decorator

#

otherwise that code looks more or less fine? what does the command look like on your UI

sage tendon
#

restart your discord @proven valley

proven valley
sage tendon
#

always gotta do it when you touch command metadata

proven valley
#

Must be a skill issue

opal swan
#

video upload on discord is it discord.File

#

?

sage tendon
#

yes

opal swan
sage tendon
#

of?

opal swan
#

and how we can get discord.AudioSource

lyric idol
#

.. Coding in js rather than pycord, but question is relevant enough. For some reason I'm receiving blank messages, I'm assuming this has something to do with my intents? Does anyone know if I'm missing any?

When printing the context it's just " "

shell radish
#

you’re missing the MessageContent intent

lyric idol
#

That doesn't come with GuildMessages?

#

Thanks

opal swan
#

ye I remember now for js guys u need to go on intents generator or smthing like that

lyric idol
#

No because the less intents the less usage of memory and cpu and network

#

Enabling all intents when you don't need them is just silly

opal swan
proven valley
#

Can pages work dynamically, like based on the data it has to display or something?

loud kayak
#

pages require content to show

#

whether thats an embed, or message content

proven valley
#

displaying match history, some users might have more or less matches played than others

loud kayak
#

then whats the issue?

proven valley
#

I was asking if pages will adjust how many pages will be displayed based on data available

lofty parcel
#

You're the one supposed to handle that.

#

If you have an array of data, then iterate over it and create a page for each one (assuming each item is a piece of data for the user)

proven valley
#

okay, thanks

real glacier
#

i tested out this code https://docs.pycord.dev/en/stable/ext/pages/index.html but it returns this error```py
Extension 'cogs.page' raised an error: AttributeError: 'Bot' object has no attribute 'remove_command'
AttributeError: 'Bot' object has no attribute 'add_command'

real glacier
errant trout
#

...yes?

#

what's your full error

real glacier
#
Exception has occurred: ExtensionFailed
Extension 'cogs.page' raised an error: AttributeError: 'Bot' object has no attribute 'remove_command'
AttributeError: 'Bot' object has no attribute 'add_command'

During handling of the above exception, another exception occurred:

  File "/Users/macbookprom1/PomPom/cogs/page.py", line 265, in setup
    bot.add_cog(PageTest(bot))
AttributeError: 'Bot' object has no attribute 'remove_command'

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

  File "/Users/macbookprom1/PomPom/main.py", line 20, in <module>
    Pompoki.load_extension(cog)
discord.errors.ExtensionFailed: Extension 'cogs.page' raised an error: AttributeError: 'Bot' object has no attribute 'remove_command'```
errant trout
#

ok, what Bot class are you using in your main file

real glacier
#

Pompoki

errant trout
#

and what Bot class does it inherit

real glacier
#
import discord
import os
from discord.ext import commands
from dotenv import load_dotenv
load_dotenv()
Pompoki = discord.Bot()

@Pompoki.event
async def on_ready():
    print(f"{Pompoki.user} is ready and online ^^!")

int_ext = []

for file in os.listdir('./cogs'):
    if file.endswith('.py'):
        int_ext.append("cogs." + file[:-3])

if __name__ == '__main__':
    for cog in int_ext:
        Pompoki.load_extension(cog)

Pompoki.run(os.getenv('TOKEN'))```
errant trout
#

use commands.Bot, not discord.Bot

#

.tag client

sly karmaBOT
#
discord.Client # just for events
discord.Bot # events + slash/user/msg commands
commands.Bot # above + prefixed commands
bridge.Bot # above + bridge commands (application commands and text commands in one)