#Basic Pycord Help

1 messages · Page 49 of 1

deft kestrel
#

alr thx guys

lofty parcel
#

He's Steve jobs bud, he's got money

deft kestrel
#

wait does this still crash everything if something dies on runtime?

#

cuz like

#

loading it i already have handling foe

#

for

#

but this died during its running

sage tendon
lofty parcel
#

I've honestly never had my bot stop for a runtime error

deft kestrel
#

.

#

i fixed it by specifing

#

but literally 0 commits have been made

sage tendon
deft kestrel
#

discord api bug or whatever toothy said

#

idk how a param causes a runtime crash in the first place

#

because it should only take it in once

#

i think

sage tendon
#

thats why i said reconnect

stoic patio
sage tendon
#

that is great, but its expensive as shit

#

and aws is no different from any other VPS

stoic patio
#

also my bot's website is hosted on aws

#
  • some other complicated shit that even i don't really understand lol
echo wraith
errant trout
#

If you're only at 7k members then you should absolutely not be running into any cache issues

sage tendon
#

They have 1GB RAM

#

and they say their EC2 crashes out weekly

errant trout
#

That's very silly, my bots with 40k members use under 400mb

sage tendon
#

my 400 member server bot uses like 400mb too eyebrow

errant trout
#

I also remember running my first two bots on the student trial windows ec2 instance for a year, if you've somehow capped that out then you're doing too much

short rivet
#

maybe they are caching alot of things like prefixes for each guild and all

sage tendon
#

no

zealous tiger
#

elif member.guild_permissions.ban_members:
^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'User' object has no attribute 'guild_permissions'

in doc I can see there are guild_permissions for user object ??

sage tendon
#

there arent

#

ever

zealous tiger
#

what should I do?

sage tendon
#

get their member object

zealous tiger
#

member: discord.Member

#

like this?

sage tendon
#

i mean, show your code first of all

zealous tiger
#
class Bankick(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

    @discord.slash_command(guild_ids=GUILDS, name="ban", description="Bans a member")
    @commands.has_permissions(ban_members=True)
    @option("member", discord.Member, required=True)
    @option("reason", str, required=False)
    @discord.default_permissions(ban_members=True)
    async def ban(
        self,
        ctx,
        member: discord.Member,
        reason: str | None,
    ):
        if member.id == ctx.author.id:
            await ctx.respond("You can't ban yourself!")
        elif member.guild_permissions.administrator:
            await ctx.respond("You can't ban an admin")
        else:
            if not reason:
                reason = f"None provided by {ctx.author}"
            await member.ban(reason=reason)
            await ctx.respond(
                f"<@{ctx.author.id}>, <@{member.id}> has been banned successfully from this server!\n\nReason: {reason}"
            )
#

@sage tendon

sage tendon
#

yea

#

if you do discord.User itll be converted to a User object which lacks any guild specific stuff

zealous tiger
#

Like this? or changing all members to discord.user

sage tendon
#

what

#

that line makes no sense lol

#

i mean if you typehint it as discord.User

zealous tiger
#

I didnt understand what you mean

#

which part I'm gonna change

sage tendon
#

none
your code is good as is

sage tendon
#

yea because you are putting the ID of someone in who isnt in the server anymore

#

dont do that, or make your code able to handle that

zealous tiger
sage tendon
#

check if its a user object

#

also uh, your bot role shouldnt be so high as to be able to kick admins

zealous tiger
zealous tiger
lofty parcel
#

No

#

That comparation makes no sense at all.

sage tendon
sage tendon
grizzled loom
hoary cradle
#

trying to reset the cooldown of a command inside of my slash command in a cog but i just get none type has no attribute reset, i've tried both

command_name.reset_cooldown(ctx)
self.command_name.reset_cooldown(ctx)

do i need to get the command first and then use it? if so i also get none type

grizzled loom
hoary cradle
#

i have a command that's moving players from one team to another and also updating their database. if a user is being added to a team as a free agent i have a check for that and want it so people can add a country code in that case and not wait the standard cooldown

little cobalt
hoary cradle
#
def custom_cooldown(ctx):
    if any(role.id in ALLOWED_ROLES for role in ctx.author.roles):
        return None
    else:
        return discord.ext.commands.Cooldown(rate = 1, per = 3600)

this is my current implementation for a custom cooldown i already have, certain roles have no cooldown otherwise its just 1h

deft kestrel
#

can i upload a gif in bot pfp?

little cobalt
deft kestrel
#

HTTP Error 415

little cobalt
#

415?

errant trout
deft kestrel
errant trout
#

then blame discord

red mist
#

LMAO

errant trout
flint talon
#

discord has no attribute bot

shell radish
#

bot or Bot

flint talon
#

Bot

shell radish
#

you probably have conflicting discord libraries. Did you make sure to first uninstall all packages using the discord namespace, then installing the pycord library?

flint talon
#

We’re fine without using flash commands. As soon as I want to use them, it becomes a problem. I don’t know if it’s a pie cord thing.

#

Sorry I’m on mobile

shell radish
#

pip list and send output?

oblique sable
#

hey guys

#

can i give a list of options for voice?

sage tendon
#

yea

#
@discord.option("voice", str, choices=[...])
oblique sable
#

thx

#

awesome!

keen relic
#

i want to list ban member

sage tendon
#

speak sentence, get help

keen relic
#

I'm planning to add a command to our Discord bot that lists all banned members. Are there any specific requirements or guidelines I should follow for this implementation?

sage tendon
#

like, what

keen relic
#

add a command to our Discord bot that lists all banned members?

sage tendon
#

"any specific requirements or guidelines I should follow for this implementation"
i have no idea what this is supposed to mean tho

#

what do you mean with guidelines

#

https://docs.pycord.dev/en/stable/ here are the docs if you mean those

keen relic
sage tendon
#

use the search

keen relic
lethal loom
#

Is there such a thing for errors that occur when I press buttons etc.?

async def on_application_command_error(ctx: discord.ApplicationContext, error: discord.DiscordException):
    if isinstance(error, commands.CommandOnCooldown):
        await ctx.respond("This command is currently on cooldown!")
    else:
        raise error  # Here we raise other errors to ensure they aren't ignored```
flint talon
#

guys

#

when I try ctx.respond using a slash command

#

and try to send my discord embed

#

it just sends <discord.embed at yadayadayda>

#

any ideas?

lofty parcel
#

You're not using the embed kwarg

flint talon
#

wdym

flint talon
lofty parcel
lofty parcel
flint talon
#

ohh i see

#

thanks for catching that

#

brain fart

#

-_-

flint talon
#

one more thing

#

how can I detect if a user is spamming messages

#

or spam editing channels

#

or spam handing out perms

#

u get the idea

sage tendon
#

thats an issue you have to solve yourself really

#

need to record all those actions and decide how much is too much

#

or use an established anti spam and anti nuke bot

flint talon
#

nah I wanna have my own

fresh sierra
sage tendon
#

and Dark already told them that

fresh sierra
#

this also exist but it’s not for all view you will need to setup for each

sage tendon
#

there's no need to reopen that issue

fresh sierra
#

i did not talk about the same thing

sage tendon
fresh sierra
#

you that’s the thing

#

the on error exist also so i can if i want tell him about that

lofty parcel
sage tendon
#

how nice of you

#

and thanks if that wasnt entirely sarcastic :>

lofty parcel
#

little bit of this, little bit of that

shell radish
sage tendon
#

sssh

ebon swift
#

is it possible to make group commands from slash commands ?

fresh sierra
#

group cant be command also with slash

ebon swift
#

okay so to imitate this behavior I should probably have a choices as second argument thank you

flint talon
#

how to create automod rule

sage tendon
sage tendon
#

took me ~5s

#

knowing where to look helps ;3

flint talon
#

🙃

#

I searched automod and that didnt come

#

😭

sage tendon
#

i mean

#

automod rules belong to a guild

#

so go to the guild class

flint talon
#

i've had enough of not getting my searches

little cobalt
flint talon
#

newrule = await ctx.guild.create_auto_moderation_rule(
name = "Spam setup",
event_type = discord.AutoModEventType.message_send,
trigger_type = discord.AutoModTriggerType.spam,
trigger_metadata = discord.AutoModTriggerType.spam,
actions = discord.AutoModActionType.block_message,
enabled = True,
exempt_roles = None,
exempt_channels = None,
reason = f"Rule creation ordered by {ctx.author}",

)
#

this returns this error:

#
File "c:\Users\[redacted]\Desktop\vscodeprojects\[redacted]\main.py", line 67, in spamsetup
    newrule = await ctx.guild.create_auto_moderation_rule(

AttributeError: '_EnumValue_AutoModTriggerType' object has no attribute 'to_dict'
edgy nest
flint talon
edgy nest
#

you need a comma at the end of it because it's a parameter list

#

_total_limit = 5),

flint talon
#

oh shoot

#

-_-

flint talon
# edgy nest `_total_limit = 5),`
newrule = await ctx.guild.create_auto_moderation_rule( <--- this line right here
        name = "Spam setup",
        event_type = discord.AutoModEventType.message_send,
        trigger_type = discord.AutoModTriggerType.spam,
        trigger_metadata = discord.AutoModTriggerMetadata(mention_total_limit = 5),
        actions = discord.AutoModActionType.block_message,
        enabled = True,
        exempt_roles = None,
        exempt_channels = None,
        reason = f"Rule creation ordered by {ctx.author}",

    )

Returns this error:

Traceback:
File "c:\Users\[redacted]\Desktop\vscodeprojects\raidbot\main.py", line 67, in spamsetup
    newrule = await ctx.guild.create_auto_moderation_rule(
AttributeError:
'str' object has no attribute 'to_dict'
-I have no clue what's going on
-It's been happening for a while
lapis dock
#

Is that the full traceback?

flint talon
#

thats where the error is and what it is

lapis dock
#

yes please :)
full traceback is needed for this issue

flint talon
#

😄 will do

#

here u go:

Traceback (most recent call last):
  File "C:\Python312\Lib\site-packages\discord\bot.py", line 1137, in invoke_application_command
    await ctx.command.invoke(ctx)
  File "C:\Python312\Lib\site-packages\discord\commands\core.py", line 435, in invoke
    await injected(ctx)
  File "C:\Python312\Lib\site-packages\discord\commands\core.py", line 146, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'str' object has no attribute 'to_dict'
+Full traceback
little cobalt
sage tendon
#

actions have to be a list

lapis dock
sage tendon
#

your action is a single action but the docs require it to be a list of actions

lapis dock
#

try what toothy said first tho

#

I might be wrong

sage tendon
#

show your code and the traceback

flint talon
sage tendon
#

also, why do you explicitly pass "None"? just leave those options away

flint talon
#
newrule = await ctx.guild.create_auto_moderation_rule(
        name = "Spam setup",
        event_type = discord.AutoModEventType.message_send,
        trigger_type = discord.AutoModTriggerType.spam,
        trigger_metadata = discord.AutoModTriggerMetadata(mention_total_limit = 5),
        actions = [discord.AutoModActionType.block_message],
        enabled = True,
        exempt_roles = None,
        exempt_channels = None,
        reason = f"Rule creation ordered by {ctx.author}",

    )
#

wait

#
PS C:\Users\[redacted]/Desktop/vscodeprojects\raidbot> & C:/Python312/python.exe c:/Users/NishanPC/Desktop/vscodeprojects/raidbot/main.py
We have logged in as Glum#9657
Ignoring exception in command spamsetup:
Traceback (most recent call last):
  File "C:\Python312\Lib\site-packages\discord\commands\core.py", line 138, in wrapped
    ret = await coro(arg)
          ^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\site-packages\discord\commands\core.py", line 1082, in _invoke
    await self.callback(ctx, **kwargs)
  File "c:\Users\[redacted]\Desktop\vscodeprojects\raidbot\main.py", line 67, in spamsetup
    newrule = await ctx.guild.create_auto_moderation_rule(
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\site-packages\discord\guild.py", line 3925, in create_auto_moderation_rule
    "actions": [a.to_dict() for a in actions],
                ^^^^^^^^^
AttributeError: '_EnumValue_AutoModActionType' object has no attribute 'to_dict'

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

Traceback (most recent call last):
  File "C:\Python312\Lib\site-packages\discord\bot.py", line 1137, in invoke_application_command
    await ctx.command.invoke(ctx)
  File "C:\Python312\Lib\site-packages\discord\commands\core.py", line 435, in invoke
    await injected(ctx)
  File "C:\Python312\Lib\site-packages\discord\commands\core.py", line 146, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: '_EnumValue_AutoModActionType' object has no attribute 'to_dict'
edgy nest
#

you need one of these

flint talon
#

where??

edgy nest
#

instead of an AutoModActionType

sage tendon
flint talon
#
trigger_type = discord.AutoModAction(action_type=discord.AutoModActionType.timeout, metadata=discord.AutoModActionMetadata(channel_id=ctx.channel, timeout_duration=20m, custom_message="Message blocked. Do not spam."))
#

it says that

#

parantheses aren'tclosed

sage tendon
#

no

#

read the docs.

#

automodaction goes into the action kwarg

#

should be obvious from the name

flint talon
lofty parcel
#

Bud

sage tendon
#

read this. pass what belongs.

lofty parcel
#

You're providing to trigger_type a AutoModAction

#

When trigger_type takes a AutoModTriggerType

#

And actions is the one that receives a list of AutoModActions

dense summit
#

Hey there, is it possible with paginator to use dropdowns menu or do i need to make it from scratch?

lapis dock
#

can you eleborate on what you want to do

dense summit
#

I would like to make an help command where by a dropdown menu you can select for which category of commands you want to see the information for, and everytime you select the category from the dropdown menu the embed updates.

#

I was asking if paginator supports dropdown menus and if so how do i use them with paginator

lapis dock
#

Yes you can

#

When you make a page group with the paginator it will create a select menu for switching between groups

dense summit
#

Alright thank you very much!

flint talon
lapis dock
#

can you show the code again

flint talon
sage tendon
#

you arent listening

lapis dock
#

You are still passing the wrong type to actions

flint talon
sage tendon
#

you aren't passing AutoModAction

#

pass AutoModAction

#

look at the docs

lapis dock
#

And actions is the one that receives a list of AutoModActions

flint talon
#

I'm confused

#

do I need more than one action?

sage tendon
#

you are passing the wrong thing in the list

flint talon
#

then

safe quarry
#

Is it possible to make a discord bot that can;
For example,
A webhook is named Xavier but it says "Govern.co" as it's username.

It takes that Govern.co webhook user, switches it to "Anonymous" as it's username, with the same message, or altered message that sends the user to a website by saying "Go Now!"

lofty parcel
#

Webhook.send takes a username (or user) kwarg

#

.rtfm webhook.send

sly karmaBOT
noble flax
#

I think I already know the answer to this - but with slash commands/autocomplete I have my autocomplete that retrieves the names from the sqlite3 db and then those names are used in the autocomplete. However when I obviously hit enter at present I pass the "string" i.e. the name and have to make another call to the db to retrieve the additional details - I assume I can't pass the "object" i.e. list of dict from the autocomplete to the command for example?

lapis dock
#

No, but you can cache the name dict pair from the first call. {name: dict} Than in the command reference that cache instead of making a second API call.

sage tendon
#

make sure to cache it based on the user and clear it every few minutes

keen relic
sage tendon
#

just use the docs search

keen relic
#

@sage tendonBro App Emoji Api Is not add??

sage tendon
#

No

keen relic
sage tendon
#

next release

keen relic
#

any beta

sage tendon
#

master has it I think

keen relic
carmine jackal
#

how do external apps work?

sage tendon
#

they're called user apps

#

not much different from a normal bot

carmine jackal
#

do they work in any server

sage tendon
#

yes, thats the point

carmine jackal
#

where can i find the docs for it

sage tendon
#

it's already all documented

#

in the normal docs

carmine jackal
#

the github one right

#

or the website

sage tendon
#
carmine jackal
#

thank you

flint talon
#

how can I check if someone is spam handing out admin

#

or spam banning people?

sage tendon
#

i already told you

flint talon
#

no...?

sage tendon
#

yes

flint talon
#

when

sage tendon
#

#1132206148309749830 message

flint talon
#

ok so what I mean is

#

how can I record and in essence create my own audit log

#

that the bot can see

#

then I can use datetime to observe how closely the actions are taking place

sage tendon
#

i mean, thats what you have to figure out really
use a database, handle it all in memory, everything's possible

flint talon
#

basically any ban, kick actions are recorded precisely with details and precise time

#

but my problem now is

#

I don't know how to listen to when a ban happens, and determine if the last ban was within x time to take action

#

and ik about bot.add_listener

errant trout
#

it has everything you want

lofty parcel
dense summit
#

hey there, is it possible to suggest slash command so the person click it and it appears in his message?

rugged lodgeBOT
shell radish
#

or ctx.command.mention

dense summit
#

thanks

#

can i also suggest options?

echo wraith
dense summit
echo wraith
echo wraith
echo wraith
dense summit
#

the command is /image collage and the option is layout

#

and i want that the user can click on a message that fills the layout option

shell radish
#

no, discord removed that because of potential for abuse

dense summit
#

Anyway how do i get the SlashCommand class?

shell radish
#

ctx.command will return a SlashCommand object if used by a slash command

dense summit
shell radish
#

it cannot be mentioned

#

you can also use </name:command id> to do it manually

dense summit
#

yeah that's better, although how can i get the id?

dense summit
#

oh thanks i didnt know about this

echo wraith
dense summit
echo wraith
shell radish
#

sub-commands would be like </math add:123>

dense summit
dense summit
#

no need to change the id this way

dense summit
echo wraith
rugged lodgeBOT
dense summit
#

It doesn't mention it for some reason

echo wraith
dense summit
#

Hai ragione mi ero scordato che ora era una menzione e quindi non mi serviva più segnarlo con i ``

dense summit
dense summit
lofty parcel
echo wraith
#

And I spent basically the first 13 years of my life going to school in italian

stoic patio
#

is it normal for discord bots being used by several thousand ppl to experience memory fragmentation

dense summit
stoic patio
#

nowhere near the point of having to consider sharding

echo wraith
stoic patio
#

but a few of the servers have a huge amount of users

echo wraith
#

But why is memory fragmentation a big deal anyways?

#

Like it's the point of ram to fix that

stoic patio
#

i'm running the thing on ec2 free tier

#

and i sometimes find sudden jumps in memory usage

#

that don't go down

#

i asked chatgpt 4o, and it tells me it's most likely memory fragmentation

echo wraith
#

Maybe run some profilers on your python code, or just use a better provider honestly... even though ik that is not a real answer

stoic patio
#

i used objgraph to find which objects grow a lot, and used psutil to tell me my memory usage at different times

#

each one of those "----" things corresponds to a 15 minute interval

#

for the 87.39 to 92.39, there aren't new objects, but there are new objects for the bunch of 92.39's

echo wraith
stoic patio
#

i've used tracemalloc

#

the lines that take the most memory are all the ones used by libraries

echo wraith
echo wraith
stoic patio
#

all

echo wraith
shell radish
#

you just have a big bot. ec2 free tier is just simply unviable

stoic patio
#

113 servers, ~7-8k users is considered big?

shell radish
echo wraith
stoic patio
#

i see

#

gotta convince my parents lmao

#

to get a better server

echo wraith
shell radish
#

if you are a student, microsoft azure is a free solution

echo wraith
#

not gonna mention anything not to make advertisement

stoic patio
#

i'm almost 17

echo wraith
stoic patio
#

not in uni yet, if that's what you mean by "student"

echo wraith
shell radish
shell radish
stoic patio
#

i see

#

the thing is, i don't think my dad's that proficient at azure, and he's the one who made all the configs for my ec2 host

#

and i don't have the time to learn aws well enough to do it all alone

echo wraith
stoic patio
#

yes i mean aws

echo wraith
#

nor you need much config for running a small docker container

#

at this point, I would really look for some small cheap vps, instead of getting locked behind config stuff

shell radish
#

azure should support docker

stoic patio
#

i don't use docker

shell radish
#

and docker is like easy

echo wraith
shell radish
#

shouldn’t take more than 10 min to setup imo

echo wraith
#

yeah

stoic patio
#

also, my bot's website, as well as its db, are both hosted on aws

#

using route 53 (domain) and rds (db)

#

both of which my dad are highly proficient in

echo wraith
#

At this point I don't wanna look mean, but i don't think that using aws for everything is the way. Your dad (probably) uses that because of complex problems he has to face, like scalability, and high availability. Aws and other cloud providers can be helpful, but in the end, end up costing a lot and add unnecessary (in your case) configuration steps, which while probably helpful for the aforementioned usecases, make no sense to have on a discord bot.

stoic patio
#

a lot of the configuration is for like security

shell radish
#

what security

stoic patio
#

like, only letting certain ips connect to the server

#

and db

shell radish
#

the like only security issue is like your host getting ddos’ed and sql injects

echo wraith
stoic patio
#

tbf he uses aws for work

echo wraith
#

But you don't need that

#

Like if you spin up a small docker stack with a db + a custom image + some webserver you can call it a day, and forget ips access, because there isn't any public facing ports for the database

stoic patio
#

i can't just host this thing locally

echo wraith
echo wraith
#

You get a small vps and you can forget it until your bot becomes wwaaay bigger. On the other hand, with big cloud providers, you would start getting instant bills, and be locked behind their thing because they won't allow you to take out your database data without paying even more. Trust me, go away while you can. Big cloud has a lot of advantages, but not really for you right now.

#

It is interesting when it handles a bunch of complicated things for you, and it becomes actually worth paying for it.

stoic patio
#

wdym by "taking out db data"

shell radish
#

if you try to migrate to something else, they will charge based on how many bytes of data you have

stoic patio
#

interesting

dense summit
shell radish
#

I don’t know more than that though

dense summit
#

i dont know, im part of the github student program but yeah it was pure mess tbh

#

i don't have any problem getting other free things like the jetbrains softwares

#

i ended up paying for a ovhcloud vps, 1€/month

shell radish
#

using railway rn and paying 0

little cobalt
#

I just use my own Server and paying for the electric bills...

echo wraith
echo wraith
#

cuz I did the same for a long time

dense summit
dense summit
#

i just access the vps with ssh

echo wraith
#

Yeah I definitely didn't have only a vps there, I had a bunch of other things like domains and webmail, and I just moved everything

dense summit
echo wraith
stoic patio
#

i use ssm for my current ec2

dense summit
echo wraith
little cobalt
#

oh

dense summit
# echo wraith ye

arent the prices in switzerland VERY high? this is what ppl say in italy

little cobalt
#

Grüezi

echo wraith
little cobalt
#

Schweizer Franken

echo wraith
dense summit
#

average salary in italy is probably 1400 ish

little cobalt
echo wraith
#

idk

dense summit
#

yeah per month sorry

echo wraith
#

but at the same time it's an average, so you have like 1% of people bumping that

dense summit
little cobalt
#

I dont know if its right

dense summit
#

10k per month?

echo wraith
#

at all lol

little cobalt
#

some say it 4k?

stoic patio
#

what language is that

little cobalt
stoic patio
#

i see

little cobalt
#

why?

#

;3

echo wraith
#

but Ik the minimum salary, if you work 100% is around 3.5k chf

shell radish
#

@echo wraith i was looking at your website and wondered why wikipedia is a skill then realized it’s wordpress

echo wraith
#

like at some point i was like i will add everything I did at some point

little cobalt
echo wraith
#

But also should just remake that website, cuz I didn't touch it in like 1 year and it's from when I didn't know to program yet

stoic patio
#

are you also in hs

echo wraith
dense summit
#

what is this?

shell radish
#

arduino

stoic patio
echo wraith
echo wraith
#

wanna see something cool?

dense summit
#

sure

#

it sounds italian

shell radish
dense summit
#

it's an italian company?

echo wraith
dense summit
little cobalt
#

I dont know if this is expensive for domains

echo wraith
shell radish
#

#general

little cobalt
#

^^

echo wraith
red mist
#

💀

#

*Billiger

#

Sogar .eu ist billiger

#

Wtfff

#

.org teurer als .com ergibt eig auch wenig sinn

stoic patio
#

how would you host a domain you purchased from aws on something other than aws

echo wraith
stoic patio
#

interesting

hybrid fossil
#

Hi there!
I wanted to know if you found it convenient to do an “import discord” in all the files of the project or if you had done otherwise?

hazy turret
#

Is it possible to buy a bot Nitro so that you can upload and share files up to 500 MB with the bot?

shell radish
#

no

hazy turret
#

Does that mean I can only get up to 100 mb via Server Boost Level 3?

echo wraith
stoic patio
#

pycharm tells me that intent attributes are read only, so would doing smth like that have any effect

stoic patio
#

so they do have effects?

little cobalt
#

but you can ignore stuff like that

stoic patio
#

bruh

#

i'm asking about intents.reactions and intents.polls

stoic patio
#

i see

echo wraith
echo wraith
# stoic patio i see

but you should probably start with intents.default() and then enable or disable what you need

stoic patio
#

in that case i'd have to disable those things + enable messages, presences, and members, which is more lines

dense summit
errant trout
sly karmaBOT
#
f = discord.File("some_file_path", filename="image.png")
e = discord.Embed()
e.set_image(url="attachment://image.png")
await messagable.send(file=f, embed=e)```
dense summit
#

Thank you very much, i got it

errant trout
#

(Also, commands have a mention attribute you can use instead of formatting it yourself)

dense summit
errant trout
#

Well you're already doing it

#

With get_application_command

#

Or get_command i forget which one applies where

dense summit
#

i just replace #.qualified_id with #.mention right?

errant trout
#

Ah get_command works if you're using discord.Bot

#

Pretty much, and remove the other </ parts since it's all included

dense summit
#

yeah thank you

sage tendon
#

youd only ever consider that for passing kwargs

unique quartz
#

Does anyone know how to use the emojis thing in the dev portal?

errant trout
unique quartz
#

API.

errant trout
#

see #1132206148309749830 message, it's currently not merged to master

sage tendon
#

you can still just use the emoji markdown, no?

errant trout
#

well yeah, but they probably mean actual management of the emojis

unique quartz
#

Hm okay.

echo wraith
#

Is there an issue for tracking forwarderd messages support?

errant trout
#

we didn't open the pr yet because it's still widely unsupported and unfinished on discord's end

digital bear
#

Is there a way to test slash commands without waiting for an hour?

sage tendon
#

...why would you need to wait an hour?

digital bear
sage tendon
#

that was never really true

#

restart discord and they'll appear

#

commands sync in seconds

digital bear
#

Okay thanks, i'll try that since I don't like waiting

errant trout
#

it was true when slash rolled out, the answer is just outdated

digital bear
#

Restarting discord client indeed fixed it, thanks

sage tendon
#

i think i tried making slash commands on day 1 but i dont recall ever waiting longer than like 1m max

sage tendon
#

and you dont have to restart if you only change the function content

digital bear
#

Thanks, I didn't know about that

errant trout
#

GuraShrug it was widely tested and actually announced that global commands would take that long to sync, lib devs wouldn't have pushed users to use guild commands so strongly otherwise

sage tendon
#

prolly cause my bot wasnt in a lot of servers then

digital bear
short rivet
# sage tendon none your code is good as is

actually in slash commands even if u type hint a parameter as discord.Member still it will get discord.User because discord returns a user object so they would have to add an additional line to get the member object and that would be member = ctx.guild.get_member(user.id)

sage tendon
#

that is just completely wrong

#

It's only a user object if the ID that was supplied is of someone who is not in the server

#

If the person is in the server, it will always be discord.Member unless the command is from a user app

lofty parcel
#

Discord always supplies a discord.User

#

It's the library that makes the conversion

#

Or that's what I remember Nelo said

errant trout
#

not quite

lofty parcel
#

I shut

errant trout
#

the option type is ONLY user (i.e. if you annotate member: discord.Member, discord just interprets it as a user - this is why you can pass any user ID, not just member IDs)
discord does the conversion on their end and will return either member or user

sage tendon
#

yep

#

it's kind of dumb that you can't force it to actually be only member, since right now you have to handle the case that a non-member is submitted in any member options

grizzled loom
sage tendon
#

thats... exactly what i just said

grizzled loom
#

OHHHH

#

Silly me, i thought you were refering to "None" as in "can't find any data for some odd reason"

#

I beg your pardon Mr. Toothy 🙃

little cobalt
#

got channel permission change a hard ratelimit like renamen them?

#

I know if you change the channel name its like 2 every 10 minutes

#

but is that also for permissions?

errant trout
#

channel names were made stricter because discord got tired of people using them as live counters

oblique sable
#

hey guys, any idea why my bot is doing that? when sending the right file

#

however when i send a wrong voice or a wrong file extension it does not

#

my friend tried it, it worked for him, not for me

#

it doesnt even print the content just says failed

errant trout
oblique sable
#

nope

#

for my friend it worked and printed the content in my console

errant trout
#

how big is the file you're uploading

#

i'd try deferring before file.read

oblique sable
#

ughh my bad i changed pc and didnt turn on auto save on vscode 😭 so it was blank

errant trout
#

rip LOL

oblique sable
#

spent like 20m on thatprayadge

errant trout
#

the default help command of commands.Bot displays command.signature, which is a list of arguments

#

if you specify usage in a command, it will be used instead of the default signature

#

(it's easier to understand if you just try your bot's default help command)

shadow sigil
#

I can't tell a difference between when I have usage="..." and when I don't

errant trout
shadow sigil
#

OH

#

I see

#

it's the [args...] part in -command [args...]

errant trout
#

mhm

shadow sigil
#

I kept changing it to some small text and missing it as a result

umbral gazelle
sage tendon
#

the username?

umbral gazelle
sage tendon
#

then the name of what lol

umbral gazelle
sage tendon
#

ctx.command

umbral gazelle
sage tendon
#

ah

#

no clue then

umbral gazelle
fresh sierra
sage tendon
#

Luma, they only have the message

rugged lodgeBOT
echo wraith
#

Maybe?

#

Wait it's deprecated

#

#1130595287078015027 message

red mist
fresh sierra
sage tendon
#

i doubt they'd need to go off a message object if its their own bot's commands

#

they'll need to tell us

echo wraith
#

And that is the parameter required in get_context

fresh sierra
#

Ooo maybe not since it’s for slash command and not prefix in this case

echo wraith
fresh sierra
#

Yep mb

fresh sierra
echo wraith
#

This is German and swiss layout

red mist
#

Yeah Qwertz

#

English is Qwerty

echo wraith
#

Literally just inverted z and y

little cobalt
red mist
echo wraith
red mist
#

*how to

#

:>

#

(edit it a 3rd time tehheeh)

echo wraith
red mist
#

4th?

#

Damn

umbral gazelle
#

How can I supress DeprecationWarning?

sage tendon
#

fix it and dont use something that's deprecated :>

rancid arrow
#

is it possible to add an image to embed that's not a url but a file

sly karmaBOT
rancid arrow
#

thanks

umbral gazelle
echo wraith
umbral gazelle
errant trout
#

GuraShrug disable logging? lol

#

or just edit the library and remove it yourself

lapis dock
#
import warnings
warnings.filterwarnings("ignore", message="divide by zero encountered in divide")

-# Source
I think this should work

errant trout
lapis dock
umbral gazelle
sage tendon
#

show your code

digital bear
#

What is the best practice for catching errors like this?

discord.errors.DiscordServerError: 503 Service Unavailable (error code: 0): upstream connect error or disconnect/reset before headers. reset reason: connection termination
sage tendon
#

what are you doing that causes that error

digital bear
#

It rarely happens, but it completely crashes the bot I think

#

It was with a simple channel.purge, but I think Discord servers were having issues that time

sage tendon
#

pycord should completely handle such errors, and it shouldnt crash the bot

digital bear
#

Hmm, okay i'll let it go for now, no use on adding a lot of try and excepts everywhere for something that rarely happens

sage tendon
#

can you show the full traceback

sage tendon
digital bear
#

Sure, this is it:

Traceback (most recent call last):
File "/home/akkie100/.local/lib/python3.9/site-packages/discord/ext/tasks/init.py", line 169, in _loop
await self.coro(*args, **kwargs)
File "/home/akkie100/fintwit-bot/src/cogs/loops/timeline.py", line 144, in get_latest_tweet
await self.on_data(tweet, update_tweet_id=True)
File "/home/akkie100/fintwit-bot/src/cogs/loops/timeline.py", line 172, in on_data
e, category, base_symbols = await make_tweet_embed(
File "/home/akkie100/fintwit-bot/src/util/tweet_embed.py", line 80, in make_tweet_embed
e, category, base_symbols = await add_financials(
File "/home/akkie100/fintwit-bot/src/util/tweet_embed.py", line 331, in add_financials
await tweet_overview.overview(category, base_symbols, prediction)
File "/home/akkie100/fintwit-bot/src/cogs/loops/overview.py", line 59, in overview
await self.make_overview(category, tickers, sentiment)
File "/home/akkie100/fintwit-bot/src/cogs/loops/overview.py", line 181, in make_overview
await self.crypto_channel.purge(limit=1)
File "/home/akkie100/.local/lib/python3.9/site-packages/discord/channel.py", line 456, in purge
return await discord.abc._purge_messages_helper(
File "/home/akkie100/.local/lib/python3.9/site-packages/discord/abc.py", line 176, in _purge_messages_helper
await ret[-1].delete(reason=reason)
File "/home/akkie100/.local/lib/python3.9/site-packages/discord/message.py", line 1365, in delete
await del_func
File "/home/akkie100/.local/lib/python3.9/site-packages/discord/http.py", line 371, in request
raise DiscordServerError(response, data)
discord.errors.DiscordServerError: 503 Service Unavailable (error code: 0): upstream connect error or disconnect/reset before headers. reset reason: connection termination
echo wraith
#

Ooh loops don't have error handling

#

I already had that once

#

like if a loop crashes once it will never re-run

digital bear
echo wraith
#

unless you restart

echo wraith
sage tendon
#

well in that case it is probably best to put a try except around that because i have no idea if loop / task errors have an event / listener

digital bear
sage tendon
#

you cant restart your bot with a command if it isnt running lol

digital bear
echo wraith
sage tendon
#

i find it very odd that it complains about line 144 when that is just else:

echo wraith
sage tendon
#

"line 144"

echo wraith
#

wait nvm

#

mb wtf did I just say

digital bear
#

Yeah the error is from some time ago, I was working through my issues so the current code is probably already a bit different then at the time I got that error

echo wraith
lapis dock
digital bear
lapis dock
#

I just found it now when skimming the docs XD

digital bear
echo wraith
digital bear
#

So i'm thinking if I add this:

@global_overview.error
    async def overview_error(self, error: Exception):
        logging.error(f"Error in global_overview loop: {error}")
        # TODO: add more code

It should be able to handle errors better.

sage tendon
#

# TODO: add more code
looooool

digital bear
#

haha before anyone says that more code should be added

#

Thanks again for the help, now I have an idea how to handle this

shell radish
#

there should be two spaces after the pound symbol and text

#

you probably don’t care

umbral gazelle
#

Is it possible to get guilds of a certain shard like in bot.guilds?

fresh sierra
rugged lodgeBOT
shell radish
#

.shards returns a map of shard_id to guilds

fresh sierra
#

How can i create a event that is trigger only when the cog is loaded

#

kinda like the cog_onload but for the loading

errant trout
#

i'll make a tag for it, but here's an example of custom events #998272089343668364 message

fresh sierra
#

and ig you put the bot.dispatch inside the init

#

i will try that thanks

errant trout
#

it might NOT work in init during load, since the listener might not exist at that point in time

#

hmm

fresh sierra
#

yeah true

errant trout
#

eh give it a try i guess

#

i was personally thinking you just dispatch it after using load_extension

#

(maybe override it to super().load_extension -> dispatch with get_cog)

errant trout
#

oh wait

#

just dispatch it in setup

#

way easier

fresh sierra
#

what i will do ig is since i have many cog and a func update it will first load everything and then dispach it for all of them

errant trout
#

but you only need a single dispatch

fresh sierra
#

like so
-> unload
-> update file
-> load
-> dispatch

#

yep

errant trout
#

so i guess it's back to your own function

fresh sierra
#

yep i added it in my setup hook

#

that is trigger when i update my bot

#

and it works

#

thanks nelo

errant trout
#

allgood

deft kestrel
#

how to have the "status" with the phone icon?

lofty parcel
# deft kestrel how to have the "status" with the phone icon?
sage tendon
#

TLDR not worth

shell radish
#

and isn't it technically against tos

lofty parcel
#

But breaking the rules is fun

deft kestrel
red mist
#

Lmao watch me host my bot on an android 4.3 tablet

#

Because then technically speaking my bot is on mobile

opal swan
#

is await ctx.create_custom_emoji bug ?

#

or the function await emoji.read() ?

echo wraith
digital bear
digital bear
digital bear
echo wraith
echo wraith
#

@sage tendon do you think it would make sense to open an issue about loops not restarting if they crash?

#

maybe a decorator

digital bear
opal swan
echo wraith
# opal swan ...

Well you can't expect everything to comme immediately. In any case, you can still upload emojis in the ddev portal and use them in your bot's messages witht heir id

#

once it is in master, you can use the github version of you want

opal swan
echo wraith
#

my bad sorry

rugged lodgeBOT
opal swan
opal swan
echo wraith
#

wait 'm explaining to you

#

it isn't ctx. it is ``ctx.guild.`

#

ctx is an application context

#

you need to use the guild object

opal swan
#

imo it's the thing image

opal swan
#

mb

echo wraith
# opal swan I know

Can you send me then entire code where you take the emoji from the first guild and add it to the other?

opal swan
#

wanna see my code to check or no ?

digital bear
# echo wraith ```py import logging ... def __init__(...): ... self.global_...

I made a decorator for it so I can use it on all my loops:

from functools import wraps

def handle_errors(func):
    @wraps(func)
    async def wrapper(*args, **kwargs):
        try:
            return await func(*args, **kwargs)
        except Exception as e:
            logger.error(f"Error in {func.__name__}", exc_info=e)

    return wrapper

Still need to add more exceptions but it works

fresh sierra
#

So for example log the error and then start the loop again

echo wraith
fresh sierra
#

Since it’s a loop

#

Imagine a while or a for in that continue Even with error

#

It would be a giant mess

digital bear
#

If they crash it's either Discord's servers fault or the website that i'm scraping lol

#

Depending on the error I could always stop the loop manually or restart it

echo wraith
fresh sierra
#

Yeah maybe, but that how I think because for me this loop is like a while or a for in so it should have the same behavior. Maybe other will have different option ion

#

Maybe even add an arg restart after error

echo wraith
echo wraith
#

Is there just buttons and select menus as ui elements?

sage tendon
#

modals

echo wraith
sage tendon
#

yea

echo wraith
#

right thanks wanted to be sure

#

cuz I'm making the reactive views thing

echo wraith
#

in this thing

if TYPE_CHECKING:
    from ..emoji import Emoji
    from .view import View

B = TypeVar("B", bound="Button")
V = TypeVar("V", bound="View", covariant=True)


class Button(Item[V]):
    """Represents a UI button.

there is this B and V typevars. How do I use this thing if I subclass button? And what is it for exactly?

quartz umbra
#

Hello, I would like to implement some functionality, but I'm not quite sure how to approach it
What I want is this: A message is sent with the bot's reaction. I then would want to wait for x time (say 20 minutes), and listen for if a certain user reacts to this message, if this time runs out and the user has not reacted to the message, I want to do some other action.

Can anyone help me implement this logic?

rugged lodgeBOT
echo wraith
echo wraith
quartz umbra
sage tendon
echo wraith
quartz umbra
#

this is very basic but say I call this: ```py
async def foo(x):
y: int = await something_that_takes_a_while(x)
print(y)
print("Hello there")

would the output be: ```bash
Hello There
<some number>

or bash <some number> Hello there

aka, does an await call stop execution?
If it does stop execution, how do you have something running in the background in py-cord? Do you have to use multiprocessing / threading?

sage tendon
#

async isnt threading

#

if you ran that function in a thread, it'd print like the top example (most likely, depends on the timing)

#

but normal async doesnt change the order in which code is executed

#

await means "wait here until this function finishes, and in the meantime, free the thread to do other stuff" e.g. handle other commands

#

also your example is kinda wrong, for your example to work properly you'd have to print inside of the async function, but i get what you mean lol

#

And sidenote cause i noticed you're typehinting the variable definition, you don't have to do that if the return type of the function you're calling is a single type (multiple work too, but is ambiguous)

echo wraith
#

pycord suddently broke

 system, node, release, version, machine = infos = os.uname()
                                                      ^^^^^^^^
AttributeError: module 'os' has no attribute 'uname'. Did you mean: 'name'?
sage tendon
#

that has absolutely nothing to do with pycord

echo wraith
#

you are right

#

bro wtf
AttributeError: partially initialized module 'discord' has no attribute 'ui' (most likely due to a circular import)

little cobalt
#

Can you show the pip list pls

echo wraith
#
╭───────────────────────┬─────────┬────────────────────────────────────────────────────────────╮
│ name                  │ version │ location                                                   │
├───────────────────────┼─────────┼────────────────────────────────────────────────────────────┤
│ aiohappyeyeballs      │ 2.3.4   │                                                            │
│ aiohttp               │ 3.10.0  │                                                            │
│ aiosignal             │ 1.3.1   │                                                            │
│ attrs                 │ 23.2.0  │                                                            │
│ basedpyright          │ 1.15.1  │                                                            │
│ frozenlist            │ 1.4.1   │                                                            │
│ idna                  │ 3.7     │                                                            │
│ multidict             │ 6.0.5   │                                                            │
│ nodejs-wheel-binaries │ 20.16.0 │                                                            │
│ py-cord               │ 2.6.0   │                                                            │
│ pycord-reactive-views │ 0.1.0   │ -e C:\Users\Jérémie\Documents\GitHub\pycord-reactive-views │
│ python-dotenv         │ 1.0.1   │                                                            │
│ ruff                  │ 0.5.6   │                                                            │
│ yarl                  │ 1.9.4   │                                                            │
╰───────────────────────┴─────────┴────────────────────────────────────────────────────────────╯
sage tendon
#

whatever that view package is, that's likely it

echo wraith
#

it's the project I' making and I rolled git back to when it worked and nothing changed

sage tendon
#

reinstall pycord

echo wraith
#

I did that like 4 times now

sage tendon
echo wraith
sage tendon
#

man

#

nuke your venv

#

reinstall it

little cobalt
#

lol

echo wraith
sage tendon
#

then give up

little cobalt
#

try 3.11

echo wraith
#

but I don't see why since 3.12 always worked since today now...

sage tendon
#

try it

#

programming is magic we all know that

echo wraith
#

TypeError: _patch_task.<locals>.task_new_init() got an unexpected keyword argument 'eager_start'
python-BaseException
sys:1: RuntimeWarning: coroutine 'ClientRequest.write_bytes' was never awaited

sage tendon
#

time for a new project

echo wraith
#

yeah

#

doing 3.11 rn

#

3.11 works YEEEEE

sage tendon
#

good luck debugging why it doesn't work on 3.12

nova epoch
#

?rtfm discord.commands.SlashCommandGroup

rugged lodgeBOT
sage tendon
#

you can use the doc search yknow

echo wraith
#

Ok no dosen't work on 3.11 either

#

HOWEVER

sage tendon
echo wraith
#

I found the issue

#

and you will never believe it

sage tendon
#

go on

echo wraith
#

SO basically I have a folder called examples

#

And what I do is that I create the lib and write the examples

#

and run the examples to see if it works

#

I added a new example

#

and the name of the file broke everything

#

I called my example select.py

sage tendon
#

wow

echo wraith
#

and for some reason python decide that that should be used instead of discord's own select.py file

sage tendon
#

namespace collisions

#

always bad

echo wraith
#

yeah

little cobalt
#

what would be a "good" way to get a category?

sage tendon
#

get_channel

deft kestrel
#

how to put the time in embed footer? like that but "Today at [...]"

errant trout
#

(if you want the current time discord.utils.utcnow() is convenient, but it can be any time you want)

deft kestrel
#

ok

#

thank you

amber galleon
#

So I am trying to remake my bot in pycord. The commands work, but I keep getting an error message that the application did not respond. Never used pycord b4 so all help is appreciated! ```import random
import discord
from discord.ext.commands import Bot
from discord.ext import commands

bot = commands.Bot()

@bot.slash_command(name='motivationalunicorn',
description="Writing advice, prompts, and motivation!",
brief="A unicorn that helps you navigate through the journey of writing.")
async def motivational_unicorn(ctx):
possible_responses = [
'Virtual huggie!',
'Who is the best? You are!',
'YOU CAN DO IT!',
'You will never know if you do not try',
'You have come so far!',
'You got this!',
'Hang in there!',
'You are unstoppable!',
'You will take the world by storm!',
'I am so proud of you!',
'You are creating something out of nothing and that is a huge deal!',
'No matter what happens, you started something big and no one can take that away!',
'Do not give up!'

]
await ctx.respond(random.choice(possible_responses))
sage tendon
#

i dont think brief does anything for slash commands btw

amber galleon
#

This is what the error looks like. I don't see anything in my terminal.

echo wraith
#

.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)
sage tendon
echo wraith
#

Maybe check that dpy isn't still installed

amber galleon
#

@echo wraith I changed it to discord.Bot and now it works!

#

Thank you!

sage tendon
#

that shouldnt happen tho lol

amber galleon
#

what part?

sage tendon
#

it not working lol

amber galleon
#

oh

#

what is it doing that is wrong? The error message disappeared.

sage tendon
#

can you show your pip list

sage tendon
#

it should respond like normal

#

with commands.Bot as well

lofty parcel
#

Tf

sage tendon
#

yea it might be discord.py being installed alongside

#

pip list would help

dense summit
#

Hey there, im trying to make an help command where i can switch between command categories with a dropdown menu. Im trying to use paginator but im at a dead point i don't know how to switch to the new embed when a person select the category from the dropdown menu.

This is my command:
https://paste.pythondiscord.com/2ZHQ

This is my dropdown callback in another file:
https://paste.pythondiscord.com/NVIA

dense summit
#

Or do i need to use page groups and how? there are no examples.

lofty parcel
#

I was about to mention page groups

#

pages in PageGroup is your list of embeds for each command (I assume each command has its own embed)

#

And then you care about label and description which is what the Dropdown will use later

cobalt belfry
#

Has anyone successfully webhook.edit_message'd an image that has alt text/description? I can add an image, but it doesn't seem like the description gets submitted (can move to a thread if that's preferred).

dense summit
cobalt belfry
#

I've tried

files=[discord.File(description="Whatever", ...)]
chunked_messages[idx] = await webhook.edit_message(
message_id=chunked_messages[idx].id,
content=content,
thread=thread,
files=files,
)

as well as stuff like

chunked_messages[idx].attachments[0].description="Whatever"
attachments=[chunked_messages[idx].attachments[0]]
chunked_messages[idx] = await webhook.edit_message(
message_id=chunked_messages[idx].id,
content=content,
thread=thread,
attachments=attachments,
)
``` (since I'd expect that to `PATCH` the existing attachment to add a description field, please assume that content and thread are sane non-null values)
deft kestrel
#

can i use Context Menu Commands in DM with users?

#

authorizing my app in my account

sage tendon
#

of course

shell radish
cobalt belfry
#

That makes sense, but I'm also failing to add a fresh attachment with a description property (first example)

shell radish
#

something like this perhaps

await webhook.edit_message(
message_id=chunked_messages[idx].id,
content=content,
thread=thread,
files=files,
attachments=[]
)
cobalt belfry
#

I'm making files via something like

discord.File(buffer, filename=name, description=prompt[:1024])
``` where buffer is a `io.BytesIO` off of an `aiohttp` request, and I'm sure that `prompt` is a non-zero length string because I just used it for generating the image.
shell radish
cobalt belfry
#

Sorry, revising my kinda n00b question here - I'm sending a webhook with no attachments initially, then retrieving an image in the background and updating with a new attachment. I have a good image description and want to attach it as alt text, but I don't understand how the web request is being generated to see if it's being sent to Discord (Discord bug) or if it's not (PyCord bug). Could I get a pointer to how editing a WebhookMessage creates a PATCH request with a body?

errant trout
#

from what i can tell either:

  • we didn't implement certain attachment compatibility in webhooks
  • discord doesn't allow it (which i find unlikely?)
carmine jackal
#

@sage tendon Sorry, where's the exact link to user apps documentation?

deft kestrel
# sage tendon of course
@bot.user_command(
    name="test",
    integration_types={
        discord.IntegrationType.guild_install,
        discord.IntegrationType.user_install,
    },
    )```
like that?
rugged lodgeBOT
#

Here's the slash users example.

deft kestrel
#

ok

lofty parcel
#

Each page group would be your category

dense summit
carmine jackal
cobalt belfry
#

Amazing! Thank you so much, I'll test now.

errant trout
#

hmmmmm, behaviour is still inconsistent with normal message edits...

#

but that's more of a cache thing, not something we can deal with

#

not without restructuring how webhook messages work anyway

cobalt belfry
#

Patch seems to work for my use case. Cheers, appreciate the help, and now I know more about where this gets serialized to debug in future.

stoic patio
#

why do i get the feeling that my bot does the on_ready event whenever it resumes its session

stoic patio
#

i thought that was on_resumed?

shell radish
#

the session may not necessarily be resumed

stoic patio
#

interesting

#

why's that

#

how likely is it that that's my own fault

shell radish
#

like none

stoic patio
#

so it's always on discord's end if it doesn't just resume normally?

shell radish
#

not always

stoic patio
#

so when would it my fault if that happens

tidal vessel
#

@shell radish Sorry if I'm annoying, what is the limit of characters a bot can send in a message? Is it the same as the normal user? (a user who does not have nitro)

errant trout
#

2000 in content

shell radish
stoic patio
#

interesting

#

i'm asking about issues with the bot

tidal vessel
quartz umbra
#

In Py-Cord, how do I have a function, take for instance: ```py
async def foo(x):
sleep(10)
print(10)

run in the background, say in exec, something like this?:```py
<call foo>
print(20)

output:

20
10
#

Do you use multiprocessing / threading or can you do it in py-cord differently

#

I would like to use wait_for in this background process, that's why

quartz umbra
#

should I be using asyncio.create_task?

echo wraith
#

May I know exactly what this blocking code is?

quartz umbra
#

From the Py-Cord Docs: ```py
@client.event
async def on_message(message):
if message.content.startswith('$thumb'):
channel = message.channel
await channel.send('Send me that 👍 reaction, mate')

    def check(reaction, user):
        return user == message.author and str(reaction.emoji) == '👍'

    try:
        reaction, user = await client.wait_for('reaction_add', timeout=60.0, check=check)
    except asyncio.TimeoutError:
        await channel.send('👎')
    else:
        await channel.send('👍')
That's essentially *exactly* what I want to do, except, its not in `on_message` and there's more logic I want to run after `wait_for` if you get what I mean
#

cuz my timeout=1200

#

yo to DM a user is it just user.send() or do I have to call user.create_dm() first?

fresh sierra
quartz umbra
quartz umbra
# quartz umbra From the Py-Cord Docs: ```py @client.event async def on_message(message): if...

I will pose my original question better:

I would like to achieve the following: Give a user 20 minutes to react with 👍 to a specific message, but handle this in the background, so that I can handle other logic in the same function. I think discord.Bot.wait_for is exactly what I'm looking for, I just need a way to handle this (dummy) code:```py
def check(reaction, user):
return user == message.author and str(reaction.emoji) == '👍'

    try:
        reaction, user = await client.wait_for('reaction_add', timeout=60.0, check=check)
    except asyncio.TimeoutError:
        await channel.send('👎')
    else:
        await channel.send('👍')
in the background
echo wraith
#

And that's it so your current code is good

rugged lodgeBOT
echo wraith
#

And yeah you would use create task for running multiple things

#

But what I would do is put the other logic in the background, not the wait_for

#

In the init

    self.tasks: set[asyncio.Task] = set()

In your thing

        task = asyncio.create_task(YOUR COUROUTINE WITHOUT AWAIT HERE)  
        self.tasks.add(task)
             task.add_done_callback(tasks.discard)
quartz umbra
echo wraith
echo wraith
echo wraith
echo wraith
#

np

graceful spindle
#

is it possible to load a new cogs file and register the cog's slash commands?

#

without having to restart the bot

graceful spindle
#

If i use self.bot.load_extension it loads the cog but doesnt register the slash command inside the file

sage tendon
#

i dont think you can

fresh sierra
#

you can

graceful spindle
#

i didnt think you could I just wanted to make sure

#

oh?

fresh sierra
#

just add await bot.sync_cmmands

sage tendon
#

ah yea

fresh sierra
#

to sync command

graceful spindle
#

thanks ill try that now mate

#

Thanks

sand bolt
#

Small problem... I hope

I’m creating my own bot but when I have to test it, it doesn’t let me show its commands in the menu. It only goes if I put for exemple "!"

I’m just starting out in programming.

sage tendon
#

if you made them prefix commands, theyll of course just work as prefix commands

#

show your code

sand bolt
# sage tendon show your code
import discord
from discord.ext import commands
from dotenv import load_dotenv
from discord import app_commands
import os

# Carica il token dal file .env
load_dotenv('.env')
TOKEN = os.environ['TOKEN']

class Bot(commands.Bot):
    def __init__(self):
        intents = discord.Intents.default()
        intents.members = True
        intents.message_content = True
        super().__init__(command_prefix=None, intents=intents)  # Assicurati che command_prefix sia None

    async def on_ready(self):
        print('Il bot è online e pronto a ricevere comandi!')

    async def setup_hook(self):
       
        # Carica i vari cogs per i comandi
        
        await self.load_extension('cogs.pex_depex')
        await self.load_extension('cogs.staff_break')
        await self.load_extension('cogs.ping')
        await self.load_extension('cogs.counting')  
        await self.load_extension('cogs.exemple')
        print("Comandi caricati")

bot = Bot()

# Evita di utilizzare process_commands in quanto non hai prefisso
bot.run(TOKEN)

fresh sierra
#

the setup hook is not gonna be trigger

#

there is no setup hook in py-cord

sage tendon
#

put loading the cooks somewhere above bot.run