#Basic Pycord Help (Quick Questions Only)

1 messages ยท Page 73 of 1

fervent cradle
#

i feel like this is a pretty common thing but i have a problem in my code that makes it so that every time i send a command it says command not found while i coded a command

young bone
fervent cradle
#

let me check

#

No

#

Could that be the problem?

young bone
#

Yes

fervent cradle
#

Ah

#

so do i need to put on message send or smth like that

young bone
#

No

#

I mean the error

#

That usually happens if you have the on_message Event and you try to use a command

fervent cradle
#

oh

#

could this have something to do with it?

fervent cradle
cyan quail
#

if you paste it then it'll probably embed so go for it

#

or wrap it in codeblock with ```py

fervent cradle
#

oh ok

#

intents = discord.Intents.default()
intents.message_content = True

client = commands.Bot(command_prefix='h!', intents=intents)

@client.event
async def on_ready():
print('We have awaken the beast')

client.run('token')

@client.command()
async def ping(ctx):
await ctx.send("Pong!")

@client.command()
async def pingtest(ctx):
await ctx.send(f'Pong! {round(client.latency * 1000)}ms')

@client.command(aliases=['8ball', 'test3'])
async def _8ball(ctx, *, question):
responses = ['Surely',
'yes',
'definitely',
'mhm',
'probably',
'maybe not',
'maybe',
'No',
'Never',
'definitely not',
'nope',
]
await ctx.send(f'Question: {question}\nAnswer {random.choice(responses)} ')

#

posting it like ``that` didn't work

cyan quail
#

you should have client.run at the end

fervent cradle
cyan quail
#

ah oh well

#

close enough, without slashes

fervent cradle
#


intents = discord.Intents.default()
intents.message_content = True

client = commands.Bot(command_prefix='h!', intents=intents)


@client.event
async def on_ready():
    print('We have awaken the beast')


client.run('token')


@client.command()
async def ping(ctx):
    await ctx.send("Pong!")


@client.command()
async def pingtest(ctx):
    await ctx.send(f'Pong! {round(client.latency * 1000)}ms')


@client.command(aliases=['8ball', 'test3'])
async def _8ball(ctx, *, question):
    responses = ['Surely',
                 'yes',
                 'definitely',
                 'mhm',
                 'probably',
                 'maybe not',
                 'maybe',
                 'No',
                 'Never',
                 'definitely not',
                 'nope',
                 ]
    await ctx.send(f'Question: {question}\nAnswer {random.choice(responses)} ')...
#

here we go

young bone
#

client.run at the end pls

cyan quail
#

but yeah, client.run is blocking so nothing after that will run

fervent cradle
#

yeah i did that

young bone
#

client.run has to be the last line at the file

fervent cradle
#

i just copied the previous code

#

to see if id work

#
 intents = discord.Intents.default()
intents.message_content = True

client = commands.Bot(command_prefix='h!', intents=intents)


@client.command()
async def ping(ctx):
    await ctx.send("Pong!")


@client.command()
async def pingtest(ctx):
    await ctx.send(f'Pong! {round(client.latency * 1000)}ms')


@client.command(aliases=['8ball', 'test3'])
async def _8ball(ctx, *, question):
    responses = ['Surely',
                 'yes',
                 'definitely',
                 'mhm',
                 'probably',
                 'maybe not',
                 'maybe',
                 'No',
                 'Never',
                 'definitely not',
                 'nope',
                 ]
    await ctx.send(f'Question: {question}\nAnswer {random.choice(responses)} ')




@client.event
async def on_ready():
    print('We have awaken the beast')


client.run('token') 
#

so uh ill see if it works

#

IT WORKED

#

Tysmpogthumbsup

pallid token
#

So I'm having some issues that when a command takes a bit to execute, it times out and I get a NotFound: 404 Not Found (error code: 10062): Unknown interaction.
I was wondering how long Discord expects a response after (seems to be within a second or two) and how I might address it. Was thinking of maybe sending a message and then editing it when it's done processing? Is there an easy way to send that message as a response, keep executing and then update it later using the same context?

full basin
#

If your responses takes more than that, you should defer

pallid token
#

Thanks ๐Ÿ™‚

#

So when deferring... If you send a response, you end up with the InteractionResponded error. Just wondering if there is a way to know when to use followup.send("Hi"). Do I have to shield all potential responses in a try-except block and instead use followup.send if the error occurs?

#

(I handle some of my errors in a separate cog-wide method)

#

The reason I ask is because I would rather cut down on unnecessary requests to Discord.

#

Ignore my previous messages. Found a solution.

full basin
undone falcon
#

is there a way to reduced the RAM usage of the bot ?

quasi mulch
#

Anyone know why my AutoShardedBot won't start more than 25 shards even though I've asked it to start 32? It's in 28.8k guilds so I don't need more shards yet, but I like keeping up with about 1 shard per 1k guilds. Please ping me if you respond ๐Ÿ‘

undone falcon
quasi mulch
undone falcon
#

yeah and it is fill with a bunch of information that I dont use and just take up space for nothing

undone falcon
#

I only have 4 Gb of ram to in my server ahaha

cyan quail
undone falcon
cyan quail
#

then disable chunk_guilds_at_startup in your bot class

#

by default, when the bot starts up it will go through every guild and cache all members

#

that kwarg will toggle it

undone falcon
cyan quail
#

the other information is miniscule... you can't just erase the rest of the contents of the class

#

unless you want to completely rewrite the member object and how the library interacts with it

undone falcon
cyan quail
#

depending on your use case, chances are you don't need every member cached; you can still recieve members through commands and events, or fetch by ID

#

bio text isn't even on the api...

undone falcon
#

I am giving example, not saying it is

undone falcon
cyan quail
#

if you just want role and user IDs and nothing else then this library isn't for you, you're better off making http requests directly

#

cache just means to have them on hand at all possible times; that doesn't mean you can't see them at all

#

for example, every interaction comes with a member object

undone falcon
cyan quail
#

ultimately it depends on what your bot does

#

you can fetch all members with await guild.fetch_members

#

that being said, you should use this sparingly

undone falcon
cyan quail
#

that won't cache them, it's an iterator

undone falcon
#

ooh I see, thank you !

#

if I dont have members in the caches, what could be in the members attribute in a Role object ?

cyan quail
#

probably an empty list

undone falcon
#

I see i would probably need to construct that list myseft !

#

thank you for your help !

undone falcon
#

can I only cache the members I need (I got all their id in a database) ?

cyan quail
#

just fetch them

#

assuming you don't need every member at once, you can use guild.fetch_member

undone falcon
cyan quail
#

don't think so

silver moat
undone falcon
#

is there a way I can add them in the cache in that case ?

silver moat
#

right now we only add/change things to cache via events

cyan quail
#

well

#

if you want to modify the cache manually, you can use guild._add_member

#

and it'll probably update fine after that

#

but we can't help much further since it's a private method

undone falcon
cyan quail
#

interestingly enough, MemberConverter also does this for you which is nice

#

so even prefix commands with a Member argument will cache the member object

undone falcon
#

oh that is pretty nice !

cyan quail
#

(client was only the variable name, the issue was something else)

dry cove
#
        pages__ = []
        files_ =  []
        for filename in os.listdir("./assets/examples"):
            embed = discord.Embed(title=filename[:-4], color=config.primary_color)
            file = discord.File(f"assets/examples/{filename}", filename=f"{filename}")
            embed.set_image(url=f"attachment://{filename}")
            pages__.append(embed)
            files_.append(file)
        page = 0
        pagelist = [
            pages.PaginatorButton(
                "first", emoji=':left:', style=discord.ButtonStyle.gray
            ),
            pages.PaginatorButton("prev", emoji=":left:", style=discord.ButtonStyle.gray),
            pages.PaginatorButton(
                "page_indicator", style=discord.ButtonStyle.gray, disabled=True
            ),
            pages.PaginatorButton("next", emoji=":right:", style=discord.ButtonStyle.gray),
            pages.PaginatorButton("last", emoji=":right:", style=discord.ButtonStyle.gray),
        ]
        paginator = pages.Paginator(
            pages=pages__,
            show_disabled=True,
            show_indicator=True,
            use_default_buttons=False,
            custom_buttons=pagelist,
            loop_pages=False
        )
        await paginator.respond(ctx.interaction,files=files_)

Im getting this error Paginator.respond() got an unexpected keyword argument 'files'

grizzled sentinel
#

Instead of adding an embed to pages__ you should add a Page object with files and embeds set

dry cove
#

๐Ÿ‘ works

jaunty jewel
#

app command can be only visible to one person ๐Ÿคจ

jaunty jewel
odd prairie
#

How to reset a dropdown's displayed value? The goal is to get the first picture each time you select something, yet I get the second one.

cyan quail
#

(in a subclassed view, this would be view=self)

odd prairie
young bone
cyan quail
jaunty jewel
cyan quail
#

or if you have admin in the guild you can edit the permissions in server settings > integrations

jaunty jewel
odd prairie
cyan quail
#

So it would typically reset after refreshing

#

Or, as you tried, it's different on another device

#

The only workaround for this being to send the view again to forcefully reset it

odd prairie
coarse cargo
#

Hey there guys, i have 2 files main.py and colors.py. In the second i have a function that contains a dictionary and returns it unpacked. So in the first file i import this function and i want to use it for format a string. But i get a KeyError

This is my code:

# colors.py

class TerminalColors:
    header = '\033[95m'
    purple = '\033[0;35m'
    blue = '\033[94m'
    cyan = '\033[96m'
    green = '\033[92m'
    red = '\033[91m'
    orange = '\033[93m'
    yellow = '\033[0;33m'
    bold = '\033[1m'
    underline = '\033[4m'
    end = '\033[0m'


def get_colorsformat():
    color_vars = {
        'header': f'{TerminalColors.header}',
        'purple': f'{TerminalColors.purple}',
        'blue': f'{TerminalColors.blue}',
        'cyan': f'{TerminalColors.cyan}',
        'green': f'{TerminalColors.green}',
        'red': f'{TerminalColors.red}',
        'orange': f'{TerminalColors.orange}',
        'yellow': f'{TerminalColors.yellow}',
        'bold': f'{TerminalColors.bold}',
        'underline': f'{TerminalColors.underline}',
        'end': f'{TerminalColors.end}',
        'TIME': f'{datetime.now().strftime("%H:%M:%S")}',
    }

    return {**color_vars}

And my other code

# main.py

print(log.format(get_colorsformat(), USERNAME=f"{interaction.user.name}",
                             CHANNEL_NAME=f"{interaction.channel}"))
grizzled sentinel
#

Does format take all of those kwargs anyways?

coarse cargo
# grizzled sentinel Can you share the full error
Ignoring exception in view <PanelView timeout=None children=1> for item <Button style=<ButtonStyle.success: 3> url=None disabled=False label='Open a Ticket' emoji=<PartialEmoji animated=False name=':incoming_envelope:' id=None> row=None>:
Traceback (most recent call last):
  File "C:\Users\Federico\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ui\view.py", line 414, in _scheduled_task
    await item.callback(interaction)
  File "C:\Users\Federico\Desktop\TicketBot\main.py", line 187, in button_callback
    print(log.format(get_colorsformat(), USERNAME=f"{interaction.user.name}"))
KeyError: 'bold'
#

This is the string, i replace <> with {} before formatting it.
open_ticket: "<bold><header>LOGS<end><blue> - <cyan>The user <underline><blue>{USERNAME}<end><green> created<cyan> a new ticket<blue> - <cyan>{TIME}"

grizzled sentinel
#

What if you just returned the dict and unpacked it in the format function directly.

coarse cargo
#

I use the function for format every log i dont want to have all these duplicates

grizzled sentinel
#

Sorry I'm not knolagable enough with unpacking to help.

slate arrow
#

Does Anyone Know How To Add Slowmode To A Server Using Pycord

grizzled sentinel
#

.rtfm TextChannel.set_slo

winter condorBOT
#

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

slate arrow
patent knoll
#

i have this but members can still use that command - is this me being stupid or?

slow halo
#

Does anyone has the same Problem with guild.fetch_auto_moderation_rules() ???

i always get the Error

AttributeError: 'Guild' object has no attribute 'fetch_auto_moderation_rules'

but https://docs.pycord.dev/en/stable/api/models.html#discord.Guild shows that Function is there....

patent knoll
#

screenshot your code

slow halo
#

would be a lot xD

#

okay...found it.....didnt had the current version and i thought i updated it with "pip install pycord"....but nope

patent knoll
#

the part where you use that function

slow halo
#

py-cord would have been correct

patent knoll
#

you need to do pip install py-cord

#

yea, idk if its just typosquatting or an old package

slow halo
#

now i have 2.4.1...and now its working

silver moat
patent knoll
#

okay what tf do i put here lol, i tried everything from a string "MANAGE_GUILD" to discord.Permissions.manage_guild and idk anymore

silver moat
patent knoll
glad remnant
#

Hello, anyone knows how to fix this? It add reaction but print error in log

glad remnant
#

Yeah, it was because of ephemeral message before. That was causing that error

patent knoll
#

Okay so what i can tell from the actual discord.Permissions file is that discord.Permissions.ban_members should return 1 << 2
however it just doesnt work when i put it into default_member_permissions, but it does work if i manually write 1 << 2 there

patent knoll
#

How do I properly do this with bridge commands?

cyan quail
patent knoll
#

i tried that

cyan quail
#

you said discord.Permissions.manage_guild

#

but what you want is discord.Permissions(manage_guild=True)

patent knoll
#

oh..

cyan quail
#

alternatively, the @discord.default_permissions decorator already uses that syntax

patent knoll
#

which one is better to use

cyan quail
#

they do the same thing GuraShrug

#

just a matter of convenience

patent knoll
cyan quail
#

they should

#

ah wait

cyan quail
patent knoll
#

i see, thx

candid coral
#

Can you name a method that waits for a response after a given command?

grizzled sentinel
#

Depends what kind of response you need just a message would be the "message" event

topaz ruin
#

Is there a way to download a file that's been sent with a command?
eg a user types /upload along with a file that has been attached and the file will be downloaded by the bot. i've been looking for tutorials but all
the ones i've found use "ctx.message.attachments[0]" but all that does is output the following error: "discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'NoneType' object has no attribute 'attachments'".
is there something i'm missing, or is this some obvious fault on my part

topaz ruin
#

meaning it cant find the file?

full basin
#

A slash command doesnt have a message

topaz ruin
#

i see

#

so is it possible to do in another way?

young bone
#

file: discord.Attachment and file would have anything

cyan quail
topaz ruin
#

yes

#

i was using that

full basin
#

show your code

cyan quail
#

whatever the variable name you used is

topaz ruin
#

i dont have the code anymore as it didnt work, so i removed it from the bot

young bone
#

lol

topaz ruin
cyan quail
#

(you should)

fervent cradle
#
class ManageSubscriptionButton(
    discord.ui.View
):  # Create a class called MyView that subclasses discord.ui.View
    def __init__(self):
        super().__init__(timeout=None)  # timeout of the view must be set to None

    @discord.ui.button(
        label="Manage Subscription",
        row=0,
        style=discord.ButtonStyle.primary,
        custom_id="manage_subscription",
    )
    async def first_button_callback(self, button, interaction):
        await interaction.response.send_message(
            view=ManageSubscriptionMenu(interaction.user.id)
        )


class ManageSubscriptionMenu(discord.ui.View):
    def __init__(self, discord_id, *args, **kwargs) -> None:
        super().__init__(timeout=None, *args, **kwargs)

    # i wanna send an embed with the users remaining subscription time here?
    
    @discord.ui.button(
        label="Manage Subscription",
        row=0,
        style=discord.ButtonStyle.primary,
        custom_id="manage_subscription",
    )
    async def first_button_callback(self, button, interaction):
        await interaction.response.send_message(
            view=ManageSubscriptionMenu(interaction.user.id)
        )```
#

i wanna send an embed with the users remaining subscription time here?

how would i do this part?

#

like regarding sending the embed

#

would i send it when i send ManageSubscriptionMenu?

#

or in ManageSubscriptionMenu

fervent cradle
#

nvm

grizzled sentinel
#

I think you got it but here is the answer.
Embeds and views are sent attached to a message. You cannot attach an embed to a view.

fervent cradle
#
async def checkSubscriptionInfo(discord_id):
    plex_data = await db_plex["plex"].find_one({"discord_id": discord_id})
    user_data = await db_payments["plex"].find_one({"discord_id": discord_id})
    print(user_data)
    print(plex_data)
    print(discord_id)```
#

can someone help me with this? trying for hours

#
None
None
1082205117249499137```
#

it prints this when ran

#

fuck im stupid thats not my id

distant roost
#

How do i force a member to input a role in an slash command? Like channel=discord.TextChannel or member=discord.Member? I tried role=discord.Role but that didnโ€™t work

proud mason
#
- role = discord.Role
+ role: discord.Role
coarse spire
#

trying to add voice recording to my discord bot, but when I try to import PyNaCl, I get the error: ExtensionFailed: Extension 'cogs.recording' raised an error: ModuleNotFoundError: No module named 'pynacl'

even though that I have installed it.
Anyone has any idea on how to solve this?

proud mason
#

also, the module name is nacl

coarse spire
proud mason
coarse spire
#

oh, ok

proud mason
#

can you share the line where it says that?

#

ill ask to get it changed

coarse spire
#

well, I don't have access to that line anymore as my host doesn't allow scrollback so far ๐Ÿ˜• And I can't uninstall PyNaCl either now without reinstalling the whole server

agile dust
#

can anyone tell me how to make buttons and responses to when the button is clicked?

proud mason
coarse spire
proud mason
#

oh nvm then lol

patent knoll
#

In short
Subclass a view and then add your stuff to it
Here's an example of my own button that does exactly that

#

It looks like a lot but most of that is just code for my specific purpose, the only stuff you truly need is the constructor, @discord.ui.button() and the callback
the callback is what happens when the button is pressed

proud mason
#

check out the guide too

#

.guide

winter condorBOT
patent knoll
patent knoll
proud mason
#

true doggokek

coarse spire
#

How can I create a new automod rule using PyCord? I couldn't really find much information about it

distant roost
coarse spire
#

Thanks ๐Ÿ™‚

topaz ruin
formal wadi
#

Hello there, I wonder how to use external emojis with interaction.response.edit_message, because when my bot edits message, it will unload all the external emoji and display just a text :Emoji:

patent knoll
#

are you sure you are formatting the emojis correctly if its custom emojis

formal wadi
#

Yes, with send_message they load

#

But after edit_message they will unload

patent knoll
#

show your code

formal wadi
#

Its a bit long

patent knoll
#

just the edit part

formal wadi
#

Shouldn't we go to dms?

patent knoll
#

its fine

grizzled sentinel
formal wadi
#

I have dict

emoji = {
"shark" : ":Shark:",
"tuna" : ":Tuna:"
}

The function that will extract value from dict by key (works properly)

Then function to build embed

async def BuildEmbed(args):
emoji = GetEmoji("shark")
embed = discord.Embed(
        title = "Title",
        description = "",
        color = discord.Colour.blurple(),

    )
    embed.add_field(name = "Shark:", value = emoji, inline = False)

Command

@bot.slash_command()
async def fish(ctx):
    await ctx.respond(f"{ctx.author.mention}!", view=MainView(ctx))

MainView has for example button to select fish you want to display (emoji)

async def callback(self, interaction):
        if interaction.user.id == self.ctx.author.id:
            await interaction.response.send_message( embed = await BuildEmbed(fish), view = self.View)

And on another line

await interaction.response.edit_message(embed = await BuildEmbed(fish, view=self.View)
#

The dict, discord removed my emoji IDs

#

This should be enough to understand, on send_message external emoji works properly, but on edit_message they will unload and display plain text, also bot is member of server where I store the external emoji

#

And on that server it works properly, they wont unload

grizzled sentinel
#

await interaction.response.edit_message(embed = await BuildEmbed(fish, view=self.View) I think you are missing a ) after fish

formal wadi
#

Yes, but not in the code

#

Code works properly, there is only problem with the external emoji from another server

#

If I will use local emoji then everything is fine

grizzled sentinel
#

Can yo ushow getEmoji function

formal wadi
#
def GetEmoji(key):
    for name, value in emoji.items():
        if name == key:
            return value
grizzled sentinel
#

So if they are custom emojis why are you not using the IDs in your emoji dict?

formal wadi
cyan quail
#

this sounds more like a discord issue than a library thing

proud mason
proud mason
#

Try that

formal wadi
#

Okay I will try

formal wadi
#

Seems like it is working

proud mason
#

nice

formal wadi
#

Oh maybe not, I forget to edit code

#

I tried it with message.delete and then response.send_message

#

Doesn't matter, it works anyways

#

Thank you!

patent knoll
#

currently trying to catch a cooldown error, but this seems to not work

young bone
patent knoll
cyan quail
#

on_application_command_error

young bone
#

that is for prefix commands you have to use on_application_command_error

#

lul

#

@patent knoll ^^

patent knoll
#

oof

cyan quail
#

(also not necessary, but i'd personally make it ephemeral)

river summit
#

Is it possible to use slash cog groups with different classes (difficult to explain)?

I have a folder with games for the bot and in order to organize things I use different python files with different classes (/flip & /rps are in different python files). How do I access a slash cog group without the two commands being in one class? Is it possible?

patent knoll
#

the order matters, right? i am currently switching them around because it only works with the cooldown below the bridge decorator

patent knoll
cyan quail
formal wadi
#

Is there any way to clear parameter file in message?
For example I have send_message(content = "This is your image", file = image)
And then something like edit_message(content = "Do you like it?", file = None) -> Error

patent knoll
#

what is the error

#

also i dont get why you'd basically wanna hide the pic again

river summit
formal wadi
#

discord.errors.InvalidArgument: file parameter must be a File

proud mason
#

Also try None if empty list doesn't work

formal wadi
#

Both doesnt work

worn void
#

how do I integrate my classes for select menus/buttons into cogs?

patent knoll
#

You can in the discord UI but there seems to be no way to do it via the API
you could try to pass a 1x1 image

formal wadi
#

Then is there any other way to use local images?

patent knoll
#

try passing some .png 1x1 image

formal wadi
#
async def GetFile(fish):
    fish_id = fish["id"]
    file_name = f"{fish_id}.png"
    file_path = f"images/fish/{file_name}"
    file = discord.File(file_path, filename = file_name)
    return fil

file = await GetFile(fish)
patent knoll
#

ah, uh, wait lmfao

formal wadi
#

I use this to load an image

patent knoll
#

here, there's a 1x1 image inside (cant send it because its too tiny to copy)

patent knoll
#

then how?

formal wadi
#

And then this in embed

embed.set_image(url = f"attachment://{fish_id}.png")
patent knoll
#

actually

#

try passing attachments=[]

worn void
#

how do I integrate my classes for select menus/buttons into cogs?

patent knoll
formal wadi
patent knoll
#

the same way you passed file=[]

proud mason
formal wadi
#

Its says it require discord.File

worn void
proud mason
#

And again. And again blobpain

patent knoll
patent knoll
proud mason
formal wadi
proud mason
#

Message.edit does

patent knoll
formal wadi
worn void
patent knoll
#

can you retroactively upload files to existing messages via the API??

patent knoll
proud mason
worn void
#

I'm just new to cogs and wanna move my existing code into cogs since its like 1000+ lines now lmao

proud mason
patent knoll
#

thats nice, wish discord allowed that normally too

proud mason
#

Files is always addition to existing files. Attachments is complete replacement

formal wadi
formal wadi
#

Wrong message

#

Sorry

proud mason
#

Ah lol

patent knoll
worn void
#

but isnt there a way to integrate it normally into cogs?

patent knoll
#

Even if you can, you kind of shouldn't IMHO
But I'm also not a __Pro__grammer so maybe more experienced people know better

worn void
#

because this is how my example cog is setup

formal wadi
#

I dont know what cogs are but I normally import my classes to main code

patent knoll
worn void
#

because vscode

patent knoll
#

yea duh
but somethings wrong with that then

young bone
#

is py-cord installed?

patent knoll
#

mind the dash
VERY important

worn void
#

yes im aware

#

just ignore it, pycord works fine lol

patent knoll
#

see you back in 2m then :D
anyway, the way you do it is good, just add import utils at the top

worn void
#

my classes for the select menus/buttons are like 100+ lines each and having them in 1 file seems redundant

young bone
patent knoll
worn void
#

yeah ik and I should but

#

im making a sorta all purpose bot for myself

formal wadi
worn void
patent knoll
#

did you install pycord or py-cord :)

worn void
#

py-cord

young bone
patent knoll
worn void
#

mhm

patent knoll
young bone
#

uninstall python and pylance and reinstall it to fix it

worn void
#

its fine thats not what im focused on lol

#

so can I just make a ../cogs/utils/xyz.py then in my ../cogs/Test.py I can just import xyz then use xyz.ButtonClassExample()??

young bone
#

what?

patent knoll
#

i dont know how imports work with subfolders tbfh

#

but basically, yea

worn void
#

i really dont think that's how that should work with cogs, and I feel like theres an actual proper way to do it

#

maybe im wrong tho

patent knoll
#

If you want to clutter your actual code files with class definitions (and find a way to do so in the first place) no one stops you

worn void
#

im saying I feel like theres a proper way to organize your classes for buttons/selects/modals, etc while using cogs

full basin
#

Otherwise it'll look in the same folder

worn void
#

i see

#

can I still call zyx tho?

#

or do I have to do import utils.xyz as xyz

patent knoll
full basin
worn void
full basin
worn void
#

or is the normal method just to import the file?

full basin
#

And I just import them

patent knoll
#

you really should imo
organised and less cluttered

#

plus you might wanna reuse those classes in other cogs eventually

#

at which point its basically required anyway unless you want import hell

worn void
#

so another question, I made reaction roles with select menus, I have like 10 classes for each one category, is there a better way to do that?

patent knoll
#

yes

worn void
#

LMAO

patent knoll
#

make it one flexible class that takes arguments

full basin
#

Dynamic options. Indeed

worn void
#

yes thats a good idea

#

but that requires effort

full basin
#

Making 10 classes requires effort

worn void
#

its copied and pasted :)

full basin
#

I'm sure you a select menu with dynamic options should take more than 30 lines

patent knoll
#

in all honesty its really not that complicated

#

dynamic title
dynamic role selection view thing
thats.... kind of it already

#

hardcoding ANYTHING is a bad practice in most cases

worn void
#

thats fair

#

but im also not using any database because idk sql and the bot for the time being is meant for 1 server

patent knoll
#

well you need some way to make it persist between bot restarts

#

ideally

worn void
#

yes which already exists

#

by using client.add_view()

patent knoll
#

no idea what that is lolw

worn void
#

bruh.

patent knoll
#

yea if you hardcode it that works
but if you make it dynamic its not that easy if i understand your approach right

#

weigh your options shrug

worn void
#

im slowly working on making the bot better lmao

#

currently im just moving it into cogs

#

how do I export the file so I can import it?

patent knoll
#

you dont

#

all you need is import x in the file you want it in

worn void
#

with client.load_extension(extension)

patent knoll
#

no, literally just make a normal class definition

#

in the file itself

#

you really dont need to do anything in any other file other than the import statement (and then x.class() of course)

cyan quail
worn void
#

How would I import utils>reaction_roles.py inside commands>fun.py

patent knoll
#

not sure how to import from folders but dark said import utils.reaction_roles

worn void
cyan quail
worn void
#

No module named 'utils'

cyan quail
#

What is your folder structure

worn void
#

oh sorry i forgot to send it

cyan quail
#

How about .utils then

worn void
#

hm?

cyan quail
#

.utils.reaction_roles

worn void
#

syntax error

cyan quail
#

Does it actually error though

worn void
#

yes

cyan quail
#

Then how about cogs.utils

patent knoll
#

then just try import ./utils/reaction_roles

cyan quail
#

/ isn't valid syntax for imports

patent knoll
#

dang

cyan quail
#

It's .

patent knoll
full basin
#

Why the . Before

patent knoll
#

it just tells you it isnt accessed yet because you arent using it

worn void
#

yeah it worked

cyan quail
#

Because it's a relative import

patent knoll
#

lol

patent knoll
#

i mean according to your IDE it works

#

its just not used by you yet

worn void
#

no it doesnt

patent knoll
cyan quail
#

This is why I'd never use vscode for python

patent knoll
#

just do utils.reaction_roles and use it, trust me

cyan quail
#

It's not helpful at all

worn void
patent knoll
#

"it errors"

worn void
patent knoll
#

screenshot the error

worn void
#

bro

#

will you admit you're wrong yet?

#

jesus christ

patent knoll
#

now show your imports

young bone
worn void
cyan quail
#

Are bot.py and cogs in the same folder

worn void
#

yes

cyan quail
#

Because if so, it should be cogs.utils.reaction_roles

cyan quail
#

Nice

worn void
#

toothy is just trying to argue even lmfao

patent knoll
#

oh wait, i thought utils was a subdirectory of cogs

#

bruh

worn void
patent knoll
#

id recommend making it a subfolder of cogs, so that you can import it with the current import statement

cyan quail
#

It ran relative from root so it's fine

patent knoll
#

try from utils import filename

worn void
#
await ctx.respond("no :3", ephemeral=True, view=reaction_roles.SelectMenu())```
this returns `AttributeError: module 'cogs.utils.reaction_roles' has no attribute 'SelectMenu'`
even though the SelectMenu class is inside reaction_roles.py
patent knoll
#

wait no

#

i give up lol

#

screenshot your reaction_roles file

worn void
#

I just imported discord, and pasted my classes which i assume is wrong but

#

@patent knoll ^

patent knoll
worn void
#

wait nvm now it works somehow

patent knoll
#

hm
i could only imagine there's still something weird with your import because that should work if the file got imported

worn void
#

that's actually just really easy to do lmfao

#

i thought i would have to change stuff to use cogs

full basin
#

What's your file structure

worn void
#

the names are wrong btw

proud mason
#

why did no one suggest from utils import reaction_roles pogbruh

worn void
#

good question

worn void
#

no module named utils

proud mason
#

oh must have missed it then lol

worn void
#

i changed it to cogs.utils

proud mason
#

and what about from .utils import reaction_roles

worn void
#

you cant have a . at the start

#

from cogs.utils import reaction_roles works

proud mason
#

ah right. cogs are loaded at the bot level, not the cog level

#

weird thing even i used to encounter

worn void
#

oh also how could I make some easy configs for myself in bot.py to use in other files?

proud mason
proud mason
proud mason
#

bad idea

#

that will result in circular imports

worn void
proud mason
#

yes

#

best to make it at the same level as the bot.py file

#

i wouldnt put them in the same folder as my cogs

worn void
#
config.py >

special = [1, 2 , 3 , 4]
string = "the quick brown fox.."
..


cogs > utils > reaction_roles.py >
import config
class TestClass(discord.ui):
  ..
  print(config.string)
  ..
#

like that?

patent knoll
#

yea

proud mason
#

yes that works

worn void
#

kk

patent knoll
#

dont tell me you have your bot token right in your bot.py too

worn void
#
import config

dotenv_path = Path('token.env')
load_dotenv(dotenv_path=dotenv_path)

token = os.getenv(config.token)
patent knoll
#

not quite what i expected

worn void
#

that's why it pulls from the config

cyan quail
worn void
cyan quail
#

It's the default typechecker that vscode uses

#

So I'm blaming vscode

worn void
#

im using cmd to run the bot anyways

agile dust
#

why am i always getting this error on startup? I have installed pycord correctly and I do not have a running version of dpy installed

silver moat
#

?tag replit-install

obtuse juncoBOT
agile dust
#

thanks for the response

agile dust
agile dust
young bone
woeful skiff
#
Ignoring exception in on_connect
Traceback (most recent call last):
  File "/home/container/.local/lib/python3.10/site-packages/discord/client.py", line 378, in _run_event
    await coro(*args, **kwargs)
  File "/home/container/.local/lib/python3.10/site-packages/discord/bot.py", line 1164, in on_connect
    await self.sync_commands()
  File "/home/container/.local/lib/python3.10/site-packages/discord/bot.py", line 719, in sync_commands
    registered_commands = await self.register_commands(
  File "/home/container/.local/lib/python3.10/site-packages/discord/bot.py", line 599, in register_commands
    registered = await register("bulk", data, _log=False)
  File "/home/container/.local/lib/python3.10/site-packages/discord/http.py", line 371, in request
    raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In 65: Application command names must be unique
#

How do i fix this? :c

young bone
woeful skiff
#

I checked every Command, and there was no not unique one

#

@young bone

harsh dust
#

what's the maximum amount of commands a SlashCommandGroup can have?

silver moat
woeful skiff
#

btw how can i see the line of my not unique command ?

silver moat
woeful skiff
#

BROOOOOOOOOOOO

silver moat
#

65 is the index so it would be your 66th command

woeful skiff
#

That helped me alot

woeful skiff
silver moat
woeful skiff
#

OHH ok

#

Tysm

#

But also bot.command?

silver moat
#

If you are referring to text-based commands, no

woeful skiff
#

Ok

#

Tyupvote

fervent cradle
#

What change in pycord3?

young bone
fervent cradle
#

General

woeful skiff
#

Fixed upvote upvote upvote

silver moat
fervent cradle
silver moat
#

and incomplete

fervent cradle
#

Thanks

candid coral
#

How can an ID be changed to a mention or any other information?

ctx.author.id
Reversed
???

cyan quail
coarse spire
candid coral
#

ID as a number:
586562858595385356

cyan quail
#

yes

coarse spire
#

You can just use ctx.author.mention for example

cyan quail
#

do you mean you have an ID, and want to get a User/Member object?

candid coral
#

Can I just do this?
ID = 586562858595385356
f"<@{ID}>"

coarse spire
#

Yes, if you want to mention them only

cyan quail
#

if you want the object, use guild.get_member(id)

#

or bot.get_user(id)

candid coral
#

How I can separate databases into different servers?

#

Just the way it works

candid coral
jaunty jewel
#

WHY THE COGs ARE BROKEN

solemn idol
jaunty jewel
#

every time i use the command cogs the command begin un responding or un registered at all

an if i used it it will just "didn't respond" then after some moments i get 404 (unknown interaction) in the console :\

silver moat
#

show code

jaunty jewel
solemn idol
jaunty jewel
#

:\

#

fnuc name :

silver moat
#

How is the cog loaded

solemn idol
#

Have you synced your commands?

silver moat
#

.slashnoshow

winter condorBOT
#

Checklist for Application Commands Not Showing Up:
โ€ข Does your bot have the application.commands scope?
โ€ข Are you loading cogs before on_ready and on_connect?
โ€ข Is on_connect not overridden?
โ€ข Did you update to the newest version of py-cord (tag: install)?
โ€ข Is User Settings > Accessibility > Chat Input > Use legacy chat input turned off?
โ€ข Did you share your code and errors?
โ€ข Do you still have libraries that conflict with the discord namespace (e.g. discord.py)?

jaunty jewel
#

the command is showing "sometimes" and if its it just dies

solemn idol
silver moat
#

are you running many instances of your bot

jaunty jewel
#

and about the replit (also tried to work on local) same issue

solemn idol
#

hmm synced globally or synced to a debug guild?

#

If you synced globally it can take a bit.

jaunty jewel
# solemn idol ?

and the bot.sync_commands (don't remember that fr fr) make the whole commands that in the main file die (also didn'tknow WHY)

solemn idol
#

What.

jaunty jewel
silver moat
#

just send link to your entire repl, I'm not asking 50 questions just to find what I want.

jaunty jewel
#

wait

silver moat
jaunty jewel
#

nope ๐Ÿคทโ€โ™‚๏ธ

solemn idol
#

We're waiting ๐Ÿ˜ตโ€๐Ÿ’ซ

silver moat
#

and they are gone

silver moat
# jaunty jewel

senior python developer and still doesn't know python conventions.

jaunty jewel
solemn idol
# jaunty jewel :\

(we are waiting for you to show us your project so we may be able to help you)

jaunty jewel
solemn idol
#

While I was just trying to reorganize my bot- I could not put my cog loader above my help command for no reason at all.

jaunty jewel
solemn idol
#

what

jaunty jewel
#

wait.. where should the cog loader to be ๐Ÿคจ

young bone
#

not on ready or connect

jaunty jewel
#

so that's right:\

#

there is a command but i think that will not effect

young bone
#

Do you use Replit?

jaunty jewel
young bone
#

bot.say? what?

jaunty jewel
#

lol bro

#

respond or how ever:\

solemn idol
#

So it does get loaded and the command does get executed when you run it? Can you try adding a print statement under the await ctx.respond just to make sure it actually gets executed.
And its actually not responding.

silver moat
#

tf are you doing

jaunty jewel
#

ikik but this is a broken command idc

silver moat
#

bot.say is like v0 and like removed years ago

jaunty jewel
silver moat
#

that definitely produces a runtime error

solemn idol
jaunty jewel
#

(the autocomplete who's type that command)

jaunty jewel
jaunty jewel
#

the highlight in VScode are some sort of "he is need a guide"

worn void
#

im using separate files for my classes and importing them into my cogs,
how do I call client? do I define it again inside the class file?

full basin
worn void
full basin
#

Interaction has a client attribute

worn void
full basin
#

Read the docs and see.

#

.rtfm interaction.client

winter condorBOT
worn void
#

also

#

im getting a discord.errors.ExtensionFailed: Extension 'cogs.commands.admin' raised an error: TypeError: issubclass() arg 1 must be a class error when I try to register the cog

#

nvm i found it

coarse spire
#

what am I doing wrong here?

await ctx.guild.create_auto_moderation_rule(name="Words", reason="Automod", enabled=True, event_type=discord.AutoModEventType.message_send, trigger_type=discord.AutoModTriggerType.keyword_preset, trigger_metadata=discord.AutoModTriggerMetadata(presets=discord.AutoModKeywordPresetType["profanity", "sexual_content", "slurs"]), actions=[discord.AutoModAction(discord.AutoModActionType.block_message, metadata)])```

I have read the docs about this multiple times
signal topaz
#

can anyone help? i wanna know how you add choices for args in a slash command

coarse spire
errant craneBOT
#

Here's the slash options example.

proud mason
#

@signal topaz see this

winter condorBOT
signal topaz
#

got it

lime lichen
#

i dont understand why im getting a return of both discord.Interaction and discord.webhook.async_.WebhookMessage for the exact same line of code in two different places. the main thing im trying to do is edit the message and it just started telling me that when i run it a certain way that "interaction has no attribute 'edit'" but why is an interaction being returned from an interaction response?

proud mason
#

.rtfm interaction.edit_original_response

winter condorBOT
proud mason
#

use that to edit the msg sent

lime lichen
#

does that change anything?

proud mason
#

.rtfm applicationcontext.edit

winter condorBOT
proud mason
#

yep

lime lichen
#

thanks

proud mason
#

np

patent knoll
#

how do i properly make an @Option parameter
I'm too stupid to figure it out rn lol

proud mason
patent knoll
#

yea

patent knoll
#

I did it exactly like this with the options=[] argument and it worked perfectly

#

ah weird
previously, it never worked when i did input_type=str but now it does

#

Yea okay but now if i do input_type=discord.Member it wont actually suggest the latest members in chat

patent knoll
#

if i do

...options=[
    discord.Option(discord.Member, name="name", description=description="desc"
]

it works just fine. However, if you just use the @option decorator, you cant use the positional first argument, and using input_type=discord.Member just doesnt work, even in above code

patent knoll
#

why would I need them?
it works just fine if i do it like in the above codeblock

young bone
#

Oh

patent knoll
#

its just a weird case of discord.Option() working differently from the decorator version

young bone
#

option(discord.Member, )

patent knoll
#

it'd save me like 100 lines of code total when using the decorator so i want to, but i just cant get it to work

patent knoll
#

here, 1s, ill show you

#

is it capital or lowercase option

#

if i use the lowercase option, this happens

#

and if i use @Option, its "not callable"

errant craneBOT
#

Here's the slash options example.

patent knoll
#

never heard of Union, let me see

young bone
patent knoll
#

well

#

let me test

#

its still confusing AF to have both option and Option

cyan quail
#

Not really

patent knoll
#

Currently my bigger problem is that the options dont even update

#

This should give a user option with the automatic userlist, and the same for the channel option, right?

young bone
#

Can you show the async def line?

cyan quail
#

I'll be honest

#

Decorator sucks

young bone
#

Its working fine for me

patent knoll
cyan quail
#

yeah but i swear every week it breaks

#

why would you use options as a list

patent knoll
#

yea it works now, idk what kind of aids discord just had to not update the command (and it still worked??? with the old args?)

patent knoll
cyan quail
#

just define it as regular function args

patent knoll
#

what

cyan quail
#
async def command(self, ctx, option1: discord.Option(...), option2: discord.Option(...):```
patent knoll
#

is this not good

cyan quail
#

i mean, you can

#

and if it works then fair enough

young bone
#

What is brief?

patent knoll
#

well i wanna do it the right and clean waya

patent knoll
cyan quail
#

there is no "right" way

#

whatever way works

patent knoll
# patent knoll is this not good

i'm still just not quite sure how what gets put into the options gets put into the actual function
is it just positional? as in, e.g. here, the user argument is the first positional argument and so on?

young bone
#

What is with the discord.commands Option one?

cyan quail
#

yes it's positional

patent knoll
# cyan quail yes it's positional

So e.g.
if i had two nonrequired arguments, and only filled the latter one, it'd break (if i dont somehow handle it in the function)

cyan quail
#

well you'd still recieve the variable

#

it'd just be None

patent knoll
#

i see

#

is there a way to kwarg it or is that over the top lol

young bone
cyan quail
#

kwarg what

patent knoll
cyan quail
#

you can set default inside option

patent knoll
patent knoll
cyan quail
#

yeah

patent knoll
#

yea its a bit annoying because the @option thing is just **kwargs so i get zero suggestions on what other options there are lolw
yes i am reading the docs too (sometimes) but im lazy

cyan quail
#

i mean the docs do tell you all possible options

patent knoll
#

i still dont quite get why the decorator is @option but if you do options=[] its Option

cyan quail
#

where are you even doing options=[]

#

the command decorator?

patent knoll
#

yes

cyan quail
#

yikes

patent knoll
#

that's the first way i learnt how to do it

cyan quail
#

it's because Option is an actual object, while @option is a function that adds the Option object to the command

patent knoll
#

look i just wanna make clean code that most people would say "this is the way" to

#

i havent changed how i am doing options just yet so i am taking suggestions :)

signal topaz
#

is it possible to add emojis in choices?

cyan quail
#

@option is fine, but i'd personally do it as typehints py async def command( self, ctx, user: discord.Option(discord.Member, "desc"), channel: discord.Option(discord.TextChannel, "channel") ):

cyan quail
#

not in autocomplete though

patent knoll
#

that works? damn that kind of looks like some weird hacky way lmao

signal topaz
#

unicode?

cyan quail
#

as in regular emoji

#

not custom emotes

signal topaz
#

oh

cyan quail
#

ultimately as long as you have it working as intended then it's fine

signal topaz
#

how to edit messages? like lets say user filled option in a select menu now i need to edit message

cyan quail
#

well

patent knoll
#

which message

#

the message the select menu was / is in?

signal topaz
#

edit that message while removing the select menu, yea something like that

cyan quail
#

in the callback, use interaction.response.edit_message

#

to remove it, you want view=None

signal topaz
#

thx

patent knoll
#

hm, alright, i noticed something

#

somehow, the "members" in the async def basically overrides the @option

#

there is no users option shown, only members

cyan quail
#

remove *

#

(not valid in slash commands)

patent knoll
#

that is legacy code
i am so scared of touching that

cyan quail
#

it doesn't do much

patent knoll
#

its one of those things that if you remove them some powerplant in china will explode for some reason

cyan quail
#

in prefix commands, it means that all input in the message is accepted

#

without it, each arg would be parsed by spaces

patent knoll
#

yea, i am converting a bridge bot to a slash-only bot, thats why its there

#

okay, i did, but unless my discord cache is deceiving me, it still does the same thing

cyan quail
#

maybe in the decorator it's name=users, input_type=str

#

....though you could just rename the variable

patent knoll
#

no, the problem is that it completely overrides the option

#

its as if the @option didnt exist, and it only constructs the option out of the async def

cyan quail
#

eh...

patent knoll
#

okay i am certainly doing something wrong, as even if i remove everything but self, ctx from the function it still wont work (now NO options show lmao)

patent knoll
#

oh yea i do mb

#

well i guess that is the only way then, bruhw

cyan quail
#

that's just the most reliable way that i know of

patent knoll
#

aha
new knowledge
It does work if the option and the argument inside the function definition are called the exact same

#

didnt expect that

#

well that solved that
and now final question
there isn't a way to make multiple user selections without making multiple options right

cyan quail
#

i was probably wrong about positional then LOL

#

yeah discord doesn't let you

#

you probably can in select menus tho

patent knoll
#

that really sucks, that forces us to accept members as str and then pull the mentions from it

patent knoll
cyan quail
#

so you can use that if you want

patent knoll
#

yea we do that too

cyan quail
#

nice

patent knoll
#

typehinting inside of the function definition would only make it easier for me to code, right?
like, i already define the input types in the option decorator so thats dealt with

#

Like inside the async def, the typehinting is basically useless, no?

#

i do know how to code but i really have no idea about good coding practices like that ngl

cyan quail
patent knoll
#

but it does the same, no?

young bone
#

You dont need the bool and None stuff

patent knoll
#

so i can better use the empty line-space of the @ option instead of cluttering the definition

patent knoll
#

Like this looks nice imo

#

only thing i miss out on like that are the IDE suggestions

#

Why do I get this when my only command with more than 1 option looks like this?

young bone
#

Why is default False?

patent knoll
#

because that is the default if the option isn't used

#

i know i could leave out the required=False when i use default, but that doesnt change the error i'm getting

#

I'm quite confused as to what causes this

#

or is discord made because of this somehow?

#

i commented everything but that command, so somehow, that is the culprit

patent knoll
#

#1102262376084021309

fervent cradle
#

Is there any way to send a string as a voice message?

cyan quail
hardy hinge
#

Is possible to make all the slash commands in a SlashCommandGroup have the same check at once ?

proud mason
patent knoll
#

Same topic here, but how exactly do I define a slashcommand group in cogs?

errant craneBOT
#

Here's the slash cog groups example.

patent knoll
#

thats quite a bit different from the non-cogs example wow

#

VSC complains about the variable never being used lol

vapid pumice
#

rtfm.modal

#

.rtfm modal

vapid pumice
#

Sorry if dumb ?, but how to respond to send a modal from a UI Button interaction when reaction has already been responded to?

proud mason
vapid pumice
#

frek

#

okay ty doe <3

proud mason
#

if you want to send a message and a modal, send the modal as the response and message as the followup

proud mason
#

lol np

river summit
#
if ctx.guild.fetch_ban(user):

This returns either true or false, right?

patent knoll
#

that returns the ban entry

river summit
#

so basically if it returns one then they are banned, else they are not?

patent knoll
#

it'll only enter the if if there is a ban for that user

river summit
#

alright, thanks

patent knoll
#

I'm so sorry but how, it doesnt do thing

fervent cradle
solemn idol
#

How the hell do I mention a subcommand?

patent knoll
#

the same way you mention a normal command

solemn idol
#

Nope.

patent knoll
#

yes

solemn idol
#

I tried it

patent knoll
#

</name subcommandname:id>

solemn idol
#

I mean by like the .mention Attribute

hardy hinge
patent knoll
#

please tell me there is some way to not make it as hardcore painful as it is

worn void
#

in a cog file how do I use client? do I use self.bot or self? I'm trying to use client.get_user() in a command

patent knoll
#

self.bot

solemn idol
#

should look ab something like this

worn void
soft girder
#

Whats a problem?

signal topaz
#

uh i created 2 select menus in one message, but if i select an option in any one no matter what i do and how fast i select an option in the remaining one it will say interaction failed and not fetch data based upon user selection

#

i have set callback for both select menus in one callback function too

silver moat
solemn idol
patent knoll
silver moat
solemn idol
#

I tried this;

for name, cog in bot.cogs.items():
                commands = cog.get_commands()
                if commands:
                    command_mentions = []
                    for c in commands:
                        if isinstance(c, SlashCommandGroup):
                            for subcommand in c.subcommands:
                                bot.get_application_command("logging setup").mention
                                command_mentions.append(bot.get_application_command(subcommand.name).mention)

And it kept telling me NoneType Object has no attribute "mention"

#

So this is really confusing at this point

#

I can mention a normal command... but not a CommandGroup using the mention attribute....

#

WHy???

young bone
#

because its None?

#

Can you print it

patent knoll
#

you arent getting the command correctly

solemn idol
young bone
#

</Zervyrel:366518394863878147>

#

mhm

#

</The Zervyrel:366518394863878147>

solemn idol
#

these are the two outputs I got of

print(subcommand.name)
# and
print(bot.get_application_command(subcommand.name))
young bone
#

do you need a name or id for it?

solemn idol
#

wait a minute...

solemn idol
#

alright

#

so I tried subcommand itself because obviously subcommand returns logging setup (which is the entire command with parent and subcommand itself)

worn void
#

what's the discord.Member equivalent for a channel for input validation on a slash command?

patent knoll
#

wdym for a channel

worn void
#

like a channel

#

#general

#

a channel object

solemn idol
young bone
#

member.channel?

solemn idol
worn void
patent knoll
#

if you want the channel use ctx.channel lol

worn void
#

no i want to take a channel as an input for a slash command

patent knoll
#

discord.TextChannel

worn void
#

thanks

young bone
#

discord.TextChannel or discord.VoiceChannel

patent knoll
#

or Union[discord.TextChannel, discord.VoiceChannel] for both i think

silver moat
#

forum channel, news channel.

young bone
silver moat
#

or for more specific, use the channel_types kwarg

signal topaz
solemn idol
#

Yeah I dont understand, if I try printing it, it works just fine but when I try mentioning it, it says no fuck you Vox, I find a NoneType only.

#

it makes absolutely no sense, I print the subcommand.name it works fine, I try mentioning that and it says "NoneType"

#

thinkCat ???

#

it gives me None...

#

wtf

young bone
#

it has to be an ID

#

</Command Name: Command ID>

undone falcon
#

I am trying to do a hybrid cache (some in memory and some in disk), I saw somewhere in the past that you can change how the cache store and get information, but I cant seem to find it in the doc. Do you know where that info is ?

solemn idol
silver moat
solemn idol
proud cargo
#

should I use cogs

silver moat
proud cargo
# silver moat it's your choice

I have like vanity bots which run the same code but have different pfps etc, would i be able to have only one file for each cog then each bot can import that

cyan quail
solemn idol
cyan quail
solemn idol
#

2.4.1

#

Latest

cyan quail
#

can you show the full code you're using to test this

solemn idol
solemn idol
cyan quail
#

but anyway, if mention is still giving you a None then there's something significantly wrong because it would mean the command group doesn't have an ID

#

(or you're on something older like 2.2 but eh GuraShrug)

silver moat
#

where is this code? Maybe it was before on_ready?

solemn idol
#

No it's in a command which gets executed

#

A self generated help command actually

cyan quail
#

(spoiler: get_application_command(subcommand.name) is a guaranteed fail because you should be using qualified_name)

solemn idol
#

The ... Why what is-

cyan quail
#

(docs)

proud mason
#

Same for id

solemn idol
river summit
#

how many cogs is too many? when will performance be effected?

patent knoll
#

apparently the code i sent just cant be made prettier, its just destined to be horrible

livid juniper
#

Should I make my cogs be on separate files??

young bone
silver moat
livid juniper
#

ok

patent knoll
#

you can make cogs in one file?

patent knoll
#

Does discord.TextChannel contain announcement channels?

solemn idol
heavy bough
#

how do i call a function that i defined in a cog from another file? Or should i not do that and keep just the basic commands in there?

solemn idol
#

cogs are basically just classes so I suppose you can just class.function

solemn idol
young bone
#

That is basic python stuff ;3

patent knoll
#

How to wait for a button press from a view i already have?

cyan quail
#

where name is the class name

heavy bough
#

is that better than importing it?

cyan quail
#

depends

#

if you import it then you've created a new instance of the cog/file

#

while get_cog will access the existing instance, and thus any attributes that have been set during it

cyan quail
#

well, kind of

#

really you should be using callbacks

patent knoll
#

i am using callbacks, but i am unsure how to then go on with it in my main function

cyan quail
#

oh ok

#

hold on

patent knoll
#

idk if im explaining it right im tired lol
But basically, if i press a button, i want it to just return, and if i press another button, it should do smth

#

and i also have the issue that somehow having 2 @discord.ui.button decorators makes only one work

cyan quail