#Basic Pycord Help

1 messages · Page 51 of 1

lofty parcel
#

I can finally fix something without it being complex

errant trout
#

Technically we can actually assign a type to partialmessageable which fixes it, but this is a rather old issue

#

But it's strange, because if you recieve a message like in the error you should have the full channel no?

edgy nest
errant trout
#

poll_event wasn't the actual event (that's just a gateway function?), was message_update

#

But either way I should probably adjust the behaviour

#

Oh messages don't even have full channel data ok

deft kestrel
#

What's the method name for creating a post in a forum channel?

errant trout
#

create_thread

edgy nest
errant trout
#

Polls?

edgy nest
#

yeah

#

do we really need channel/message objects to cache polls?

errant trout
#

They're always attached to a message, and have related methods, so yeah

edgy nest
#

i suppose that makes sense

edgy nest
#

or just not checking the type if it turns out to be None (since that should only be possible for partialmessageable)

deft kestrel
#

can someone help me here? #1271568482206617672 I've been debugging it since yesterday but still coudln't figure out why it's not working

bronze frigate
#

Hey there, I'm looking for a way to know how many messages a user has sent in a channel in the past. Could someone nudge me in the right direction pretty please 😅 ?
(just to be clear I don't want to start counting from when my bot was added to a server, I want my bot to be able to check the history of specific channels to see who wrote messages in them and in the end obtain a list of users and how many messages they wrote)

lapis dock
#

TextChannel.history is a start. Not sure what the ratelimits are. Might take a while depending on the channels size.

stray yarrow
#
Command raised an exception: Forbidden: 403 Forbidden (error code: 50013): Missing Permissions

What would the error handler be for that?

#

e.g, if isinstance(error, ???):

frail basin
stray yarrow
#

im using on command error if that makes any difference

lofty parcel
stray yarrow
#
elif isinstance(error, discord.Forbidden):
            print("forbidden")
#
elif isinstance(error, discord.HTTPException):
            print("http")
#

no responses

sage tendon
#

is it a slash command?

stray yarrow
#

no

#
@commands.Cog.listener()
    async def on_command_error(self, ctx, error):
#

if thats any help

sage tendon
#

what is type(error)

stray yarrow
#
<class 'discord.ext.commands.errors.CommandInvokeError'>
sage tendon
#

ah i had that too

#

i'm pretty sure that means it's not a pycord exception
and you can get the actual error via error.original

#

i'm doing the same in my bot

#

if its not a discord exception, error.original will "unwrap" it

stray yarrow
#

alright thanks

deft kestrel
#
        await channel.create_thread(name={nome_e_cognome}, embed=embed, auto_archive_duration=60, type=discord.ChannelType.private_thread, reason=None)

I got: create_thread() got an unexpected keyword argument 'type'

#

i mean this to create threats

lofty parcel
#

I assume they're always public. You can't create a private post

deft kestrel
#

ok i'll try

deft kestrel
lofty parcel
#

.rtfm ForumChannel.tags

sly karmaBOT
#

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

lofty parcel
#

And then just applied_tags=[the tags you wanna apply] to the method

deft kestrel
#

There's any limit of ctx.followup.send?

Like I can send max 2/3 responses

sage tendon
#

yea i think you can do 2 followups after the original response

#

but you should use .respond, there's (afaik) no need to ever use followup.send

little cobalt
#

you can also do a 100 times a ctx.respond ;3

sage tendon
#

really? i thought discord limits it at 3 "responses"

errant trout
#

Except for user installed apps - they have a max of 5

#

Otherwise, your limit is 15 minutes

sage tendon
errant trout
#

Uhhh theoretical spam

flat tapir
#

hey! how could i use the utils module to get the name of a person from their id?

errant trout
#

Utils module?

flat tapir
#

im looking at the docs but i have massive skill issue

errant trout
#

Just use bot.fetch_user (api call, id should be int)

#

discord.utils would be unrelated

sage tendon
#

and prefer get_user if anyhow possible

errant trout
#

If it's a member in one of the bots guilds, guild.get_member or bot.get_user

flat tapir
#

oh, right.. thanks ill check em

flat tapir
sage tendon
#

never said that

flat tapir
#

so i can use it?

#

eh, prolly, this isnt some super optimized bot to begin with

#

thanks all

sage tendon
bronze frigate
bronze frigate
#

Or wait it seems that actually when you do not add a limit it actually sets it to 100 by default

bronze frigate
#

What's the actual risk of setting it to 10.000/100.000/1.000.000

#

I'll just get rate limited and the command will take more time to execute, right?

#

Not like my IP is gonna get banned from accessing discord API (?)

echo wraith
#

I did once do something similar and didn't get anything other than rate limit

bronze frigate
bronze frigate
#

sigh

errant trout
#

default limit is 100 because that's how much the api supports

#

So setting limit=None will do (total/100) requests

#

That being said, the library handles it with no issue

bronze frigate
#

Yeah okay, makes sense.

errant trout
#

It'll just take some time for large channels

bronze frigate
#

Thanks for the help 🙂

brave ice
#

class AutomationCog(commands.Cog):
    def __init__(self, bot: discord.bot.Bot):
        self.bot = bot


bot = discord.Bot()

bot.add_cog(AutomationCog(bot))

if __name__ == "__main__":
    bot.run(DISCORD_KEY)

Traceback (most recent call last):
  File "/var/home/lucas/Projects/werk/ti_automation/main.py", line 11, in <module>
    bot.add_cog(AutomationCog(bot))
  File "/var/home/lucas/.pyenv/versions/ti_automation/lib/python3.12/site-packages/discord/cog.py", line 666, in add_cog
    cog = cog._inject(self)
          ^^^^^^^^^^^^^^^^^
  File "/var/home/lucas/.pyenv/versions/ti_automation/lib/python3.12/site-packages/discord/cog.py", line 574, in _inject
    raise e
  File "/var/home/lucas/.pyenv/versions/ti_automation/lib/python3.12/site-packages/discord/cog.py", line 568, in _inject
    bot.add_command(command)
    ^^^^^^^^^^^^^^^
AttributeError: 'Bot' object has no attribute 'add_command'. Did you mean: 'all_commands'?

does someone know if im doing something wrong? im trying to make cogs to split up my discord bobt

little cobalt
#

also can you show the pip list pls

brave ice
# little cobalt why bot.Bot?

i kind of figured it out, i was using discord.bot to create the bot instead of commands.bot

but now none of my slash commands show up haha

from discord.ext import commands  # noqa: I002

from config import DISCORD_KEY
from dc.cogs.automation import AutomationCog

bot = commands.Bot()

bot.add_cog(AutomationCog(bot))

if __name__ == "__main__":
    bot.run(DISCORD_KEY)
#

any clue if i need to do more in order for them to show up again

little cobalt
#

Why did you import the cog?

#

You load them with load_extension("cogs")

brave ice
sage tendon
brave ice
sage tendon
#

discord.ApplicationContext

#

also, typehints cant "not work"

brave ice
#

ahh thanks!

sage tendon
#

its either right or wrong lol

brave ice
#

yeah hahah tho i meant the extension crashes when using the wrong one

sage tendon
#

that shouldnt happen for all i know lol

brave ice
#

discord.errors.ExtensionFailed: Extension 'dc.cogs.automation' raised an error: TypeError: Invalid class <class 'discord.ext.commands.context.Context'> used as an input type for an Option

sage tendon
#

ah

verbal torrent
#

Hey. How can i make a list with activitys for the bot like playing Minecraft or watching Youtube or something else, and choice one of it every 30 seconds?

echo wraith
#

.rtfm tasks.loop

verbal torrent
lofty parcel
#

You're either adding extra arguments or you're missing arguments.

little cobalt
sage tendon
#

no

little cobalt
sage tendon
#

oh yea i forgor

#

@lofty parcel no, i just tried, it does that

deft kestrel
#

Any idea how to develop custom slash commands per-server or per-user?

sage tendon
#

pass guild_ids=[] in the slash command decorator

#

per user isnt possible

lapis dock
#

If you mean that a server can run /create_command text: Hello here is the starting point:
Bot.add_application_command than Bot.sync_commands but make sure to set guild_ids and the command just in case the library does not handle it well you do not want to hit ratelimits

#

Like toothy said I dont think per-user is possible

sage tendon
lapis dock
#

you get 200 global and 200 per guild a day

#

might be 100 per guild. Not 100% sure but I know you get some per guild

deft kestrel
#

How do I sync channel permissions with category?

sage tendon
#

the sync_permissions kwarg

#

if you're using channel.edit

deft kestrel
#

I am creating a channel though

#

category.create_text_channel

sage tendon
#

then it's synced by default

deft kestrel
#

oh ok

sage tendon
#

as per the docs

#

always read the docs first :>

opal swan
sage tendon
#

?

opal swan
sage tendon
#

you are giving me 0 context my guy

opal swan
#

or it not work with discord.Guild.create_custom_emoji parameter "image"

opal swan
opal swan
sage tendon
#

don't DM me

opal swan
#

so u can see wth I mean

opal swan
sage tendon
#

i dont want it

opal swan
#

we can be ban ?

sage tendon
#

send it here

opal swan
#

alr so

#
commands.command() 
async def create(self, ctx : commands.Context, emojis : commands.Greedy[discord.Emoji]):
   for emoji in emojis :
      await ctx.guild.create_custom_emoji(name=emoji.name, roles=[ctx.guild.default_role], image=await emoji.read())
opal swan
#

sry for the mention

sage tendon
#

and what about that doesn't work?

opal swan
sage tendon
#

well

#

if you use an emoji thats already in the guild it wont do anything of course

opal swan
#

so I thought it was a api error in the code

sage tendon
#

so you're using an emoji from another guild?

opal swan
#

and a guy tell me I need self.bot need to be in the guild

sage tendon
#

well, yea

opal swan
sage tendon
#

wait, which guild

#

im so confused man

opal swan
#

the guild of owner emojis

opal swan
sage tendon
#

no, for all i know

opal swan
#

alr ty also

#

nah i'm stupid

heavy inlet
#

any way i can differentiate between channel id and user id ?

#

using pycord?

sage tendon
#

why do you not know what kind of ID you have lol

#

thats the more important question

heavy inlet
#

well just asking, is it possible or no

little cobalt
#

lol

sage tendon
#

and its better to fix that earlier

#

but no, not easily for all i know

heavy inlet
#

alright thanks

little cobalt
#

They are just numbers at the end...

sage tendon
#

i still wanna know why you ask

lofty parcel
#

The closest thing is to assume they're checking authorizing_integration_owners

river oriole
#

Can I set the min_value and max_value dynamically like this or will this only get set when I start the bot

sage tendon
#

No

#

static

#

because discord verifies that before the command is sent

river oriole
#

I see. Thank you

deft kestrel
deft kestrel
sage tendon
#

No

#

options and anything related to them except autocomplete is static

edgy nest
#

if you want diff options per server you can make a different command for every server

#

:p

#

but you can't change the options constantly

bronze frigate
#

Hi there again, does someone know if there is a way to add colour to a single field's value in an embed?

shadow sigil
#

is it possible to have a slash command with the same name as a command group?

red mist
#

/test test should be possible

shadow sigil
#

i don't quite mean that

little cobalt
#

but that was your question

shadow sigil
#

rather, having
/test that does something
and /test something which does something more specific
or whatever

red mist
#

no that does not work

#

only /test as a normal command or /test test

red mist
#

Embeds have a color you can set

#

Single embed field values are just values with text etc. you cannot fill it out with just a color

shadow sigil
#

dang

#

different question, is making aliases for slash commands possible

little cobalt
#

no

#

why do you want aliases for slash commands?

shadow sigil
#

i'm mainly just curious

red mist
#

You can make multiple commands that do the same tho, yet its still registered as a different command

bronze frigate
#

I want the text of the value to be a certain a colour obviously 😂

lapis dock
#

There is code blocks that you can sometimes set to different colors

#
Welcome to Rebane's Discord Colored Text Generator!
#

Only works on PC I think

#

Or if you only need 2 colors you can use diff

+ Green
- Red
red mist
bronze frigate
#

I thought there would be something specific for fields in embeds but if that works then I'll take it 😄

#

Thanks for the help

rancid arrow
#

Make an image with a transparent background but with colored text that matches the size and font of discord pepe_Evil

bronze frigate
#

Oh I hadn't understood that it only worked in code blocks. That looks ew.

#

shame there's nothing better 😦

deft kestrel
#

Hello, i need add 2 buttons or more using classes, how to do it? discord.ui.View

sage tendon
#

use the decorator to create buttons inside the view class

deft kestrel
sage tendon
#

pretty sure that's all in the guide

sly karmaBOT
#
from discord.commands import Option
@bot.command()
async def help(ctx,options:Option(str,"this is a option", choices=["fun","admin"]))```
sage tendon
#

and stay in one place asking for help please

deft kestrel
sage tendon
#

just add another decorator for a button lol

deft kestrel
# sage tendon just add another decorator for a button lol
        @discord.ui.button(label="Узнать Кто Написал", style=discord.ButtonStyle.grey, emoji="❓")
        async def button_callback(self, button, interaction):
            await interaction.response.send_message(ctx.author)
        @discord.ui.button(label="Узнать Кто Написал", style=discord.ButtonStyle.grey, emoji="❓")
        async def button_callback(self, button, interaction):
            await interaction.response.send_message(ctx.author)```
#

Like this?

sage tendon
#

yea

deft kestrel
sage tendon
#

restart the bot

#

and maybe give them different labels lol

errant trout
sage tendon
#

really? i thought the decorator just consumed them basically

errant trout
#

no lol

echo wraith
#

The decorator changes the method to an attribute of type Slash command but it is still there

echo wraith
#

Still typing?

deft kestrel
#

Some one help

r=random.randint(1, 70)
class MyModl(discord.ui.Modal):
        def __init__(self, *args, **kwargs) -> None:
            super().__init__(*args, **kwargs)
            self.add_item(discord.ui.InputText(label="Угадай Число от 0 до 70", style=discord.InputTextStyle.long))
        async def calback(self, interaction: discord.Interaction):
            if self.children[0].value == r:
                await interaction.response.send_message(f'Вы угадали число и это был: {ctx.author}')
            else:
                await interaction.response.send_message('Вы не угадалм число.')```

Bot didnt send something 'if else'
sage tendon
#

whatever you're doing, its wrong i think

sage tendon
#

read?

#

it tells you everything you need to know

deft kestrel
sage tendon
#

oh nevermind i thought that was a view class

#

well, did you try print if it gets into the callback at all?

deft kestrel
#

No, lemmi try

#

Wait

deft kestrel
#

Didnt works

sage tendon
#

is the print the first line in your callback?

deft kestrel
deft kestrel
sage tendon
#

but the modal shows up?

deft kestrel
#

Yes

sage tendon
#

also uh, you're using ctx inside of your callback
there is no ctx

#

oh bruh, your callback is called calback

#

typo

cedar snow
#
@alex.event
async def on_message(message: discord.Message):
    if not (message.author.bot):
        if (message.attachments):
            channel = alex.get_channel(os.getenv('MEDIA_ID'))
            for img in message.attachments:
                channel.send(img.url)

If I send a message with an image the debugger shows attachments list and content as empty. I'm pretty stumped as to why

#

I have a past project that did something similar and it looks the same

sage tendon
#

are you sending the image via a link?

#

also, you dont need brackets around the if conditions lol, this isnt java

cedar snow
#

and no, its a drag and drop file

#

message.content is also empty

sage tendon
#

you dont have message content intents then most likely

cedar snow
#

I thought I did. I'll double check

deft kestrel
cedar snow
#

ty

#

❤️

sage tendon
#

np

shadow sigil
#

what does a command group's description affect?

echo wraith
#

Also application directory stuff

deft kestrel
# sage tendon np

How can I make it so that when I press a button, other buttons appear for me?

sage tendon
#

edit the view of the message

deft kestrel
sage tendon
#

just pass another view to the message by editing it

#

or send a new message with the new view

deft kestrel
sage tendon
#

try it and see

deft kestrel
#

Unknown Webhook?

#

I dont have some webhooks in code

sage tendon
#

all interactions are webhooks in a way

deft kestrel
#

A ok

sage tendon
#

but idk then, im too tired, someone else maybe

deft kestrel
#

Okay

deft kestrel
#

User has no attribute timeout

#

user: discord.Option(discord.Member)

#

Whats wrong

sage tendon
#

if it's actually a user object, it has no guild specific stuff

#

a user is a discord user without any relation to a guild

deft kestrel
#

User to didnt work

sage tendon
#

you probably put in the ID of someone not in the server you're using the command in

sage tendon
#

yea because user is what you DON'T want

deft kestrel
sage tendon
#

put in the ID / mention someone who is in the server, then you'll get a member object

sage tendon
#

show your code

deft kestrel
sage tendon
#

?

deft kestrel
#

Code

await user.timeout(seconds=1800, reason='Panel Muted')```

Error

Member.timeout() got an unexpected keyword argument 'seconds'```

#

@sage tendon

sage tendon
#

check the docs

rugged lodgeBOT
sage tendon
#

and use timeout_for

deft kestrel
sage tendon
#

no

#

you need to pass a datetime.timedelta object

#

the pycord docs link to what that is

deft kestrel
sage tendon
#

cant help you with reading it i'm afraid

deft kestrel
sage tendon
#

No

#

the python docs have a clear example in them

#

i wont copy paste it

stoic patio
#

how do i make a discord.ext.tasks.loop() function not run upon a bot's startup

#

for example, if i have a task that runs every 15 mins, how do i make it run for the first time 15 mins after startup rather than upon startup?

tidal vessel
stoic patio
#

i see, thx

errant trout
#

also fun to automatically construct it, e.g. this does every 30 mins of the day py times = [datetime.time.min] for i in range(47): times.append(datetime.time(hour=math.ceil(i/2), minute=(not (i%2))*30))just gotta figure out the right logic for your use case

stoic patio
#

turns out, adding a sleep in the task.before_loop worked

edgy nest
#

petition to make tasks accept cron time formats

errant trout
#

just implement it wyd

shell radish
edgy nest
#

no

graceful spindle
#

How come when I execute a slash command. it doesnt allow me to run anymore commands? Like none show even in the integrations tab in discord settings

sage tendon
#

wdym lol

#

do you mean all the commands disappear?

graceful spindle
#

Yeah

sage tendon
#

restart discord and see if it happens again

graceful spindle
#

Yeah its still happening

sage tendon
#

so you cant even use the same command again or what

graceful spindle
#

I cant use the same command or even any

#

I have to restart the bot

sage tendon
#

show your code

graceful spindle
#

Which part

sage tendon
#

the main file

#

also, does it happen with every command you execute?

graceful spindle
#
import discord
import os
import config


bot = discord.Bot(intents=discord.Intents.all(), debug_guilds=config.DEBUG_GUILDS)
col = config.COL

for file in os.listdir("cogs"):
    if file.endswith(".py"):
        name = file[:-3]
        bot.load_extension(f"cogs.{name}")
        print(f"[-] ✅  Loaded {name}")


@bot.event
async def on_ready():
    print("##################################################")
    print(f"[-] ✅  Logged in {bot.user.name}#{bot.user.discriminator} | {bot.user.id}")
    print("##################################################")
    await bot.change_presence(status=discord.Status.idle)

bot.run(config.TOKEN)```
#

yes

sage tendon
#

do you have any on_application_command listener

graceful spindle
#

Nope

#

on_guild_channel_delete

sage tendon
#

can you show one cog

graceful spindle
#

Thats my listener

#

One of

#
import discord
from discord.ext import commands
import config
import app
import msgs


class DevCmds(commands.Cog):

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

    @discord.slash_command()
    async def reload(self, ctx, file: discord.Option(str, choices=config.choices)):
        check = await app.dev_check(ctx=ctx)
        if check:
            self.bot.unload_extension(f'cogs.{file}')
            self.bot.load_extension(f'cogs.{file}')
            await ctx.respond(f"Successfully reloaded `{file}`", ephemeral=True)

    @discord.slash_command()
    async def load(self, ctx, file=''):
        check = await app.dev_check(ctx=ctx)
        if check:
            if file == '':
                await ctx.respond(msgs.ERR_LOAD_FILE, ephemeral=True)
            else:
                self.bot.load_extension(f'cogs.{file}')
                self.bot.sync_commands
                await ctx.respond(f"Successfully loaded `{file}`", ephemeral=True)

    @discord.slash_command()
    async def unload(self, ctx, file=''):
        check = await app.dev_check(ctx=ctx)
        if check:
            if file == '':
                await ctx.respond(msgs.ERR_UNLOAD_FILE, ephemeral=True)
            else:
                self.bot.unload_extension(f'cogs.{file}')
                self.bot.sync_commands
                await ctx.respond(f"Successfully unloaded `{file}`", ephemeral=True)


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

yea, that would explain

#

you aren't calling the sync_commands function lol

graceful spindle
#

facepalm Where do i go from here

sage tendon
#

call the function?

graceful spindle
#

I see

sage tendon
#

your IDE should've given you a warning about that too

#

because that line does nothing like it is

graceful spindle
#

Yeah it did i ignored it

#

self.bot.sync_commands()

#

?

sage tendon
#

its async

#

await it

graceful spindle
#

👍

#

Thanks for the help

sage tendon
#

np

opal swan
#

wth represent "Entitlement"

#

wth is it ?

sage tendon
#

basically an active subscription for all i know

opal swan
sage tendon
#

yea

opal swan
#

why the doc don't say it's an active sub

#

😭

sage tendon
#

because its documented the exact same way in the discord api docs

sage tendon
#

and its not only subscriptions

#

but mostly

opal swan
#

wth is "accent_color"

#

wth it does

#

?

sage tendon
#

where?

opal swan
sage tendon
#

a user's profile theme color

opal swan
sage tendon
#

Yes, it says that in the description

opal swan
#

nice tysm

opal swan
sage tendon
#

yes

opal swan
sage tendon
#

shrug i dont do the docs

opal swan
#

cause the dev didn't have the time imo

sage tendon
#

no, its a bug

opal swan
#

probably

shell radish
#

it’s a bug

opal swan
mellow pebble
#

is there a way to use one modal after anotehr

#

like what is mean is after i sumbit a modal

#

can i start filling up anotehr one

#

like the second modal will open right after clicking the sumbit button

sage tendon
#

no

mellow pebble
#

cause i am trying to create a form which has over 5 questions

sage tendon
#

buttons

mellow pebble
#

likw using 2 buttons okkay np

#

thanks though

sage tendon
#

you can just reuse the same button but send a different modal

mellow pebble
#

ooo another good idea thanks sir

opal swan
#

how to use new thing call emoji (the one in dev portal)

#

I read the doc and I do it with f-string but don't work

sage tendon
#

You can use them just using the markdown that you can copy via the dev portal

#

pycord itself doesnt have anything for them yet, but they work if you just paste the markdown

opal swan
#

that ? :

{
  "id": "41771983429993937",
  "name": "LUL",
  "animated": true
}
sage tendon
#

no

#

go to the dev portal > app emoji and click copy markdown

opal swan
#

yo bro i'm stupid

#

nice now it's good for guys without nitro like me

#

also tysm

sage tendon
#

there were already bots for that kind of stuff ages ago lol

shell radish
#

nqn?

sage tendon
opal swan
#

nqn ?

sage tendon
#

"not quite nitro"

#

bot

shell radish
#

app

echo wraith
#

appli

opal swan
opal swan
heavy inlet
sage tendon
#

..no?

heavy inlet
#

?

opal swan
#

wth he mean

sage tendon
#

hes confused

lucid crest
#
    @bridge.bridge_command(name="timeout", description="Timeout a Member", guild_ids=guild_id)
    @discord.default_permissions(administrator=True)
    async def timeout(self, 
                      ctx, 
                      member:discord.Member, 
                      duration: BridgeOption(str, "Duration", required=True),
                      reason: BridgeOption(str, "Reason", required=False),
                      ):

The Reason is working for the Slashcommand version, but when used through the old way, it only picks up the first word, can I fix it?

sage tendon
#

make it *reason

#

if that doesnt work, put the reason into quotation marks when you use the command

opal swan
#

i'm so confused fr

stoic patio
#

can very frequent garbage collection possibly cause this issue?

#

my threshold is (200, 3, 3)

#

made it that low cuz of my ec2 free tier limitations

stoic patio
#

idk if it should do that cuz ik the self.bot's user is always cached

fleet cedar
stoic patio
#

if that actually happens, might that be a library bug?

#

this sometimes happens when my bot tries to resume its connection

opal swan
#

is there any difference with discord.Member and discord.User

echo wraith
rugged lodgeBOT
echo wraith
#

for example you have discord.Member.roles but not discord.User.roles

#

let's keep english, I don't really know that website, I don't think it has anything to do with that

opal swan
echo wraith
#

you need to have an iterable in the first parameter

#

so for example a list of users

#

and it would give you the one user with the id you specified

opal swan
#

bruh so discord.User is bad

echo wraith
opal swan
meager mantle
#

I have a Discord.Message object from on_message which is the response of some bot to a slash command. How do I get the user who called the command from this object? I tried to use Discord.Message.reference but in this case it is None since there is no explicit message being replied to.

lofty parcel
#

Use discord.Message.interaction_metada.user

#

.rtfm Message.interaction_metadata

sly karmaBOT
#

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

lofty parcel
meager mantle
sly karmaBOT
# meager mantle I use it wrong? ``` user = ctx.guild.get_member(ctx.interaction_metadata.user.> ...

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.

meager mantle
little cobalt
#

?

meager mantle
# little cobalt ?

I understand that the problem is that the interaction_metadata is missing from the message object in this case, no?

little cobalt
#

other question, what do you want to do?

meager mantle
edgy nest
#

you don't need a bot to do that

meager mantle
edgy nest
#

as for your actual answer; interaction_metadata is none if the message wasn't created from an interaction

round heart
#

What's the way to use get_or_fetch for messages? I tried

await discord.utils.get_or_fetch(channel, 'message', message_id)

but since there's no get_message on the channel, it fails.

little cobalt
#

1 sec.

#

.partial-objects

sly karmaBOT
#

Partial Objects

These can be used to make API calls when you have channel id and/or message id, and you don't want to rely on the cache to have their objects.

Methods which can be used on them are

  • Partial Messageable (analogous to a Channel) - Docs
  • Partial Message (analogous to a Message) - Docs

Example Usage:

async def star_message(channel_id: int, message_id: int):
    # Get Partial Messageable object
    partial_channel = bot.get_partial_messageable(channel_id)

    # Get Partial Message
    partial_message = partial_channel.get_partial_message(message_id)

    # Add a reaction
    await partial_message.add_reaction(":star:")
round heart
#

"Partial" is essentially constructing an empty class with a reference to the id? I just want to set a reply, so I guess that should work.

sage tendon
#

yea, think so

#

since the library very often uses <object>.id, it's often enough to create a barebones object with just an ID

round heart
#

Hm.

.get_partial_message() is throwing an Exception

TypeError("Expected TextChannel, VoiceChannel, StageChannel, DMChannel or Thread not <class 'discord.channel.PartialMessageable'>")
#

Which is true. PartialMessage's __init__ checks the incoming channel type.

Raised GH Issue.

stoic patio
fleet cedar
stoic patio
#

i see

#

then what might cause that?

sage tendon
#

werent you the guy who disabled like, all cache?

#

and gets the weirdest-af errors because of it?

#

if so, thats probably why

stoic patio
#

i re-enabled it

#

cuz i realized i needed member cache for member-related events

#

and i didn't really touch any other cache

fresh sierra
#
    @Lumabot.group("role")
    @Lumabot.command()
    @Lumabot.has_perm("manage_roles")
    async def add(
        self,
        ctx: LumabotContext,
        member: discord.Member,
        role: discord.Role | str,
        reason: str = None,
    ):
        if not ctx.is_app:
            role_name = role
            if isinstance(role, str):
                role = ...

Is there a way to do something like so ?

sage tendon
#

the role? no

#

p sure no

fresh sierra
#

including handle the error of discord.Role not found and then trigger the function with the role as str and not discord.Role

sage tendon
#

i dont see why .Role would ever fail

fresh sierra
#

(with prefix)

sage tendon
fresh sierra
#

my goal is if the user use the slash it works fine

sage tendon
fresh sierra
#

else with prefix it get the role using the name to get a list and fuzzy wuzzy this

sage tendon
#

you can just do that whie keeping discord.Role only i'm pretty sure

fresh sierra
#

to do +addrole @sage tendon helpeur for example even with the name is not excatly helpeur

fresh sierra
sage tendon
#

try it and see

#

and if it does, you can catch it

fresh sierra
#

it does

#

i will explain better my question

sage tendon
#

i know what you want

fresh sierra
#

is there a way to trigger a function by changing an arg even with the wrong typehint

sage tendon
#

now that idk what that means

fresh sierra
#

i will try to do something like so :

#
    @add.error
    async def error(self, ctx: LumabotContext, error: commands.CommandError):
        if isinstance(error, commands.RoleNotFound):
            if not ctx.is_app:
                role_name = ctx.kwargs.get("role", None)
                if isinstance(role_name, str):
                    roles = await get_role(role_name=role_name)
                    role = roles[0] if roles else None
                    if role:
                        await self.add(
                            ctx,
                            member=ctx.kwargs["member"],
                            role=role,
                            reason=ctx.kwargs.get("reason", None),
                        )
sage tendon
#

well, i guess

fresh sierra
#

well

#

the decorator is not triggered

sage tendon
#

honestly your bot is so hard to debug because you have so much custom shit going on

#

like @add.error is just not a thing

fresh sierra
fresh sierra
#

but i might have an idea

sage tendon
#

its yet another of your custom things

#

that make it impossible for an outsider to help with your bot

edgy nest
red mist
#

How can I safely test out an oauth application?

I dont wanna get rate limited by discord which makes them force me to verify my account, because they suspect me of potentional spam.
(once verified I cannot unverify myself or my account would be useless)

sage tendon
fresh sierra
#

...

edgy nest
sage tendon
little cobalt
edgy nest
fresh sierra
#

its add becasue my command is name add...

#

its about the command name like @loop.error etc etc

edgy nest
#

what are you trying to do luma?

sage tendon
#

bruh since when do fucking per-command error handlers exist
that is so stupid

edgy nest
#

since we released app commands

#

cry about it

fresh sierra
#

/ addrole @fresh sierra roleobject
+addrole @fresh sierra str

#

so here i will handle the error of a bad arg

edgy nest
#

is this a slash command or

fresh sierra
#

to then check if its an str

fresh sierra
sage tendon
#

🤓

edgy nest
fresh sierra
sage tendon
#

they want to fuzzy match too

fresh sierra
#

but i think i know why my error is not trigger

edgy nest
#

so you want to reinvoke the command

fresh sierra
#

yes but ig the code is good

    @add.error
    async def on_hybrid_command_error(
        self, ctx: LumabotContext, error: discord.DiscordException
    ):
        if isinstance(error, commands.RoleNotFound):
            if not ctx.is_app:
                role_name = ctx.kwargs.get("role", None)
                if isinstance(role_name, str):
                    roles = await get_role(role_name=role_name)
                    role = roles[0] if roles else None
                    if role:
                        await self.add(
                            ctx,
                            member=ctx.kwargs["member"],
                            role=role,
                            reason=ctx.kwargs.get("reason", None),
                        )
        raise error
edgy nest
#

you could write a custom converter

fresh sierra
#

just my custom bridge does not trigger something

fresh sierra
edgy nest
#

idk about that one

sage tendon
#

you are using the wrong event

#

it's on_bridge_command_error

edgy nest
#

that's not getting triggered

#

toothy

sage tendon
edgy nest
#

can you just shut the fuck up

#

please

sage tendon
#

sorry for pointing out errors??

edgy nest
#

that's not an error

#

that's correct

#

the name does not matter

fresh sierra
# edgy nest wdym

i overwrite the invoke thing, so ig inside it should have something to trigger the decortor of the error

sage tendon
#

no reason to be rude then

fresh sierra
#
    async def invoke(self, ctx: LumabotPrefixContext):
        if ctx.command is not None:
            self.dispatch("hybrid_command", ctx)
            try:
                if await self.can_run(ctx, call_once=True):
                    await ctx.command.invoke(ctx)
                else:
                    raise discord.errors.CheckFailure(
                        "The global check once functions failed."
                    )
            except commands.errors.CommandError as exc:
                if DEBUG_MODE:
                    await ctx.command.dispatch_error(ctx, exc)
                self.dispatch("hybrid_command_error", ctx, exc)
            else:
                self.dispatch("hybrid_command_completion", ctx)
        elif ctx.invoked_with:
            exc = commands.errors.CommandNotFound(
                f'Command "{ctx.invoked_with}" is not found'
            )
            self.dispatch("hybrid_command_error", ctx, exc)
sage tendon
#

if i said that to you you'd prolly be pissed and mute me

#

but whatever, have fun debugging luma's custom mess of a bot

edgy nest
fresh sierra
#

and i have seen that with the event rn it trigger sometime the bridge event and sometime not

#

so i made my own that is trigger everytime

edgy nest
#

so your command error handler isn't getting called properly?

fresh sierra
#

the decorator is not triggered at all

edgy nest
#

one sec

edgy nest
#

what class is it in

fresh sierra
#

commands.Bot

edgy nest
#

so dispatch_error is the method that calls the command error handlers

#

and it looks like you've stopped it from calling unless you have your debug mode enabled

fresh sierra
#

let me try with debug enable, i was thinking about that

#

nope it still not triggering

#

but its raising the error inside the terminal

#

in addition as my dispatch

edgy nest
#

can you just take out the debug mode check entirely

fresh sierra
#

no wait

#

i will just try something and then remove it

edgy nest
#

oh

#

it is calling now

#

:3

fresh sierra
#

yes

#

it was it

edgy nest
#

now you just need to handle it properly

fresh sierra
#

is there a way to handle that for it does trigger the decorator but not print inside the terminal ?

edgy nest
#

take out the raise at the end

fresh sierra
edgy nest
#

wdym

fresh sierra
#

it does both like so

edgy nest
#

just override the default command error handler

fresh sierra
#

so i mean if it dispatch to the hybrid_command_error so it does not

edgy nest
#

on_command_error

fresh sierra
#

inside the discord.Bot ?

edgy nest
#

just adding a listener for it works

fresh sierra
#

i will try because in my memory it was not

#

like it was working for some and not for other

#

(prefix or slash)

#

might be because of my custom invoke

edgy nest
#

yeah just add an on_command_error listener and have it just ignore errors

fresh sierra
#

it is working

edgy nest
#

app commands do the same thing unless you have their error handler as well

#

you need help with anything else?

fresh sierra
#

thanks you about that it really help and made me learned new things

edgy nest
#

👍

#

glad I could help

#

im gonna go apologize to toothy now

fresh sierra
#

maybe a last thing:

#
    @add.error
    async def on_hybrid_command_error(
        self, ctx: LumabotContext, error: discord.DiscordException
    ):
        logger.log(ctx.message.content)
        logger.log(ctx.kwargs)
#

return

#

2024-08-14 18:25:21 [LOG] : +role add @fresh sierra member
2024-08-14 18:25:21 [LOG] : {}

#

but

edgy nest
#

because you're not using kwargs

#

you're using args

fresh sierra
#

i forgot i did *, for the debug eval...

#

Dumb thing, thanks for pointing it

#

this does not contain the role attr, is that because it was the wrong typehint and so it raise an error ?

    @add.error
    async def on_hybrid_command_error(
        self, ctx: LumabotContext, error: discord.DiscordException
    ):
        for arg in ctx.args:
            logger.log(arg)
#
2024-08-14 18:42:18 [LOG] : <Slashs.Role.add.RoleAdd object at 0x7fe0bf62d950>
2024-08-14 18:42:18 [LOG] : <Utils.client.LumabotPrefixContext object at 0x7fe0bfc9c090>
2024-08-14 18:42:18 [LOG] : ghostfrost___ (!! 𝓰𝓱𝓸𝓼𝓽𝓯𝓻𝓸𝓼t)
edgy nest
#

it would've stopped parsing arts there so

#

args*

fresh sierra
#

okay i will handle that diferetnly

edgy nest
#

the RoleNotFound class should have an attr with the thing it got for the argument

#

you can use that

fresh sierra
#

true it will be way more easier

#

i forgot that

edgy nest
#

error.argument

fresh sierra
#

thanks

#

still an issue:

                        return await self.add.invoke(
                            ctx,
                            member=ctx.args[2],
                            role=role,
                            reason=ctx.kwargs.get("reason", None),
                        )
        raise error
#

File "/home/container/.local/lib/python3.11/site-packages/discord/ext/commands/core.py", line 610, in transform
raise MissingRequiredArgument(param)
discord.ext.commands.errors.MissingRequiredArgument: ctx is a required argument that is missing.

#

do i have to handle it differently ?

errant trout
#

why not just call add directly

fresh sierra
#

also tried to edit the ctx.arg but then give me member is missing

errant trout
#

wtf did you do to your command because normally it is lol

sage tendon
#

How is it not callable lol
at its base its just a function

errant trout
#

how about ctx.invoke instead?

fresh sierra
errant trout
#

hm if it's bridge... try calling add.slash_variant

#

or ext_variant idk what you're doing

fresh sierra
#

i tried and here the thing :

  return await self.add.ext_variant(
      ctx,
      member=ctx.args[2],
      role=role,
      reason=ctx.kwargs.get("reason", None),
  )
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: RoleAdd.add() missing 1 required positional argument: 'ctx'
errant trout
#

eh

fresh sierra
#

and with invoke it only take the ctx parameter

#

i could try to edit it

errant trout
#

what happens if you add another argument before ctx

#

just make it anything

fresh sierra
#

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: Command.invoke() got an unexpected keyword argument 'member'

#

mhhh

#

last time it was saying role add has not attribute.is_app

#

so it mean now i might be able to just edit the ctx

opal swan
#

(sry for ping and i'm not a good dev so I can't help u)

opal swan
fresh sierra
#

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: Command.invoke() takes 2 positional arguments but 3 were given

fresh sierra
fresh sierra
opal swan
#

ahhh it mean don't worry 😂

sage tendon
#

no, its one too much

opal swan
#

1 not optional arg imo

fresh sierra
#

yeah but thats the thing

#

i didnt not forget anything ;)

opal swan
#

weird fr

fresh sierra
#

if i remove the self ctx is not passed and else it raise that error

errant trout
#

slash_variant works fine, for ext_variant just pass ctx twice

fresh sierra
#
  ctx.args.append(role)
  ctx.kwargs["reason"] = ctx.message.content.split(role_name)[1]
  for arg in ctx.args:
      logger.log(arg)
  logger.log(ctx.kwargs)
  if role:
      return await self.add.ext_variant.invoke(self, ctx)
fresh sierra
errant trout
#

nah just do ext_variant(ctx, ctx)

sage tendon
#

why is that

fresh sierra
errant trout
#

idk the library handles invokes normally, i can't be bothered to look into it properly when circumventing the normal usage

fresh sierra
#

return await self.add.ext_variant.invoke(ctx, ctx)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Command.invoke() takes 2 positional arguments but 3 were given

errant trout
#

not invoke

fresh sierra
#

finally

opal swan
fresh sierra
#

ngl thanks u so much nelo without u i will have to pass 1000 years on that

#

fix it by diong:

  return await self.add.ext_variant(
      ctx,
      ctx,
      member=ctx.args[2],
      role=role,
      reason=ctx.message.content.split(role_name)[1],
  )
opal swan
fresh sierra
#

well i will later find a fix for that decorator does not also trigger my custom dispatch cos i gotta go

#

thanks again nelo and plun for that

errant trout
#

im fairly sure there's a better way of doing it but yeah that works lol, the first arg is always ignored

#

which is odd because calling prefix commands normally works fine

#

slash_variant also works fine, i guess ext_variant is wrapped differently

dense summit
sage tendon
#

my god

dense summit
sage tendon
#

well, this discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction error most usually happens if you take longer than 3s to respond

#

you can fix it by deferring the interaction

dense summit
sage tendon
#

it's await interaction.response.defer()

#

ideally as the first line

dense summit
#

and the response: await interaction.response.send_message() ?

sage tendon
#

it might be followup.send_message, not sure rn

dense summit
#

none of these two worked:
await interaction.followup.send_message()
await interaction.response.send_message()

echo wraith
sage tendon
#

oh neat

#

didnt know that

rugged lodgeBOT
sage tendon
#

ah dang i thought about that but wasnt sure

#

but ig it makes sense, you cant followup a modal

deft kestrel
#

if the bot cant send a message what exception is that?

lofty parcel
sage tendon
#

methods that can throw exceptions will list these on the docs with a description

stoic patio
#

how do i get the user who got kicked through a discord.AuditLogEntry whose action is AuditLogAction.kick? the target attribute seems to be None, and my member caching is turned on

opal swan
#
activities = member.activities

if acitivties == discord.Spotify:
     albulm = activities.album

is it right ?

sage tendon
#

No

#

check the docs on Member.activities please

opal swan
#

but idk how it work

sage tendon
#

the return type is a tuple

opal swan
#

IK

sage tendon
#

so iterate over the tuple

lofty parcel
# opal swan IK

You kinda don't know if you're quite literally comparing a tuple with discord.Spotify

sage tendon
opal swan
#

ty

lofty parcel
sage tendon
#

use google

#

you wont come far without google as a developer

lofty parcel
#

A tuple is a basic concept...

opal swan
#

Tuple items are indexed, the first item has index [0], the second item has index [1] etc.

#

i'm stupid I forgot it

lofty parcel
#

Yes? But you have to iterate over the tuple to find the spotify activity

sage tendon
#

if you're fancy you can even use any()

opal swan
#

in fact i'm stupid

#

I need to fix that after

deft kestrel
#

So, how can I remove add app button

sage tendon
#

remove the install link in the dev portal

#

This, in the "installation" tab

deft kestrel
#

Thanks

brave ice
#

sometimes my discord bot just randomly disconnects and wont turn on again in discord until i restart

is there some fix for this? so it auto reconnects or stop it from happening

little cobalt
brave ice
little cobalt
#

like requests

brave ice
#

all api calls are async

little cobalt
#

or sqlite3

sage tendon
#

Do you get any error in the console?

brave ice
#

database is also async using asyncpg

fresh sierra
#

pillow

brave ice
#

actually it might be windows fucking i see theres a thing selected in the cmd

#

it stops all execution hten

#

that might be it

#

no errors in the console

#

yeah def was that

#

my bad

hoary plank
#

How can I get the number of users who have installed my bot using Pycord?
I only know that I can use len(bot.guilds) to get the number of guilds where my bot has joined.

stoic patio
#

len(bot.users) i think

hoary plank
#

but that is the total number of users that in all guilds

sage tendon
#

do you mean user installs specifically?

hoary plank
#

yes

sage tendon
#

That was [just](#discord-api-updates message) added to the API and will likely be in pycord in 2.7

hoary plank
#

oh! I see.
Thanks for the response!

sage tendon
#

until then you can check the discord dev page

shell radish
sage tendon
#

figured they'd push the update message once they, like, update

shell radish
#

and the pr should be merged soon, just waiting for the green light from one of the core devs

unkempt cipher
#

imagine not learning lol

sage tendon
#

lol

little cobalt
little cobalt
#

lol

oblique sable
#

typed it like this but its a slash command, ig thats why xd

little cobalt
#

?

oblique sable
#

uhm

#

yeah

#

weird

#

double checked and its good

#

channel = (await ctx.channel()).name
TypeError: 'TextChannel' object is not callable

#

why is it typed as a method though

sage tendon
#

please use the docs lol

oblique sable
#

what

sage tendon
#

intellisense can be misleading

oblique sable
#

i mean i know how to do iit

#

but it just feels wrong xd

sage tendon
#

why?

#

it makes perfect sense

oblique sable
#

because here channel is typed as a method

sage tendon
#

it doesn't make any sense to try to call a channel object

sage tendon
#

again, use the docs, intellisense can be misleading

oblique sable
#

i know how to make it work, just thought you guys had an idea on why it was typed weiirdly

#

but yeah

sage tendon
#

go to the definition and check what it does

real glacier
#

any doc where it can guides me about slash cmd options or sub group command?

shell radish
fresh sierra
#

Install a previous version

#

And it will fix the typehint

sage tendon
oblique sable
#

i actually think its because its a property method

fresh sierra
oblique sable
#

which doesnt have to be called

#

i think

sage tendon
fresh sierra
#

Just use another version of pulange

#

And it will fix it

sage tendon
#

Luma, the suggestion is correct.

fresh sierra
#

Like one of a month ago or something like so

#

And u will get back all of the autocomplete etc

sage tendon
#

Luma

oblique sable
#

i think older versions of pylance could type property methods as a variable and not as a method, because i remember before it wasnt like that

fresh sierra
#

It’s since the new release

#

Got the same thing and tbf it’s pretty annoying cos all of the autocomplete goes crazy

opal swan
#

how to transform ctx.author.avatar.url into a byte (for await ctx.guild.create_webhook method)

fresh sierra
#

Cos some author has no avatar etc

opal swan
#

alr tysm

sage tendon
opal swan
#

let's try it

fresh sierra
#

And then for the display_avatar u have an arg.read() normally that converge to byte

opal swan
fresh sierra
#

It is a corotine

opal swan
fresh sierra
#

But for exemple member.avatar will return none if the doesn’t have any

#

Display_avatar will return his default avatar

opal swan
sage tendon
opal swan
#

bcs it didn't say it return asset

sage tendon
#

Member.avatar returns Asset

#

and display_avatar does too
its not really a bug that it doesnt directly say the return type, ig its just missing

opal swan
deft kestrel
#

where can i find list of events i can use? cat

little cobalt
sage tendon
#

that looks to be it doesnt it

errant trout
#

(click "the regular events" near the top)

little cobalt
deft kestrel
errant trout
#

congratulations

deft kestrel
#

great, thanks

sage tendon
#

oh i didnt realise it was the wrong one mb

deft kestrel
#

i couldnt find an event if you kick the bot out of voice channel

sage tendon
deft kestrel
#

what should i write next to event

@cli.listen("on_voice_state_update",False)
async def left(event:Member):
    print(event)
deft kestrel
fresh sierra
#

i dont understand what it mean

deft kestrel
fresh sierra
#

.rtfm on_voice_state_update

kindred lava
#
async def autopublisher(self, ctx: discord.ApplicationContext,
                            action: discord.Option(str, ":rocket: • Wähle 'on' zum Aktivieren oder 'off' zum Deaktivieren",
                                                   choices=["on", "off"]),
                            channel: discord.Option(discord.TextChannel, ":rocket: • Wähle einen Kanal", required=False)):```
sage tendon
#

in the option, do channel_types=[discord.ChannelType.news]

#

wait its not completely correct 1s

kindred lava
sage tendon
#

ChannelType* singular

#

there

kindred lava
#

Can you change it here?

async def autopublisher(self, ctx: discord.ApplicationContext,
                            action: discord.Option(str, ":rocket: • Wähle 'on' zum Aktivieren oder 'off' zum Deaktivieren",
                                                   choices=["on", "off"]),
                            channel: discord.Option(discord.TextChannel, ":rocket: • Wähle einen Kanal", required=False)):```
sage tendon
#

just put what i sent it in the channel option instead of discord.TextChannel

kindred lava
#

ok

sage tendon
#

actually after, since its a kwarg

#

after the description

#

but you can still remove the discord.TextChannel

#
async def autopublisher(self, ctx: discord.ApplicationContext,
                            action: discord.Option(str, ":rocket: • Wähle 'on' zum Aktivieren oder 'off' zum Deaktivieren",
                                                   choices=["on", "off"]),
                            channel: discord.Option(":rocket: • Wähle einen Kanal", channel_types=[discord.ChannelType.news], required=False)):
#

here

kindred lava
kindred lava
sage tendon
#

what

sage tendon
kindred lava
sage tendon
#

show the channel you're trying to use it on in the channel list

sage tendon
#

hm

#

does the bot have access to see those

kindred lava
kindred lava
sage tendon
kindred lava
sage tendon
#

(your own discord)

kindred lava
kindred lava
sage tendon
#

can you show your code as is rn

kindred lava
#

@sage tendon

sage tendon
#

hm
try re-add discord.TextChannel to the option

kindred lava
sage tendon
#

you still have channel_types right

kindred lava
sage tendon
#

yea duh... i never told you to remove that

kindred lava
kindred lava
# sage tendon yea duh... i never told you to remove that
    async def autopublisher(self, ctx: discord.ApplicationContext,
                            action: discord.Option(str,
                                                   ":rocket: • Wähle 'on' zum Aktivieren oder 'off' zum Deaktivieren",
                                                   choices=["on", "off"]),
                            channel: discord.Option(discord.TextChannel(channel_types=[discord.ChannelType.news]), required=False)):```
sage tendon
#

no

kindred lava
#

like this?

sage tendon
#
async def autopublisher(self, ctx: discord.ApplicationContext,
                            action: discord.Option(str, ":rocket: • Wähle 'on' zum Aktivieren oder 'off' zum Deaktivieren",
                                                   choices=["on", "off"]),
                            channel: discord.Option(discord.TextChannel, ":rocket: • Wähle einen Kanal", channel_types=[discord.ChannelType.news], required=False)):
kindred lava
#

Thanks

shadow sigil
#

hello, i'm having the issue of

#

it responds to commands fine

#

however,

[2024-08-16 01:19:27] [WARNING ] discord.gateway: Can't keep up, shard ID None websocket is 149.0s behind.
[2024-08-16 01:19:29] [WARNING ] discord.gateway: Shard ID None heartbeat blocked for more than 110 seconds.
sage tendon
#

do you have any long operations going on in your bot

#

or something new you added since it, well, didn't do that

shadow sigil
#

not any that i'm aware of

sage tendon
#

oh wait you said it responds to commands fine, hm

#

might just be a minor discord issue then

#

I'd say wait a little and see if it still happens

fresh sierra
#

usually its because of a blocking fonction

#

can be pillow, sqlite3, a def function etc etc

errant trout
#

heartbeat blocked is usually your code's fault yeah

sage tendon
#

but wouldn't that also block commands?

fresh sierra
#

if you do +ping -> code blocking -> result of +ping

#

it can explain both ig (big ping + warning)

#

ik i got that issue a lot cos rn my bot has a sync db but command still work, sometime just have a big delay

shadow sigil
#

i can just run the bot and it does it

fresh sierra
#

you code might run a blocking thing

shadow sigil
#

also, any command that i use gives a response pretty much immediately

fresh sierra
#

.tag paste

sly karmaBOT
#

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

fresh sierra
#

if you want put all ur thing here

#

it will be easier for us to find the issue

#

(make sure to remove token)

shadow sigil
#

okay

#

(also it's apparently both 1280 and 260 seconds behind right now)

#

...actually that's just the heartbeat

fresh sierra
#

cos something might block it

shadow sigil
fresh sierra
#

all since we dont know which part can cos that

#

just before

#

send pip list

#

it might give us a quick answer

shadow sigil
#
Package            Version
------------------ --------
aiohappyeyeballs   2.3.4
aiohttp            3.10.3
aiosignal          1.3.1
attrs              23.2.0
certifi            2024.7.4
charset-normalizer 3.3.2
frozenlist         1.4.1
idna               3.7
multidict          6.0.5
pillow             10.4.0
pip                24.2
py-cord            2.6.0
python-dotenv      1.0.1
requests           2.32.3
ruff               0.5.5
urllib3            2.2.2
yarl               1.9.4
fresh sierra
#

pillow 10.4.0

#

requests 2.32.3

#

both of them are blocking

#

are you using them inside ur code ?

shadow sigil
#

i'm not using requests at all