#Basic Pycord Help (Quick Questions Only)

1 messages Β· Page 15 of 1

grizzled sentinel
#

Handel button presses, yes (if they were persistent)
Commands, no (there is a very small chance you will get your bot restarted in 3 seconds)
Deferred commands, im not sure.

lime lichen
#

i was more interested in View.children

grizzled sentinel
#

get_x trys to find the thing in the bots cache, if get_x returns None than use fetch_x

grizzled sentinel
errant craneBOT
#

Here's the persistent example.

lime lichen
#

ty ty

stuck sparrow
lime lichen
#

hey thats all im interested in

fervent cradle
#

How can i take datetime.datetime and output something like In {time} minutes!

fervent cradle
fervent cradle
#

well i was saying if i wanted to convert something like 2022-08-26 13:17:47.949812+00:00 to minutes like in 30 minutes the max it could be is one hour because thats the loop time

grizzled sentinel
#

Ah ok, the datetime object should have an attribute minutes

#

nvm

#

you would need to subtract the datetime object from now, than you could get minutes

fierce elm
#

which would be a timedelta

grizzled sentinel
#

^

fervent cradle
#

so this (what u stated above) would not work?

grizzled sentinel
#

it would

grizzled sentinel
grizzled sentinel
fervent cradle
#

So it would work

grizzled sentinel
#

yes

fervent cradle
#

or should i do something like this

grizzled sentinel
fervent cradle
#

πŸ‘

#

Thanks

amber shale
#

why is my guild.categoeries and channels returns a empty list?

#

guild != None and i am using it to get category by id [get(guild.categories, id=category_id)]

real warren
#

I'm getting "In 2: Application command names must be unique"
but I'm pretty sure that there's no duplicates

real warren
tiny wagon
#

how can i use variables in button label in subclassed buttons?

stuck sparrow
#

how to delete/unregister a slash command?

#

ok nvm it just had to cache for few minutes

#

my bad

slender abyss
#

i have a doubt
is there a ratelimit on interactions

#

like how many interaction can bot take at a time

cyan quail
#

there's probably a ratelimit on interactions, but it's completely separate from your other bot ratelimits

little hill
#

So the Bot class has these lines in on_application_command_error

command = context.command
if command and command.has_error_handler():
    return

cog = context.cog
if cog and cog.has_error_handler():
    return

What do I need to do to essentially turn that into

if command has been handled by a per-cog or per-command error handler:
  return

I only want the global error handler to trigger if the error has not been handled already by another error handler

#

(If this is going to be a long discussion/better suited for its own thread, let me know and I can move it)

cyan quail
little hill
#

well say i have this (pop is a slash command)

@pop.error
async def on_application_command_error(self,
    ctx: ApplicationContext, error: DiscordException
):
    if isinstance(error, CommandOnCooldown):
        await ctx.respond(
            "stuff",
            ephemeral=True,
        )
        return

    else:
        raise error

right now, if an error such as Forbidden is raised by pop, the bot's error handler ignores it entirely, when ideally it would run through its own ifinstance checks

cyan quail
#

what about just raise

proud pagoda
#

Just use a global error handler then

cyan quail
little hill
#

basically a backup error handler

proud pagoda
#

Yeah but then what's the point in it going through the isinstance checks?

little hill
#

to give the correct response per error type

cyan quail
#

because you want specific behaviour...?

proud pagoda
cyan quail
#

what he means is the custom handler is being used to specifically handle CommandOnCooldown

#

but if he has a condition for Forbidden in his global handler, it will never be reached because the custom handler is in the way

little hill
#

the global one also has CommandOnCooldown, for other commands that may raise it but don't have their own error handling for that specific error

proud pagoda
#

Oh, so the error handler should be used only for certain errors?

little hill
#

for the command-specific one, yes

cyan quail
#

you could remove the if command and command.has_error_handler():, but then you could run into multiple error handlers running for 1 error

little hill
#

yeah

#

which is messy

proud pagoda
#

Isn't there a way to run the bot's error handler manually?

cyan quail
#

true

proud pagoda
#

Like bot.on_application_command_error(error)

#

So you can use isinstance to check the error within the command's error handler, and then add an else and run this ^

little hill
#

the same logic would apply, meaning it would do nothing because it detected that there is a per-command handler

cyan quail
#

no he's right

#

if you invoke it manually, you can just remove the has_error_handler lines

#

hm

#

well

#

ehhhhh

little hill
#

that would still end up with multiple handlers per error, if the global and per-command handlers both handle CommandOnCooldown

proud pagoda
#

Hold on, why are you using the default error handler anyway?

cyan quail
#

as in, he wants to use the has_error_handler logic in their global handler

proud pagoda
#

If you want the same behavior as it from within the command's error handler, then in the else just write:

print(f"Ignoring exception in command {context.command}:", file=sys.stderr)
traceback.print_exception(type(exception), exception, exception.__traceback__, file=sys.stderr)
#

Oh

little hill
proud pagoda
#

how about you add a param called smthn like check_handler, and set default to True, but pass False in the else for the command error handler so it skips checking whether there is already an error handler for the command

little hill
#

elaborate

cyan quail
#

maybe we should allow users to return True/False if an error was handled

#

and then override how they're dispatched

little hill
#

I'm surprised that a solution doesn't already exist for this, I feel like it is a commonly used thing

proud pagoda
# little hill elaborate

Here's a code example:

async def on_application_command_error(ctx, error, check_handler=True):
  if check_handler:
    # Perform the logic necessary to check whether the command already has its own error handler
    ...  

  # Handle the error
  ...

@pop.error
async def pop_error(ctx, error):
  if isinstance(error, ErrorType):
    # Handle the error
    ...
  else:
    await on_application_command_error(ctx, error, check_handler=False)
cyan quail
#

oh that's true

#

you can mess with the global handlers args as long as you make them optional

#

hmm

#

that'd still fail in theory though py finally: ctx.bot.dispatch("application_command_error", ctx, error) so global would run anyway with check=True

little hill
#

this works!

#

thanks :D

stuck sparrow
#

how does variables work in pycord like for example economy system vars idk

fervent cradle
#

Is there a way to get the number of users in a guild without intents?

stuck sparrow
#

variables

#

idk

fervent cradle
#

bro

#

learn python first.

stuck sparrow
#

MAN

#

not these variables

#

like variables set for users, servers etc

fervent cradle
#

tyy

proud pagoda
meager heron
#

I'm trying to use the new SlashCommand.mention via ctx.command.mention. I get this output:
</character image upload:None>
Is this expected? I assumed it would look something similar to other mentions.

smoky forge
meager heron
#

Ah, you mean it doesn't work with slash command groups/subcommands?

sinful pivot
#

Before you try to help me, let me just tell you. I do not know much about reaction events.

I've been trying to make a thing that if someone reacts to the bot's message with a certain reaction it will do something. I've been trying to get this done using the on_raw_reaction_add event. When I try to get the message(to check if the message author is the bot) it returns None. I'm trying to do it using self.bot.get_message since I would have to make like 3 API calls if I was going to do it using fetch_message

smoky forge
#

all command.mention does is format it into a string but if the command has a parent then it doesn't work for some reason

sinful pivot
#

What could I do?

meager heron
smoky forge
#

cuz idk if its intended behavior

round rivet
#

it's not

#

it should be fetching the id from the parent command

smoky forge
meager heron
#

I'll be honest, I figured it was a Discord issue, lol

sinful pivot
smoky forge
#

message returns none for messages sent after the bots restart

sinful pivot
#

ik

#

ok nvm i got it working

meager heron
#

And SlashCommandGroup has no mention attribute

round rivet
sinful pivot
#

Can anyone now help me with how I would actually do it? Is this how?py if message.author.id == self.bot.user.id: if message.emoji == "emoji unicode here": print("Someone has reacted to the bot using the emoji")

round rivet
#

although I haven't actually touched the groups with get_command because it doesn't seem to work

sinful pivot
#

k ill test it out

#

Doesn't work sadly

#

no errors aswell

#

Here's my whole code: py @commands.Cog.listener() async def on_raw_reaction_add(self, payload): message = self.bot.get_message(payload.message_id) if message is None: channel = self.bot.get_channel(payload.channel_id) message = await channel.fetch_message(payload.message_id) if message.author.id == self.bot.user.id: if message.emoji == "πŸ‘‹": await message.reply("Test")

#

hmm, i'll try to print message.emoji

round rivet
#

message.emoji doesn't exist

#

it'd be in payload

sinful pivot
#

oh yeah im dumb

#
``` this messes it up
#

I did a print before it, it prints out. The prints inside that do not

#

Seems out, both the values are different

#

oh wait! It's not a bot's message I'm testing it on my own message, sorry lol

#

Do I need to get the emoji object and compare it to that? The emoji doesn't seem to be equal.

amber shale
stuck sparrow
#

ok

sinful pivot
#

Can anyone help me? The emoji seems to be the same. I'm getting \πŸ‘‹ as a print and I'm doing:

if payload.emoji == "πŸ‘‹":
    print("test")```
shy crow
#

Hey. How can i lock all commands in a Cog to a specific Channel Category with @before_invoke

cyan quail
cyan quail
sinful pivot
#

how do I compare it though..

#

I tried to get the thing

cyan quail
#

read the link there and you'll see

sinful pivot
#

I literally have..

shy crow
#

can i catch which check failed?

young bone
shy crow
#

no i mean i have a check function which checks if the command used in a specific category

#

to catch which check failed if i have multiple

cyan quail
stoic peak
#

i need some help with some coding

#

i do not know what to run this on

prisma flicker
stoic peak
#

k.

loud holly
errant craneBOT
#

examples/wait_for_event.py line 14

async def on_ready():```
hushed ledge
#

One message removed from a suspended account.

grizzled sentinel
grizzled sentinel
loud holly
grizzled sentinel
#

what version are you on now?

loud holly
#

2.0.1

grizzled sentinel
#

yeah, I would upgrade, no downside. Not sure why it does not work on that version

loud holly
grizzled sentinel
#

There are not any breaking changes mentioned in the update

loud holly
grizzled sentinel
#

πŸ‘

loud holly
grizzled sentinel
#

Well, than i think it must have something to do with the interpreter or something.
You are using the imports and slash command exactly how theyare in the example correct?

loud holly
#

yup

shy crow
cyan quail
#

if you made a custom check then it'll be CheckFailure

loud holly
#
@bot.slash_command(name="guess", description="Guess a number between 1 and 10!")
    async def guess_number(ctx: discord.ApplicationContext):
        await ctx.respond("Type in your number. *(It should be between 1 and 10)*")

        def is_valid_guess(m: discord.Message):
            # This function checks three things at once:
            # - The author of the message we've received via
            #   the wait_for is the same as command author.
            # - The content of the message is a digit.
            # - The digit received is within the range of 1-10.
            # If any one of these checks fail, we ignore this message.
            return m.author == ctx.author and m.content.isdigit() and 1 <= int(m.content) <= 10

        answer = random.randint(1, 10)

        try:
            guess: discord.Message = await bot.wait_for("message", check=is_valid_guess, timeout=5.0)
        except asyncio.TimeoutError:
            return await ctx.send_followup(f"Sorry, you took too long it was {answer}.")

        if int(guess.content) == answer:
            await guess.reply("You are right!", mention_author=True)
        else:
            await guess.reply(f"Oops. It is actually {answer}.", mention_author=True)
grizzled sentinel
loud holly
#

only change I had to do was mention asyncio.TimeoutError

#

3.9 i believe

grizzled sentinel
loud holly
grizzled sentinel
#

yes, it sends the "sorry you took to long" message

#

can you show the full traceback

loud holly
#

that's the breakpoint of the error

#

ok so without these, it works fine

grizzled sentinel
#

whatever that is must not be flawless

#

Β―_(ツ)_/Β―

loud holly
#

Well that's great then 😭

grizzled sentinel
#

what is it?

loud holly
# grizzled sentinel what is it?

I mainly use the breakpoints so I can catch errors however if that gets in the way then I won't be able to catch errors easily (I'm using the wait for ... for applications via DMs)

grizzled sentinel
#

I have just never seen breakpoints like that

loud holly
grizzled sentinel
#

No i dont use VSC

pearl sail
#

How can i make a slash command which output is only visible to the user that invoked the command?

#

nevermind found it πŸ‘

night warren
#

Hi, I have a category that makes all the channels created within it restricted to some roles. However, applying permission overwrites to a user will unsync the channel's permission from the category permissions, thus making the channel visible to all roles. How may I sync everything except for the overwrite?

naive remnant
#

How can make slash commands of my bots working in the servers he's in

full basin
#

Wdym

young bone
naive remnant
#

I know I have to use a for loop

#

But how's the code

young bone
#

??

full basin
#

What?

#

Just make it a global command.

young bone
#

^

naive remnant
#

Whatt

#

So it can be used in all servers?

full basin
#

Just don't set any guild id

young bone
#

remove the guild ids stuff to get it global

naive remnant
#

It will not work

young bone
#

?

full basin
#

?tag idw

obtuse juncoBOT
#

Saying it doesn't work or asking what's wrong with this code? is not helpful for yourself or others.
Describe what you expect and/or tried (with your code), and what isn't going right.
Please provide any errors you get for optimal assistance.

naive remnant
young bone
#

it takes some time to see them

naive remnant
#

Nvm I have an idea

#

What's the code for getting guild id

young bone
naive remnant
young bone
#

if you do it with the guild id you have to restart the bot?

naive remnant
#

Yes

#

How much time it takes to register?

young bone
#

without the guild id?

naive remnant
#

Yes

young bone
#

that last information I know it can take 1h

naive remnant
#

Okay but it will work on every server?

young bone
#

yes

naive remnant
#

Okay tnx

young bone
#

I had it that it was still after hours not at some server and idk why but...

naive remnant
#

Okay

iron halo
#

i made a modal using the example but it keeps telling me File "bot.py", line 1845, in apply modal = test_modal(title="test modal") File "bot.py", line 1818, in __init__ discord.ui.InputText( TypeError: can't multiply sequence by non-int of type 'InputText'

#
    def __init__(self, *args, **kwargs) -> None:
        super().__init__(
            discord.ui.InputText(
                label="test",
                style = discord.InputTextStyle.long
            ),
            discord.ui.InputText(
                label="test2",
                placeholder="test2",
                style=discord.InputTextStyle.long
            )
            *args,
            **kwargs,
        )
    async def callback(self, interaction: discord.Interaction):
        await interaction.response.send_message("yes")

@bot.slash_command(name="test")
async def test(ctx: discord.ApplicationContext):
    modal = test_modal(title="test modal")
    await ctx.send_modal(modal)
grizzled sentinel
#

missing comma after the second Input Text, line above *args

iron halo
#

oh πŸ€¦β€β™‚οΈ

#

thanks

surreal glade
#

does anyone know how to make a button that when clicked, deletes the message that the button is attached to?

#

Like a cancel button

surreal glade
#

thx

surreal glade
grizzled sentinel
#

can you show the callback

surreal glade
grizzled sentinel
#

can you paste the whole callback function :)

surreal glade
#

shit that indentation one sec

#
        @discord.ui.button(label="Mark User", style=discord.ButtonStyle.danger, emoji="❕", )
        async def button_cback(self, button, interaction):
            embed = discord.Embed(title="Moderation Action", color=0xff0000)
            embed.add_field(name=f"βœ… {user} marked!", value=reason, inline=False)
            await ctx.send(embed=embed)
            role = discord.utils.get(ctx.guild.roles, name="marked")
            await user.add_roles(role) #add the role marked to the user
            await delete_original_message(delay=None)```
#

there

young bone
#

you use ctx.send in a button?

surreal glade
grizzled sentinel
#

also you need interaction.response. in front of the delete_orig...

young bone
grizzled sentinel
#

shoot, they are right ^ no response

grizzled sentinel
surreal glade
#

ye

#

oh no response ok

surreal glade
young bone
#

can you send the code again?

surreal glade
#
        @discord.ui.button(label="Mark User", style=discord.ButtonStyle.danger, emoji="❕", )
        async def button_cback(self, button, interaction):
            embed = discord.Embed(title="Moderation Action", color=0xff0000)
            embed.add_field(name=f"βœ… {user} marked!", value=reason, inline=False)
            await ctx.send(embed=embed)
            role = discord.utils.get(ctx.guild.roles, name="marked")
            await user.add_roles(role) #add the role marked to the user
            await interaction.delete_original_message(delay=None)
young bone
#

you have still ctx.send

surreal glade
#

oh lmao

#

i swear i replaced that

#

oh wait i replaced it in the wrong button cback function

#
        @discord.ui.button(label="Mark User", style=discord.ButtonStyle.danger, emoji="❕", )
        async def button_cback(self, button, interaction):
            embed = discord.Embed(title="Moderation Action", color=0xff0000)
            embed.add_field(name=f"βœ… {user} marked!", value=reason, inline=False)
            await interaction.response.send_message(embed=embed)
            role = discord.utils.get(ctx.guild.roles, name="marked")
            await user.add_roles(role) #add the role marked to the user
            await interaction.delete_original_message(delay=None)

so here is the code but it is deleting the embed instead of the original message which contains the button

surreal glade
grizzled sentinel
#

Delete the message before you send a new one i guess

prisma flicker
#

Or store the message

surreal glade
prisma flicker
#

message = interaction.original_message I think

young bone
#

^

grizzled sentinel
surreal glade
prisma flicker
#

Yeah maybe

#

But I think I use "original_message" as the response sometimes so fixing it would be a breaking change πŸ’€

surreal glade
#

@prisma flicker do u have any idea on how to set the character length for a cmd arg, im making a warn command and when it outputs the reason it only outputs the first word

errant craneBOT
#

Here's the slash options example.

night cargo
#

How do I send a datetime like this

simple canopy
#

?tag Timestamps

obtuse juncoBOT
#

To make a timestamp you need a unix timestamp. Then, put your time and date into the converter and copy the "Unix Timestamp" (https://www.unixtimestamp.com/) Then to use the timestamp, follow this syntax: <t:COPIED_TIMESTAMP_HERE:FORMAT>

Where it says FORMAT, you can put a few different things:

R: Relative, says "two weeks ago", or "in 5 years"

D: Date, says "July 4, 2021"

T: Time, "11:28:27 AM"

F: Full, "Monday, July 4, 2021 11:28:27 AM"

Example: (note: 1000190514 is Unix time for 11 September 2001)

<t:1000190514:R> -> says 20 years ago
<t:1000190514:D> -> says 11 September 2001
<t:1000190514:T> -> says 12:11:54
<t:1000190514:F> -> says Tuesday, 11 September 2001 12:11
grizzled sentinel
surreal glade
#

for example if i do %moderate @prisma flicker pycord is the best (pycord is the best being the reason), and i output that message to a channel, it will just print out "pycord" aka the first word

full basin
surreal glade
full basin
#

What

#

That's not a command?

surreal glade
#

wait

#

u just said funciton params

#

here

#

async def moderate(ctx, user: discord.Member, reason):

full basin
#

You add * before the argument to make it multi-word. Otherwise they only the one word

surreal glade
#

ah so like this

#

async def moderate(ctx, user: discord.Member, *reason)

full basin
#

Yes

#

Iirc that also works

surreal glade
#

@full basin gave me this ```diff

  • TypeError: can only concatenate str (not "tuple") to str```
full basin
#

Do (..., *, reason: str)

prisma flicker
#

When I did prefix I never had more than ctx and would do it all manually

#

async def moderate(ctx):

#

user = ctx.message.mentions[0]
reason = ctx.message.split(" ")[2:]

surreal glade
#

tyty

round rivet
patent halo
#

Is discord.ext.pages.Paginator not supposed to work with discord.File objects? If not are there any plans to make it accept files as pages?

fierce elm
#
Traceback (most recent call last):
  File "/home/ken/PycharmProjects/ticket_man/venv/lib/python3.10/site-packages/discord/ext/commands/core.py", line 184, in wrapped
    ret = await coro(*args, **kwargs)
  File "/home/ken/PycharmProjects/ticket_man/ticket_man/bot/cogs/todo.py", line 36, in list
    async with get_session as s:
AttributeError: __aenter__

I figure this is a sqlalchemy problem, but wonder if anyone else has gotten this

prisma flicker
#

I think either d.py had bad examples or people gave me bad advice, or the bot I copied from did it that way so I just kept doing it that way

#

Or more likely a combination

sinful pivot
#

Can anyone help me? The emoji seems to be the same. I'm getting \πŸ‘‹ as a print and I'm doing:

if payload.emoji == "πŸ‘‹":
    print("test")```
#

I know its not a str but I want to figure out how I can get that object

stuck sparrow
#

how does cogs work

copper dew
stuck sparrow
#

a

proven cipher
#

How do I get an interaction (button or select) that wasn't handled by the bot? Something like "This interaction is no longer available"

verbal dawn
#

In options.1: Required options must be placed before non-required options

#

help

round rivet
#

read the error

verbal dawn
#

I did, still same error

storm hinge
#

uh
why won't the image be attached to the embed?

                elif command == "finish":
                    async with ctx.typing():
                        img = await bld.finish()
                        img.save(f"build_saves/build_{ctx.author.id}/_build.png")
                        embed = discord.Embed(title="PAYDAY 2 Builder", colour=discord.Colour.blurple(), description="Build finished!")
                        embed.set_image(url="attachment://_build.png")
                        await channel.send(file=discord.File(f"build_saves/build_{ctx.author.id}/_build.png", filename="_build.png"), embed=embed)
                        storage.is_finished = True```
errant craneBOT
#

Here's the persistent example.

amber shale
#

how to get categories in a guild

#

i cant get it throught guild.categories or guild.by_categories()

#

but i was able to get roles

#

reinvited bot with admin permission still it is empty

#

intents = Intents.all()

thorny breach
#

Is their a method to sync a channels permissions with it's category, I couldn't find Anything in the docs.

amber shale
#

i found the problem (it is not in cache) but how to solve it, i want to change permission of a category..

fervent cradle
#

is there a way to fetch a discord user directly without fetching a guild first

amber shale
#

empty

grizzled sentinel
amber shale
fervent cradle
grizzled sentinel
grizzled sentinel
fervent cradle
#

ahh

amber shale
#

[] <class 'discord.channel.CategoryChannel'>

#

is that a problem? channel.CategoryChannel?

grizzled sentinel
#

Actually ya know what fetch channels likely updates the cache so after fetching try guild.catagories again

amber shale
#

still empty

#

i have weird problems every time

grizzled sentinel
#

Can you show the code of how you are sgorting out the categories?

dry echo
#

is it possible to grey out user commands for some people?

grizzled sentinel
amber shale
#
channels = await guild.fetch_channels()
print(guild.categories)
object = get(channels, id=object_id)```
#

object = category here

#

wait is object a reserved word 🀦

grizzled sentinel
#

And ID is the id of the categorie channel?

#

Ohhhh, lol

amber shale
#

from db and it is verified

amber shale
#

object_id = task.get("channel_id", None) or task.get("category_id", None)

#

task is a dictionary that has channel_id or category_id

grizzled sentinel
#

Would that not get a channel id forst?

#

First*

#

Did changing away from object help?

dry echo
amber shale
amber shale
errant craneBOT
amber shale
#

no it didnt

grizzled sentinel
dry echo
amber shale
#

@commands.has_guild_permission(ban_members=True)

#

to check if user has a permission to ban members

dry echo
grizzled sentinel
#

Oop I was beat to it

amber shale
grizzled sentinel
#

I dont think discord has grayed out commands anymore. They are just hidden now

Sorry I gtg tho.

amber shale
#

πŸ‘‹

dry echo
#

this image is from this server a year ago....discord what have you done

amber shale
#

sorry

fervent cradle
#

hey

#

guild_ids don't work for me, adding it to a pre-existing slash cmd

full basin
#

It's guild_ids=[...]

fervent cradle
#

sorry typing mistake, yes that's what I'm doing

full basin
#

What owner_guilds contains

fervent cradle
#

oh i think this is the issue, it should be int right-

full basin
#

Yes

fervent cradle
fervent cradle
#

DEBUG | [880368659858616321, 956173253469151253]

#
import discord

bot = discord.Bot(debug_guilds=[...]) # specify the guild IDs in debug_guilds

# since global slash commands can take up to an hour to register,
# we need to limit the guilds for testing purposes

@bot.command(description="Sends the bot's latency.") # this decorator makes a slash command
async def ping(ctx): # a slash command will be created with the name "ping"
    await ctx.respond(f"Pong! Latency is {bot.latency}")

bot.run("TOKEN")

any help would be appreciated

#

I would like to have global commands instead of server specific ones tho

fervent cradle
fervent cradle
fervent cradle
bleak cloud
#

how do i access the value of discord.SelectOption?
Select.values returns only the name of selected items

full basin
#

select.values returns a list with the selected options values

#

Either the name or value you set through value=...

bleak cloud
#

oh wait, so not the labels?

full basin
#

Returns the label if didn't set a value

bleak cloud
#

i see, thanks a lot!

fervent cradle
fervent cradle
#

oh he's back

#

I am not offline, just invisible, plus that's an alt

#

ahh

fervent cradle
#

there is no import error

fervent cradle
#

uninstall the package

#

the same error

#

alright

full basin
#

Do pip freeze and show

fervent cradle
full basin
fervent cradle
#

alr

#

I got a list of packages,

#

u want a screenshot of those?

full basin
#

Yes..

fervent cradle
#

weird, I have this installed

full basin
#

There you go

fervent cradle
full basin
#

That's your conflicting library

fervent cradle
#

ah so I'll uninstall

#

that one, and retry the command?

full basin
#

And you're using py-cord 1.7.3

#

My god that's old as hell

fervent cradle
#

so that's outdated

#

okie

full basin
#

pip install -u py-cord==2.1.1

fervent cradle
#

the default version that installs seems to be 1.7.3 too

full basin
#

#library-updates

#

Should work

#

pip install -U py-cord==2.1.1

fervent cradle
#

i think I found the issue lmao

#

gimme a sec

#

I am using python 3.9

#

eee

cyan quail
fervent cradle
#

yeah I did the big goofy

#

sorted it out rn

#

yep everything is smooth, except slash commands arent registered

#

that's weird cause I checked out application.command everywhere

rare ice
#

With commands.FlagConverter, how can I make a flag where when the flag is provided in the command (e.g. ?myflagname (no value here)) it returns a specific value, but it doesn't fall back on it's default value as None? so that I can do something like !warn @member ?dm so that when the flag ?dm is provided it is True but when not provided, it's False. not sure if this is possible?

cyan quail
fervent cradle
#

Hey,
can i remove all previous rights of a channel, even from roles rights?

rare ice
#

i want to be able to set a value for the flag when the value isn't provided (!warn @member ?dm) but still have a value when the flag itself isn't provided (!warn @member).

cyan quail
rare ice
#

like do you know the bot Wick?

#

how it uses it's own flags for commands

cyan quail
#

nop

fervent cradle
cyan quail
#

oh wait

cyan quail
#

idk give it a try, i've read all about flagconverter but i've never actually tried it myself

fervent cradle
cyan quail
#

hold on

cyan quail
#

basically an empty dict so discord would reset them

tiny wagon
#

how can i use variables in button label in subclassed buttons?

fervent cradle
cyan quail
fervent cradle
fervent cradle
# cyan quail no?

await channel.set_permissions(overwrites={}) i have get the channel.

#

so channel is my channel object whats the permissions changed

#

but he don't change the permissions

dry echo
#

channel.edit

cyan quail
#

^ i linked channel.edit, not set_permissions

fervent cradle
#

ups yeah thanks

fervent cradle
cyan quail
#

nice

fervent cradle
#

hello folks

#

discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: '_MissingSentinel' object has no attribute '_get_overridden_method'
I was going for a fetch avatar from url
this is my code so far

utilitycom = bot.create_group("utility", "Use for userinfo, serverinfo, etc")

@utilitycom.command(description="Get user avatar")
async def av(ctx, member):
    member =  discord.Member = None
    if not member:
        member = ctx.message.author
    userAvatar = member.avatar_url
    await ctx.send(userAvatar)
full basin
#

member = discord.Member = None?

fervent cradle
#

oh

full basin
#

The hell is that?

fervent cradle
#

fucking kek

#

but I doubt that's the issue

#

(i fixed it)

full basin
#

Its indeed the issue

#

That line makes no sense

fervent cradle
#

yea I fixed it

#

and tried again,

#

what is an asset

amber shale
#
    @commands.slash_command(name="addrole", description="Add a role to a member.")
    @commands.has_guild_permissions(manage_roles=True)
    @commands.bot_has_guild_permissions(manage_roles=True)
    async def _add_role(
        self,
        ctx: ApplicationContext,
        member: Member,
        role: Role,
        reason: str = None,
    ) -> None:
        await ctx.defer()
        await self.manage_role(ctx, member, role, reason, "add_role")
        embed = Embed(description=f"{role.mention} added to {member.mention}.")
        await ctx.respond(embed=embed)```
#

can i know why this is not working

#

it is inside a cog, removerole command is working and bridge command is working

dry echo
#

any error?

amber shale
bright shard
#
    for i in range(4):
        buttnum = random.randint(1,100)
        @discord.ui.button(label=f"Button{buttnum}", style=discord.ButtonStyle.primary)
        async def buttcall(self, button, interaction):
            print('augh')```
#

anyone know a way to put a bunch of buttons using something like this?

#

this only puts 1 button im assuming because the callback is the same for each one idk how to make different callback for each one tho

fervent cradle
#

How to make auto responder commsnd for multi servers ?

prisma flicker
fervent cradle
#

@prisma flicker can u trll plz

prisma flicker
fervent cradle
prisma flicker
prisma flicker
obtuse juncoBOT
#

Saying it doesn't work or asking what's wrong with this code? is not helpful for yourself or others.
Describe what you expect and/or tried (with your code), and what isn't going right.
Please provide any errors you get for optimal assistance.

amber shale
# prisma flicker ?tag idw

i didnt get any error, and it didnt show up on slash commands, removerole just below it showed and another bridge command also showed..

prisma flicker
#

also update to 2.1.1 or put store=False in load_extension

#

oh it's not getting registered?

amber shale
prisma flicker
amber shale
#

no

prisma flicker
#

can you start a new thread and put the code that's working and the code that isn't there please

amber shale
#

u mean new post?

prisma flicker
#

yes

prisma flicker
proud mason
#

if i have a bot running continuously, will msgs from its cache ever get removed? or will the ram usage keep going up?

prisma flicker
#

the default message cache is 1k

proud mason
#

so the thing is

#

im making a giveaway system

#

i make an object of a custom giveaway class
i store the message object in it while doing so

#

if the message is removed from cache, it shouldn't be removed from my object right

prisma flicker
#

you'd still have the message object

proud mason
#

also

#

i store these giveaway objects in a list

#

what the best to discard these x days after ending

prisma flicker
#

del giveaways[1]?

proud mason
#

i dont want fifo cause that is based on object creation time
i rather want it to be deleted when smth like 3 days after it ended

prisma flicker
#

or giveaways[1] = None

#

or store them in a set instead

proud mason
prisma flicker
#

how do you get the right giveaway out of the list now?

proud mason
#

well

#

using discord.utils.find

prisma flicker
#

do you loop through the whole list every time?

proud mason
prisma flicker
#

so yes

proud mason
#

i can have it in a dict tbh

prisma flicker
#

why don't you use a dict of id to message object?

proud mason
#

with the msg id

#

yea

#

i can do that

prisma flicker
#

and then you can just do delkey or whatever

proud mason
#

but how do i delay it πŸ‘€
add a function that deletes itself to the object itself and use asyncio.sleep(3days+time_ended) ?

#

can an object delete itself?

prisma flicker
#

store the ones to delete in a separate list, and have a loop that goes through and deletes them from the dict after 3 days or something

proud mason
#

also if i do del gaw_obj will it automatically remove it from the stuff that has references to it?

#

like lists for eg

prisma flicker
#

no it just removes that one object

#

I think

#

depends if the things in the list are by reference or by value πŸ™‚

proud mason
#

that wont use double memory right. storing same obj in 2 lists

prisma flicker
#

how many giveaways are you going to have? lmao

#

I think you're trying to optimize a little prematurely

proud mason
proud mason
#

idk why optimization comes into my mind so early

#

i dont even have the system ready

#

lmao

prisma flicker
#

I would just get the core system working, and if memory goes up too high then look into optimizing

#

or, y'know, use a persistent data store

#

like a database

#

and then you don't have to keep it all in memory πŸ™‚

proud mason
#

hmm good idea

prisma flicker
#

plus if your bot restarts then it would all be gone

proud mason
#

i can actually have the giveaway id same as the message id
that would make stuff easier for me

prisma flicker
proud mason
#

oh wait

#

if i have them in a db, how do i implement functions on the class ThinkO_O

prisma flicker
#

you can use an orm

proud mason
#

i got this πŸ’€

proud mason
prisma flicker
#

yeah

proud mason
#

bro πŸ’€

#

i should have done that in my previous project

#

actually makes sense lmao

#

dumb me πŸ’€

#

aight ty

#

oh also i have a schedule_end method that does- await asyncio.sleep(duration) and then await self.end()
and i do self.task = asyncio.create_task(self.schedule_end()) in __init__

#

is there any better alternative

#

cuz this way i can cancel it too

#

but i feel it is weird

#

dk

prisma flicker
#

I like to program defensively "what happens if my bot restarts"

#

so I would have a task that runs every minute and gets all the giveaways that have ended and end them

proud mason
#

cuz now that im using a db

prisma flicker
#

and I avoid sleeping in general

#

it's just not a very good practice imo

proud mason
proud mason
#

its a public bot but developed with a specific server in mind

#

i wonder if any one else would ever add it πŸ€”

#

but thats besides the point πŸ˜‚

prisma flicker
#

then I would have a button instead, that only lets you enter if it hasn't ended yet. and if someone tries to enter late the button can end the giveaway too and show the results. it would just call the same method

meager heron
#

I get discord.errors.Forbidden when trying to delete one of the bot's own posts. Is that normal? I thought you could always delete your own posts

topaz rune
#

hi, how can I verify is the last message of a channel is a button pls? now I have this code

#
@commands.Cog.listener()
    async def on_message(self,message):
        if message.channel.id == 1003590390009577493:
            if not message.components == discord.button:
                channel = await self.bot.fetch_channel(1003590390009577493)
                ticket_act = channel.last_message_id
                await channel.send(view=button_fermeture_ticket(ticket_act))
#

but I have this error:
AttributeError: module 'discord' has no attribute 'button'

naive remnant
#

Use

#

Button

#

With a CAP

topaz rune
#

oh ok thanks bro

naive remnant
#

Np

proud mason
#

idk ill see tomorrow

#

almost 2am now

#

if im doing stuff db based, i should save everything as per id right

tranquil pivot
#

How do you make drop downs and buttons persistent?

errant craneBOT
#

Here's the persistent example.

raven island
#

what permission is required for this?
I am getting a weird
discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access error message now....

Nothing has changed in my bot....

prisma flicker
#

@tranquil pivot ^

tranquil pivot
#

Thank you

proud mason
cyan quail
#

or

#

eh

#

wait no

#

are you 100% sure it's that line?

proud mason
#

get_channel wont raise that

raven island
proud mason
#

it will rather return None if a channel with that id isnt found

cyan quail
#

your bot can't send to that channel

raven island
#

Can I ask why? It has been sending to this channel for many many months and now its not working all of a sudden

cyan quail
#

how would we know

#

maybe the perms changed

#

ultimately you're gonna have to go look at that channel yourself

tired birch
#

so um how do I edit a response with ctx? I know that interaction.response.edit() exists but I don't have interaction defined in the command...

cyan quail
#

that's under ctx.interaction

#

but you just need to use ctx.edit

tired birch
#

oh ok, thx

proud mason
# prisma flicker like a database

i just realised, if i store the entered users in a db, does that mean ill have to have a table with all the members the bot has access to? πŸ’€

#

cuz yk, many to many field

cyan quail
#

that's like, literally the point of the members intent

proud mason
#

dang 😩

#

how big would the table get

cyan quail
#

however big your code makes it GuraShrug

proud mason
#

how large would a table with 10k rows be

#

goes in MB or nah

#

lets say postgres

#

i wonder if sqlite can handle this

cyan quail
#

eh you'll be fine

proud mason
#

hmm

proud mason
cyan quail
#

you can try interaction.edit_original_message, but i think self.view.message.edit may have a higher chance of working

cyan quail
proud mason
#

true

proud pagoda
#

You could try interaction.response.edit_message

proud mason
#

and one more thing

cyan quail
#

they're avoiding response because of modal

#

ok nice

proud mason
#

the owner says he want this as a requirement

β€’ messages (number)
The minimum amount of messages sent by the user after the giveaway started

cyan quail
#

well

proud mason
#

i dont think imma save each and every msg to a db

#

lets say i skip the content

#

but still

cyan quail
#

yeah that's fine

proud mason
#

πŸ’€

cyan quail
#

on_message, save userid and +1 to it each time i guess

#

kinda a pain but then the data can be discarded after the gw ends

proud mason
#

msg after the giveaway started.
maybe i have a mapping for user and msgcount idk

cyan quail
#

that's all you need yeah

proud mason
#

how do i have this in a db

#

gonna need another table

#

foreign key and reverse relation on the gaw table

#

ig

#

man too complicated for simple shit

#

why cant stuff be straightforward

#

imagine he ends up not using it

cyan quail
proud mason
#

πŸ˜”

#

kden imma sleep

#

kill_brain.exe was run by developing bot

#

πŸ’€

topaz rune
#

can someone know how I can verify if the last message sent on a channel is a button or not pls?

topaz rune
#

im on this

#

but not working

cyan quail
#

that won't work because it won't be None, it'll be an empty list

#

just do if message.components

topaz rune
#

well, it's not doing what it should do, I need to verify on a on_message func if the last message is anything else than a button, and send a button if the last message isn't a button

cyan quail
#

so uhh

#

have you considered that in on_message, the current message is the last message?

#

you're already accessing message.channel so you don't need to fetch_channel again

#

if you want to check if the message doesn't have a button (or any items), then it'd be the opposite; if not message.components

topaz rune
cyan quail
#

yeah but my point is that you're checking if the current channel is the same as the one you're fetching

#

you can completely remove the fetch line and do message.channel.last_message_id

prisma flicker
#

Or any of them

#

Beyond like the id

topaz rune
pallid token
#

Hey guys. I'm trying to clean up my sessions on the bot's shutdown. I've tried doing so in both a cog_unload and __del__ function in my cogs. The cog_unload function doesn't seem to get called at all and the __del__ function occurs after the event loop is already called thus causing issues with running self.client.loop.create_task(). Just wondering if there is a way I can make this work. Thanks πŸ˜„

topaz rune
#

:/

cyan quail
topaz rune
cyan quail
pallid token
cyan quail
#

oh i see now

topaz rune
#

exactly buddy

#

and thats the dfficulty here

cyan quail
#

not really... you said something completely different before

#

just check message.embeds

cyan quail
topaz rune
cyan quail
#

in which case, in your shutdown function you could go through all your cogs and unload them

#

all good

pallid token
#

Ahh that makes sense lol
A little backwards, but if it works, it works πŸ˜†

cyan quail
#

alternatively, if it's only in one or two cogs you could just use get_cog to access the attributes

#

but whatever works i suppose

pallid token
#

I'll probably go for the first one as quite a few of my cogs use it. Thanks for the help, I'll try that out πŸ™‚

cyan quail
#

all good

iron halo
#
    member = discord.Guild.get_member(guild, ctx.author.id)```
this is returning None and im going crazy
iron halo
#

if u mean guild_id= then that broke aswell.

cyan quail
#

no

iron halo
#

oh the note

cyan quail
#
  1. read the note for fetch_guild on that page
  2. it should just be guild.get_member, not discord.Guild.get_member
iron halo
#

oh yea ofc

cyan quail
#

you should use bot.get_guild to grab the guild from your cache, which will contain members

iron halo
#

ah ok ty

pallid token
#

Hey Nelo. Just wondering if there is an event called on the bot's shutdown (equivelant to on_ready, but called on shutdown). I know there is one for on_disconnect, but that's not what I'm looking for here. I can't seem to find a suitable one in the event reference.

#

I need to be able to call this before the cogs are unloaded and the event loop is shut down.

loud holly
#

the wait for event, is there a way to get the user mention on it? Trying to find an event for it, but can't find it unless I'm looking for the wrong one

full basin
#

on_message?

loud holly
full basin
#

I mean, you said get user mention

#

Then you want a message.

#

Then you need to wait_for a message

cyan quail
pallid token
#
INFO:discord.client:Received signal to terminate bot and event loop.
INFO:discord.client:Cleaning up tasks.
INFO:discord.client:Cleaning up after 3 tasks.
INFO:discord.client:All tasks finished cancelling.
INFO:discord.client:Closing the event loop.
<BOT LOOP TERMINATION OCCURS>
<COG UNLOADING OCCURS>
cyan quail
#

hmmm

pallid token
#

The loop terminates before cogs are cleaned up/deleted.

cyan quail
#

it's caught as a keyboardinterrupt in bot.run

pallid token
#

In fact, the only reason why the cogs clean up in the end (triggering the __del__() function is because Python terminates. By then, the loop has long since finished running and you cant really run anything to load/unload them.

pallid token
cyan quail
#

your best bet may be to override _cleanup_loop in client.py py def _cleanup_loop(loop: asyncio.AbstractEventLoop) -> None: try: _cancel_tasks(loop) loop.run_until_complete(loop.shutdown_asyncgens()) finally: _log.info("Closing the event loop.") loop.close()

#

or if you want i guess you technically don't need to use run at all, use start and implement your own KeyboardInterrupt logic

pallid token
#

I'll do it if I have to, but I do wonder why it is necessary in the first place. Is it really that uncommon for people to need to run async logic when the bot shuts down that an on_teardown or on_shutdown event was not created when a on_ready one is?

cyan quail
#

people doing that likely aren't using run in the first place

If you want more control over the event loop then this function should not be used. Use start() coroutine or connect() + login().

#

there are other ways to do it, run is just if you don't want to think about anything else

pallid token
#

Ahh fair. Still feels like an over-complicated way of handling things when an event could just as easily exist for it. Not here to argue with you of course, but by the same logic on_ready shouldn't exist (barring, of course, reconnects) πŸ€·β€β™‚οΈ

#

Thanks for all the help though. I really appreciate it πŸ˜„

cyan quail
#

i mean, on_ready exists because it is an event from discord; same with connect and disconnect etc

full basin
#

Are there any dynamic cooldown examples? Cant seem to find it

full basin
#

I said dynamic cooldown.

stiff fiber
#

How do I get modal data in a callback without having to subclass the modal?
All modal examples I can find involve subclassing the modal and handling it that way - this isn't applicable for my use case

young bone
#
modal = discord.ui.Modal()
.
.
.
hearty mauve
#
In Cog/staff.py
class staff(commands.Cog):
    def __init__(self, client):
         self.client = client

@commands.slash_command(name='mute', description='Mutes <user> for <duration> minutes because of <reason> using discords new timeouts')
@commands.has_guild_permissions(moderate_members=True)
async def mute(ctx, member: discord.Member, duration, reason):
    minutes = datetime.timedelta(minutes=int(duration))
    await member.timeout_for(minutes, reason=reason)
muteem=discord.embed(title=f"{member.mention} was muted for {minutes} for {reason}", color=0x2F3136)
await ctx.message.delete()
    await ctx.respond(embed=muteem)

@commands.slash_command(name='unmute', description='unmuting <user> with <reason> using new discord timeouts')
@commands.has_guild_permissions(moderate_members=True)
async def unmute(ctx, member: discord.Member, reason):
    await member.remove_timeout(reason=reason)
unmuteem=discord.Embed(title=f"Unmuted {member.mention}", color=0x2F3136)
await ctx.message.delete()
    await ctx.respond(embed=unmuteem)


@commands.slash_command(name="purge", description="Deletes certain amount of messages **ADMIN**")
@commands.has_permissions(administrator=True)
  async def (self, ctx, amount=10):
    print('Purge enabled')
    await ctx.channel.purge(limit=amount + 1)


@commands.slash_command(name="ban", description="Bans specified user | /ban <user> <reason>")
@commands.has_permissions(moderate_members=True)
  async def ban(self, ctx, member: discord.Member, *, reason=None):
  banem=discord.Embed(title=f"Banned {member.mention} for {reason}", color=0x2F3136 ")
  await member.ban(reason=reason)
  await ctx.respond(embed=banem)

def setup(client):
  client.add_cog(staff(client)))
In main.py

import discord, json, os, random, asyncio, string, time, requests
from discord.ext import commands, tasks
from datetime import datetime

for file in os.listdir('Cog'): 
    if file.endswith('.py'):
      client.load_extension(f'Cog.' + file[:-3]) 
hearty mauve
#

This wont work

young bone
#

Any errorΒ΄s?

hearty mauve
#

No errors

young bone
#

which one doesnΒ΄t work?

hearty mauve
#

The cog

#

The cog doesnt work

young bone
#

can you add store=False to the load_extension()?

hearty mauve
#

Is it cause a command doesn't have self?

smoky forge
#

the commands have to have self as first argument

#

as with every class

rugged lantern
#

their main.py isn't in a class though

stiff fiber
# young bone ```py modal = discord.ui.Modal() . . . ```

That's not what I meant - I'm fine with creating and sending modals, but I'm having difficulty receiving the modal's text input fields in a callback.

...

async def cb(interaction: discord.Interaction):
    # parse modal fields somehow

async def some_interaction(interaction: discord.Interaction):
    modal = discord.ui.Modal(title="Sample")
    modal.add_item(discord.ui.InputText(label="Field"))
    modal.callback = cb
    await interaction.response.send_modal(modal)
stiff fiber
young bone
stiff fiber
#

some_interaction is a placeholder for some event - the cb function is the callback for the modal

grim canopy
#
Extension 'cogs.owner raised an error: TypeError: Owner.maintenance() got an unexpected keyword argument 'guild_ids'

I believe this is a core library issue

young bone
grim canopy
stiff fiber
grim canopy
#

I want it global

young bone
#

k

stiff fiber
#

This is my callback function that I pass to a modal. I can't subclass the modal because I want to process its data inside another class.
The second line is the only method I have found to access a modal's input data from a callback without subclassing the modal, but it's very hacky.

fervent cradle
#

how do i feckin remove the default help command

#
bot.remove_command('help')
#

this is what i tried

meager mica
#

you can also do bot = commands.Bot(prefix,help_command=None) i think

fervent cradle
#

alr, imma try that

silver moat
fervent cradle
#

you'd think I havent been racking my brains over the docs since yesterday

#

but you're wrong

meager mica
fervent cradle
#

oh yes

#

thanks a lot, after I'm done with this I'm gonna make a repo with examples for all basic ass stuff

slender abyss
#

my whole console if full of this error why it happens and any way to reduce it?

#

everything works but this

prisma flicker
slender abyss
#

yeah

#

the view has a timeout of 300s

prisma flicker
#

well there's your problem

proud mason
# prisma flicker Beyond like the id

Yea I only need the id, but you can't store them without SQL relations. It's bad practice to store a list without a table (like raw bytes of a python list) and I'm not gonna store it as text and parse it every time

meager mica
#

is there a way to have multiple views in one message

#

like a list somehow

prisma flicker
cold storm
#

hey, what api scopes would i need to detect a users activity (listening to song) and is there a scope in pycord to use it

prisma flicker
#

again you're worrying too much πŸ˜„

full basin
proud mason
proud mason
#

i need people to hold me back

slender abyss
#

i thought of defering the interaction instead and sending a followup if it fails

#

like this

sacred dragon
#

How to get membercount in pycord?

slender abyss
sacred dragon
#

but IM facing another issue

#
@bot.slash_command(name = "avatar", description = "Shows the avatar of a user")
async def avatar(ctx, user: discord.Member):
    avatar = user.avatar_url
    av = discord.Embed(title = "Avatar")
    av.set_image(url = f"{avatar}")
    ctx.respond(embed = av)
#

its giving this error

discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'Member' object has no attribute 'avatar_url'
sacred dragon
proud mason
#

what is better? django orm or tortoise orm?

#

or like which is the best/fastest orm for python

copper dew
#

im currently using sqlalchemy orm, but tortoise orm probably would provide an advantage. the reason why im probably not going to switch for my current bots is that i probably have around 1-2K lines of code that use sqlalchemy orm already

fervent cradle
#

Can someone help me?

    async with aiohttp.ClientSession() as session:
        webhookx = Webhook.from_url('https://discord.com/api/webhooks/1013384645582262293/nDJOCgwRwFc2wy9fR9UEFpMi1T-9OyDhoPgtPAdsg-50dLznA9ULl90Bw--q2ze97XMr/messages/1013385759677501471', session=session)
    await webhookx.edit_message(1013385759677501471, content="sal")

Command raised an exception: RuntimeError: Session is closed

proud mason
#

can i add a non field element to an orm model?

#

idk what to call this

#

what i want to do is, pass my bot object to the orm model

I have defined methods in the model that use it

fervent cradle
#

Hello!

#

How's everyone today?

#

I am in need of help.

#

I am 13 and I just found a thing called "programming" I was lured into it and I was wondering if anyone could help me.

#

I am using python and I think what I would like to do is statistics.

#

If anyone could help it would mean my life.

#

❀️

undone smelt
#

How would I edit a response after it's sent? I tried storing it in a variable but get the following error.

    @slash_command()
    async def timer(self, ctx: discord.ApplicationContext):
        response = await ctx.respond(embed=discord.Embed(title="Started..."))
        print(type(response))
        await asyncio.sleep(1)
        await response.message.edit(embed=discord.Embed(title="Ended!"))  # type: ignore

discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'NoneType' object has no attribute 'edit'

undone smelt
#

lol...yep

#

tyty

slender abyss
#

what is this error and how do i fix this

proud pagoda
cold hamlet
#

It might be a very bad and hacky idea, but could I misuse the discord.ui.View.interaction_check function and use it as a way to perform a before-callback-invoke hook?

grizzled sentinel
grizzled sentinel
fervent cradle
#

Hey,
why he say me that code is incorrect when i use random.randint(), but when i use code = ["2112", "1213", "2102"] its that correct? Why?

Code:

self.code = random.randint(1000, 9999)

if self.children[1].value == self.code:
    print("Correct..")
else:
    print("Incorrect..") 
grizzled sentinel
slender abyss
grizzled sentinel
cold hamlet
grizzled sentinel
slender abyss
fervent cradle
grizzled sentinel
grizzled sentinel
fervent cradle
#

Okay thanks

slender abyss
#

I have an empty file manager

#

The code is directly taken from github

#

Idk where the files could go wrong

grizzled sentinel
#

They have a great support team, open a ticket with your error.
It is an issue with there setup with the server, should be a simple fix once they see it :)

slender abyss
#

Okay

fervent cradle
grizzled sentinel
#

what are you trying to output?

#

like what is the end goal

fervent cradle
#

I want to generate random four numbers and I input those and the bot see its correct or its incorrect.

#

but he gives me only a number 1 - 9

#

when i use this in a string

grizzled sentinel
#

so random.randint will generate 1 random number with 4 digits.
If you want 4 random numbers of 4 digits use list comprehension.
[str(random.randint(1000, 9999)) for x in range(4)]
Does that make sense?

#

Random choice would choose a random charecter in the string

grizzled sentinel
#

it will make a list of 4 items

#

The code i sent is the same as this

code = []
for x in range(4):
    code.append(str(random.randint(1000, 9999)))
fervent cradle
#

Mhmm okay thanks

slender abyss
#
Traceback (most recent call last):
  File "C:\Python310\lib\site-packages\discord\client.py", line 382, in _run_event
    await coro(*args, **kwargs)
  File "C:\Python310\lib\site-packages\discord\bot.py", line 1025, in on_connect
    await self.sync_commands()
  File "C:\Python310\lib\site-packages\discord\bot.py", line 685, in sync_commands
    await self.http.bulk_upsert_command_permissions(self.user.id, guild_id, guild_cmd_perms)
  File "C:\Python310\lib\site-packages\discord\http.py", line 357, in request
    raise HTTPException(response, data)
discord.errors.HTTPException: 405 Method Not Allowed (error code: 0): 405: Method Not Allowed
#

what is this

silver moat
#

?tag application.commands

obtuse juncoBOT
#

dynoError No tag application.commands found.

silver moat
#

?tag application.command

obtuse juncoBOT
#

dynoError No tag application.command found.

silver moat
#

?tags command

obtuse juncoBOT
#
Tags (4)

subcommands, slashcommandmention, commandnoshow, applicationcommands-registration-delay

silver moat
#

?tags 405

#

?tags 405

obtuse juncoBOT
#

dynoInfo There are no tags that match your search.

silver moat
#

bruh

silver moat
#

Or you are on 2.0.0b7 or older and implementing permissions that are deprecated

slender abyss
#

also

#
Ignoring exception in command list clear:
Traceback (most recent call last):
  File "/home/container/.local/lib/python3.10/site-packages/discord/commands/core.py", line 127, in wrapped
    ret = await coro(arg)
  File "/home/container/.local/lib/python3.10/site-packages/discord/commands/core.py", line 1202, in _invoke
    await command.invoke(ctx)
  File "/home/container/.local/lib/python3.10/site-packages/discord/commands/core.py", line 356, in invoke
    await self.prepare(ctx)
  File "/home/container/.local/lib/python3.10/site-packages/discord/commands/core.py", line 278, in prepare
    if not await self.can_run(ctx):
  File "/home/container/.local/lib/python3.10/site-packages/discord/commands/core.py", line 373, in can_run
    local_check = cog._get_overridden_method(cog.cog_check)
AttributeError: '_MissingSentinel' object has no attribute '_get_overridden_method'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/home/container/.local/lib/python3.10/site-packages/discord/bot.py", line 997, in invoke_application_command
    await ctx.command.invoke(ctx)
  File "/home/container/.local/lib/python3.10/site-packages/discord/commands/core.py", line 359, in invoke
    await injected(ctx)
  File "/home/container/.local/lib/python3.10/site-packages/discord/commands/core.py", line 135, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: '_MissingSentinel' object has no attribute '_get_overridden_method'
#

what is this

silver moat
#

see ##1593

slender abyss
#

is this a latest issue?

silver moat
#

##1593

#

yeah

slender abyss
#

which is yet to be solved?

silver moat
#

it is solved

slender abyss
#

umm how

#

lol i have been scratching my head for almost an hour now

silver moat
#

you can use master branch

#

?tag install

obtuse juncoBOT
#
  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 !git to find out how to install git.

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

silver moat
#
pip install -U git+https://github.com/Pycord-Development/pycord```
slender abyss
#

git+https://github.com/Pycord-Development/pycord

#

i just paste this in my requirement.txt file right

silver moat
#

yes

slender abyss
#

nope

rare ice
#

I’m using 2.0.0rc1 and I’m using a wait_for('message'), and I have a check that is:

def check(m):
  return m.author == interaction.user and m.channel == interaction.channel
``` (the context is in a subclassed button callback)
it doesn’t actually return True so I printed `m.channel` and it printed: `Direct message with Unknown User`. Is this a bug with 2.0.0rc1?
slender abyss
#

did not work i still get that error

#

and my command fail to run

meager mica
rare ice
# silver moat why rc1

I haven’t upgraded to 2.0 because I was experiencing the issue of cogs not throwing errors when loading. But I’ll be upgrading to the latest soon

proud pagoda
#

Yeah just set store=False when loading extensions

silver moat
rare ice
rare ice
silver moat
rare ice
#

oh rip

silver moat
rare ice
#

so which version do I upgrade to?

#

that’s stable

silver moat
#

2.0.0 also has vulerability that can crash your bot

#

so 2.0.1 i would say

rare ice
#

yeah

#

k

slender abyss
#

master branch also have the issue with slash commands groups

silver moat
#

so ##1594 didn't fix it?

silver moat
#

you're not in a DM, correct?

rare ice
#

No

#

In a DM

#

Still saying "Direct Message with Unknown User"

silver moat
#

what is interaction.channel ?

rare ice
#

the same channel, the DM

#

it prints it correctly I think

rare ice
#

It’s just m.channel

#

which is the message it waits for

silver moat
#

it might be a discord api issue

rare ice
#

:/

slender abyss
#

its ##1594

silver moat
#

yeah that one

#

that should've fixed the issue

prisma flicker
# slender abyss what? >_>

The view timed out, and people are still interacting with it, so you're gonna get that error in your logs

prisma flicker
echo pond
#

Got a small question,

I am trying to make a slash command (that worked fine)
But I am also using the on_interaction event and now my slash command gets 'handled' only by the event and not it own function.
Is there a way to 'continue' from the on_interaction that it just finishes the code that is written in the slash_command?

silver moat
#

or is it process_application_command

#

one of them

echo pond
#

I will send a screen of my code gimme sec

#

but yeah since I got the on_interaction event, the slash commands get handled by the event instead of the slash_command

silver moat
echo pond
silver moat
#

np

slender abyss
#

No the view did not timed out its less than 10s before the view has been started

#

@prisma flicker

#

For the fix i thought of defering the interaction

rare ice
silver moat
#

probably if message_content intent is enabled then it may be availible

proud mason
proud mason
proud pagoda
hushed ledge
#

One message removed from a suspended account.

#

One message removed from a suspended account.

hushed ledge
proud pagoda
#

np

proud mason
proud pagoda
#

yeah

proud mason
#

But how am I to get it when i get use model.get

slender abyss
#

Ignoring exception in view <FeeAdd timeout=300 children=2> for item <Button style=<ButtonStyle.danger: 4> url=None disabled=True label='Add Fee' emoji=<PartialEmoji animated=False name=':heavy_dollar_sign:' id=None> row=None>:
Traceback (most recent call last):
  File "/home/container/bot.py", line 150, in addfee
    await interaction.response.send_message("Debt Added to all the **members** in the list :white_check_mark:")
  File "/home/container/.local/lib/python3.10/site-packages/discord/interactions.py", line 712, in send_message
    await self._locked_response(
  File "/home/container/.local/lib/python3.10/site-packages/discord/interactions.py", line 959, in _locked_response
    await coro
  File "/home/container/.local/lib/python3.10/site-packages/discord/webhook/async_.py", line 211, in request
    raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/container/.local/lib/python3.10/site-packages/discord/ui/view.py", line 375, in _scheduled_task
    await item.callback(interaction)
  File "/home/container/bot.py", line 152, in addfee
    await interaction.response.defer()
  File "/home/container/.local/lib/python3.10/site-packages/discord/interactions.py", line 559, in defer
    await self._locked_response(
  File "/home/container/.local/lib/python3.10/site-packages/discord/interactions.py", line 959, in _locked_response
    await coro
  File "/home/container/.local/lib/python3.10/site-packages/discord/webhook/async_.py", line 211, in request
    raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction
#

man how do i avoid this

#

i get this everytime

proud mason