#Basic Pycord Help (Quick Questions Only)

1 messages · Page 18 of 1

long moat
#
self.children[n].disabled = True```
where `n` is the button location (within a view)

If you have a custom label you can use:
```py
custom_name.disabled = True```
dusk burrow
#

how do i add tags to a forum chanel post created by a bot

fervent cradle
#

tysm

amber shale
#

how to get list of roles in one argument

cerulean yacht
wooden zenith
#

someone pls help me

#

im trying to do the link button

#

and its not working

#

this is what i have

#

class MyView(discord.ui.View):
@discord.ui.button(label="go to support page", style=discord.ButtonStyle.url, emoji="😎")
async def button_callback(self, button, interaction):
await interaction.response.send_message("You clicked the button!")

@bot.slash_command()
async def button(ctx):
await ctx.respond("This is a button!", view=MyView())

#

and idk where i put the url in

proud pagoda
#

Also

wooden zenith
#

wait

#

what

proud pagoda
#

?tag codeblock

obtuse juncoBOT
#

Please put your code in a code block:
```py
Here is your Code
```

That makes reading code in Discord a lot easier:

print("This is an example.")
wooden zenith
#

in the where

proud pagoda
#

Add this to your view:

def __init__(self):
  super().__init__()
  self.add_item(discord.ui.Button(label="...", url="..."))
wooden zenith
#

in the section where it says

#

(discord.ui.view)

#

?

proud pagoda
#

Add it as another method for the disord.ui.View

wooden zenith
#

ok

proud pagoda
#

It's a basic python thing

#

It just initalizes the view

wooden zenith
#

i didnt understand what u where saying at first

proud pagoda
#

Alright

wooden zenith
#

i know now

proud pagoda
#

👌

cerulean yacht
#

is there anyway to get replied message

#

hi

cerulean yacht
wooden zenith
#

What

#

@cerulean yacht

cerulean yacht
#

is there any way for the bot to access ur message

#

i mean replied message

fervent cradle
#
gnoring exception in command owners guild_notify:
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 904, in _invoke
    await self.callback(self.cog, ctx, **kwargs)
  File "/home/container/cogs/owners.py", line 112, in guild_notify
    channel = await guild.fetch_channel(int(channel_id))
  File "/home/container/.local/lib/python3.10/site-packages/discord/guild.py", line 2036, in fetch_channel
    data = await self._state.http.get_channel(channel_id)
  File "/home/container/.local/lib/python3.10/site-packages/discord/http.py", line 353, in request
    raise Forbidden(response, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access

why am i getting 403 while tryna get a channel

#
                guild = self.client.get_guild(int(guild))
                channel = await guild.fetch_channel(int(channel))

fervent cradle
#

no indents, worked before

cyan quail
#

missing access is a very literal error

#

you can't get the channel from that guild

fervent cradle
#

wdym

cyan quail
#

idk GuraShrug you literally don't have permissions

frank herald
#

Is there any way to see who removed someones reaction

cyan quail
frank herald
#

Sad

#

Someone is mass removing reactions and we dont know who

cyan quail
#

well they at least need manage messages

#

does that not narrow it down enough?

vagrant crystal
#

how do i add options to a select menu after it loads? when i make a Select object on __init__ it complains about the callback, and doing it in decorators doesnt work because the options are loaded from __init__ also

vagrant crystal
#

the follow_init used to just be in init

#

the data is passed through the bot object

#

oop forgot the callback

cyan quail
#

yeah you kinda just left it there

#

that syntax looks fine

vagrant crystal
#

i'd done dyn_sel.callback = self.the_method

#

and it complained about the arguments

cyan quail
#

can you show the full error?

vagrant crystal
cyan quail
slender abyss
vagrant crystal
#

so how do i get the selected thing out? is that a property on ctx?

cyan quail
#

this is a view right?

#

the class

vagrant crystal
#

yeah

cyan quail
#

access self.children

slender abyss
#

rtds

#

?

vagrant crystal
#

is the order of that list always consistent?

cyan quail
#

yes

#

the order they were added in

slender abyss
#

from left to right

slender abyss
vagrant crystal
#

is that the order of decorators? nvm ill figure it out

#

oh the theme is one monokai python i think

slender abyss
#

ty

vagrant crystal
#

thanks nelo

slender abyss
#

this

#

hmm

empty tree
vagrant crystal
#

did fix, thanks though

empty tree
#

ah alr

amber shale
#

@silver moat sorry i forgot to thank you
Thanks you very much for helping me 🙂

silver moat
#

np

loud holly
#

Is it a good practice to make the ticket buttons persistant view? the examples ^^

silver moat
loud holly
#

since bc everytime after the update, through thorough testing, I somehow find bugs etc

#

and then depending on the severity, I have to patch it ASAP

frank herald
#

Does anyone have an idea why Role.member doesnt work

#

Too much members?

silver moat
shadow stratus
#

#1016058923045888050 this bug is so annoying, it's been days and it still not patched

shadow stratus
#

The command still don't have options

fervent cradle
#

Hey, is there somehow an event where I can manage my data entries from my database for my giveaway command? I was thinking of the on_ready event, but that's only when the bot comes online

fervent cradle
cyan quail
#

so why don't you just save their entry when they click it

fervent cradle
#

That is made however I must draw the yes somehow and I can not make two raffles....

cyan quail
#

?

fervent cradle
#

so when i create the modal with the options so the time and the prize .. then have a asyncio with the time yk? and now when i start two giveaways then he draws only the last because of the asyncio. yk?

cyan quail
#

i'm not following

fervent cradle
#

And that's why I ask if there is an event for it where I can manage it so my database

cyan quail
#

so the command brings up a modal for you to set the time and prize

prisma flicker
#

Just use a task

#

Have it run every minute and process any giveaways that ended in the last minute

cyan quail
#

oh i see, deciding the winner

#

yeah that's the better option

#

it sounds like you're currently trying to sleep to the end of the giveaway?

fervent cradle
#

yes but its not works because when i create two giveaways then is the one giveaway not working because asyncio is then for the two giveaway. can you follow or not? btw. i'm sorry for my english.

cyan quail
#

all good

prisma flicker
#

Use a task

cyan quail
#

like jab said, you're better off using the tasks extension

fervent cradle
cyan quail
#

mhm

fervent cradle
#

Okay

fervent cradle
#

i know this ^^

#

but how time was check?

cyan quail
#

just have it loop every minute and check if the current time is past the giveaway's end time

prisma flicker
#

In your giveaway table you store the winner and end time, and in the task you get all giveaways that ended in the past and have no winner, and then you pick the winner and update the table

sly comet
#

Would this be a good place for help with webhooks? I currently need help with creating them in a channel when something specific is said and use it only if there's no existing webhook in said channel, otherwise it uses the existing webhook.

surreal glade
#

does anyone know how to make a subcommand within a subcommand

#

im trying to make a command like %cfg usr set <val>

#

it raises an error with my code

#
@bot.group()
async def cfg(ctx):
    if ctx.invoked_subcommand is None:
        await ctx.send("ERR: ctx.invoked_subcommand is None")
@bot.group()
@cfg.command()
async def usr(ctx, usr: discord.Member):
    if ctx.invoked_subcommand is None:
        ctx.send("ERR: ctx.invoked_subcommand is None")

@usr.command()
async def set(ctx, vlue):
    embed = discord.Embed(title="Config ⚙", color=0xff0000)
    embed.add_field(name=f"User Set", value=f"{usr} set to {vlue}", inline=False)
    ctx.send(embed=embed)
loud holly
loud holly
surreal glade
#

urgent

#

actually wait stackoverflow solved

sly comet
dusk burrow
#

when will this be supported in forum_channel.create_thread?

surreal glade
dusk burrow
#

okie

loud holly
#

What is the other best way to only get text channel, since the Union needs 2 args

#

i tried discord.channel hoping a miracle would work since I got that option but npe

#

I only want to get TextChannel

#

nvm I can put in only discord.TextChannel, it didn't work previously now it somehow worked

heavy ibex
#
overwrites = {
            interaction.user: discord.PermissionOverwrite(send_messages = True),
                'Members': discord.PermissionOverwrite(view_channel = False)
        }

guild = interaction.guild
cat = discord.utils.get(guild.categories, name="TESTING")
ticketchannel = await guild.create_text_channel(name='channel-name', category=cat, topic="testing", overwrites=overwrites)

What do I add instead of 'Members' to call to a role?

sly comet
median tinsel
#

Hi there, I recently migrated from discord.py too pycord, but when I did, I got an error saying that the discord.utils package didnt exist. I tried uninstalling and reinstalling several times but too no avail. Please let me know what could be causing the issue. Thanks.

silver moat
median tinsel
undone smelt
#

Does anyone have mondodb integrated I could peek at?

median tinsel
#

sorry for the ping it was an accident

silver moat
#

so uninstall py-cord and reinstall it

median tinsel
lean marten
#

Is it possible to check if a user voted for the bot in the last 12 hours?

lean marten
full basin
#

Assuming the site has an API

silver moat
lean marten
full basin
#

Theres a library for topgg iirc

lean marten
#

I only saw a event

lean marten
#

yea

#

on_dbl_vote

#

but it doesnt tell me if someone voted in the last 12 hours

lean marten
#

hm I try ty

#

ty

#

Other question

#

How can I add an element to an Object?
pymongo and in general

#

Like this:

feedback: {

  92919238298392: {
    msg: "Good ig"
    stars: "5"
  }

  92919238298392: {
    msg: "not good lol"
    stars: "1"
  }

}

sly comet
sly comet
umbral island
#

Does anyone know how to make an argument have "Choices", for example the default /timeout command has the argument duration that shows a dropdown list of options to choose from. How can I have this dropdown as an argument? I cannot seem to find docs on it.

prisma flicker
#

duration: Option(int, choices=[1,2,3])

umbral island
umbral island
lime lichen
#

and a colon..

#

and indenting

umbral island
#

jesus..

#

im must be tired af

lime lichen
#

this is the best i can do when i see it

@DaveMod.command(description = "Toggles the UrlBlocker")
async def toggle_url(ctx, setting : Option(bool, choices = [True, False])):
    await ctx.respond(setting)
umbral island
#

i think i just need to sleep now. That fixed my issue ofc, thank you

lime lichen
#

sure

#

night

umbral island
#

lol

#

night

lime lichen
#

anyone know why my on_ready event keeps getting called? it happens maybe once a day (i try to host my bot 24/7) and its rather frustrating as members intent is enabled and sometimes it just wont respond

copper dew
lime lichen
#

alright

undone smelt
#

Any idea to get pylance to chill? ive checked the source, the types are all there and correct. I have no idea why this happens

prisma flicker
prisma flicker
umbral island
#

i figured it out, thank you

rigid sable
#

How do I do persistent views with pycord?

errant craneBOT
#

Here's the persistent example.

rigid sable
#

Does anyone know how to set up persistent views without OOP?

loud holly
#

I believe its bot.add_view(persistent class)

#

In the on ready function I believe, just woke up so yeah

bleak cloud
#

I tried to run my bot on Ubuntu VPS, but it gave me RuntimeError: PyNaCl library needed in order to use voice
So I checked the doc and it says I can install voice dependenses with this command: apt install libffi-dev libnacl-dev python3-dev
I ran it and installed it successfully, but I still get the same error.
What should I check?

prisma flicker
#

did you install it with pip?

bleak cloud
#

you mean the dependences?

prisma flicker
#

actually nvm

#

do you have opus?

bleak cloud
#

what is it?

#

i've heard of it

prisma flicker
#

a dependency for pynacl

bleak cloud
#

how can I check if I have one?
It seems I have one installed

amber shale
#

is lavalink light? i have a vm in azure with 1 core, 1 gb ram and 60 gb storage

#

in that i host my bot (running ubuntu 22.04)

obsidian cargo
#

If i am overriding the on_interaction() event, do I need to invoke the process_application_commands() coroutine as well? Because I have override it without invoking the coroutine, and all the commands work correctly.

cyan quail
errant craneBOT
#

discord/bot.py lines 1057 to 1058

async def on_interaction(self, interaction):
    await self.process_application_commands(interaction)```
obsidian cargo
#

I've done this:

@commands.Cog.listener()
async def on_interaction(self, interaction):
    #Some code here
cyan quail
#

that's not overriding, that's an additional listener

#

so the original method still remains

obsidian cargo
#

oh, that makes sense. Then I don't really need to override it for anything

#

Then, how would I override it?

cyan quail
#

you'd override it in the main bot file with @bot.event if you didn't subclass

obsidian cargo
#

ok, thx

fervent cradle
#

Hey, I am sending two help menu messages with the same view, after sending the second one if I press a button on the first message the corresponding callback of the second view object gets called, why doesn't the first view call its own callbacks and instead the callbacks of the second view? I am confused please help

prisma flicker
#

because you're sending both with the same view...

#

make a new view if you want them to be different

fervent cradle
prisma flicker
#

sure you can

fervent cradle
# prisma flicker sure you can

why does it then always call the callbacks of the second instance even if I click on the buttons of the view which should be the first instance

prisma flicker
#

I only see you sending one message with one view

#

so I'm confused on your issue

fervent cradle
#

yeah sorry I didn't speak clearly there, this is a slash command and if I execute it twice

#

What I would expect is, that the view of the first message would callback callbacks of its own instance, but I have noticed that it always calls the callbacks of the newest instance (in this case second message) and I don't fully understand why

prisma flicker
#

why are you setting view.message?

#

you can just get the message in the callback from interaction.message

fervent cradle
#

sadly that doesn't fix my issue tho

prisma flicker
#

can you send your view code

#

?tag codeblock

obtuse juncoBOT
#

Please put your code in a code block:
```py
Here is your Code
```

That makes reading code in Discord a lot easier:

print("This is an example.")
fervent cradle
#

not sure if that helps but I print out the view.id when I send the message first that are the two ids on top and they are two different views but then I react to a button on the first view and a button on the second view and I print the view.id in the callback and it only calls the second instance

fervent cradle
#
class help_view(View):
    def __init__(self,ctx):
        super().__init__(timeout=timeout)
        self.context = ctx
        self.page_counter = 0
        # await interaction.response.send_message(view = self)
    @discord.ui.select(placeholder="choose the page here or use the buttons below", min_values=1, max_values=1, options=options, custom_id="help_select")
    async def help_select_callback(self, select, interaction):
        value = select.values[0].split(":")
        self.page_counter = int(value[0])-1
        await self.maybe_disable(interaction)
        await interaction.response.defer()

    @discord.ui.button(emoji = "⏮️",disabled = True, custom_id="start_button")
    async def start_button_callback(self, button, interaction):
        self.page_counter = 0
        await self.maybe_disable(interaction)
        await interaction.response.defer()

    @discord.ui.button(emoji = "◀️", disabled = True, custom_id="back")
    async def back_button_callback(self, button, interaction):
        self.page_counter -= 1
        await self.maybe_disable(interaction)
        await interaction.response.defer()

    @discord.ui.button(label=f"1/{len(help_dictionary)}",disabled =True, custom_id="label")
    async def label_button_callback(self, button, interaction):
        pass

    @discord.ui.button(emoji = "▶️", custom_id="next")
    async def next_button_callback(self, button, interaction):
        print(self.id)
        self.page_counter += 1
        await self.maybe_disable(interaction)
        await interaction.response.defer()

    @discord.ui.button(emoji="❌", custom_id="delete_help_button")
    async def delete_help_callback(self, button, interaction):
        if hasattr(interaction.message,"delete"):
            await interaction.message.delete()
        else:
            await interaction.message.delete_original_message()     
#

sorry for the messy code

#

and thank you for helping me

prisma flicker
#

looks like your 2nd half got deleted

fervent cradle
#

oh

#

why does it keep getting deleted?

#

ah theres a link in it

#

    async def maybe_disable(self,interaction):
        for child in self.children:
            if child.custom_id == "label":
                child.label = f"{self.page_counter+1}/{len(help_dictionary)}"
            elif self.page_counter == 0:
                if child.custom_id in ["back","start_button"]:
                    child.disabled = True
                elif child.custom_id == "next":
                    child.disabled = False
            elif 1 <= self.page_counter <= len(help_dictionary)-2:
                child.disabled = False
            elif self.page_counter == len(help_dictionary)-1:
                if child.custom_id == "next":
                    child.disabled = True
                elif child.custom_id in ["back","start_button"]:
                    child.disabled = False
        await interaction.message.edit(embed = make_embed(list(help_dictionary.values())[self.page_counter]),view=self)

    async def interaction_check(self,interaction):
        if interaction.user != self.context.author:
            await interaction.response.send_message(embed = make_embed(f"embed   This is not your help menu\nUse `/help` to get your own.    [Support Server]invite/wBGgE7drvt) 0"), ephemeral = True)
            return False
        return True

    async def on_timeout(self):
        for child in self.children:
            child.disabled = True
        try:
            if hasattr(self.message,"edit"):
                await self.message.edit(view=self)
            elif hasattr(self.message,"edit_original_message"):
                await self.message.edit_original_message(view=self)
        except Exception:
            pass
prisma flicker
#

where were you using self.message before?

fervent cradle
fervent cradle
#

do you have any idea what could cause the problem?

topaz rune
#

Hi, does someone know how to remove only the file from a message sent by a bot?

cyan quail
topaz rune
night warren
#

Hi, is there a way of restricting a slash command to a role or to exclude a role from it?

cyan quail
#

can you try interaction.edit_original_message instead

cyan quail
topaz rune
# cyan quail can you try `interaction.edit_original_message` instead
Ignoring exception in view <piece_class timeout=None children=9> for item <Button style=<ButtonStyle.primary: 1> url=None disabled=False label='a7' emoji=None row=None>:
Traceback (most recent call last):
  File "C:\Users\celia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\ui\view.py", line 371, in _scheduled_task
    await item.callback(interaction)
  File "f:\bot_cafe\chess.py", line 228, in piece_callback
    await interaction.edit_original_message(attachments=[])
  File "C:\Users\celia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\interactions.py", line 375, in edit_original_message
    data = await adapter.edit_original_interaction_response(
  File "C:\Users\celia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\webhook\async_.py", line 211, in request
    raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10015): Unknown Webhook
cyan quail
#

hm

topaz rune
#

I never use webhook on my code

#
async def piece_callback(self, interaction):
                if interaction.custom_id == 'Back':
                    await interaction.message.edit(view=chess_class.type_piece(self.pieces,self.id))
                else:
                    self.pieces[self.id][2] = interaction.custom_id

                    piece = self.get_piece(self.pieces[self.id][2],self.id)
                    size = (100,100)
                    case = Image.open("chess/case_poss.png")
                    case = case.resize(size, Image.ANTIALIAS)
                    background = Image.open("chess/echequier_base.png")
                    for y in range(8):
                        for x in range(8):
                            if piece.move_possible([y,x]):
                                print([x,y])
                                #On peut mettre la piece
                                background.paste(case,((x)*100,(y)*100), case)
                    background.save('chess/echequier_base.png',"PNG")
                    path = 'chess/echequier_base.png'
                    await interaction.edit_original_message(attachments=[])
                    await interaction.message.edit(file=discord.File(path))
cyan quail
#

well interactions are webhooks

#

oh you didn't respond

#

hold on lemme test something, im fairly sure you can do the bottom two lines in a single line

topaz rune
# cyan quail oh you didn't respond

ok I found the problem, it works if I only edit the message once, like this:

await interaction.message.edit(attachments=[],file=discord.File(path))
cyan quail
#

yeah

topaz rune
#

well

cyan quail
#

also at the top there

topaz rune
#

thanks buddy for your help

cyan quail
#

you should be doing interaction.response.edit_message

#

unless you're already responding somewhere else in the callback

topaz rune
cyan quail
#

all interactions need to properly be responded to via interaction.response

#

just once

#

so your first message edit should be response.edit_message instead of message.edit

topaz rune
#

got it

#

thanks

cerulean yacht
#

how to make a command that creates embed

#

what would be best option (i want it to be customizable

#

like any num of field

rare ice
cerulean yacht
#

using a command

#

*slash command

rare ice
#

That’s something you have to do. I have a system like that and I use buttons and modals so they can set the values themselves. It’s as a simple as having an embed and editing it depending on what modal they submit.

cerulean yacht
#

ok inviting ur bot

rare ice
#

I-

rare ice
#

#help-rules Rule 4

cyan quail
#

someone over in #creations posted their embed maker function #creations message

cerulean yacht
cerulean yacht
cyan quail
#

i mean

#

command options....?

cerulean yacht
#

i like his method so going to use it

#

thanks vNziie--

rare ice
#

Mhm

cerulean yacht
#

i assume u misunderstood and thought i am asking for code 😅, sorry i have problems in communication

fair crescent
#

im using my bot to manipulate files.

i want to make a select ui to select file and do some operations like delete or rename them... nelo already helped me to do that.

But i noticed something... if i do a class for this view in a separate file, the class is inicializated when the bot starts running, so i cant see the file change

@discord.ui.select( 
            placeholder = "Seleccionar presets",
            min_values = 1,
            options = os.listdir() # <---- 
        )
#

im trying to give the list as a parameter, but i cant find a proper way to do it, since i cant use self.varname inside the decorator

radiant nebula
#

Hi guys. How do I make a command that can only be performed by people with a certain role?

fair crescent
#

ctx.author.roles gives you the role list iirc

radiant nebula
#

Why?

rare ice
#

make sure you're in one of those roles

night warren
#

what difference is there between discord.Bot and commands.Bot? Can I use both prefixed commands and slash commands with commands.Bot?

fervent cradle
#

Help, on my pc it works but on VPS it doesn't

  File "/home/container/main.py", line 230, in <module>
    @bot.slash_command(guild_ids=[settings["guildID"]], name="whitelist", description="Whitelist a person to use the bot.")
AttributeError: 'Bot' object has no attribute 'slash_command'```
#

i have this in main.py

from discord.ext.commands import Bot

bot = Bot(command_prefix='$', activity=activity, status=discord.Status.online, intents=discord.Intents.all())```
cyan quail
fervent cradle
#

how do i do that on vps? well not vps i only have hosting and panel

cyan quail
#

note your vps needs python 3.8 or newer, if it's on 3.7 or below then it won't be able to update to v2

fervent cradle
#

Is it possible to make an embed look like the embed the automod uses

cerulean elbow
#

hello, is anyone good at oop?

cyan quail
#

or a requirements.txt file

fervent cradle
#

yep it installs packages from requirements.txt file

#

it has 3.9 python installed on it

iron halo
#

why does ctx.author.avatar.url sometimes give AttributeError: 'NoneType' object has no attribute 'url'
surely everyone has a profile picture

tiny wagon
#

how can i make a slash subcommand available to admins only, (disable them for others)

cyan quail
cyan quail
#

use display_avatar instead

#

though note that will also use guild-specific profile pictures instead of global

fervent cradle
cyan quail
#

well discord-sided anyway, you can always use internal @commands.checks decorators

tiny wagon
cyan quail
#

don't think so no

#

if it doesn't appear separately in guild settings > integrations then it won't work because discord technically treats subcommands as options, only top level commands are truly considered commands

tiny wagon
cyan quail
#

it raises CheckFailure

tiny wagon
#

i wonder they still work with app commands

cyan quail
#

yep

iron halo
cyan quail
#

they can't hide them from the ui, but they do still work

tiny wagon
#

so is there like seperate error handler for only one command, like prefixed commands, @command_name.error

cyan quail
#

it should work the same with application commands yes

tiny wagon
cyan quail
#

that would get the bot's member

fervent cradle
cyan quail
tiny wagon
#

ok ty lemme try it out

cyan quail
#

like does it go through installing or

fervent cradle
#

yes

cyan quail
#

so what does it say for py-cord

fervent cradle
#

requirement already satisfied

cyan quail
#

same error?

fervent cradle
#

yes still the AttributeError

cyan quail
#

can you print(discord.__version__) somewhere in your bot file

fervent cradle
#

yes

#

2.0.1

cyan quail
#

bruh

#

that should still work...?

#

just checking, you haven't installed another discord library right

fervent cradle
#

i guess not

empty kraken
#

Hey guys, How can i run a function from another file with only knowing relative path? (without hard coded import)
just like how py-cord adds cog classes

cyan quail
errant craneBOT
#

discord/ui/view.py lines 53 to 54

from ..components import _component_factory
from .item import Item, ItemCallbackType```
cyan quail
#

it looks like your bot is using another one that your console isn't using

fervent cradle
#

I do have "additional python packages" in the panel settings but i don't use it

#

i will delete .local and .cache files and try again

cyan quail
#

i wouldn't recommend deleting ALL of that

#

if im not mistaken, .local is the folder it SHOULD be using

fervent cradle
#

It'll just download the dependencies again

cyan quail
#

fair enough

fervent cradle
#

okay uhhh that worked lol

#

@cyan quail thank you very much

#

my problem has been resolved

cyan quail
#

allgood

empty kraken
#

so i cant import it hard coded

#

i need to use reflection tho but i never tried reflection in python.

cyan quail
#

then perhaps you want to use the os module to iterate through the folder?

empty kraken
#

yes

cyan quail
#

something like py for root, folders, files in os.walk("src/extensions")

#

but that for loop should work

empty kraken
# cyan quail but that for loop should work

after some search, i found what i wanted:

for folder in listdir("extensions"):
    for file in list(filter(lambda f: f[-3:] == ".py", listdir("extensions/"+folder))):
        print(f"extensions.{folder}.{file[:-3]}")
        mainFile = importlib.__import__(f"extensions.{folder}.{file[:-3]}")
        setup = getattr(getattr(getattr(mainFile, folder), file[:-3]), "loadApp")

        setup()
cyan quail
#

nice

empty kraken
#

this might not be best way, but it works

#

¯_(ツ)_/¯

worn void
#

I'm trying to use replit to share code with another dev and I can't import pycord for some reason

fervent cradle
#

is there a way to get the bot's avatar url with ctx?

cyan quail
fervent cradle
fervent cradle
#

how can i make a "hidden" slash command?

#

so the command interaction wont show for everyone

night warren
#
class MyHelp(commands.HelpCommand):
    def get_command_signature(self, command):  # to get the command (Ex. "-ban")
        return '%s%s' % (self.clean_prefix, command.qualified_name)```

AttributeError: 'MyHelp' object has no attribute 'clean_prefix'
grizzled sentinel
fervent cradle
#

discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: TypeError: send_message() got an unexpected keyword argument 'empherial

grizzled sentinel
grizzled sentinel
fervent cradle
#

its ephemeral

#

thx

night warren
night warren
#

now I don't get errors but

#

I need a way of fetching the prefix in my subclassed help command

#

before self.clean_prefix used to work

#

solved

#

it is self.context.clean_prefix

fervent cradle
#

also does anyone know if i can include attachments in command replies?

errant craneBOT
#
Tag Search | persistent view
lean marten
#

Is it possible to make slash commands only visible to me? (owner of bot)

fervent cradle
#

idk if its what you mean

cyan quail
lean marten
#

so not possible?

cyan quail
#

not via the bot, no

rare ice
#

It is, not with the bot

lean marten
#

..

silver moat
cyan quail
#

no one is authenticating their bot with oauth2

lean marten
#

no I mean e.g. commands to add premium to a user

#

yk

silver moat
#

global and add checks

cyan quail
lean marten
#

doesnt that look b a d ?

silver moat
#

no

cyan quail
#

you can hide by specific permissions (e.g. administrator) but that's about it

silver moat
#

it's actually better from a marketing perspective because it shows your users than premium features exist

cyan quail
#

though discord is adding built in support for bot subscriptions/premiums so maybe you'll see it in the future

lean marten
#

ok

#

And how can I make it only visible to admin ?

#

@default_permissions or what was it?

cyan quail
#

yeah @discord.default_permissions()

lean marten
#

ty

cyan quail
#

but note any other guild admins can override these

lean marten
#

uh whut

#

How?

cyan quail
#

from guild settings

lean marten
#

ahh

#

Alr ty

cyan quail
#

as per the docs

These permissions can be updated by server administrators per-guild. As such, these are only “defaults”, as the name suggests. If you want to make sure that a user always has the specified permissions regardless, you should use an internal check such as has_permissions().

lean marten
#

ig i make them visible for everyone then..

cyan quail
#

so basically use default_permissions combined with the checks from ext.commands if you truly want to keep commands limited

lean marten
#

And how can I check if command executer is me?

#

the bot dev

cyan quail
#

assuming you imported (from discord.ext import commands), use @commands.is_owner()

lean marten
#

works with slash commands too?

cyan quail
#

yep, it won't hide them but it still works

lean marten
#

alr

cyan quail
#

all check decorators from prefix commands also work with slash commands

lean marten
#

ty

cyan quail
#

allgood

fervent cradle
#

it sends an empty file :Cccc

cyan quail
#

uhh

#

you used it correctly

#

which means there's a problem with how you wrote the file above

fervent cradle
#

ohhh

#

ok

#

i added printing number of bytes in that file

#

and it kinda works

#

but still, there are 0 bytes showing on discord

round rivet
#

try seeking to 0 (rv.seek(0))

rigid sable
#

what are the other attributes for slash command interactions

little hill
#

When do you guys find it necessary to use max_concurrency?

cyan quail
#

one place i use them is in step-by-step commands where the user may spend some time going through the command's instructions and you don't want them to start another instance of the command

little hill
#

yeah that makes sense

#

Does Discord do a form of ratelimiting on a user's end to prevent them from spamming commands? It kinda looks like it

cyan quail
#

yeah

little hill
#

cool, means that we don't need to do that on our end

cyan quail
#

in general the library also already handles all ratelimits it can

#

though you may find internal cooldowns are still worth implementing

silver moat
#

and interactions have their own ratelimit

#

so that solves some problems

little hill
#

or a call to an external api

stiff fiber
#

Maybe a dumb question but is there any way to force emojis as slash command arguments?

cyan quail
#

you can use the discord.Emoji type, but it won't force it

#

(i think)

stiff fiber
#

that's sort of what I guessed
I'll just try it out and see what happens 🙃

full basin
#

Is it possible to create threads on ephemeral messages?

raven island
#

I know there is a async def on_guild_join event. is there an event for when the bot leaves a server that gets triggered?

raven island
#

ah was looking at the wrong remove. Thanks!

young bone
#

o/

cyan quail
#

you could just create a thread without an existing message

full basin
#

Yeah. But the "X has created a thread" messahe pops up and its annoying

cyan quail
#

or make it a private thread, then unprivate it

#

ah, i guess you need lvl2 for private so that's not always viable

silver moat
#

full traceback thanks

round rivet
#

no it isn't

#

but basically

#

you're checking if a list is inside a string

#

which can't be done

undone smelt
#

whats this "try my commands" business

round rivet
#

shows your most used commands

tiny wagon
#

how can i change the style of other buttons in a view from callback of one button

class HelpButtons(discord.ui.View):
    def __init__(self):
        super().__init__()
        self.choice = "main"

    @button(label="Raffles", style=ButtonStyle.blurple)
    async def raffle_callback(self, buttons, interaction):
        embed = Embed(title="embed 1", description="embed 1")
        buttons.style = ButtonStyle.green
        await interaction.response.edit_message(embed=embed, view=self)

    @button(label="Auctions", style=ButtonStyle.blurple)
    async def auctions_callback(self, buttons, interaction):
        embed = Embed(title="embed 2", description="embed 2")
        buttons.style = ButtonStyle.green
        await interaction.response.edit_message(embed=embed, view=self)

    @button(label="HP | IV Checker", style=ButtonStyle.blurple)
    async def info_callback(self, buttons, interaction):
        embed = Embed(title="embed 3", description="embed 3")
        buttons.style = ButtonStyle.green
        await interaction.response.edit_message(embed=embed, view=self)
#

when i press a button, the button changes to green, but other buttons should be changed back to blurple

fervent cradle
#

How do I add slash command parameter description?

tiny wagon
fervent cradle
#

Nvm

#

It's my issue

leaden delta
#

hey. How can I make my task execute every sunday?

winged kernel
#

After sending a File object, will there will a significant issue if I do not close it?

fervent cradle
#
async def callback(interaction):
            if options.values[0] == 'Admin':
                l_button.disabled = False
                r_button.disabled = False
                admin_embed = discord.Embed(description='ADMIN Commands\n\n`/autorole`\n❯ **Description: **setup role to be given when a member joins the server\n\n`/counter`\n❯ **Description: **setup counter channel in the guild\n\n`/flagtranslation`\n❯ **Description: **configure flag translation in the server\n\n`/farewell`\n❯ **Description: **setup farewell message\n\n`/welcome`\n❯ **Description: **setup welcome message', color=discord.Color.blue())
                admin_embed.set_thumbnail(url='https://icons.iconarchive.com/icons/dakirby309/simply-styled/256/Settings-icon.png')
                async def l_callback(interaction):
                    await interaction.response.edit_message(content='oh my god', embed=None, view=None)
                l_button.callback = l_callback
                await interaction.response.edit_message(embed=admin_embed, view=view)
#

in l_callback instead of the message getting editted to something i want, the bot just posts a new message

#

i tried using interaction.edit_original_message but that doesnt work

night warren
#
       @bridge.bridge_group(invoke_without_command=True). @bridge.map_to("help")
    async def cc(self, ctx):
        if ctx.invoked_subcommand is None:
            em = await funcs.custom_embed("Custom Commands", "**Available Options**: `add`; `remove`; `list`")
            await ctx.respond(embed=em)```

discord.errors.ExtensionFailed: Extension 'cogs.customcommands' raised an error: TypeError: BridgeSlashGroup.__init__() missing 1 required positional argument: 'callback'
calm plume
#

hey um i have an issue

#

where i try to make a new command

#

and it doesn't load

#
@commands.cooldown(1, 5, commands.BucketType.user)
@bot.command(name = "test", description="desc")
async def test(ctx: discord.ApplicationContext):    
    #stuff
full basin
tiny wagon
full basin
#

All of them?...

tiny wagon
tiny wagon
fervent cradle
cyan quail
cyan quail
cyan quail
#

meh go for it

calm plume
#
import discord, sqlite3, openai, urllib, ttictoc, termcolor, datetimeimport json, httpx
from unidecode  import unidecode
from Scripts import Functionsfrom discord.ext 
import commands

bot = commands.Bot(intents = discord.Intents.all())


@commands.cooldown(1, 5, commands.BucketType.user)
@bot.command(name = "test", description="Desc")
async def test(ctx: discord.ApplicationContext):
    await ctx.guild.create_category(name = "Category")




@bot.event
async def on_ready():
    print(f'Bot is Activated at Time {termcolor.colored(text = str(datetime.datetime.now()), attrs = ["bold"])} With The Time Of Execution Taking About {ttictoc.toc()}')


@bot.event
async def on_message(message: discord.Message):
   # Stuff

bot.run(token)
cyan quail
#

do you have any other events?

calm plume
#

nope

#

thats those 2 only

#

the weird thing is

cyan quail
#

i guess it might be taking time to sync...? what if you set guild_ids inside the command decorator

calm plume
cyan quail
#

yeah but just for testing

calm plume
#

ok

cyan quail
#

you can remove guild_ids after, but it;ll still take time to sync

calm plume
#

reran the bot

#

and when i do /

#

shows nothing again

#

same when i go to integrations

cyan quail
#

do you always use the @bot.command decorator

#

oh wait

#

lol

#

if it's commands.Bot, bot.command is a prefix command

#

you're looking for bot.slash_command

calm plume
#

hmm okay let me check

#

there u go that solved the issue

#

i was copy pasting some old code

#

so that was the cause of it

full basin
rocky stump
#

How can I add per-user cooldowns to buttons? I am familiar with @commands.cooldown(1, 30, commands.BucketType.user) but this is for commands. Will I have to implement my own type of cooldown using a dictionary or so?

cyan quail
rocky stump
undone smelt
fervent cradle
#

Why pycord said in @bridge.bridge_command this to me?

Expected type '_SpecialForm', got 'str' instead

proud pagoda
#

Just pass it into the _init_

#

So put bedingungen in between the parentheses when you create an instance of the view

#

Wdym

#

Send more code

#

Oh wait NVM where are you storing the database2 instance?

fervent cradle
#

how can i wait untill i get some values from dropdown in view?

#

and then proceed

proud pagoda
#

Where is bedingungen stored?

#

Well since you need to pass in bedingungen, add it as an attribute to the bot wherever you define it so you can access it anywhere

fervent cradle
#

du hast kein self.bedingungen im code

#

beim __init__()

proud pagoda
#

So smthn like this:

bedingungen = Someclass()
bot.smthn = bedingungen
fervent cradle
#

du hast ein fehler

#
    self.bot.add_view(gewinnspiel_buttons(self.bedingungen))
AttributeError: 'database2' object has no attribute 'bedingungen' 
#

dein class hat kein self.bedingungen

proud pagoda
#

No, do it wherever you define bedingungen

fervent cradle
#

woher bekommst du die bedingungen

proud pagoda
#

And then you can access it as a bot attribute anywhere

fervent cradle
#

ich seh hier nix

fervent cradle
proud pagoda
#

Wait what

fervent cradle
#

💀

#

dein database2 class hat kein bedingungen

#

geht es jzt?

#

ja

#

aber du musst die bedinungen haben

#

beim inizializieren von diesen class

#

schick mal den ganzen code

#

dm

#

gib code

#

gib den ganzen code

#

bruder ich bin zu busy fuer diesen kindergarten, gib code ich hilf und geh

#

bro mein bot ist ueber 20k also

#

egal ich geh

#

Wie unhöflich kann man sein

fervent cradle
fervent cradle
#

Is it just me or is discord having some sort of issue?
Commands are not getting updated (I have guild_ids=)

hushed ledge
#

One message removed from a suspended account.

young bone
hushed ledge
prisma flicker
young bone
hushed ledge
hushed ledge
fervent cradle
#
async def callback(interaction):
            if options.values[0] == 'Admin':
                buttons = [PaginatorButton("prev", emoji="⬅️", style=discord.ButtonStyle.gray), PaginatorButton("next", label="➡️", style=discord.ButtonStyle.gray)]
                paginator = Paginator(
                    pages = [Page(embeds=[discord.Embed(description='ADMIN Commands\n\n`/maxwarn`\n? **Description: **set max warnings configuration\n\n`/modlog`\n? **Description: **enable or disable moderation logs\n\n`/addrr`\n? **Description: **setup reaction role for the specified message\n\n`/removerr`\n? **Description: **remove configured reaction for the specified message', color=discord.Color.blue()), discord.Embed(description='ADMIN Commands\n\n`/autorole`\n? **Description: **setup role to be given when a member joins the server\n\n`/counter`\n? **Description: **setup counter channel in the guild\n\n`/flagtranslation`\n? **Description: **configure flag translation in the server\n\n`/farewell`\n? **Description: **setup farewell message\n\n`/welcome`\n? **Description: **setup welcome message', color=discord.Color.blue())])],
                    use_default_buttons=False,
                    show_indicator=False,
                    custom_buttons=buttons
                )   
                await paginator.respond(ctx.interaction)
#

hey guys so i almost gifured out everything, but the problem is the paginator sends 2 whole embeds which i dont want, i want the messages to get editted

#

can someone tell me how i can do that?

#

this is a callback for a select menu btw

loud holly
cyan quail
#

also that page section is stupidly hard to read, i'd recommend defining the embeds somewhere else so you can actually comprehend the code...

fervent cradle
cyan quail
#

but you still have to respond to the interaction separately

fervent cradle
cyan quail
#

well it kinda tells you

#

the message you want to edit

dry echo
#

does channel.edit(overwrites) rewrite all perms of this channel or only for the args i pass?

cyan quail
#

all

dry echo
fervent cradle
cyan quail
#

then pass it in...?

fervent cradle
#

but unable to do it

fervent cradle
#

its kinda complicated

fervent cradle
#

in the last part i am using pagination, and to edit i need to pass the message, which i have 0 idea on how to get the original message

fervent cradle
cyan quail
#
msg = ctx.message
await paginator.edit(message=msg)```is this not working?
fervent cradle
#

i tried with ctx.message too

cyan quail
#

are you getting an error or

fervent cradle
loud holly
#

so I'm not able to make this command only one server unless I pass the debug guilds in the bot variable, however I only want it to show in 1 server only, any suggestions on how to do this?

#

I want only this command in 1 server, and the rest of the commands globally

cyan quail
loud holly
cyan quail
#

if that fails, try interaction.message

fervent cradle
loud holly
#

discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access

I'm confused on what this error is, I have bot and application.commands enabled

#

I searched online and it says ^^ but I'm not exactly sure what application.build means either

cyan quail
#

for a guild_id you specified, either:

  • your bot either doesn't have the applications.commands scope
  • your bot isn't in the guild
simple canopy
#

read your error

proud pagoda
#

Quick question guys, if I don't have talking perms in a channel or I'm muted, will I still be able to edit my message?

simple canopy
#

no

proud pagoda
#

Alright, so the same carries over to bots right?

simple canopy
#

yes, i think

proud pagoda
#

Ok, thanks for your help

uncut skiff
#

My code to set the bot's status to streaming makes it say Playing

fiery tiger
#

Hey hey... how could i make a monthly payment thing? I have 0 knowledge into this and honestly i don't even know what to start with

surreal glade
#

I want to know how to only let certain users in a list (their id's) use a command

#

can anyone help

#

@round rivet

round rivet
#

#help-rules 6 please

lean marten
#
async def get_position(ctx: discord.AutocompleteContext):
    try:
        guildProfile = guildCollection.find_one({"_id":ctx.guild.id})
        return guildProfile["applicationPositions"]

    except Exception as e:
        print(e)
        return ["Keep Typing"]


@bot.slash_command(description="Send your application profile to the server team. (Apply to the server)")
async def apply(ctx: discord.ApplicationContext, position: Option(str, description="/positions - to see all positions.", autocomplete=get_position)):
    try:
        await guildApply(ctx, position)
    except Exception as e:
        await ctx.respond(f"Error, the developer has been informed.", ephemeral=True)
        await notusLog(ctx, "Automated Error/bug report.", e)

'AutocompleteContext' object has no attribute 'guild'

How can I fix this?

prisma flicker
lean marten
#

._.

lean marten
#

Docs, show me how to do that

prisma flicker
#

good

lean marten
prisma flicker
#

?tag tias

obtuse juncoBOT
lean marten
#

shut

#

:3

fervent cradle
#

does anyone know if it is possible for a slash command to have different names in different servers? Thanks in advance

prisma flicker
#

no, you would have to have different slash commands

#

but you could have one common method that they all call

#

the only way to have different names is to use localization

fervent cradle
prisma flicker
fervent cradle
#

thanks for the info

prisma flicker
#

there's a limit per guild yes

#

and then a limit of global commands

undone smelt
#

How would I use @is_owner() on a command within a cog? 🤔

cyan quail
undone smelt
#

where do i import it from

cyan quail
#

ext.commands

undone smelt
#

tysm

cyan quail
#

if you've already imported commands, just do commands.is_owner

undone smelt
#

how do you type all that out so fast without autocomplete

cyan quail
#

idk

undone smelt
#

how i can send messages if a check fails? like @discord.ext.commands.cooldow or @commands.is_owner

silver moat
#

on_command_error or on_application_command_error

undone smelt
#

arent those generic events?

silver moat
#

yeah and you can filter them according to what errors they raise

undone smelt
near hollow
#

Are there any good guides or information on clustering shards?

prisma flicker
#

have you tried using autoshardedbot?

near hollow
#

Doesn’t that just create shards? I thought it doesn’t have anything to do with clustering

calm pewter
#

Im taking a intro to programing class can anyone help me understand this lab its in python

tiny wagon
#

not able to get the id of a slash sub command from code and mention it

#

a = self.bot.get_application_command("a b", type=discord.SlashCommandGroup)

lilac turret
tiny wagon
#

better use subclasses buttons

#

you can declare a variable to the Button object
button = discord.ui.Button()
button.callback= callback_function()

tiny wagon
#

good way to handle buttons

#

in view param just add ButtonClassYouMade()

#

lol

#

nice game

#

real ban button in sea of button: squid games 💀

#

not able to get the id of a slash sub command from code and mention it
a = self.bot.get_application_command("a b", type=discord.SlashCommandGroup)

topaz rune
#

hi
can someone explain me how to load a file with bot.load_extension if the file is on another folder?

cyan quail
#

maybe having an official shard manager would be nice, but i don't think there are any plans for it at the moment

#

there's a bit more to clustering such as rules that apply on larger scales, but that's the jist of it

#

e.g. all clusters must have an equal amount of shards

cyan quail
#

e.g. if your bot's root folder contains a cogs folder, you'd load "cogs.filename"

topaz rune
#

Can we edit only one field of an embed?

cyan quail
#

embed.fields is a list

topaz rune
#

I cant edit an embed?

cyan quail
#

why not

#

if you want to edit an embed from a message:

  • get the message
  • get message.embeds[i] where i is the index of the embed you're trying to edit
  • edit its attributes
  • send a new message/edit the existing message with the new embed
topaz rune
#

ok thanks

vale prism
#

I am getting ratelimited of discord several times a day

fervent cradle
#

than change your api calls

rocky stump
#

Is it possible for specific slash commands to be in certain guilds and not others. e.g use debug_guilds but for specific commands, not all

vale prism
full basin
#

#rules Do not crosspost.

full basin
rocky stump
fierce elm
#

Trying to figure out how to keep state between a select view and a modal then to a database, what would be the best way to do that

fervent cradle
#

after switching from Windows to Mac, i've been getting an error where, when i interact with a button, i get an error. I have no clue how to fix it..

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/client.py", line 382, in _run_event
    await coro(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/bot.py", line 1058, in on_interaction
    await self.process_application_commands(interaction)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/bot.py", line 722, in process_application_commands
    ) and isinstance(interaction.data, interactions.ComponentInteractionData):
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/typing.py", line 2385, in __subclasscheck__
    raise TypeError('TypedDict does not support instance and class checks')
TypeError: TypedDict does not support instance and class checks```
#

Hi, my on_message in my bot does absolutely nothing.

#

in fact, my bot literally doesnt launch

#

wait

#

nope, im just stupid

#

i havent made a bot in so long i forgot that you have to add the event decorator

cyan quail
tiny wagon
#

how to handle errors in slash sub commands?

@settings_auctions.error
    async def auction_settings_error(self, ctx, error):
        print(error)
        if isinstance(error, discord.CheckFailure):
            await ctx.respond("> You are missing **Administrator** permissions.", ephemeral=True)
fervent cradle
tiny wagon
#

its not working

cyan quail
#

no reinstall pycord

cyan quail
fervent cradle
#

oh alright

tiny wagon
#

should i do a try catch error, as a check is failing

cyan quail
#

in the standard command error handler, you could check ctx.command.name and redirect it to your custom one instead

tiny wagon
#

@commands.has_guild_permissions(administrator=True)
@settings_auctions.command(description="configure auctions log channel")

cyan quail
#

checks should work fine

#

oh but put the check below the command decorator

tiny wagon
#

uhmm okay

#

didnt knew this matters

cyan quail
#

typically the command decorator should always be first

tiny wagon
cyan quail
#

wdym

fervent cradle
cyan quail
#

or you can just try to install it again

tiny wagon
cyan quail
#

you don't handle checkfailure inside the command because the error raises before the callback is called

tiny wagon
#

yeah

cyan quail
#

but since the custom error handler doesn't work, i recommended catching the command name/id/whatever in your global handler and then redirecting to your custom handler

#

like py if ctx.command.qualified_name == "settings auctioneer_role": await auction_settings_error(ctx, error)or however you need to call it

tiny wagon
#

oh um

fervent cradle
tiny wagon
#

either i can check in the code block itself?

cyan quail
#

that works too

tiny wagon
#

what the code snippet for it again 😓

cyan quail
#

for what

tiny wagon
#

for checking within the code if user has admin

#

oh me is for the bot

cyan quail
#

yeah

#

check member.guild_permissions.administrator

tiny wagon
#

hmm

somber cloak
#

it seems like if you do ctx.defer() without ephemeral=True then the response won't be ephemeral, even if you have ctx.respond(ephemeral=True) later on. is this true? is there a way to specify ephemerality only at the response stage?

fervent cradle
tiny wagon
hybrid oasis
#

hi friends -- is it possible to add a custom button to a paginator using the @discord.ui.button() decorator? (not a paginator button)

#

or maybe a different decorator i can't find?

#

my class if this helps (extends discord.ui.View)

#

the button decorator isn't adding the button and i think i missed something 😅

#

ahh i am silly, the decorator is inside the init oops

#

disregard me

tardy kindle
#

last time i used it was like a month or 2 back and this worked

loud holly
#

quick question, I presume animated emojis can't be used in buttons?

tardy kindle
#

last time this happened and like i added recursive it became okay now it shows error-

loud holly
#

nvm it can use animated emojis, just something wrong with my code

proud mason
#

how do i get interactions over http while still using pycord (or at least its models)

was thinking of using fastapi but my brain shattered for some reason

cyan quail
#

it'll work but you may well run into issues because the library wasn't built with http-only in mind

proud mason
#

oh hmm

proud mason
shadow stratus
#

it is possible to use localization on choices inside an option ?

cyan quail
shadow stratus
#

thx

delicate jolt
#

i've been told to not set the bot status

#

when startup

#

How am I supposed to do it

#

I'm using on_ready

cyan quail
delicate jolt
#

Ah alright thanks

#

Can I use type or?

#

like watching

cyan quail
#

oh my mistake

#

status is for offline/online etc, should be using activity

delicate jolt
#

Yeah no worries haha I probably wasn't specific enough

#

Yes

cyan quail
#

it should be similar to how you use change_presence

delicate jolt
#

await bot.change_presence(activity=discord.Activity(name="You | 👀", type=3))

#

This is what I was using

#

In the on ready

cyan quail
#

yeah you can pass the activity object right into activity when you call the bot

#

e.g. bot = discord.Bot(..., activity=discord.Activity(...))

delicate jolt
#

Yeah

#

Thank you

cyan quail
#

allgood

lean marten
#

Is it possible to add a description to autocomplete elements?

cyan quail
surreal glade
#

does anyone know how to make an automod system? i cannot find anything anywhere for some reason

#

maybe my computer is tweaking idk

agile tartan
#

hello i need hellp

#

im getting this error

#
#Traceback (most recent call last): N File "/home/user 750844707755786252/main.py", line 2, in <module> ( from discord.commands import Option d File "/usr/local/lib/python3.10/site-packages/discord/commands/__init__.py", line 26, in <module> from .context import * c File "/usr/local/lib/python3.10/site-packages/discord/commands/context.py", line 69, in <module> 7 class ApplicationContext(discord.abc.Messageable): n File "/usr/local/lib/python3.10/site-packages/discord/commands/context.py", line 337, in ApplicationContext ? @discord.utils.copy_doc(Interaction.edit_original_message) |AttributeError: type object 'Interaction' has no attribute 'edit_original_message'. Did you mean: 'edit_original_response'?
#

how do i change this

agile tartan
#

py-cord==2.1.1

#

it works on my laptop but not the hsting machine

#

i want to host it ,when requirments is then installed rom pip. i get this error from the host. but runs smooth on m computer

full basin
#

Show your requirements.txt

agile tartan
#

aiohttp==3.8.1
aiosignal==1.2.0
async-timeout==4.0.2
attrs==22.1.0
charset-normalizer==2.1.1
discord.py==2.0.1
frozenlist==1.3.1
idna==3.3
multidict==6.0.2
py-cord==2.1.1
yarl==1.8.1

full basin
agile tartan
#

do i remove it?

#

i want to use pycord for specfic reasons

#

i just copied paste, from pip freeze nd added to requirments.txt

#

@full basin

cyan quail
#

pycord is a fork of discord.py; they are intended to be used independently, not together

agile tartan
#

ok now i uninstalled discord.py . but my code isnt working anymore

cyan quail
#

well yeah, they have some differences so regardless of which one you choose to stick with you're gonna have to make changes

#

also you'd need to reinstall py-cord

agile tartan
#
  File "C:\Users\LG\dev\main.py", line 1, in <module>
    from discord.ui import Button, View
ImportError: cannot import name 'Button' from 'discord.ui' (unknown location)
``` for example
cyan quail
#

again, reinstall py-cord

agile tartan
#

how do i install pycord

#

via pip or github?

cyan quail
#

either works

#

though you could do github right now since i think we're about to release 2.1.2 or 2.1.3 something like that

agile tartan
#

ok

cyan quail
#

dpy

agile tartan
#

ah so i was smashing things together

#

no wonder. but worked smoothly on my laptop, was when i hosted gave problem

cyan quail
#

pycord is soon going to have edit_original_response, but it will not remove edit_original_message

agile tartan
#

ok

cyan quail
#

mhm

agile tartan
#

alright ill pip install the exact link hopeully works

#

by that i mean the error

#

ok i installed it

#

i installed the latet

#

works perfectly on laptop

#

Thanks it worked

cyan quail
#

allgood

agile tartan
#

I'm beginning to like pycord

worn void
#

Why is my role check not working?

    if role in ctx.author.roles():
TypeError: 'list' object is not callable
#

role is a role object btw

full basin
#

"List object is not callable"

#

ctx.author.roles**()**

worn void
#

yeah i found it

#

theres no ()

#

i though roles was a function

agile tartan
#

i set a button but when my user doesn't interact for some time. And hits the interact button it says interaction failed. Why's that?

#

Also why do people dislike pycord

full basin
agile tartan
full basin
#

timeout kwarg

agile tartan
full basin
#

If you want it to never expire (unless you restart the bot), sure.

worn void
#

How can I check the time since a user created their account? I can't figure out how to format the time so it's the time since 'member.created_at'

agile tartan
full basin
#

Init.

full basin
#

You can always checks the docs

umbral island
umbral island
worn void
umbral island
#

I’m tired 😅

dawn berry
#

how do I make the checks for a group affect all children commands?

#

nvm I figured out I just can't use invoke_without_command

tiny wagon
#

not able to get the id of a slash sub command from code and mention it
a = self.bot.get_application_command("a b", type=discord.SlashCommandGroup)

#

returns None

slender abyss
#

how to get application command id

young bone
slender abyss
#

Ty

leaden bear
#

anyone have an idea how much messages channel.history(limit=limit) going to give me on 1 api request?

leaden bear
#

no

weak violet
#

fast question, im trying to make a create sticker command but its giving a error and idk what to do now, can someone help me?

Script:

@bot.slash_command(guild_ids=gguilds, nombre='sticker', description='crea un sticker con una imagen.')
async def stickerr(ctx, nombre:str, emoji:str, imagen: Option(discord.Attachment, required=True)):
    await discord.Guild.create_sticker(name=nombre, emoji=emoji, description=ctx.author.name, file=imagen, self=ctx.message.guild)
    await ctx.respond(f'Sticker {nombre}, creado con exito ✅')```

Error:

```py
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'NoneType' object has no attribute 'guild'```
spice oyster
#

Hello! Is it possible to make a global listener for Buttons being pressed?
My previous libraries allowed it but after migrating to Pycord I'm a bit lost.

young bone
spice oyster
tiny wagon
#

there might be any event like" on_button_interaction or smth

#

then create a listener on its name

full basin
full basin
#

Just check what the interaction is

spice oyster
#

Thank you both! I will try with that. rooAww

topaz rune
#

I tried to create new roles but I can't. IDK how to say that but it won't work
At the beginning I had this code :

#players_in_game is a list of member (at least 2)
guild = bot.guilds[0]
roles = [await guild.create_role(name=f'LG - {user.name}') for user in players_in_game]

But it didn't work so I 'split' it and put some print to see were the problem is

guild = bot.guilds[0]
print(players_in_game)
print(guild.name)
roles = []
for user in players_in_game:
  role = await guild.create_role(name='LG - ' + str({user.name}))
  roles.append(role)
  print(role)
print(roles)

So the prints work until the 'print(role)'. It just don't print anything and by the things that I can see on my discord server, like the roles or the channels not created, I can say that it seems like it doesn't do the stuff after it start 'create role'.
Can anyone tell me what is the problem ??

spice oyster
full basin
#

You dont

#

You only get interaction

cyan quail
topaz rune
#

we try with 1

dawn escarp
#

2

topaz rune
#

2**

cyan quail
#

you might be getting ratelimited

topaz rune
#

even if we delete the role when we finish use them? we actually have 81 roles

cyan quail
#

but how many times has it actually created

dawn escarp
topaz rune
#

but everytime got deleted

cyan quail
#

deletion is irrelevant

dawn escarp
#

we tried things and fight some bugs...

cyan quail
#

some threads from 2 years ago suggest that it's 1000 edits per 24 hours

#

not sure if that's changed

topaz rune
#

we've done sooo much less than this]

dawn escarp
#

for today at least

cyan quail
#

do you not get anything in the console?

dawn escarp
#

nope

topaz rune
#

and thats the problem

cyan quail
#

the bot stops working? or

dawn escarp
#

no it just don't do the code

cyan quail
#

right before the for-loop, can you print(players_in_game)

topaz rune
#

like the bot is still up and can still be usedm but not for this

#
[<Member id=378661428061667329 name='Smiath' discriminator='1051' bot=False nick='「 🜲 ┆ SMIΛTH 」' g uild=<Guild id=923316085950918656 name='Café du coin ☕' shard_id=0 chunked=True member_count=50>>, <Member id=31073220
2570678272 name='VullWen' discriminator='0667' bot=False nick='Célian | VullWen' guild=<Guild id=923316085950918656 name='Café du coin ☕' shard_id=0 chunked=True member_count=50>>]
#

just us

dawn escarp
#

just the two of us

cyan quail
#

and printing directly above/below create_role inside the loop?

dawn escarp
#

it prints, but then when it start do to the create_role just once, it stop to do the rest of the code

topaz rune
#

and it only stop forn the create_role

dawn escarp
#

and so the loop

cyan quail
#

what about py try: await guild.create_role(...) except Exception as e: print(e)

dawn escarp
#

nothing on the concole

topaz rune
#

still absolutely nothing

cyan quail
#

that's... very odd

topaz rune
#

yeap

cyan quail
#

what about py try: role = await guild.create_role(...) except Exception as e: print(e) else: print(role) finally: print(...) # anything idk

topaz rune
#

if I add print(bot.is_ws_ratelimited()), console return False

cyan quail
#

role = **

dawn escarp
#

still nothing

topaz rune
#

still nothing on the console

cyan quail
#

yeah i have no clue

topaz rune
#

discord suck

#

😦

cyan quail
#

i don't think create_role can just stop like that