#Basic Pycord Help

1 messages · Page 58 of 1

meager token
#

lol

fresh sierra
#

if they remove the usage its normal

sage tendon
#

I think what's going on is that you lack permission to use and thus see the command, but your client still shows it (because of cache)

#

so a restart should fix it

#

is it a user app, btw? or a guild installed one

fresh sierra
#

maybe app command still show if the channel has an overwrite

sage tendon
#

yea i know

#

app commands on desktop are still buggy

#

@meager token can you try the same thing on mobile?

meager token
#

and it worked fine

sage tendon
meager token
#

my phones still starting

sage tendon
#

lol

ivory wind
#

thanks!

sage tendon
#

weird

#

are you the server owner?

meager token
#

no but I have admin

#

im the owner of the other server though

sage tendon
#

hm, then you should be able to use any command regardless

#

can you try clearing your custom role permission for that command and re-set it?

meager token
sage tendon
#

ah

#

why do you not use the discord-native way?

meager token
#

cuz I didnt know it existed

#

and now im stuck with py c = bot.get_channel(1231437560790781962) c.send(content="test") where c is allways none even though teh channel exists and the bot can see it

#

lol

sage tendon
#

where do you call that

meager token
sage tendon
#

what are your intents?

meager token
#

.all()

sage tendon
#

and if you view the server via the bot's role, you can see it?

#

doesnt matter for now, if the get returns none

#

but yea

sly karmaBOT
# meager token and now im stuck with ```py c = bot.get_channel(1231437560790781962) c.send(...

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 token
#

oh cache

sage tendon
#

Generally you should be able to rely on the cache having all channels in it

meager token
#

I found fetch_channel but it gives me a malloc error

sage tendon
#

yea because you arent awaiting it

#

like your send

#

fetches are API actions and need to be awaited

#

but your get still shouldnt return none if you didnt mess with cache and your bot can definitely see the channel

meager token
#

oh shit the bot has no role

#

wtf

#

how am I usign it then

sage tendon
#

probably didnt tick the right box then when making the invite link

meager token
#

I add it to the guild and others can use it??

sage tendon
#

just what i said

#

you need these scopes

#

(for normal bots)

meager token
#

oh

#

i was confused asf by that

#

why is discord making things so weird

sage tendon
#

its really not weird

#

its basic scoping

#

there are a lot more apps than bots you can make on discord

#

as you can tell by the sheer amount of scopes

meager token
#

everything works now I think thankyou

sage tendon
#

np

fresh sierra
#

does someone else have some audit log issue ?

#

some of my listener about on_raw_audit_log_entry will not get trigger in some cog

#

found why i think the on_raw_audit_log_entry will not get trigger when its updating the raw audit log

#

how can i get the update of an audit log entry

#

for exemple when a member disconnect a member it will just update the count of the number of disconnected member

sage tendon
#

not sure if you can get updates of an existing entry

fresh sierra
#

if we cant that stupid...

#

audit log are stupid in a lot of way

#

not giving all info etc

sage tendon
#

i mean, role assignments by bots arent even logged anymore

fresh sierra
#

what ????

sage tendon
#

try it :)

fresh sierra
#

is that a bug or a new feature ?

sage tendon
#

my guess is as good as yours

fresh sierra
#

i still get them

sage tendon
#

hm then it's limited to some conditions

#

but i've noticed it and there's been other people here complaining about it

fresh sierra
#

does the addrole and the edit member are under the same route ?

sage tendon
#

no idea

#

should be tho

fresh sierra
#

add role doesnt trigger the audit log

#

edit member trigger the audit log

#

i hope it will come back

errant trout
#

discord is already aware

sage tendon
#

they are aware of a lot of bugs judging by their responses to bug reports

#

but that, from my experience, means you cant expect a fix

fresh sierra
errant trout
#

idk what fucked up client you have to have disasterous bugs every day but api stuff is handled very differently

sage tendon
#

No, the bugs i report are persistent across literally all branches, on desktop and web

#

i test my shit before i bug report

errant trout
#

damn that's crazy apensive

sage tendon
#

its just that i have a natural skill for finding bugs in every program i use

#

and yea, not sure if i ever reported an API issue

#

but the client team is complete shit

arctic plover
#

I have a problem that after a while the button stops working. The bot does not restart, it happens after 5-15 minutes. The timeout is set to None, and no errors appear in the console either. Just Interaction failed

sage tendon
#

i think views need to be persistent to react after that long

arctic plover
lapis dock
#

For a view to be persistent all buttons/selects need to have a custom_id as well as setting timeout to None
The custom_id is automatically set unless you are doing somthing weird though.
You should not need to use add_view unless the bot restarts

#

Is the view in a ephemeral message? Also can you post the full error

arctic plover
#

nah stop, If I restart the bot, they will be added via bot.add_view(), and they work again for a while, and then they stop again

#

button has custom_id and timeout is set to None

arctic plover
arctic plover
#

all that i see is Interaction failed

arctic plover
sage tendon
#

can you show the code of your view, at least the vital bits

lapis dock
#

^ this
and It seems like you have some error handling that is eating some of the important information

arctic plover
arctic plover
sage tendon
#

so the button has no function? lol

arctic plover
#

callback function .-.

lapis dock
#

But you are creating a new Button object in the view args

sage tendon
arctic plover
#

Button() is my class

sage tendon
#

yea you also shouldn't shadow built-in names

arctic plover
#

I wrote it as an example

#

it has another name

sage tendon
#

please just show your actual code

meager token
#

is there no bot.fetch_message? the cache is for some reason to unreliable for me

#

it says there isnt a bot.fetch_message

little cobalt
#

.tag 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:")
little cobalt
#

that could also help

lapis dock
#

Note that you can get a full message from a partial channel.
You can use a normal channel if you already have it as well. You just need to call it off a channel object instead of a bot object

full ore
sage tendon
#

that is one complicated starting sequence

lapis dock
#

Make sure you are not starting the same bot 2 times. IE if you have it deployed and running on your PC

full ore
lapis dock
#

what command are you running that does this?

full ore
#

With each command, this happens

loud kayak
#

why tf cant i do this. discord.ui.button takes no argument url

class AdvertisementButtons(discord.ui.View):
  def __init__(self, bot):
    self.bot = bot

  @discord.ui.button(label="Invite PartnerPal", style=discord.ButtonStyle.link, url="https://partnerpal.nziie.xyz/invite")
  async def invite_button(self, button, interaction):
    return
  
  @discord.ui.button(label="Report", style=discord.ButtonStyle.red, custom_id="REPORTSERVERBUTTON")
  async def report_server_button_callback(self, button, interaction):
    await interaction.response.defer(ephemeral=True, invisible=False)
    await interaction.followup.send("Coming soon.", ephemeral=True)
lofty parcel
#

Cause link buttons don't have a callback

#

I do admit we could just make it ignore the callback at all

loud kayak
#

I tried doing self.add_item after super().__init__ but it doesn’t always show up

lofty parcel
#

Instance a Button instead and add it manually

#

Wdym it doesn't show up

fresh sierra
#

does anyone bot.description return None even if its not None ?

sage tendon
#

like, the about me?

fresh sierra
#

even if bot doesnt really have an about me but its located in the same place

sage tendon
#

is this filled in your bot?

#

(dev portal)

fresh sierra
#

because im able to edit it without issue but the bot.description is still None

#

yeah

sage tendon
#

ah

fresh sierra
#

and i didnt edit it through a command for that bot so its just a pycord/api issue

sage tendon
#

well id help but the doc search is literally broken

fresh sierra
fresh sierra
#

maybe they forgot, before it was summary i think

sage tendon
#

yea but the doc search is just broken 100% for me

fresh sierra
shell radish
#

oh i'm smart. I deprecated it without actually implementing it

sage tendon
#

lmfao

#

the QC on this guy

shell radish
#

oh wait it is tehre

#

because i remember i tested for this

#

yeah probably something with the api

#

it's returning the correct value for me

fresh sierra
#

or you are using something else

#

because for me bot.description return None

fresh sierra
#

does appinfo and bot are the same ?

edgy nest
#

no

fresh sierra
#

maybe why

#

how can i get the bot description ?

edgy nest
#

the Bot's 'description' is the docstring attached to the class

fresh sierra
#

bot.description return None even if my bot has a description visible

edgy nest
#

Client.application_info

edgy nest
fresh sierra
fresh sierra
#

for you know

sage tendon
#

ok

round heart
#

Nope. I always figured it was an aio loop thing; I've got a couple of different things hooking into it (db, 20 different non-Discord websocket connections)

quiet siren
#

I feel like an idiot rn, but how the hell do i get sentry to works properly with pycord? I tried using the sentry sdk as well as the discord-sentry-reporting package, didn't work, in the code i tried to override the on_application_command_error and on_error but they didn't help either, none of the exception are reaching Sentry

sly karmaBOT
#

In asynchronous programming a blocking call is essentially all the parts of the function that are not await. Do not despair however, because not all forms of blocking are bad! Using blocking calls is inevitable, but you must work to make sure that you don’t excessively block functions. Remember, if you block for too long then your bot will freeze since it has not stopped the function’s execution at that point to do other things.

A common source of blocking for too long is something like time.sleep(). Don’t do that. Use asyncio.sleep() instead. Similar to this example:

# bad
time.sleep(10)

# good
await asyncio.sleep(10)

Read more

echo wraith
#

Just an idea idk if it's actually that

quiet siren
#

Unlikely, I'm already doing test commands to raise the exception, as well as print() ing a message in log after the sentry capture_exception line is run, but sentry's side is not getting anything

#

That's what's making me confused

echo wraith
quiet siren
#

@bot.event
async def on_application_command_error(ctx: discord.ApplicationContext, error):
    #send the error to sentry
    sentry_sdk.capture_exception(error)
    print("Error occured in on_application_command_error, sending to sentry")
    raise error

@bot.event
async def on_error(event, *args, **kwargs):
    #send the error to sentry
    sentry_sdk.capture_exception(sys.exc_info())
    print("Error trigged in on_error, sending to sentry and rasing")
    raise
#

and command to raise that error is

#
@bot.slash_command()
async def crashtest(ctx: discord.ApplicationContext):
    if ctx.author.id != 419742289188093952:
        await ctx.respond("You don't have permission to use this command")
        return
    await ctx.respond("Crash Test", ephemeral=True)
    raise Exception("Crash Test")

echo wraith
quiet siren
#

I'll.. presume it'll just print, once again?

#

the print command works

echo wraith
sly karmaBOT
#

Tag not found.

quiet siren
#

ah no no

#

So the print command afterwards run just fine

echo wraith
quiet siren
#

reading then

#

..

#

okay i feel like an idiot there

#

of course there's an asyncio integration

echo wraith
quiet siren
#

might as well try

echo wraith
quiet siren
#

Doesn't seem to work...

#

I don't see an event fired on sentry

#

Where should I init sentry at, actually

echo wraith
echo wraith
quiet siren
#

should i just init at the start of the program or on on_ready

echo wraith
echo wraith
#

sentry_sdk.capture_yadayada(ValueError("AAAAAA")) in the crashtest command itself

quiet siren
#

uh, sure.. let me try that

echo wraith
quiet siren
#

Hm.. nothing

#

@bot.slash_command()
async def crashtest(ctx: discord.ApplicationContext):
    if ctx.author.id != 419742289188093952:
        await ctx.respond("You don't have permission to use this command")
        return
    await ctx.respond("Crash Test", ephemeral=True)
    sentry_sdk.capture_exception(ValueError("Crash Test From Within The Function"))
    raise Exception("Crash Test")


@bot.event
async def on_application_command_error(ctx: discord.ApplicationContext, error):
    #send the error to sentry
    sentry_sdk.capture_exception(error)
    print("Error occured in on_application_command_error, sending to sentry")
    raise error

@bot.event
async def on_error(event, *args, **kwargs):
    #send the error to sentry
    sentry_sdk.capture_exception(sys.exc_info())
    print("Error trigged in on_error, sending to sentry and rasing")
    raise

#

it's now this but

#

nothing either

echo wraith
quiet siren
#

it shows up on sentry

echo wraith
#

Maybe delete that

quiet siren
#

Ah, don't worry about the personal info part

#

It's a self hosted test env

echo wraith
#

Ok I don't really know how save that has to be

quiet siren
#

everything can be swapped out at a click of a button

#

but, yea..

#

I'm so confused..

#

It's definitely possible too.. I've seen a few msg in this server talking about using Sentry

echo wraith
#

That might need to use some debugger to see what's happening. Just one last thing, try this around the sentry capture thing

#

.tag rie

sly karmaBOT
#

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

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

quiet siren
#

I actually also tested that with an eval command that runs in a second executor

#

well..

#

didn't send either

#

wait actually no

echo wraith
quiet siren
#

the eval didn't use second executor

sage tendon
#

why would synchronously executed code be the issue, just wondering

#

or is it timing out somewhere

#

(i didnt read this in huge detail)

quiet siren
#

it's just

    fn_name = "_eval_expr"
    try:
        cmd = cmd.strip("` ")

        # add a layer of indentation
        cmd = "\n".join(f"    {i}" for i in cmd.splitlines())

        # wrap in async def body
        body = f"async def {fn_name}():\n{cmd}"
        parsed = parse(body)
        body = parsed.body[0].body
        insert_returns(body)
        env = {
            'bot': botobject,
            'discord': discordobj,
            'commands': commandsobj,
            'ctx': ctxobj,
            '__import__': __import__
        }
        exec(compile(parsed, filename="<ast>", mode="exec"), env)
        result = (await eval(f"{fn_name}()", env))
    except:
        result = format_exc()

    # convert result from binary to string
    if isinstance(result, bytes):
        result = result.decode("utf-8")

    return result
#

so

#

I'll try the second one ig

little cobalt
#

what is that?

echo wraith
#

From some random thing I saw online, sentry Spawn a thread by itself so it might be hiding the errors it runs in.

echo wraith
echo wraith
echo wraith
echo wraith
quiet siren
#

hm.. nothing

#

Print statements shows that the command did go though

#

I'll setup debug logging

#

okay that's a eff lot of logs

echo wraith
#

should work out of the box. Sentry spawns a background thread for sending outbound http requests. This generally works out fine regardless of whether your own code is async vs not. It is hard to tell whether this approach will have to change in the future, but if it will and we need specialized code for uvicorn, it will be part of a respective integration.

https://forum.sentry.io/t/does-sentry-honor-asynchronous-code-python-asyncio/14171

#

Also

quiet siren
#

well that explains a lot.

#

doesn't.. make much sense though

#

the sentry-cli on the same machine with the same credential and everything is sending though the event just fine

echo wraith
quiet siren
#

I.. can't seem to find where it'd be helpful for me rn

#

Since, isn't that the purpose of the asyncio integration?

quiet siren
#

Hm..

#

I have a feeling this have to do with the ipv6 networking..

#

will try something on that and report back

sage tendon
#

ipv6-only?

#

@quiet siren

quiet siren
#

ipv6 only.

#

well, the host is ipv4 and 6

#

but sentry is v6 only, (though it's also in front of cloudflare before but that didn't help)

#

There we go

#

I enabled ipv6 networking for the default network in docker and all is well now

#

thanks a lot for the help!

quiet siren
#

Definitely find it odd that Sentry does not raise any error for not being able to connect

echo wraith
quiet siren
#

Ye, I think it definitely is worth opening

quiet siren
#

the VPS itself only got it's own Dedicated ipv6, and a NATed ipv4 so

#

yea 😅

sage tendon
#

a hint of modernity in this utter ipv4 world with some DS sprinkled in

quiet siren
#

ipv4 addresses are not exactly cheap =[

sage tendon
#

lmfao imagine
here its the absolute default

quiet siren
#

I still find it slightly odd at one point though

quiet siren
#

the VPS is technically a proxmox VM

#

and the proxmox host only get 1 ipv4, and a /64 ipv6 block

#

extra ipv4 are like 5$

sage tendon
#

tf

quiet siren
#

per month

quiet siren
#

so it should be supported on both v4 and v6

#

so.. i don't know what happened there

#

I removed it off cloudflare to check if it's cloudflare itself blocking the request but

#

eh

stray pasture
#

Anybody knows how to solve the

Task was destroyed but it is pending!
task: <Task pending name='pycord: on_ready' coro=<Client._run_event() done, defined at D:\Documents\bot discord\timed_role\.venv\Lib\site-packages\discord\client.py:401> wait_for=<Future pending cb=[Task.task_wakeup()]>>

I remember seeing that as a GitHub issues at some point. I thought it got fix

#

upgrading from 2.6.0 to 2.6.1 fixed my issue 😄

fresh sierra
#

It will appear sometime and sometime not u can’t do really anything. It will need a thing in pycord to solve that

fresh sierra
#

except blocking code, is there any reason for that :
2024-10-08 06:13:44 [WARNING] : Can't keep up, shard ID 3 websocket is 10.1s behind.

vestal folio
#

is already implemented in the latest pycord dev version Soundboard

sage tendon
#

don't think bots can use soundboards

#

because they can already play whatever audio they want

fresh sierra
#

how can i get the current bot activity

jolly tundra
#

This is it working. When it doesn't the image in the embed doesn't load

#

@sage tendon

#

The image url and all is the same

#

Its there, discord just pretty much, ignores it?

lofty parcel
fresh sierra
#

I think it’s only the one that u pass in the client

jolly tundra
#

bot.activity no?

frail basin
lofty parcel
fresh sierra
fresh sierra
frail basin
#

You do for messages lol

fresh sierra
lofty parcel
#

Then just bot.activity

#

Ig

fresh sierra
fresh sierra
lofty parcel
#

Looks like bot.status and bot.activity don't change at all once the bot starts

sage tendon
jolly tundra
sage tendon
#

on mobile as well?

jolly tundra
#

Yeah

sage tendon
#

and you're 100% sure the link is always sent with the embed?

jolly tundra
#

On some rare instances, I saw the image appear for like, 0.2 seconds and then disappearing

unkempt cipher
jolly tundra
#

Its not bsky specific

#

Thats just an example

sage tendon
#

If anything it sounds like a client issue though

#

but usually those are limited to either mobile or desktop

jolly tundra
#

Its weird because if you try again it works

#

And its ONLY in DMs

#

The same command, which is a user install, if I use it anywhere else, that never happens

sage tendon
#

and its always on the second time that it works?

jolly tundra
#

Yeah, usually I delete the first response and try it again and it works

sage tendon
#

can you try not send an embed at all and just send the image link in the message content
to see if the image loads at all

violet star
#

how do i use user apps with pycord

#
 @commands.user_command(name="Test")
 async def user_bot_test(self, ctx, teststuff: str):
    await ctx.respond(teststuff)```
#

this wont work after i auth

sage tendon
sage tendon
violet star
#

explain please

sage tendon
#

user commands are commands that appear in a user's context menu

#

user apps are bots you add to your account

#

read the example i sent for how to use them

jolly tundra
#

Sometimes the embed works on the first try as well. Really weird.

sage tendon
violet star
sage tendon
violet star
sage tendon
#

that is quite an old version

#

update to the newest

lofty parcel
#

You're kinda supposed to update your library if you wanna use new features.

violet star
#

linux being wacky, it's not updating lul

lofty parcel
#

Linux is quite a thing

shell radish
#

did you add the upgrade flag?

violet star
#

it's pacman not apt

#

imma just do --break-system-packages on pip and forget about it

sage tendon
#

show the error
i have a suspicion

violet star
#

dw

#

it's just update bug

#

not showing now

#

k

#

now there's no error and no command

sage tendon
#

wdym "no command"

violet star
#

auth'd the bot

#

shows nothing

sage tendon
#

did you pass the integration type to the command?

violet star
lofty parcel
#

Did you load the cog

sage tendon
#

remove the context

violet star
#

yes

sage tendon
#

unless you only want that command to work in the bot's DMs which is pointless

#

or nvm, DMs at all, but still, try remove it to make sure there's no other issue

#

and restart discord when doing any changes to your commands

jolly tundra
fresh sierra
lapis dock
#

@ivory blaze Do you have the guild members intent?

ivory blaze
violet star
#

thx friendlies

violet star
#

what would be the equivalent of images: discord.Option(discord.Attachment, "Images to upload", required=True, max_length=10?

#

because AttributeError: Option does not take min_length or max_length if not of type str

sage tendon
#

not possible

#

one option, one value

violet star
#

huh

#

like what if i want is a list of discord.Attachement

sage tendon
#

cant

violet star
#

that's impossible?

sage tendon
#

thats what i just said yes

violet star
#

k

sage tendon
#

either do multiple options or accept a zip

lethal loom
#

When i press a button, i will get a user by id but idk

        await rating_sender(user, interaction.channel.id, interaction.guild.id, embed, view)```
#
    def __init__(self):
        super().__init__(
            label="Schließen",
            style=discord.enums.ButtonStyle.green,
            custom_id="interaction:ConfirmButton",
            emoji=":heavy_check_mark:"
        )

    async def callback(self, interaction: discord.Interaction):
        ...
        user: discord.User = self.client.fetch_user(ticket_open_from)
        await rating_sender(user, interaction.channel.id, interaction.guild.id, embed, view)

        await interaction.channel.delete()```
lethal loom
errant trout
#

also make sure the ID is an int

sage tendon
#

hasn't interaction.user been deprecated?

errant trout
sage tendon
#

huh
I've switched interaction.user over to interaction_metadata.user.id some time ago

#

mustve had a reason

errant trout
#

Tf

fresh sierra
#

my bot detect some blocking code around 3s, do you have any idea of thing that i should look around ?

lethal loom
echo wraith
#

send the code

echo wraith
# lethal loom .
class ConfirmButton(discord.ui.Button):
    def __init__(self, client):
        super().__init__(
            label="Schließen",
            style=discord.enums.ButtonStyle.green,
            custom_id="interaction:ConfirmButton",
            emoji=":heavy_check_mark:"
        )
        self.client = client
lethal loom
#

but now i need to give this to this class

echo wraith
#

You do ConfirmButton(client)

#

instead of ConfirmButton()

lethal loom
#

ok thx

#

Why when i rate on a button its delete the link button?

        view.add_item(TranscriptButton(f"x"))

        channel1 = self.bot.get_channel(data[0])
        await channel1.send(file=file, embed=embed, view=view)

        user: discord.User = self.bot.get_user(ticket_open_from)
        await rating_sender(user, ctx.channel.id, ctx.guild.id, embed, view)

        await ctx.channel.delete()

# Setup
def setup(bot):
    bot.add_cog(ticketsv2(bot))

async def rating_sender(user, channel, guild_id, embed, view):
    rating_view = RatingView(channel, guild_id)
    
    for item in rating_view.children:
        view.add_item(item)
        
    await user.send(embed=embed, view=view)
    
class RatingView(View):
    def __init__(self, channel, guild_id):
        super().__init__()
        self.channel = channel
        self.guild_id = guild_id

    @discord.ui.button(row=2, 
                       label="1",
                       style=discord.ButtonStyle.red,
                       emoji=":star:",
                       custom_id="rating_1")
    async def Rating1(self, button, interaction):
        await ticket_db.update_rating(1, self.guild_id, self.channel)
        self.disable_all_items()
        await interaction.edit(view=self)
        
    @discord.ui.button(row=2, 
                       label="2",
                       style=discord.ButtonStyle.red,
                       emoji=":star:",
                       custom_id="rating_2")
    async def Rating2(self, button, interaction):
        await ticket_db.update_rating(2, self.guild_id, self.channel)
        self.disable_all_items()
        await interaction.edit(view=self)
        
    @discord.ui.button(row=2, 
                       label="3",
                       style=discord.ButtonStyle.blurple,
                       emoji=":star:",
                       custom_id="rating_3")
    async def Rating3(self, button, interaction):
        await ticket_db.update_rating(3, self.guild_id, self.channel)
        self.disable_all_items()
        await interaction.edit(view=self)
        
    @discord.ui.button(row=2, 
                       label="4",
                       style=discord.ButtonStyle.green,
                       emoji=":star:",
                       custom_id="rating_4")
    async def Rating4(self, button, interaction):
        await ticket_db.update_rating(4, self.guild_id, self.channel)
        self.disable_all_items()
        await interaction.edit(view=self)
        
    @discord.ui.button(row=2, 
                       label="5",
                       style=discord.ButtonStyle.green,
                       emoji=":star:",
                       custom_id="rating_5")
    async def Rating5(self, button, interaction):
        await ticket_db.update_rating(5, self.guild_id, self.channel)
        self.disable_all_items()
        await interaction.edit(view=self)```
sage tendon
#

"rate on a button"?

#

i dont even see a link button in your code
and what is this..? why are you doing this?

#

if your transcriptbutton is the link button, then its deleted because in your RatingView, you edit the message's view to "self", which is your RatingView, and your RatingView doesnt have a link button in it

full ore
sage tendon
#

do you manually sync your commands anywhere

fresh sierra
full ore
sage tendon
#

does it happen to anyone else

full ore
#

I dont know anyone else they Programm Discord bots

sage tendon
#

just let them use your bots command once lol

#

anyone

full ore
#

Im from germany, no one Programm bots Here HAHAHAH

sage tendon
#

you just need someone else to use a command.

fresh sierra
#

and did you check if you only have 1 instance of that bot running, if there is many bot it can create conflit and remove them

full ore
full ore
fresh sierra
#

can you try with another bot, it with the other bot everything works fine we know that 2 instance might be running

sage tendon
#

i think its a client problem tbh

fresh sierra
#

well actually you can even start 2 directly from ur code

#

so might even with another token do it twitch

full ore
#

Ahhh u only run 1 bot but they run on multiple Servers

sage tendon
#

what

full ore
#

This my output

fresh sierra
fresh sierra
#

i will check if it disappear for me too

fresh sierra
#

it does the same for me

sage tendon
#

why are you setting debug guilds btw

#

why dont you let your commands sync globally naturally

fresh sierra
#

well i have no idea

full ore
sage tendon
#

why are you doing it?

edgy nest
#

because they want to

full ore
sage tendon
#

yea, but time and time again it leads to issues

sage tendon
full ore
sage tendon
#

your bot is only in those 2 guilds

#

so setting debug guilds is pointless

full ore
sage tendon
#

so you do manually sync them? or what

full ore
sage tendon
#

my bot is in 3 guilds with about 50 commands and starts in 4 seconds so idk why it would take long for you

#

and ~500 members

full ore
sage tendon
#

wtf

full ore
#

where i have to sync commands after on_ready or before ?

sage tendon
#

nowhere.

#

you do not do that manually unless you wanna run into issues

full ore
#

okay i will automatically

sage tendon
#

just remove the debug guilds and try if you still get the issue

full ore
#

okay i do

#

okay i do no i show you what happen... wait

#

ahh wait

#

"The Programm doesnt respond"

sage tendon
#

that error just means your bot never responds to the interaction

full ore
#

yeahh but whhyyy

sage tendon
#

usually a code issue

nova epoch
violet star
#
Traceback (most recent call last):
  File "/home/glitchy/.local/lib/python3.12/site-packages/discord/ui/view.py", line 422, in _scheduled_task
    allow = await self.interaction_check(interaction)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/glitchy/puppeteer-lmao/terminator/cogs/KirkaInfo.py", line 410, in interaction_check
    await self.next_page(interaction)
  File "/home/glitchy/puppeteer-lmao/terminator/cogs/KirkaInfo.py", line 384, in next_page
    await interaction.response.edit_message(content=f"Clan {self.clan_data['name']} info:\nDiscord link: <{self.clan_data['discordLink'] if self.clan_data.get('discordLink') else 'None'}>", attachments=[file], view=self)
  File "/home/glitchy/.local/lib/python3.12/site-packages/discord/interactions.py", line 1074, in edit_message
    payload["attachments"] = [a.to_dict() for a in attachments]
                              ^^^^^^^^^
AttributeError: 'File' object has no attribute 'to_dict'```
lofty parcel
#

Also at least say "hey I'm having this error" gawd, we ain't chat gpt where you just slap the errors into the chat

violet star
shell radish
#

you use the files kawrg to upload files

lofty parcel
#

Use files

lofty parcel
shell radish
violet star
#

i wanted to clear the files

#

coz im editing

shell radish
#

then use an empty array

violet star
#

but i bypassed that error by setting attachements=[] and file=file

#

now im getting a new error so progress

Traceback (most recent call last):
  File "/home/glitchy/.local/lib/python3.12/site-packages/discord/ui/view.py", line 422, in _scheduled_task
    allow = await self.interaction_check(interaction)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/glitchy/puppeteer-lmao/terminator/cogs/KirkaInfo.py", line 417, in interaction_check
    await self.next_page(interaction)
  File "/home/glitchy/puppeteer-lmao/terminator/cogs/KirkaInfo.py", line 385, in next_page
    await interaction.edit_original_response(attachments=[])
  File "/home/glitchy/.local/lib/python3.12/site-packages/discord/interactions.py", line 513, in edit_original_response
    data = await adapter.edit_original_interaction_response(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/glitchy/.local/lib/python3.12/site-packages/discord/webhook/async_.py", line 222, in request
    raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10015): Unknown Webhook

interaction.edit_original_response() wont work

shell radish
#

we need more code to diagnose the issue

violet star
lofty parcel
#

?tag pastebin

#

?tag paste

limber wagonBOT
#

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

lofty parcel
#

Tag names alzheimer

violet star
violet star
lofty parcel
#

Did you switch interaction.response.edit_message to interaction.edit_original_response?

violet star
#

yes

#

coz the former was rejecting multiple edits

lofty parcel
#

Yeah you can only send one response

#

But the first + the second should work

violet star
#

neither do

lofty parcel
#

Otherwise you wouldn't be responding to the interaction

violet star
#

well im not sending a seperate response

#

im editing a message

lofty parcel
#
await interaction.response.edit_message(attachments=[])

await interaction.edit_original_response(content=...)
lofty parcel
#

Editing a the message is also a response

violet star
#

k

#

this worked

#

but any idea why an image would display as 0 bytes?

            image = generate_profile_image(member_data)
            imageBytes = BytesIO()
            image.save(imageBytes, 'PNG')
            print("DEBUG: Profile image generated")
            file = discord.File(imageBytes, filename="profile.png")
            print("DEBUG: Discord file created")
            await interaction.response.edit_message(attachments=[])
            await interaction.edit_original_response(content=f"Profile of {selected_member['user']['name']} ({selected_member['allScores']:,})", file=file, view=self)
#

the image is a PIL image

lofty parcel
#

Oh, no idea, I don't really work with images

#

Maybe @shell radish knows

violet star
shell radish
#

uhh you literally just put 0 bytes?

violet star
#

oh fuck

#

i didnt seek bruh

#

fml

shell radish
violet star
#

aight

echo wraith
#

Apps are allowed to send polls, right ?

sage tendon
#

yes

fresh sierra
#

Is that bad to defer before every command ?

sage tendon
#

if you dont need it, theres no point

little cobalt
fresh sierra
fresh sierra
little cobalt
#

I HATE MY INTERNET

#

I cannot even open Google

#

oh

#

nvm Its google which got a problem

#

lol

#

now its working

#

wtf

shell radish
#

/j

fresh sierra
sage tendon
#

overcomplicated for no gain

fresh sierra
#
    @commands.Cog.listener()
    async def on_hybrid_command(self, ctx: LumabotContext):
        if not await is_command_allowed(ctx):
            return
        elif not ctx.is_app:
            await ctx.trigger_typing()
        else:
            await ctx.defer()
#

i mean that

sage tendon
#

and why again do you want to defer every command

fresh sierra
sage tendon
#

you should do it on a per-command basis

fresh sierra
#

if for exemple a guild doesnt want that command to be visible they can choose that it will be ephemeral

sage tendon
#

because some commands require it, while for others its completely pointless

fresh sierra
#

for the 2nd point i still need to do it like this

#

so it like 2 in one

fresh sierra
#

my bot is blocked because of that:

[ERROR] : Event loop was blocked for 1.92 seconds because of:
  File "/usr/local/lib/python3.11/subprocess.py", line 2011, in _try_wait
    (pid, sts) = os.waitpid(self.pid, wait_flags)

#

any idea of what this is ?

#

because i dont really use that

sage tendon
#

i think thats out of your control lol

#

thats literally python itself

fresh sierra
#

well i have found

#

i got a function callback a subprocess.call to udpate my bot using git

#

its i think not the only blocking thing but thankfully i finish my blocking code detector and so it give me the line of the issue

deft kestrel
#

AttributeError: 'Bot' object has no attribute 'slash_command'

Why? I was trying to reinstall pycord

#

I use commands.Bot

deft kestrel
errant trout
#

did you ever install any other discord libraries

fresh sierra
#

this can be the issue ig

#

.tag install

sly karmaBOT
#

1. Uninstall discord.py or any other forks of discord.py you might have with the namespace discord.
python -m pip uninstall discord.py discord -y

2a. Install py-cord
python -m pip install py-cord

2b. Update py-cord
python pip install -U py-cord

Installing other builds:
Note: You need to have git installed. Use ?tag git to find out how to install git.

Updating the module to master branch (unstable):
pip install -U git+https://github.com/Pycord-Development/pycord

fresh sierra
#

also try that

errant trout
#

nah, it doesn't use bot

errant trout
deft kestrel
# errant trout if not, just reinstall py-cord

i still have the problem after reinstalling

Traceback (most recent call last): File "timer.py", line 2, in <module> from discord.ext import commands, tasks ImportError: cannot import name 'commands' from 'discord.ext' (unknown location)

errant trout
#

That's... a different error entirely

#

Are you sure it actually installed

#

Or do you perhaps have a folder called discord

little cobalt
deft kestrel
errant trout
#

I'm aware www, but didn't really feel the need to point it out

little cobalt
#

xd

little cobalt
#

uh wait

deft kestrel
little cobalt
#

You use Python 3.8

deft kestrel
#

yes

#

is there any issue with it?

errant trout
#

eh... is that meant to be the entire folder? It's missing a lot

errant trout
#

How did you install it

deft kestrel
errant trout
#

Try uninstall, make sure the folder doesn't exist, then install again

deft kestrel
#

wtf now it works

errant trout
#

Nice

deft kestrel
#

i already have py-cord voice

errant trout
#

Uhh I forgot the install for voice

#

You need to do it again since you uninstalled

deft kestrel
#

python3.8 -m pip install "py-cord[voice]"

sage tendon
#

you should think about upgrading your python somewhat soon

#

3.8 is out of support this month i believe

deft kestrel
#

i already upgraded but i'm lazy to reinstall all libraries to python3.11

sage tendon
#

but then using that command installs it to the wrong dir..

deft kestrel
#

wtf

#

hmm

#

nope it doesn't work f

little cobalt
#

THE COMMAND > r.txt

fresh sierra
#

why does adding a ctx.defer give me that error ?
Application Command raised an exception: ValueError: I/O operation on closed file

errant trout
fresh sierra
#

but i dont really understand anything of why does that occur tbh

errant trout
#

well

fresh sierra
#

it seems that when i put an asyncio.sleep(1) it doesnt give me that error

#

i think i might have an idea

errant trout
#

glancing through, py File "/home/container/Slashs/Casino/flip.py", line 100, in flip await ctx.respond(embed=embed, view=view, file=file)this caused it

#

...probably

#

you fucked up something with the file

fresh sierra
#

i think i know

errant trout
#

fair enough

fresh sierra
#

this

#
    @commands.Cog.listener()
    async def on_hybrid_command(self, ctx: LumabotContext):
        if not await is_command_allowed(ctx):
            return
        elif not ctx.is_app:
            await ctx.trigger_typing()
        else:
            await ctx.defer()
#

fuckup

#

because i think the await ctx.defer() is reach after the real command already start

errant trout
#

oh yeah you're defering after respond lol

fresh sierra
errant trout
#

just dispatch the event earlier no?

fresh sierra
#

so its already invoke before

fresh sierra
errant trout
#

eh....

fresh sierra
#

just before the invoke

#

this
if not await is_command_allowed(ctx):
return

#

takes too much time i think

errant trout
#

it's because events run in async

fresh sierra
#

and because of that the command is invoke before the await ctx.defer()

errant trout
#

it would be better to run this function directly

#

instead of dispatching an event for it

#

otherwise you've created a race condition

fresh sierra
#

yeah i might create a function instead of dispatch and call it inside the invoke command

fresh sierra
#

i thought about a bot_check like so:

    async def bot_check(self, ctx: LumabotContext):
        if ctx.is_app:
            await ctx.defer()
        else:
            await ctx.trigger_typing()
        return True
#

however i get for every slash command

Application Command raised an exception: InteractionResponded: This interaction has already been responded to before
#

but the thing that i dont really understand is that i only defer once in the bot check, so why does it dont send the command as a followup ?

errant trout
#

eh, sounds like it's running the check multiple times?

#

try printing

fresh sierra
#

can the issue be it update the ctx only in this functiopn

errant trout
#

do you have any other bot checks

fresh sierra
#

and so in the invoke it will keep the old one

shell radish
errant trout
#

if im not mistaken it shouldn't, and seemingly he's already tested it to run once

fresh sierra
#

so adding print in the bot check only print 1, and also the sub command ping is not even invoke

fresh sierra
lapis dock
#

In your command callback are you using followup? Because defer would count as a response

fresh sierra
#

it fail during the invoke

lapis dock
fresh sierra
errant trout
#

rip

fresh sierra
#
bot
test
True
bot ping
test
#
    async def bot_check(self, ctx: LumabotContext):
        print(ctx.command.qualified_name)
        print("test")
        if ctx.is_app:
            await ctx.defer()
        else:
            await ctx.trigger_typing()
        print(ctx.response.is_done())
        return True
errant trout
#

well

#

you can just add a responded check before deferring

fresh sierra
#
    async def bot_check(self, ctx: LumabotContext):
        if isinstance(ctx.command, discord.SlashCommandGroup):
            return True

        if ctx.is_app:
            await ctx.defer()
        else:
            await ctx.trigger_typing()

        return True
errant trout
#

ehhhhhhh perhaps but that might have an unexpected impact on other commands

#

maybe, idk, go for it if you want

#

i'd just check if not ctx.response.is_done()

fresh sierra
#

i will do that then

#

how cna i check if the bot is typing already N

errant trout
#

uhhhhhhh

#

i don't think a function exists for it

sage tendon
#

i thought ctx.guild.me.is_typing but thats only for DMs i think

#

like user.is_typing

#

i wish the doc search would work..

errant trout
#

works fine on my end?

sage tendon
#

Doesn't for me, everything disabled, i'm on the stable docs

#

since a few days or a week now

errant trout
#

try hard refresh

#

#discussion message

#

idk what happened but never ran into it myself

sage tendon
#

bruh, that worked

#

thx

errant trout
#

nice

fresh sierra
#

i dont think there is a rate limit for the trigger typing so it should not be an issue if its double

errant trout
#

yeah

lapis dock
errant trout
#

If I had to guess some docs build caused a desync with whatever version you have cached

#

Hard refresh is always handy if you run into some inexplicable issue

sage tendon
#

it still says v0.1 too lol

errant trout
#

Yeah versioning broke at some point

lapis dock
#

Didn't we fix that once already?

lethal loom
#

Error

Ignoring exception in on_ready
Traceback (most recent call last):
  File "C:\Users\jurek\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\discord\client.py", line 409, in _run_event
    await coro(*args, **kwargs)
  File "c:\Users\jurek\Documents\Development\Python\DC Bots\Xenority\Xenority-Main-Pycord-V2-PY\cogs\dev\ticketsv2.py", line 47, in on_ready
    self.bot.add_view(RatingView())
  File "C:\Users\jurek\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\discord\client.py", line 1972, in add_view
    raise ValueError(
ValueError: View is not persistent. Items need to have a custom_id set and View must have no timeout
#

Code

...
    @commands.Cog.listener()
    async def on_ready(self): 
        view = discord.ui.View(timeout=None)

        view.add_item(Tickets(self.bot))
        view.add_item(CloseButton())
        view.add_item(ClaimButton())
        view.add_item(CloseReasonButton())
        view.add_item(ConfirmButton())
        view.add_item(UserSys())

        self.bot.add_view(view)
        self.bot.add_view(RatingView())
...


class RatingView(View):
    def __init__(self, channel=None, guild_id=None, url=None):
        super().__init__(timeout=None)
        self.channel = channel
        self.guild_id = guild_id
        self.add_item(TranscriptButton(url)) 

    def disable_rating_buttons(self):
        for item in self.children:
            if isinstance(item, discord.ui.Button) and item.custom_id and item.custom_id.startswith("rating_"):
                item.disabled = True
                
    @discord.ui.button(row=4, 
                       label="1",
                       style=discord.ButtonStyle.red,
                       emoji=":star:",
                       custom_id="rating_1")
    async def Rating1(self, button, interaction):
        await ticket_db.update_rating(1, self.guild_id, self.channel)
        self.disable_rating_buttons()
        await interaction.edit(view=self)
        
    @discord.ui.button(row=4, 
                       label="2",
                       style=discord.ButtonStyle.red,
                       emoji=":star:",
                       custom_id="rating_2")
    async def Rating2(self, button, interaction):
        await ticket_db.update_rating(2, self.guild_id, self.channel)
        self.disable_rating_buttons()
        await interaction.edit(view=self)
        
    @discord.ui.button(row=4, 
                       label="3",
                       style=discord.ButtonStyle.blurple,
                       emoji=":star:",
                       custom_id="rating_3")
    async def Rating3(self, button, interaction):
        await ticket_db.update_rating(3, self.guild_id, self.channel)
        self.disable_rating_buttons()
        await interaction.edit(view=self)
        
    @discord.ui.button(row=4, 
                       label="4",
                       style=discord.ButtonStyle.green,
                       emoji=":star:",
                       custom_id="rating_4")
    async def Rating4(self, button, interaction):
        await ticket_db.update_rating(4, self.guild_id, self.channel)
        self.disable_rating_buttons()
        await interaction.edit(view=self)
        
    @discord.ui.button(row=4, 
                       label="5",
                       style=discord.ButtonStyle.green,
                       emoji=":star:",
                       custom_id="rating_5")
    async def Rating5(self, button, interaction):
        await ticket_db.update_rating(5, self.guild_id, self.channel)
        self.disable_rating_buttons()
        await interaction.edit(view=self)

class TranscriptButton(discord.ui.Button):
    def __init__(self, url):
        super().__init__(
            label="View Online Transcript",
            emoji=":scroll:",
            style=discord.enums.ButtonStyle.url,
            url=url,
            custom_id="interaction:TicketTranscriptButton",
        )

When i remove the Transcript button from the ratingView all works without errors

errant trout
#

and it's likely you're not passing url at all

#

if you have an option for url, you shouldn't accept None for it

lethal loom
errant trout
#

are you 100% sure you are actually passing a URL to it that isn't None

lethal loom
#
    
class RatingView(View):
    def __init__(self, channel=None, guild_id=None, url=None):
        super().__init__(timeout=None)
        self.channel = channel
        self.guild_id = guild_id
        self.add_item(TranscriptButton(url)) 

    def disable_rating_buttons(self):
        for item in self.children:
            if isinstance(item, discord.ui.Button) and item.custom_id and item.custom_id.startswith("rating_"):
                item.disabled = True
                
    @discord.ui.button(row=4, 
                       label="1",
                       style=discord.ButtonStyle.red,
                       emoji="⭐",
                       custom_id="rating_1")
    async def Rating1(self, button, interaction):
        await ticket_db.update_rating(1, self.guild_id, self.channel)
        self.disable_rating_buttons()
        await interaction.edit(view=self)
        
    @discord.ui.button(row=4, 
                       label="2",
                       style=discord.ButtonStyle.red,
                       emoji="⭐",
                       custom_id="rating_2")
    async def Rating2(self, button, interaction):
        await ticket_db.update_rating(2, self.guild_id, self.channel)
        self.disable_rating_buttons()
        await interaction.edit(view=self)
        
    @discord.ui.button(row=4, 
                       label="3",
                       style=discord.ButtonStyle.blurple,
                       emoji="⭐",
                       custom_id="rating_3")
    async def Rating3(self, button, interaction):
        await ticket_db.update_rating(3, self.guild_id, self.channel)
        self.disable_rating_buttons()
        await interaction.edit(view=self)
        
    @discord.ui.button(row=4, 
                       label="4",
                       style=discord.ButtonStyle.green,
                       emoji="⭐",
                       custom_id="rating_4")
    async def Rating4(self, button, interaction):
        await ticket_db.update_rating(4, self.guild_id, self.channel)
        self.disable_rating_buttons()
        await interaction.edit(view=self)
        
    @discord.ui.button(row=4, 
                       label="5",
                       style=discord.ButtonStyle.green,
                       emoji="⭐",
                       custom_id="rating_5")
    async def Rating5(self, button, interaction):
        await ticket_db.update_rating(5, self.guild_id, self.channel)
        self.disable_rating_buttons()
        await interaction.edit(view=self)
errant trout
#

you

#

are literally

#

passing url=None

lethal loom
#
    def __init__(self, url=None):
        super().__init__(
            label="View Online Transcript",
            emoji=":scroll:",
            style=discord.enums.ButtonStyle.url,
            url=url,
        )```
#

this is all

errant trout
#

please read your code

#
        self.bot.add_view(RatingView(url=None))```
errant trout
#

you have to have a url for it to be persistent

#

why would you even make a url button without a url

lethal loom
errant trout
#

you need it for the view to exist at all

lethal loom
#

I don't think I understand you, so what exactly should I do now?

errant trout
#

pass a valid URL.........

lethal loom
#

oh okaysry fpor my bad

errant trout
#

(ok tbf, there's not really any reason for is_persistent to require a set URL, but that's besides the point since it's not like we're gonna change that behavior this very instant)

#

anyway havefun

lethal loom
#

ok

lethal loom
#

is it possible to convert a guild name to a id?

shell radish
#

if the guild is cached, yes

sage tendon
#

first question, why do you only have the name?

lethal loom
errant trout
#

if you included it in a formatted string, it'll only show the name

#

it's likely still a full guild object

lethal loom
#

i found this idea

        guild_name = self.message.embeds[0].author.name
        guild_id = discord.utils.get(self.bot.guilds, name=guild_name)
        return guild_id```
sage tendon
lethal loom
#

i find a solution

    def __init__(self, channel=None, guild_id=None, url=None, guilds=None):
        super().__init__(timeout=None)
        self.channel = channel
        self.guild_id = guild_id
        self.guilds = guilds
        self.add_item(TranscriptButton(url)) 

    def disable_rating_buttons(self):
        for item in self.children:
            if isinstance(item, discord.ui.Button) and item.custom_id and item.custom_id.startswith("rating_"):
                item.disabled = True
                
    def get_id(self):
        return self.message.embeds[0].fields[0].value
    
    def get_guild_id(self):
        guild_name = self.message.embeds[0].author.name
        guild_id = discord.utils.get(self.guilds.guilds, name=guild_name)
        return guild_id
                
    @discord.ui.button(row=4, 
                       label="1",
                       style=discord.ButtonStyle.red,
                       emoji=":star:",
                       custom_id="rating_1")
    async def Rating1(self, button, interaction):
        ticket_id = self.get_id()
        guild_id = self.get_guild_id()
        print(guild_id.id)```
lethal loom
errant trout
#

that isn't confusing at all

lethal loom
#

` @commands.Cog.listener()
async def on_ready(self):
view = discord.ui.View(timeout=None)

    view.add_item(Tickets(self.bot))
    view.add_item(CloseButton())
    view.add_item(ClaimButton())
    view.add_item(CloseReasonButton())
    view.add_item(ConfirmButton())
    view.add_item(UserSys())

    self.bot.add_view(view)
    self.bot.add_view(RatingView(guilds=self.bot))`
errant trout
#

...please name your variables better

#

that aside, did it actually work or error

lethal loom
#

yeah :/

sage tendon
#

that was an or question

lethal loom
#

yeah works fine

errant trout
#

oh nice

errant trout
#

is the url button the last one in the view?

#

your disable_rating_buttons function is correct because it's editing self.children, but you went in the opposite direction with change_url

#

if it's the last item, just update self.children[-1].url

lethal loom
errant trout
#

whichever button it is, just update the necessary index

#

-1 is last item, 0 is first item etc.

lethal loom
errant trout
#

wherever you want

lethal loom
#

okay thx works fine

errant trout
#

sick

echo wraith
#

@lethal loom Can you send the code of TranscriptButton ? Also, use syntax highliting like this please
```python
your_code_here
```

#

or paste your entire file here

#

.tag paste

sly karmaBOT
#

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

lethal loom
#

yeah wait

fresh sierra
#

Anyone experiencing this weird bug ?

errant trout
frail basin
fresh sierra
fresh sierra
#

how should i do to remove the error raise by the paginator timeout trying to update a message that's got deleted ?

echo wraith
#

I wanna look into it

fresh sierra
errant trout
fresh sierra
errant trout
#

nah just override it in your paginator object

#

similar to how you'd subclass Bot, View and override that stuff

#

if you don't want to subclass, you could just do paginator.on_timeout = new_timeout_func

fresh sierra
#

i will look at that because it might be interesting to change my paginator

#

like custom button, adding the view only if there is more than 1 page etc

#

thanks

errant trout
#

and if you don't feel like doing completely new logic you could just try: await super().on_timeout() -> except: pass to completely ignore it

#

yeah go for it

deft kestrel
#

why discord in this period have so many crashes on their end?

#

:////

sage tendon
#

discord is a buggy mess

#

it's a surprise it works this well on the API side

stray pasture
#

It is fixed now, Discord made a patch

#

Posting on the GitHub actually worked 😮

tiny fractal
slender lantern
#

I've got a discord.Bot subclass. Is it possible to have ApplicationContext.bot be a subclass instead of the Bot superclass, for type checking purposes?

shell radish
#

and override the return type manually

rugged lodgeBOT
#

Here's the custom context example.

slender lantern
#

Would it be as simple as:

class MyAppCtx(ApplicationContext):
    bot: MyBot

?

#

(and then overriding the method in the bot)

#

(Looks like yes. Sweet!)

red cedar
#

I can’t host my bot cause I keep getting this error ImportError: cannot import name ‘PartialMessageable’ from ‘discord.channel’ (/home/container.local/lib/python3.8/site-packages/discord/channel.py)

red cedar
#

im using python3.8 aswell

lofty parcel
#

Update to 2.6.1

red cedar
lofty parcel
# red cedar

Well you didn't update the library? It's saying you got a conflict

red cedar
#

i just removed specific version for typing-extensions==3.10.0.2 from my requirements.txt file

#

and that worked

lofty parcel
#

Well, the console literally says that

red cedar
#

bot online now

#

thanks!

fresh sierra
#

what can be the cause of

2024-10-12 10:02:10 [WARNING] : Can't keep up, shard ID 3 websocket is 42.0s behind.
frail basin
#

Why doesnt the WebAPI cog get loaded?

#

the setup func in the cog never gets called

#

This fixes the issue, not sure why

#

Does the html file really mess everything up?

fresh sierra
frail basin
#

thats the only thing I've changed since it broke

fresh sierra
frail basin
#

I was using the folder (s) version before

fresh sierra
frail basin
#

notice the difference between the string I am passing

#

One is a folder and one is a file

#

Either properly read what I send, or let someone who actually cares reply please

fresh sierra
#

dont think it change anything

frail basin
#

Well it definetly did, as I said, loading the folder doesnt load any cogs, loading the file works

fresh sierra
#

can you try with
self.load_extension("cogs", recursive=True) ?

frail basin
#

doesnt work

fresh sierra
#

but still to your answer

Either properly read what I send, or let someone who actually cares reply please
bot.load_extension has always no s if you are passing only 1 name

frail basin
fresh sierra
#

and it does not matter that you pass a forlder or not

frail basin
#

so the s doesnt matter

#

since it takes *names

#

it would be a single item loop

fresh sierra
#

and since cogs is not *names there should not be an s

frail basin
#

It doesnt matter, neither works

fresh sierra
#

cogs is not multiple name so it should not have an s still

frail basin
#

neither works

#

so it doesnt matter

fresh sierra
#

so it was still an error even if the other doesnt work

rugged lodgeBOT
frail basin
#

names would be a list containing a single item

#

thats not the issue

#

it shouldve still worked

#

it doesnt

#

and I dont even want to argue about it, since its pointless

fresh sierra
#

it would have done each letter of the thing as far as i know

frail basin
#

thats not how * works...

fresh sierra
#

also can you try to do
src.cogs ?

#

because it might try to take it from the root rather than the relative

frail basin
#

already tried

echo wraith
#

@frail basin Just to be clear, in what file is your load_extensions located ?

fresh sierra
#

bot class

fresh sierra
frail basin
echo wraith
frail basin
#

which is in the cwd

echo wraith
#

ok thx

sage tendon
#

remvoe the src. part

sage tendon
fresh sierra
#
bot.load_extension("src.cogs", recursive=True)
frail basin
#

Well it doesnt work for some reason, even though it did before

fresh sierra
sage tendon
#

you dont need src luma

#

because the main file is already in src

echo wraith
fresh sierra
#

as long as its not in

sage tendon
#

this is how i load my cogs

echo wraith
#

@frail basin What command do you use to run the bot ?

sage tendon
#

both the cogs folder and the main.py are in the same folder

echo wraith
#

k

frail basin
#

It works in the docker container still

sage tendon
#

can you just try load_extensions("cogs") without recursive? you dont have any folders inside anyway

frail basin
#

tf

echo wraith
#

self.load_extensions("cogs", recursive=True, package=".")

#

or

#

self.load_extensions(".cogs", recursive=True)

#

what happens ?

frail basin
fresh sierra
#

do you have an init in one of ur folder ?

frail basin
#

no

echo wraith
sage tendon
frail basin
#

though, it should already use . for relative imports

#

its weird

fresh sierra
#

because i tried to reproche the same tree file and it was working without

echo wraith
sage tendon
#

it already uses the path relative to the main file

echo wraith
#

Imo there is some confusion somewhere

fresh sierra
#

can you develop ?

echo wraith
#

Since it runs in src, . references src/. In this case it was trying to load from cogs/ instead of src/cogs/ (ModuleNotFoundError). Vscode gave me similar problems in the past. I thought that explicitly stating that the package we want to import from is . relative to main.py would make it understand it has to look in the src/ folder instead of ./

fresh sierra
#

because he put as cwd with is the root src and not . ?

echo wraith
#

It's the kind of thing you shouldn't have to do and the computer should do itself so it feels wierd when you do it

fresh sierra
#

during a rate limit, if the bot continue to send requests does that matter ?

frail basin
#

Yeah you'll get CF banned

fresh sierra
#
discord.errors.HTTPException: 429 Too Many Requests (error code: 0): You are being blocked from accessing our API temporarily due to exceeding our rate limits frequently. Please read our docs at https://discord.com/developers/docs/topics/rate-limits to prevent this moving forward.
frail basin
#

Thats just a discord ban, not cf

#

Cf bans return html

fresh sierra
#

ok thanks

frail basin
fresh sierra
#

i think i made a too big clear

#

i should add some lower limit

frail basin
#

I mean, the lib handles ratelimits fairly well

#

Unless you messed with that you shouldnt get CF banned

#

CF bans are more common on shared hosts

fresh sierra
#

its a first time that i get compltetly kick so i dont really know why rn

frail basin
#

If you have multiple bots (shards?) on the same IP

fresh sierra
#

and one of them has 4 shards

echo wraith
#

@fresh sierra use some kind of code profiler and see what function are called the most, to find out what is really using that much, and add some caching wherever possible, ie with redis or smth.

frail basin
#

Thats 5 req / second / bot

#

Which is not much

fresh sierra
#

no i think i found it

#

in case of an error my bot log a webhook

#

i forgot that i did put that log to test something

#

so it did just spam without any handle

frail basin
#

v4 IPs are like 2$/IP so you should just buy one from your host tbh

fresh sierra
#

was wanting to check if that was the reason of the blocking code

frail basin
fresh sierra
#

i will look at that after

frail basin
#

It is

fresh sierra
#

how many ip should i use per bot ?

frail basin
#

We generally recommend 20 bots / IP for hobby bots, 10 / IP for small public bots and 1 IP / Bot for medium - large bots

#

generally

fresh sierra
#

ok so rn 1 ip should be good since i have 1 bot public with around 2k, and 9 others with less than 10 guild each

#

but i will look at it, maybe put the public bot on another ip

#

will also have to make some conf for the other ip also refer to the same ndd

frail basin
#

You could also buy your /29 since most hosts support BYOIP

#

It costs like 3-5$ per month which is not that much

echo wraith
frail basin
#

Well v6 IPs are cheap, but most uplinks do not have their IPv6 infa built out properly

echo wraith
frail basin
#

Again, the only issue with v6 is that its not widely adopted yet

sage tendon
#

which is a fucking shame because its twenty five years old

#

its older than fucking 1080p as a resolution

fresh sierra
torn barn
#

Nope

#

Make sure any libs you use or functions dont make long sync calls

fresh sierra
#

i have a blocking detector and i got no blocking code detected for 50ms block

fresh sierra
#

shouldnt purge handle itself when trying to delete a message that has already been delete ?

#

for when we try to clear 100 messages it doesnt stop directly

frail basin
#

Would this code work for deleting messages from DMs?

await self.bot.http.delete_message(channel_id=Partial(id=user_id), message_id=Partial(id=message_id))
#

Partial is just discord.Object

fresh sierra
#

@sage tendon how do you catch error that occurs during an event ?

fresh sierra
#
    async def on_error(self, event_method, *args, **kwargs):
        print("event:", event_method)
        print("args:", args)
        print("kwargs:", kwargs)
#

this only give me trhe event method, arg and kwargs are always emty

fresh sierra
#

you dont want to tell me or you dont ?

sage tendon
#

i dont catch them

#

or well, i just handle them where they occur
i dont have an extra handler