#Basic Pycord Help

1 messages Β· Page 41 of 1

shell radish
#

the guide states that discord.Bot should be used if text-based commands aren't used

little cobalt
#

I noticed that if you have a command with options but without the self , ctx is not shown as a option

#

but if you add it, ctx is shown as an option

#

and I still wonder why I cannot add a description to my slash commands...

fresh sierra
sage tendon
fresh sierra
#

he doesnt know that the things ;)

sage tendon
#

No, he's saying he cant, so there's a reason why he thinks that

fresh sierra
#
 I still wonder why I cannot

for me that mean he doesnt know

tidal vessel
#

One question, what is the maximum number of options that I can put in thechoices parameter?

fresh sierra
#

if you want more you can use a autocomplete

tidal vessel
sage tendon
#

also fyi you dont need required?True

#

and you set the name twice lol

#

you can delete the name=

tidal vessel
# sage tendon you can delete the name=

It asks me for the name of the parameter of the function to which it is associated, or so I read in the documentation. And the parameter is called the same πŸ€” correct?

sage tendon
#

no

#

the first positional parameter is the name parameter

#

if your parameter name in the function header differs from the option name, you set that via parameter_name=

tidal vessel
fresh sierra
#

there is no guid about it

#

that sad because there is soo munch thing that u can do using those

sage tendon
#

at least the bare minimum ^^

#

but neither of the ways shown there use the decorator which is sad because the decorator is universally better

tidal vessel
#

is that I used to work with the Option object directly in the function parameter, but for some reason Python gives me an error when I use it there. I'm migrating to @option() decorator rooFine haha

fresh sierra
little cobalt
tidal vessel
fresh sierra
# little cobalt

i think name and description have to be put prior to the bot running

#

im doing like that :

        description = cmd_default.get("description")
        if description is not None:
            command.description = description

and its working so i guess the issue can either be from the description, either because of the decorator( which will be strange)

#

if you add some print before the command.description

#

are they triggered ?

little cobalt
#

that still not explains why its working at the main file but not at a cog at the same command

fresh sierra
#

so maybe it put those description at that moment

#

and then when the bot has run it cant place the description no more

#

i guess

little cobalt
#

I can test it without running the .run and the stuff is getting added to the command

fresh sierra
#

like in the cog ?

little cobalt
#

both

fresh sierra
#

how can you test without running the bot i dont understand

#

so in ur test the description is set but when ur bot is running its not set

little cobalt
#

well, I can just print it at the config one and see

fresh sierra
#

can you send me the code in codeblock, i will try to do it and make that work

#

and just how look the json for one command

half terrace
#

I have a problem that I can see the slash commands, but my friend can't. Any ideas why it's like that?

half terrace
#

we both did and it still only shows up for me

sage tendon
#

check the permissions

#

if you have default permissions set it wont work (obv)

little cobalt
fresh sierra
#

i tried a bunch of thing

#

and its not possible

#

i forgot that nelo already told me that

#

when i was trying to do that

#

command.name cant be done after bot is run because it will send that to the api before

little cobalt
#

its all before of it

fresh sierra
#

and even by changing the local like so :

def test_config(command: discord.SlashCommand) -> discord.SlashCommand:
    with open(f"test.json", "r", encoding="UTF-8") as file:
        data: dict = json.load(file)

    if "name" in data:
        if (current := getattr(command, "name_localizations")) in (None, discord.MISSING):
            setattr(command, "name_localizations", {"fr": data["name"]})
        else:
            current["fr"] = data["name"]

    if "description" in data:
        if (current := getattr(command, "description_localizations")) in (None, discord.MISSING):
            setattr(command, "description_localizations", {"fr": data["description"]})
        else:
            current["fr"] = data["description"]

    return command

fresh sierra
#

but its not run with the load extension i think

#

(from what i remember nelo told me

#

if you want i have another solution without decorator that im using

little cobalt
#

so its getting run with load extension

fresh sierra
#

yeah

#
{'id': '1246890345002827857', 'application_id': '1127255044182507662', 'version': '1246890345002827858', 'default_member_permissions': None, 'type': 1, 'name': 'test', 'description': 'No description provided', 'dm_permission': True, 'contexts': None, 'integration_types': [0], 'options': [{'type': 3, 'name': 'test', 'description': 'No description provided', 'required': True}], 'nsfw': False}
#

here what is sent to the api

#

using ur decorator

#

as you can see neither name or description are different

little cobalt
#

still weird, because it was working for some time x3

fresh sierra
#

because after looking at dorukmng

#

i kill his name sorry

#

he was using something similar

#

which is not working either

#

so if you want i have another solution but ur thing doesnt appli neither name or description

fresh sierra
#

you do a function before the bot run

#

that itinerate into the self.bot._pending_application_command

#

and you do ur thing

#

its like easier and faster

#
for command in self.bot._pending_application_commands:
    ur function
#

if you need help with that let me know

little cobalt
#

or just at the config file for the command?

fresh sierra
#

however you will need to handle the sub command

#

for example :

#
    def add_default_commands(self):
        for command in self.bot._pending_application_commands
            self.add_default_command(cmd)

    def add_default_command(self, command: discord.ApplicationCommand | discord.SlashCommandGroup):
        if isinstance(command, discord.SlashCommandGroup):
            for cmd in command.walk_commands():
                self.add_default_command(cmd)
        name = ...
        if name is not None:
            command.name = name
        
        description = ...
        if description is not None:
            command.description = description
#

this is an example so it cant have some mistake its just for u have a little idea of how to do it

#

for me i have done a file lang.py that have an instance to do all the traduction throught my bot etc and then in my bot client i have a setup_hook that will trigger those function

sage tendon
#

recursion

fresh sierra
#

yeah its for handle the sub command and sub sub command

#

i think im the only one using pycord that use a setup_hook

sage tendon
#

just no point

#

the library already does it for you

fresh sierra
#

the setup hook ?

sage tendon
#

adding commands etc...

fresh sierra
#

im not adding command

#

im adding description localization etc to command

sage tendon
#

yea, why

#

just do it in the command decorator

little cobalt
fresh sierra
#

because i dont want to do for each single command
name =
description =
name_locazliation =

#

for each single options of each single command

#

when i can just do a function and then never touch about that

sage tendon
#

why write extra code that does nothing but complicate existing features

sage tendon
#

you write the same amount

fresh sierra
sage tendon
#

plus the code of whatever that mess is

fresh sierra
#
    @subcommand("bot")
    @commands.slash_command()
    @discord.option(name="test", type=str, required=True)
    async def test(self, ctx: LumabotContext, test: str):
        await ctx.respond(ctx.translator.bot.test.success.format(test=test))
#

its just like that

sage tendon
#

yes, because you still have to write the localizations...

#

there is nothing you gain

fresh sierra
#

and then i have a yaml file which each thing

#
    @subcommand("bot")
    @commands.slash_command(name = "test", description = "test", name_localization = {"fr": "test", description_localization = {"fr":"test"})
    @discord.option(name="test"name = "test", description = "test", name_localization = {"fr": "test", description_localization = {"fr":"test"}), type=str, required=True)
    async def test(self, ctx: LumabotContext, test: str):
        await ctx.respond(ctx.translator.bot.test.success.format(test=test))
#

no way im doing that

sage tendon
#

so instead of just writing the localizations where they belong, you write them somewhere else, and then write a whole bunch of extra code just to put the localizations where they belong

fresh sierra
#

so im actually coding less

sage tendon
#

why

fresh sierra
#

i have this file (one for french, english german)

fresh sierra
#

every single localization is set

#

no need to do anything else

little cobalt
fresh sierra
#

idk why but its stress me without it

#

and also i will need to do \'

fresh sierra
sage tendon
#

but why do you need to use a yaml

fresh sierra
fresh sierra
sage tendon
#

with a dict? lol

sage tendon
#

just add more languages lol

fresh sierra
sage tendon
#

you use dicts

#

well in the example

fresh sierra
sage tendon
#

there is no need to use a yaml

fresh sierra
#

because it take more time

#

and also

sage tendon
#

but you said you need a yaml

fresh sierra
#

yes for the reponse in the embed

fresh sierra
#

instead of this :

        await ctx.respond(ctx.translator.bot.test.success.format(test=test))
#

if you have a better way than that :

    @subcommand("bot")
    @commands.slash_command()
    @discord.option(name="test", type=str, required=True)
    async def test(self, ctx: LumabotContext, test: str):
        await ctx.respond(ctx.translator.bot.test.success.format(test=test))
#

im listening, im always open to new idea ;)

#

(ik for the requiered = true but i like letting them)

forest tulip
#

It's possible to send few messages with 'for' with interact buttons, for example, 3 messages with same buttons when clicked, the context of the message to which the buttons are attached will be sent
Or its will be broken?
M1: content 1
Button answer: content 1
M3: context 3
Button answer: 3

forest tulip
#

How I can do that for example?

my usage example should be like this:
/players_list
[Message1]
(Button)<User ID>(Button)<delete>
. . .
[Message22]
(Button)<User ID>(Button)<delete>
End of list

marble hinge
#

How to get slash commands ID?

tidal vessel
marble hinge
tidal vessel
marble hinge
#

Like I have a on_message_edit event

#

And many bots are triggering it

#

I only want humans to trigger it

#

How can I do it

tidal vessel
little cobalt
errant trout
sage tendon
#

they said on message edit

broken pivot
#

how I can stop everlasting "is thinking"? I want after 5 seconds output message

lofty parcel
broken pivot
lofty parcel
#

Defer isn't a replacement

#

I don't quite understand what's your question exactly

broken pivot
lofty parcel
#

Defer is not a replacement.

#

If you do not respond, itll just stay as "bot is thinking..." until it times out after 15 minutes.

broken pivot
#

I connect to the socket, and if the connection failed, then it returns nothing and thinks everlasting

lofty parcel
#

I don't get what your exact issue here is?

broken pivot
sage tendon
#

lol

#

i think language is also an issue here

half terrace
#

How can I get a certain message with id? Because if I give '.get_message' id of an existing message that was sent when the bot was offline, I get None while if it's a message that was sent when the bot is online, it finds it without a problem. How to find the message as this probably just searches through cached messages?

sage tendon
#

for what use case

half terrace
#

When I'm using a command, the bot sends a message and I want it to delete the one that he sent when the command was used last time

sage tendon
#

always in the exact same channel?

half terrace
#

That's the case, I want it to work with any channel, otherwise I would probably just search through channel history and I'm thinking of an easier solution

sage tendon
#

well it depends
if you want the message to exist only once per channel you probably wanna use a db to store the channel id, to then get the channel, to then fetch the message
if you want the message to exist once globally then its probably fine to just make a single json file with the channel id saved in it

half terrace
#

bc if the bot didn't cache it, the 'get_message' method will return None

sage tendon
#

ah, so you do store the channel id?

half terrace
#

wait, you meant both, channel and message id
damn, can't read

sage tendon
#

:>

half terrace
#

thanks

errant trout
#

If you just want access to a message's API calls without any of its content, use channel.get_partial_message; it supports both edit and delete

sage tendon
#

what's the benefit over just get_message

errant trout
#

get_message relies on cache

sage tendon
#

oh, get_partial_message just creates a fake object to be sent to the API or

errant trout
#

Well yeah, because it only needs the ids

sage tendon
#

yea ok, good to know

vital bramble
#

Is it ok to have an empty string as the author name in an embed?

sage tendon
#

does it work for you? then yes

half terrace
#

why does guild.get_member return None?

sage tendon
#

no member intent usually

half terrace
#

will check it, ty

little cobalt
sly karmaBOT
# half terrace why does guild.get_member return None?

Any function that starts with get_ in Py-cord is retrieving the related object from your bots cache. If the object is not in the bots cache the get_ method will return None. Because of this behavior you should check if the get_x method is None and if it is use the fetch_x method.

Why Is Using fetch_ Without Using get_ First Bad?
The fetch_ method makes a call to the discord API. This API call is unneeded if you already have the information. It will also make your command take longer because it will have to send and than wait for a response from the discord API. It will also contribute to the discord APIs global rate limit of 50 requests per second.

What Is Cache?
The cache is a temporary storage inside your bot. It holds many objects from members to messages. When you restart your bot the cache will be empty. When the cache is full it will delete older objects to make space for the new objects.

sage tendon
#

get member should never fail as long as the member is in the guild and member intents are there, though

half terrace
#

but still thanks for all that info

crimson lily
#

Is there any way to disable formatting in embed.description? the descriptions im working with have "```" a lot of times and it messes up the looks of the output

#

and nope i cannot edit the content of description by placing backslashes

sage tendon
#

why not?

crimson lily
#

description isnt hardcoded

#

depends on the contents of the file im accessing

sage tendon
#

replace all ` with \` lol

#

str.replace()

crimson lily
#

one thing i didnt wanna do lol

sage tendon
#

why?

crimson lily
#

too slow for large files

#

but yeah if theres no way to disable it then i guess ill just live with it thanks for the help

sage tendon
#

Eh..?
Embed descriptions arent thousands of characters

#

and string manipulation is so fast

crimson lily
#

makes sense in the real world but after getting into leetcode i cannot convince myself to traverse the entire string over a mild inconvinience

sage tendon
#

its one line of code lol

crimson lily
#

wont be able to live with myself πŸ˜” πŸ’”

sage tendon
#

you rn

fresh sierra
#

you don’t need to edit the file in itself

deft kestrel
#

how to change my bot profile pic in a single server?

forest tulip
#

Its possible to update bot status every 15 seconds from @task.loop in another file? I just need to take out a function that updates the status to another file, but a nonetype error appears there

sage tendon
#

show your code

sage tendon
forest tulip
# sage tendon show your code
@bot.event
async def on_ready():
    print(f"{bot.user.display_name} is ready and online!")
    channel = bot.get_channel(1243993814419636278)
    await channel.send(f"***{bot.user.display_name} - Online!***    :white_check_mark:", delete_after=3)
    update_counter.start()

@tasks.loop()
async def update_counter():
        headers = {
        'User-Agent': config.user_description
        }
        ulr = 'https://vrchat.com/api/1/visits'
        response = requests.get(ulr, headers=headers)
        if response.status_code == 200:
            current_online = response.text
            activity = discord.Activity(type=discord.ActivityType.streaming, name=f'VRC Online: {current_online}!', url="https://twitch.tv/vrchat")
            await bot.change_presence(activity = activity)
        else:
            print("Error fetching status", response.status_code, response.text)
        await asyncio.sleep(15)
lofty parcel
forest tulip
#

Why about requests

forest tulip
lofty parcel
lofty parcel
forest tulip
lofty parcel
#

You use asyncio

#

Or httpio or something like that which is more closer to the requests library but async

#

?tag requests

limber wagonBOT
#

Why you should not use the requests library for your bot
requests is a popular HTTP library for Python. It is however not a good option for Discord bots, since it is not async and blocking.

This essentially means that your bot will not be able to execute any code at all while a request is happening. Since requests usually take a few seconds to complete, this can have a detrimental effect on your bot's performance. E.g if a user executes a command that performs a request taking 5 seconds to complete, no one else will be able to use your bot for those 5 seconds.

Please look at using a HTTP library that has async support, such as aiohttp or httpx

forest tulip
#

Wow, thanks, I will know that now

lapis dock
#

Also use aiohttp as py-cord uses it so it is already installed

forest tulip
lapis dock
#

Nope. Defer is the only way to extend the timeout for interactions. Why does defer not work in your case?

forest tulip
#

Im not sure, close vs for now, but I get errors like interaction already called if I adding defer

lapis dock
#

When you defer that counts as a "response" to the interaction so you need to use interaction.followup or ctx.followup after deferring. If you are sending messages in a slash command you can use ctx.respond(...) and it will choose automatically for you

forest tulip
#

Oooh

#

Will try tomorrow, big thanks with that

lofty parcel
#

If even the defer is failing, that's your network

forest tulip
#

what is timeout time with defer?

lapis dock
#

15 minutes

forest tulip
#

well, that's definitely enough for me, I don't think it will take me 15 minutes for 2 requests with json data

#

Haha

lapis dock
#

Definitely not lol

lofty parcel
#

I meant that if you can't defer under 3 seconds, it's definitely your network

forest tulip
sage tendon
#

is the defer the first statement?

crimson lily
#

Any inbuilt method to save discord.Attachment locally to the specified path?

crimson lily
#

oh yeah i saw that but couldnt figure out the use
bot.save(file) doesnt work, neither does ctx.save

marble hinge
#

How to get channel id in which a message was sent?

#

@errant trout

#

Can you help pls

errant trout
marble hinge
#

K ty

#

Also I have a small issue

#

Can u help?

errant trout
#

go on

marble hinge
#
@bot.event
async def on_message(modmessage):
    channel_id_modmail = 12394748474744
    reaction = 'βœ…'
    if modmessage.channel.id == None:
    
        chl = bot.get_channel(channel_id_modmail)

        await modmessage.add_reaction(reaction)
        embed = discord.Embed(title='Are you sure you want to send this modmail?',description=f'Your message- `{modmessage.content}`')
        modmessage.send(embed=embed)
@bot.event
async def on_reaction_add(reaction,modmessage):
    await modmessage.send('ok')



#

Nothing is being sent to me for some reason @errant trout

#

All intents are fine

errant trout
#

that's just not possible

marble hinge
#

Dm has no channel id

errant trout
#

...wrong

#

you should check if message.guild is None

marble hinge
#

??

errant trout
#

no, just message.guild

#

otherwise that would raise an error in DMs

#

you can just do if not message.guild

marble hinge
errant trout
#

yeah

marble hinge
#

Ohk

crimson lily
errant trout
#

no, it is the variable

#

like, if you called it file then literally await file.save(path)

marble hinge
#
@bot.event
async def on_message(modmessage):
    channel_id_modmail = 1247498881818951700
    reaction = 'βœ…'
    
    if not modmessage.guild:
        chl = bot.get_channel(channel_id_modmail)

        # Add a reaction to the user's message
        await modmessage.add_reaction(reaction)

        # Send a confirmation embed (only if it hasn't been sent before)
        confirmation_msg = await modmessage.channel.history().find(lambda m: m.author == bot.user and m.embeds)
        if not confirmation_msg:
            embed = discord.Embed(title='Are you sure you want to send this modmail?', description=f'Your message: `{modmessage.content}`')
            await modmessage.channel.send(embed=embed)
            await confirmation_msg.add_reaction(reaction)


@bot.event
async def on_reaction_add(reaction, user):
    if user != bot.user:
        if reaction.emoji == 'βœ…':
            # Get the original message that was reacted to
            original_message = reaction.message

            # Your code to handle the confirmed modmail here
            await original_message.channel.send(f'Confirmed: {original_message.content}')

This code should add the reaction to only the message but it's adding the reaction to the bot message aswell. And the event of on reaction add is working for th bot message too can u help @errant trout

#

@errant trout i gotta go can u help me fast pls πŸ™‚

errant trout
#

well

marble hinge
#

What's the error?

errant trout
#

which message is it meant to add to

#

you just got the history code wrong

marble hinge
#

The message i sent

#

Lemme show ss

errant trout
#

the 2nd last line?

marble hinge
#

@errant trout

#

It should only add the reaction to Hi message i sent

fresh sierra
#

so remove the await confirmation_msg.add_reaction(reaction)

#

this will add the regaction to the confirmation message

#

so not only to the modmail message

errant trout
#

well..you have it set to react on every message

#

just check the user before using add_reaction

upper flint
#

Hello! Some of my people have troubles with button callbacks. Sometimes when button is getting disabled and the message is updated all buttons just disappear. Any ideas? The chances of this happening is pretty rare and right now we're trying to understand why exactly does this happen. Any Ideas on this? If you need any info just tell me, I will ask them and respond to you this evening

fresh sierra
upper flint
#

Basically, we're just calling View.disable_all_items and updating the view via interaction.response.edit_message()

fresh sierra
#

because im using that and im facing the this issue, the view is disappearing sometime

upper flint
upper flint
fresh sierra
upper flint
#

Yes: interaction.response.edit_message(view=view)

#

And right before: view.disable_all_items(). Maybe some logic in between but nothing related to the view itself

fresh sierra
#

so i think there is a small chance where discord remove a view if everything is timeout

#

because im not using disable_all_items, and i got that also using the disable_on_timeout

#

but not everytime

fresh sierra
upper flint
#

When did this started happening to you?

fresh sierra
#

i think it has always been the case when using disable_on_timeout

#

so i will say more than 6 month

upper flint
#

Alright

#

So this is discord thing and not a py-cord's fault?

fresh sierra
#

but i think is not a bug from py-cord but from the library that removed it

fresh sierra
upper flint
#

Alright. Hope they will fix it soon

fresh sierra
#

im not so sure about it

#

since it has been 6 month i think no one really know why its happening

lapis dock
#

Yeah, we cant fix it unless we can track down the problem and no one has found it yet.

fresh sierra
errant trout
#

i doubt it's a discord issue tbh

fresh sierra
#

And the issue is that doesn’t appear everytime so it will be harder to guess but if it can only come from this one I think

#

I will try to change it a title bit to see

errant trout
#

It's not a problem I've ever encountered, so ultimately i can't really test it

fresh sierra
round heart
#

This started happening recently, anyone ever come across this or at least can understand what might be happening here?

ERROR:asyncio:Task was destroyed but it is pending!
task: <Task pending name='pycord: on_ready' coro=<Client._run_event() running at [...]/python3.10/site-packages/discord/client.py:400> wait_for=<_GatheringFuture pending cb=[Task.task_wakeup()]>>
devout mirage
#

pycord

stray pasture
#

I had to remove one coroutine from on_ready where I init the database connections

round heart
stray pasture
little cobalt
#

Or librarys?

round heart
round heart
little cobalt
#

Which version do you use?

#

I use 2.5 and haven't got the error yet

round heart
#

This is also 2.5

fresh sierra
stray pasture
#

yeah a fiew people got the same issue, I think the cause is a bit hard to find tho πŸ˜„

little cobalt
fresh sierra
#

version doesnt change anything in this case

little cobalt
#

K

#

I only got the error when I use .close()

forest tulip
#

Why requests and aiohttp do they give me different responses?
how can I get the same answer through aiohttp as in requests

forest tulip
#

For example,
import requests response.text giving me text
Import aiohttp response.text() giving me another text that not similar what I getting in requests library

#

I used to get certain lines from the server response, for example DisplayName, but I can't do this in the aiohttp library because I get another response where these lines are not present

#

although I send all the data to the request the same

sinful juniper
#

What is the best way to make my slash command responses in multiple languages? With a json file?

shell radish
#

it’s really up to you

little cobalt
shell radish
#

personally I would try to build a language thing by yourself for fun

fresh sierra
#

Json

sinful juniper
fresh sierra
#

Just the format like you don’t need to mind about {}

sinful juniper
fresh sierra
upper flint
#

How to check if message has view attached to it or not?

#

I've seen the View.from_message() method that constructs new view from message but I'm kind of hesitant to use it. I only need to know if the view is present or not

fresh sierra
upper flint
#

How to fetch a discord message? In docs, bot.get_message() method does not do an API call to fetch the message and there is no bot.fetch_message() method that could've helped me

sinful juniper
fresh sierra
#

with else : load_translation(default)

sinful juniper
fresh sierra
#

If the bot is off, or it bug

#

Or any reason

#

It will not work so just handle it will a English yaml for example

sinful juniper
fresh sierra
#

so yeah it matter to put a default thing with the else

#

and that ur issue

sinful juniper
fresh sierra
#

just do an else language = β€œenglish”

#

it’s 2 lines and will handle all ur issue

sinful juniper
fresh sierra
#

I don’t think I’m sure

#

Since the if is not trigger

#

The language = is not set

#

So language is not associated with a value

sinful juniper
#

Since there would be a guild id in my error report I guess

fresh sierra
#

because it depend if the thing is in the database

#

if a guild has beeen joined and the bot didn’t add it for any reason like offline a bug or else

#

the guild will not be able to do command

#

well i have told u how to solve it, if u don’t want to listen i can’t do anything im sorry

sinful juniper
deft kestrel
#

why the script are broken idk

lapis dock
#

I think the keyword there is "Temporary" It might just be discord or your internet provider or something in between is having troubles

#

If it still does not work after 10min than it might be something else but you should be able to just wait a few minutes

lapis dock
sage tendon
#

the DNS is having issues

#

so whatever DNS you use was dead for a sec
or as wolfy said the entire internet but I'm pretty sure that would be a different error

young cove
#

How would I go about checking a purge both for the user and a specific string in the message?

I have the user (the bot) working so far:

   def is_me(m):
        return m.author == bot.user
    channel = bot.get_channel(xxx)
  await channel.purge(check=is_me, before=ctx.interaction)

Thanks in advance πŸ™

shell radish
#
def check(m):
  return m.author == bot.user and "abc" in m.content
keen relic
#

can i add bridge command in cog

keen relic
#

@lapis dock

keen relic
fresh sierra
#

just read the doc

rugged lodgeBOT
#

Here's the bridge commands example.

fresh sierra
#

is there a native way to do

nsfw_group = discord.SlashCommandGroup(name="nsfw", guild_only=True, checks=[discord.is_nsfw()])

using checks
for the command appear in the list of / but will not run if its not a nsfw channel

frail ocean
fresh sierra
#

NSFW = true was working but not showing the command

#

But I will try command. Nsfw

lapis dock
#

Is the command marked as nsfw? Checks should not effect what commands show up in the list

lapis dock
#

what?
Also I might be wrong but I think it is discord policy that nsfw commands are not to be shown except for in nsfw channels. What you are doing might be against the policy

fresh sierra
#

thanks i will correct that

lapis dock
#

I am trying to check to see if it is actually true, I just remember something like that a while ago

#

Prohibited behaviors and activities include those that:

  • Distribute adult content to users under the age of 18, and without age-restricted labels where applicable and appropriate to users 18 and older;
    • Unless your Application is labeled as age-restricted, you will make sure your Application is appropriate for users under the age of eighteen (18) and complies with all applicable laws (including those applicable to users under the age of eighteen (18)).
#

So it is still, on the line. I think in general it would be safer to just hide them in non nsfw channels

#

The commands need to be marked nsfw anyways. And discord might autohide based on that fact

#

idk if you ever want your bot verified, but making it as "clean" as possible will help a lot. From what I can tell is that they will deny off of any little thing that they deem wrong

atomic fern
#

is there a way to set modal input can only filled by integer? so if contains non integer then the placeholder will be red

#

like how slash commands options do

little cobalt
#

you would have to check it at your own

sage tendon
#

i just had a ping here, what

wary lava
#

how to get the guild of on_member_join event?

little cobalt
#

;3

sage tendon
#

docs = friend

little cobalt
#

^

lapis dock
#

.rtfm Member.guild

nova epoch
#

.rtfm discord.Interaction

stray pasture
#

I am not sure I understand the difference between these 2 slash commands decorator

from discord.commands import slash_command
from discord import slash_command
#

Does anyone know the difference ?

tidal vessel
fresh sierra
stray pasture
fresh sierra
stray pasture
#

so not sure if they are the same

#

or which one I should use over the other

fresh sierra
#

I think they refer to the same thing at the end, it depend of the bot.command() at the end which is different

#

But normally it’s discord.slash_command if u are using discord.Bot

#

Because with commands.Bot it can either be commands.commands or commands.slash_commands

#

And I think you can even but discord.command() with discord.Bot

stray pasture
modern prairie
#

How do you wait for a button press, just like how you wait for reaction_add

modern prairie
fresh sierra
#

you need to use callbaxk

modern prairie
#

So given a situation where you have to find out when a user clicks on a button sent by another bot, you can't find out that right

fresh sierra
#

also the case for any view

modern prairie
#

Ahh, understood.

#

Thanks for the explanation

harsh bloom
#

Hi, my bot takes ~10 min to fetch data from multiple endpoints (I'm using requests). After 6-7 minutes the bot goes offline (on Discord, the script still runs) and then comes back with the answer automatically.

Why is it so?

fresh sierra
#

Request is not asynchronous so because of that it blocked ur whole bot for 7min

#

.tag norequests

sly karmaBOT
#

Why you should not use the requests library for your bot
requests is a popular HTTP library for Python. It is however not a good option for Discord bots, since it is not async and blocking.

This essentially means that your bot will not be able to execute any code at all while a request is happening. Since requests usually take a few seconds to complete, this can have a detrimental effect on your bot's performance. E.g if a user executes a command that performs a request taking 5 seconds to complete, no one else will be able to use your bot for those 5 seconds.

Please look at using a HTTP library that has async support, such as aiohttp or httpx

harsh bloom
#

you've bot answers for everything πŸ˜„ where is it stored I'll ctrl+F

fresh sierra
fresh sierra
harsh bloom
fresh sierra
harsh bloom
#

.tag

sly karmaBOT
#
Nziie's Utilities
`.tag <name>`
Sub command(s)

alias - None
info - View info for a tag
edit - Edit a tag
delete - None
add - None
search - None

fresh sierra
#

with a s

harsh bloom
#

pain

#

fumble fr

harsh bloom
#

i see sire

#

thanks for the help

fresh sierra
#

With helps

signal trench
#

is there a limit to how many commands my bot can have ?

#
Ignoring exception in on_connect
Traceback (most recent call last):
  File "C:\Users\SOHAM\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\client.py", line 400, in _run_event  
    await coro(*args, **kwargs)
  File "C:\Users\SOHAM\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\bot.py", line 1178, in on_connect    
    await self.sync_commands()
  File "C:\Users\SOHAM\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\bot.py", line 735, in sync_commands  
    registered_commands = await self.register_commands(
  File "C:\Users\SOHAM\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\bot.py", line 599, in register_commands
    registered = await register("bulk", data, _log=False)       
  File "C:\Users\SOHAM\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\http.py", line 373, in request       
    raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 30032): Maximum number of application commands reached (100).  
#

i got this wierd error

little cobalt
signal trench
signal trench
rugged lodgeBOT
#

Here's the slash cog groups example.

signal trench
#

well any idea how to mention the subgroup channels ?

fresh sierra
#

we cant

sly pebble
#

options are being screwy

#

AttributeError: Option does not take min_value or max_value if not of type SlashCommandOptionType.integer or SlashCommandOptionType.number

#

note that this is on an option that declares that it's an integer

lapis dock
#

Check to make sure date.today().year is returning an integer.

sly pebble
#

and yes i'm using from discord import SlashCommandOptionType for the typings

#

that same error happens on each thing that uses type number

fresh sierra
#

Can you show use the code ?

fresh sierra
#

Can you try to put only int

sly pebble
#

i just did that and its even weirder

fresh sierra
#

Did u try wifh the decorator ?

lapis dock
#

The kwarg is input_type

#

Not type

fresh sierra
#

ik

#

its input_type

#

wolfy is too fast for me

#

type is only using option not Option

lapis dock
#

So it was defaulting to str and ignoring whatever you put in type

sly pebble
#

replacing type= with input_type= seems to return the same error

#

is it better if i just forego defining types

fresh sierra
#

you can use decorator

sly pebble
#

will try

fresh sierra
#

but isnt there an issue with SlahsOptionType ?

#

SlashCommandOptionType

lapis dock
sly pebble
#

all options

lapis dock
#

But the same exact error?

sly pebble
#
Traceback (most recent call last):
  File "C:\Users\mrmax\PycharmProjects\FE2TimerBot\.venv\Lib\site-packages\discord\cog.py", line 778, in _load_from_module_spec
    spec.loader.exec_module(lib)  # type: ignore
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "C:\Users\mrmax\PycharmProjects\FE2TimerBot\cogs\maps\maps.py", line 43, in <module>
    class Maps(commands.Cog):
  File "C:\Users\mrmax\PycharmProjects\FE2TimerBot\cogs\maps\maps.py", line 69, in Maps
    normal_buttons: discord.Option(input_type=SlashCommandOptionType.integer,
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\mrmax\PycharmProjects\FE2TimerBot\.venv\Lib\site-packages\discord\commands\options.py", line 297, in __init__
    raise TypeError(
TypeError: Expected <class 'NoneType'> for min_value, got "int"
#

ye

sly pebble
#

same result

#

i can drop the whole file if you want

fresh sierra
#

i will to debu that

#

let me 5mi,n

sly pebble
fresh sierra
#

mhhh

#

wtf is that

sly pebble
#

might want to correct tabbing lol

little cobalt
fresh sierra
#

i correct it

#

and still that

little cobalt
fresh sierra
#

like

#

well lets see if itrun

sly pebble
#

also yes im on latest pycord

#

fresh install as of yesterday

lapis dock
#

your first option has input_input_type sub i doubt that is the issue for the current error

sly pebble
#

masterful gambit on my part

#

odd that it doesnt cause an error tho

#

i also tried the option decorator

#

that throws a whole new error

fresh sierra
#

well

#

first

#

min value cant be 0

#

2nd

#

2024-06-07 18:27:55 [WARNING] : Failed to load extension Slashs.Bot.test: Extension 'Slashs.Bot.test' raised an error: AttributeError: Option does not take min_value or max_value if not of type SlashCommandOptionType.integer or SlashCommandOptionType.number

sly pebble
#

yeah thats the same error i was getting

fresh sierra
#

i think there is some issue with typing using Option

little cobalt
sly pebble
#

also it not being able to be 0 is a weird limitation

fresh sierra
#

let me try with my decorator

sly pebble
sly pebble
#

i also just converted everything to decorator

little cobalt
#

can you try it with discord.option?

sly pebble
#

literally all of the options are required

#

??

little cobalt
#

just send a screenshot

sly pebble
#

of the code or the traceback

lapis dock
#

I think if you specify a type with input_type= you have to use SlashCommandOptionType if you want to pass int just pass it positionally.

fresh sierra
#

well the issue come from discord.Option

#

with the decorator it works

sly pebble
#

everything was defined as SlashCommandOptionType.string tho

#

and such

sly pebble
fresh sierra
#

discord.option

#
    @commands.slash_command()
    @discord.option(name="name", description="Name of the map", type=str, required=True)
    @discord.option(name="mappers", description="Comma separated list of map creators/contributors", type=str, required=True)
    @discord.option(name="addition_month", description="What month was the map added to FE2?", choices=['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], required=True)
    @discord.option(name="highlight", description="Is the map a highlighted map?", type=bool, required=True)
    @discord.option(name="normal_buttons", description="Amount of normal buttons in a map", type=int, min_value=0, required=True)
    @discord.option(name="group_buttons", description="Amount of group buttons in a map", type=int, min_value=0, required=True)
    @discord.option(name="thumbnail", description="Link to a picture of the map", type=str, required=True)
    async def add_map(self, ctx: discord.ApplicationContext, name: str, mappers: str, addition_month: str, highlight: bool, normal_buttons: int, group_buttons: int, thumbnail: str):
        await ctx.respond('Almost done! Please select the events that the map supports using the menu below.')

sly pebble
#

is my code just haunted 😭

#

well alright i'll give that a shot

little cobalt
fresh sierra
sly pebble
#

i need to see a diff of these two hold on

fresh sierra
#

i think i will let it,


    @subcommand("bot")
    @commands.slash_command()
    @discord.option(name="test", required=True)
    async def test(self, ctx: LumabotContext, test: str):

this doesnt look great

sly pebble
#

ohhhh wait

sly pebble
#

because you use @commands.slash_command() while mine uses @discord.slash_command()

#

and yours worked

#

actually wait it still bugs if i change that in my code

#

hm

fresh sierra
#

just im using prefix + the other

sly pebble
#

yea i tried and nothing changed

fresh sierra
#

does ur code still have issue

#

@little cobalt thanks because of you i can even remove the decorator completly.

sly pebble
#

yeah

#

im using diffs to find what's different between the code

lapis dock
#

uhhh, I found the answer

sly pebble
#

oh boy

#

what is it

lapis dock
#

Remember when I said use input_type, you just are not supposed to have anything there at all
Option(int, ...) aparently input_type is positional only. You cannot use it as a kwarg.

sly pebble
#

...

#

buh

#

so the first comma of each option regardless of decorator or not

#

should always be the SlashCommandOptionType?

#

or the int

#

or whatever else

lapis dock
#

not sure about decorator, but for useing discord.Option yes

lapis dock
sly pebble
#

im gonna give the same thing a shot for decorator then one sec

lapis dock
sly pebble
#

i'll give it a shot

#

well the bot loads but it throws this instead, giving current vers of maps.py

Ignoring exception in on_connect
Traceback (most recent call last):
  File "C:\Users\mrmax\PycharmProjects\FE2TimerBot\.venv\Lib\site-packages\discord\client.py", line 400, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\mrmax\PycharmProjects\FE2TimerBot\.venv\Lib\site-packages\discord\bot.py", line 1178, in on_connect
    await self.sync_commands()
  File "C:\Users\mrmax\PycharmProjects\FE2TimerBot\.venv\Lib\site-packages\discord\bot.py", line 754, in sync_commands
    app_cmds = await self.register_commands(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\mrmax\PycharmProjects\FE2TimerBot\.venv\Lib\site-packages\discord\bot.py", line 599, in register_commands
    registered = await register("bulk", data, _log=False)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\mrmax\PycharmProjects\FE2TimerBot\.venv\Lib\site-packages\discord\http.py", line 373, in request
    raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In 1.options.7: Required options must be placed before non-required options
In 1.options.8: Required options must be placed before non-required options
In 1.options.9: Required options must be placed before non-required options
#

plagued by horrors

lapis dock
#

That is just a discord limitation

sly pebble
#

how much is positional?

lapis dock
#

wdym?

sly pebble
#

everything in this is required tho

#

like all the options have required=True

#

and its throwing the error on the last 3 options

lapis dock
#

oh, skull_cry

sly pebble
#

yeahhhhhh

#

i feel that

#

hmmm

#

the only significant differences in the last 4 are that max time uses default, and all 3 of those number/int requiring options do not use max_value

#

so what happens if i add a max value

#

WHAT

#

IT FUCKING WORKS WHEN I REMOVE DEFAULT

lapis dock
#

Oh yeah, default forces it to be non-required

sage tendon
#

you never need required=True btw

sly pebble
#

ahhhhhhhhhhhhhhhhhhhhhhhh

lapis dock
#

some poeple like it for clarity tho

sly pebble
#

noted on both fronts

#

well damn

#

glad thats over with

#

thanks for the help o7

sage tendon
#

float values suck for options btw

#

from a user perspective

#

Because it depends on the client locale on whether you use . or , as the decimal point

sly pebble
#

horror.

sage tendon
#

yea

#

it is kind of annoying :3

sly pebble
#

i can probably do away with it for max_time but im basically required to use it for the difficulty one, because the game i'm building the bot for utilizes a decimal difficulty system

#

then agani

#

oh wait yeah this is gonna be fun later on

#

oh well, later me's problem

#

again, thank you all sm

sage tendon
#

np

#

and if thats minutes, btw, decimals really dont make much sense

#

unless you really wanna make sure that something runs half a minute longer

sly pebble
#

just doing it because some maps have previously used max times with .500 or simila

#

im the only one using this command anyhow so

#

its not too bad

fresh sierra
#

finnaly finshed to remove all discord.option

#

was long

sage tendon
#

i hope you mean discord.Option

fresh sierra
#

nah

#

i dont need the decorator

sage tendon
#

i hope you stub your toe

fresh sierra
#

(im using it only for the choices)

sage tendon
#

?

lapis dock
#

discord.Option gang πŸ’―

sly pebble
#

oh also wait one quick question

sage tendon
#

i hope you all stub your toes

#

decorator is objectively superior

sly pebble
#

when you use a view, how does the original command that creates the view actually use the data from the view

sage tendon
#

wdym "use the data"

#

the command interaction is done after its code is finished

fresh sierra
# sage tendon ?

like discord.option is not useful in my case since the only thing that i cant pass directly in the func is choices, max_value and min_value. And since im not using max and min value i need it only for the choices

lapis dock
#

you can use await View.wait() and then access the views attributes but generally you are able to "use" all you need in the callback of the component.

sly pebble
#

well i made this, the reply it gives to selecting stuff is from the callback, but is it possible for the slash command to see the selections or no

sage tendon
#

see wolfy's message

lapis dock
sly pebble
#

ah i see

#

so just for clarification, am i able to get this block of data in the view's callback?

#

and if so how

#

docs are a bit confusing

sage tendon
#

holy shit

fresh sierra
#

by passing it

#

view(name, mappers, ...)

sage tendon
#

congratulations, i have never before seen a command with that many options, and that total length

fresh sierra
#

nah i got more, so give me the title

sage tendon
#

no

sly pebble
#

eh i'm still kinda toying with ideas and seeing what works best

sage tendon
#

I wanted to say "use modals" but i forgot discord never made modals anywhere near useful

sly pebble
#

yeah lol

#

i looked into those first

lapis dock
#

But yeah, you have to pass it to the view

fresh sierra
#
    @subcommand(f"stats setup")
    @commands.slash_command()
    @discord.option(name="mode", type=str, choices=["enable", "disable"], default=True, required=False)
    async def add(self, ctx: LumabotContext, role: discord.Role, mode: str, time: str = None, voice: str = None, message: int = None, mandatory: discord.Role = None, forbidden: discord.Role = None):
#

but its not a competition

sly pebble
#

ok so when passing things to the view, just dropping them all in the view=Events() works?

sage tendon
#

if your __init__ makes use of them

sly pebble
#

hmm

#

i havent done something like that before so this is gonna be new for me

sage tendon
#

its just basic OOP, not complicated

sly pebble
#

ye, just realized that and now i feel fine again

sly pebble
#

both are lengthy either way though

lapis dock
#

I think the command is a better option. In reality this is not something you will be doing very often so its ok if it is long. If you are on PC there will be no issues

#

mobile it might be hard to see but oh well

sly pebble
#

mhm

#

and im the only one doing this command

#

and on pc so

#

definitely reassuring tho ty

little cobalt
#

@fresh sierra the client._pending_application_commands is working well

#

and I have to write less code

fresh sierra
#

with that you will need only

    @commands.slash_command()
    @discord.option(name="kind", choices=["add", "remove", "edit"])
    async def channel_rate(self, ctx: LumabotContext, kind: str, channel: discord.TextChannel, rate: float = 1.0):
#

to put all name, localization, options etc etc

little cobalt
#

I only use slash_command()

fresh sierra
#

yeah but i mean you can also pass each option name, etc etc

#

here a part of my yaml if it can help you

little cobalt
#

na

#

I use json

fresh sierra
#

yeah but that the same

#

i mean options, name description choices

#

also why are you using json and not yaml ? yaml isnt easier to write than json ?

sage tendon
#

i will never understand why y'all overcomplicate it like this

fresh sierra
#

its not complicated

little cobalt
#

and I dont really have to change any code like that

tidal estuary
#

If you had a bot that was performing badly but had no apparent errors aside from interaction failures, how would you go about profiling it?

sage tendon
#

"performing badly" how

tidal estuary
#

All commands seem to intermittently stop responding, games etc get interaction failed

#

It's a big, not great codebase and I can't find anything about profiling cogs

sage tendon
#

you probably use sync instead of async often

#

do you use any db stuff?

tidal estuary
#

I try not to but there's definitely stuff like that going on that I am unaware of or forgot

#

Yeah, tons, I try to use async for all of that

#

That'd be where you'd look first?

little cobalt
tidal estuary
#

requests yes, only async sleep, and no

little cobalt
#

requests is gonna block your bot

tidal estuary
#

I didn't consider that, ngl

#

Well, that's a few good places to start

#

appreciate it πŸ™‚

little cobalt
#

.requests

sly karmaBOT
#

Why you should not use the requests library for your bot
requests is a popular HTTP library for Python. It is however not a good option for Discord bots, since it is not async and blocking.

This essentially means that your bot will not be able to execute any code at all while a request is happening. Since requests usually take a few seconds to complete, this can have a detrimental effect on your bot's performance. E.g if a user executes a command that performs a request taking 5 seconds to complete, no one else will be able to use your bot for those 5 seconds.

Please look at using a HTTP library that has async support, such as aiohttp or httpx

bronze jewel
#
@bot.event
async def on_message(message):
    if message.author == bot.user:
        return 
    if message.content.lower() == "bien":
        await message.channel.send("mercii!!")```
why is this not working ??
little cobalt
bronze jewel
lapis dock
#

.tag idw

sly karmaBOT
#

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.

bronze jewel
lapis dock
#

probably message_content

little cobalt
sage tendon
#

who needs docs when we have chatgpt amirite

warm linden
#

how do i get who clicks the button? e.g. interaction.author to mention them?

sage tendon
#

just like that

#

except its interaction.user i think

nova epoch
#

It is interaction.user

#

.rtfm discord.Interaction.user

sly karmaBOT
nova epoch
#

@warm linden ^^

sage tendon
nova epoch
#

eek >.<

warm linden
warm linden
#

.rtfm interactions.defer

sly karmaBOT
#

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

warm linden
#

how am i able to remove the "application failed to respond" when it did work though

lofty parcel
#

Or you're taking more than 3 seconds

warm linden
#

im using

    return await interaction.channel.send(embed=e)
lofty parcel
#

yeah no,

warm linden
#

oh

lofty parcel
#

you're supposed to respond to the interaction

#

you must respond to all interactions

#

you use interaction.response.send_message

warm linden
#

so interaction.respond.send_message

#

oh yeah

#

one sec

#

thanks

warm linden
lofty parcel
warm linden
#

without it replying to the first message

lofty parcel
warm linden
#

yes that exactly that i couldn't find it tho

#

.rtfm interactions.defer

sly karmaBOT
#

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

lofty parcel
#

It is interaction.response.defer

warm linden
#

ahhhhh

#

thanks man

warm linden
#

how comes i have 2 or more buttons in a msg but only 1 of them is showing?

fresh sierra
#

can you explain the usage for i can better undrstand ?

#

because if a message has more than 1 button it mean than more than 1 button will be shown, but maybe you mean more than 1 button in ur class but only some in the message, and for that it will depend or the self.add_item. Or maybe you want to refer to the disable optio,ns

sage tendon
rugged lodgeBOT
sage tendon
#

if i can tell right from the indentation, your button isn't on the right indentation level

#

or wait no i think it is

#

can you show the code where you send the message with the view

#

just screenshot that part, i hate pastebin ngl

sage tendon
#

before anything, i'd check why its underlined red lol

#

you are using the wrong view

sage tendon
warm linden
#

interaction.guild isn't working for me no more

warm linden
#

the command i screenshoted send out the public message to click a button and create a private channek

#

once thats made it send another embed

#

to close and or claim the ticket

warm linden
sage tendon
#

but the one you sent uses a different view

sage tendon
#

yea
now show that message inside discord

warm linden
sage tendon
#

no

#

the message that results from that..

little cobalt
warm linden
warm linden
#

bc now its not working

#

so i cant actually show nothing

lofty parcel
#

bud show the view code

sage tendon
#

they did.

#

in the pastebin.

sage tendon
warm linden
sage tendon
#

"or where is this in"

edgy nest
warm linden
#

its in a differnt class

edgy nest
#

change the name of one of them

warm linden
#

different

lofty parcel
#

yeah i was abou to say that

#

same callback name

sage tendon
#

oh, i thought the label was the "name" used

edgy nest
#

that's not how python works

warm linden
#

wait to see if it works can i not use interaction.guild?

sage tendon
#

nothing to do with how python works though
i just misunderstood the decorator then

edgy nest
warm linden
#

ahhh

edgy nest
#

it has everything to do with how py works

sage tendon
#

yea i thought the decorator would like just eat them and yknow do different stuff with it
man idk

lofty parcel
warm linden
sage tendon
#

you mixed up the parameters

#

switch them around

#

button and interaction

lofty parcel
#

you might want to learn python

sage tendon
#

tbf the order of those parameters is a little random, but yes, it should be clear from the error :>

warm linden
#

i coulda sworn it was working yesterday

sage tendon
#

unless someone came to your room and switched that, no, no it wasnt

lofty parcel
#

the order is self, button, interaction

warm linden
#

is the order its in

#
    @discord.ui.button(label="Contact Us!", row=0, style=discord.ButtonStyle.success, emoji="βœ‰οΈ") 
    async def button_callback(self, button, interaction):
            guild = interaction.guild
sage tendon
#

i do gotta say though, i dont really like how the self is an explicit argument in python
i just dont like that
i like the java way where you just use this

lofty parcel
#

do you realize you can name it the hell you want?

sage tendon
#

i mean that its an argument at all in the function header

lofty parcel
sage tendon
#

in java its silently passed

sage tendon
lofty parcel
#

Because d,py uses it the other way around.

lofty hedge
#
    @discord.default_permissions(manage_messages=True)
``` can i not do this on a command group because it just doesnt work, it allows users to invoke who doesnt have that permission
sage tendon
#

show all the decorators, it needs to be in the right place

warm linden
sage tendon
warm linden
sage tendon
#

yea so fix that lol

warm linden
#

OH

lofty hedge
#
    @tags.command()
    @discord.default_permissions(manage_messages=True)
    @commands.guild_only()
    @commands.cooldown(1, 2, commands.BucketType.user)```
warm linden
sage tendon
#

show your pip list

sage tendon
#

you cant further restrict commands in groups i think

lofty hedge
#

thats what im thinking but then i couldnt make it command specific

#

eh

#

cause its a group of 3 commands, only two needs manage messages

sage tendon
#

Well, not possible

lofty hedge
#

figured thanks for the help

sage tendon
#

because in discord's UI as well, you can only edit the permissions of the main group command

forest tulip
#

why if i doing view with 6 buttons in main bot file then everything work fine, but in paginator ValueError: item would not fit at row 2 (6 > 5 width)

weary meteor
#

for the Option type, how can i make the autocomplete grab all the roles in a discord server? like Option(discord.Guild.roles) or something like that

heavy inlet
#

sorry if im being dumb and stupid but im coding after a while
i tried installing py-cord using pip install py-cord as stated on the guide, it says it successfully installed but i cannot import it.
any solution?

weary meteor
heavy inlet
#

i don't

weary meteor
#

run pip freeze and send an ss

heavy inlet
little cobalt
#

do you use a venv?

weary meteor
#

yeah chances are vscodes interpreter is using the wrong one?

heavy inlet
little cobalt
#

do you get an error at the Terminal if you run the file?

heavy inlet
#

ModuleNotFoundError: No module named 'discord'

little cobalt
#

did you already restart the IDE?

heavy inlet
#

yes

warm linden
#

im trying to use the slash commands in cogs by first starting on the example code: https://guide.pycord.dev/popular-topics/cogs but the slash commands aren't showing up - recieving no errors as well.

  • My bot does have application cmds
  • Cog has been loaded

Cogs, often known as modules or extensions, are used to organize commands into groups. This is useful

#

whys this happening?

warm linden
sage tendon
#

show your code

#

the entire cog

warm linden
#

breh doesnt let me send here

#

can i use pastebin

sage tendon
#

yes

warm linden
rugged lodgeBOT
sage tendon
#

do you also load the cog in your main file

#

bot.load_extensions("cogs") if your cogs folder is called, well, cogs

sage tendon
#

did you restart discord after adding the commands?

warm linden
#

i even make bot print the loaded cogs

#

nd greetings is being loaded

sage tendon
#

can you send your main bot file too?

#

also make sure to try /goodbye, the others might not show up depending on your bot definition, and greet is a user command for example, not a slash command

warm linden
#

only the slash cmds

rugged lodgeBOT
sage tendon
#

do you really need both slash and prefix commands?

warm linden
sage tendon
#

you can do that lol

#

with slash commands

warm linden
#

oh

#

yeahh

#

how

#

i dont need prefix then

sage tendon
#

then change to discord.Bot first of all

#

and you do that by using the @discord.default_permissions(manage=members=True) decorator under the slash command decorator

warm linden
#

ahh thanks man

warm linden
sage tendon
#

that wont hide the command

warm linden
#

ahh

#

arright

sage tendon
#

but you can add that to hide it + limit execution to yourself

warm linden
#

aright bet thanks

little cobalt
#

@sage tendon ^

#

that is why its not working

sage tendon
#

ahh

#

yea i was also confused about that but i thought that was just how it was in the guide

little cobalt
#

@warm linden why did you use while True at the events?

#

also why do you have discord webhooks installed?

#

that already comes with py-cord

warm linden
sage tendon
#

no

sage tendon
#

just add bot.load_extensions('cogs') anywhere before bot.run

warm linden
#

yeah will do

#

thanks

#

.rtfm webhooks

little cobalt
sage tendon
#

and you rarely need webhooks when using bots anyway, so, whats your plan with webhooks