#Basic Pycord Help

1 messages · Page 10 of 1

graceful parcel
#

it only shows 15 options. out of which, there are 13 channels, and 2 are categories

rugged lodgeBOT
lofty parcel
#

I'm sure it.only displays 15 and you can type to search other channels

arctic plover
#

min_values: The minimum number of items that must be chosen for this select menu. Defaults to 1 and must be between 1 and 25.
max_values: The maximum number of items that must be chosen for this select menu. Defaults to 1 and must be between 1 and 25.

#

its 25

graceful parcel
arctic plover
#

so i think its able to display 25

graceful parcel
# arctic plover like no

the dropdown shows only top15 channel/categories. but i can type and search for the ones that arent shown

arctic plover
lofty parcel
graceful parcel
#

yea. im trying to play with it. but i cant make it work. also, if its possible, how i do make it only show channels from just one category and not all?

shell radish
#

you can't. But at that point, you can just use a normal select menu

lofty parcel
#

You'd use a normal select menu instead

lofty parcel
#

I hate squids

graceful parcel
#

but then, i will only be able to show a maximum of 25 channels right? this way, i can show all of them, but choose a maximum of 25

lofty parcel
#

Your category has more than 25 channels?

#

You could attach multiple select menus

graceful parcel
#

rn it doesnt, but it will in future

shell radish
#

or just use an autocomplete option

graceful parcel
graceful parcel
shell radish
lofty parcel
graceful parcel
#

ooh. i read that wrong. that helps. thanks guys

shell radish
graceful parcel
north spruce
#

Is Pycord better than Discord Py? had seen pycord and wanted to try it out but it has a lot of things that are different in discord py

latent viper
#

is it possible to send an attached text file under the bot's message embed? When you send a file it goes under your message, but when sent by bot it's above its message (if it's an embed)

deft kestrel
#

How I can edit description in embed?

#

Its goes with the title

#

embed = discord.Embed(title="Text", description="Text.", color=...)

still geode
#

Hi all. Im using py-cord 2.4.1. My on_member_update is only triggering when a change is made to the bot account but not anyone elses. I think I have done everything correctly with Intents.

shell radish
#

how is bot defined?

still geode
#

bot = discord.Bot()

little cobalt
#

why do you add intents to all intents?

#

also add the intents to your bot

shell radish
still geode
#

I see thanks. This code used to work a while ago. I guess that has changed? Now it should be this?
bot = discord.Bot(intents=discord.Intents.all())

#

Yep, that did it. You guys rock! Thanks

steep cliff
#

Somehow my bot with message intents (both in code and on the dev portal) and admin perms doesn't react to on_message events at all

#

Any ideas why?

north spruce
steep cliff
#

I did change the intents within the last 24 hours, don't know if that matters anything

shell radish
shell radish
steep cliff
north spruce
rugged lodgeBOT
#

Here's the slash basic example.

shell radish
#

how is your on_message event defined

steep cliff
#

assume you'll ask for core.Cog next

shell radish
#

well, you never initialized the parent cog class

#

not sure if that directly causes the issue

lofty parcel
#

Such method doesn't exist.

shell radish
#

also the name arg should just be left blank unless you are dispatching your own events

steep cliff
#

looks like this now

steep cliff
north spruce
lofty parcel
steep cliff
#

awesome thx

#

was confused how this'd been working for over a year if it wasn't correct

shell radish
lofty parcel
#

None of my cogs have super().init

shell radish
lofty parcel
#

Oh?

steep cliff
#

But then how have my cogs been working just fine in the past?

#

Any ideas why message.content prints an empty string?

@core.Cog.listener()
async def on_message(self, message: discord.Message):
    """Event for when a feedback message is sent.

    Parameters
    ------------
    message: discord.Message
        The message that was sent."""
    if message.guild.id != core.config.rip_guild_id or message.author.bot or not core.is_valid_thread(message.channel) or message.channel.parent_id != core.config.feedback_channel_id:
        return
    if core.is_feedback(message.content):
        tags: list[discord.ForumTag] = [tag for tag in message.channel.applied_tags if
                                        tag.id != core.config.bell_tag_id]
        await message.channel.edit(applied_tags=tags)
little cobalt
steep cliff
#

figured I'd only need message and message content no longer exists, as it's not mentioned in the docs under on_message

#

thx

lofty parcel
steep cliff
#

figured it'd be most efficient to return asap

lofty parcel
#

One if condition does the same thing

#

Python checks conditions in order

#

First to last

steep cliff
#

do you want me to combine them with and?

#

not sure what your proposing exactly

lofty parcel
#

Just group the conditions into one if with or

steep cliff
#

I don't wanna, just figured that's what you suggested I was like hell nah, not gonna add that

steep cliff
#

tho I feel like ors just make it ugly and harder to read

lofty parcel
#

Whatever you want

steep cliff
#

now you got me thinking

hybrid tinsel
#

how do i make it so that instead of disabling buttons in a paginator, it would just cancel the paginator on timeout?

lofty parcel
little cobalt
#

what was the error one for the guild_only decorator?

#

commands.PrivateMessageOnly

I found it for dm_only but not for guild_only

limber terrace
serene mirage
#

how can i create dropdowns in cog

little cobalt
hybrid tinsel
# lofty parcel What is "cancel the paginator" supposed to mean?

this

async def cancel(
        self,
        include_custom: bool = False,
        page: None | (str | Page | list[discord.Embed] | discord.Embed) = None,
    ) -> None:
        """Cancels the paginator, removing all of its components from the message.

        Parameters
        ----------
        include_custom: :class:`bool`
            Whether to remove components added via custom views.
        page: Optional[Union[:class:`str`, Union[List[:class:`discord.Embed`], :class:`discord.Embed`]]]
            The page content to show after canceling the paginator.
        """
        items = self.children.copy()
        page = self.get_page_content(page)
        for item in items:
            if (
                include_custom
                or not self.custom_view
                or item not in self.custom_view.children
            ):
                self.remove_item(item)
        if page:
            await self.message.edit(
                content=page.content,
                embeds=page.embeds,
                view=self,
            )
        else:
            await self.message.edit(view=self)
graceful parcel
#

i have a slash command. it sends a view in the response. i also passed an argument in the slash command. how can i use it in the view's callback method

tropic dawn
#

is it possible to send a sticker using bot?

graceful parcel
#

I did make a class. Called ChannelSelect which inherits the discord.ui.View

#

Is that what you mean?

echo wraith
#

and call it with self

graceful parcel
#

Oh. So like. In the slash command response when I do view=ChannelSelect()
I would be doing view=ChannelSelect(variable)

Like that?

echo wraith
echo wraith
graceful parcel
#

Yea. Got it

#

Thanks

echo wraith
graceful parcel
#

I was trying things like interaction.selected_options

#

I guess that's for command interactions and not interaction response

lofty parcel
sly pebble
#

was reading the docs on discord.ext.commands.Bot.wait_for and saw this

#

am i capable of using an asynchronous function here, with an argument?

#

and if so, how would i do so

sturdy acorn
#

i have a /command on a cog but its not load in my bot

#

i use prefix command but i only want to add one /

#

the files is load and the other command of the cog(prefixed work)

#

do i need to do other thing than simply load the cog ?

lofty parcel
lofty parcel
limber wagonBOT
#

dynoError No tag slashnoshow found.

lofty parcel
#

.tag slashnoshow

sly karmaBOT
#

Application Commands Not Showing Up?

  • Uninstall libraries that conflict with the discord namespace (e.g. discord.py).
  • Invite your bot with the application.commands scope.
  • Load cogs before bot.run() (e.g. not in on_ready).
  • Do not override on_connect.
  • Update to the newest version of py-cord (see ?tag install).
  • Turn off User Settings > Accessibility > Chat Input > Use legacy chat input.
  • Share your code and errors.
sturdy acorn
sly pebble
lofty parcel
#

It's something like

def my_check(message):
     if message.author == ...:
           return True```
sly pebble
#

yeah i had a def as it is

#

my whole problem is that i had to use

#

requests

#

if there’s no way to async it though then i’ll just have to take that L

limber terrace
#

Which problems do u occur?

#

In case of async use aiohttp

shell radish
limber terrace
#

Ok now we have THIS ONE MOMENT where are able to use a tag

#

?tag aiohttp

limber wagonBOT
#

Use aiohttp.
requests and urllib are blocking. Do not use these libraries within your asynchronous code as they are not asynchronous. Otherwise known as blocking.

Aiohttp is a low level threading and http handler. Py-cord already uses aiohttp, so it should be installed. An example of code using aiohttp and Py-cord:

async with aiohttp.ClientSession() as cs:
    async with cs.get('https://httpbin.org/json%27') as r:
        res = await r.json()  # returns dict
        await ctx.send(res['slideshow']['author']) 

For more help, see aiohttp's documentation

limber terrace
shell radish
limber terrace
#

thinkCat you CAN call async functions within a "normal" function.
But to cover this particular case i need more information about what needs to be done

#

Or do i got it wrong?

sly pebble
sly pebble
#

didn’t know how to actually use it in this specific case

deft kestrel
#

Is there a way to make animated emojis more consistent in embeds? The bot is in the server where all the emojis exist and yet in other servers they will either work or just not. The bot has administrator permissions and I even tried setting the channel permissions to allow external emojis.

The format of the emoji in the embed is ![Cash](https://cdn.discordapp.com/emojis/1153886512958673018.webp?size=128 "Cash")

fickle salmon
deft kestrel
#

Well in the other server I am testing in, some of them work and some dont

#

It also is administrator in it and the channel has external emojis enabled for the bot

#

For example here page 1 of a paginated embed

#

and this is page 2

deft kestrel
#

Turns out the guild default role needs to have it enabled.

hazy turret
#

How can I edit the paginator in the view ?

I have sent a select menu in an ephemeral night and now I want to create the paginator with the pages in the callback function and then edit the message so that the select menu is removed and the paginator is displayed in the ephemeral night. Does anyone know how I can do this?

paginator = PaginatorView(cards_info)
        
await paginator.respond(interaction)

await interaction.response.edit_message(content=f"Kategorie {selected_category} ausgewählt.", view=paginator)

class PaginatorView(Paginator):
    def __init__(self, cards_info):
        self.pages = self.create_pages(cards_info)
        self.custom_buttons = [....]
        super().__init__(
            pages=self.pages,
            use_default_buttons=False,
            custom_buttons=self.custom_buttons,
            timeout=300,
            author_check=True,
        )

robust turret
#

I'm new to bot making: I started making a bot and I tried making a simple slash command like in the docs, but I didn't found how to limit a slash command to only one guild . Thanks :D

import discord
from discord.ext import commands

intents = discord.Intents.default()
intents.typing = True
intents.presences = True

#bot = commands.Bot(command_prefix='!', intents=intents) # useless, only /command

@bot.event
async def on_ready():
    print(f'Logged in as {bot.user.name} ({bot.user.id})')

@bot.command(description="Sends the bot's latency.", guild_ids=[833351790719926292]) # is "guild_ids" the right thing?
async def test(ctx):
    await ctx.respond(f"Pong! Latency is {bot.latency}")


bot.run('TOKEN')
limber terrace
#

Hi

#

You can define guild ids within the slash command decorator

#

Like guilds=[00000,00001,00002]
(Dont push me into it. Maybe its guild_ids)

echo wraith
#

@robust turret upvote

limber terrace
limber terrace
#

Imagine

#

The possibilitys

#

If you put the stuff, that the lib is doing, onto a WEBSITE

little cobalt
little cobalt
limber terrace
#

Funfact, you can still predefine a prefix and havin both.

I thought he is knowing about the slash command stuff since he asked how to limit them, not creating

arctic plover
#

Because this is the first thing you will find in the docs

robust turret
limber terrace
#

Well than just alter the decorator

#

To @slash_command(name="stuff", guild_ids=[stuff])

#

Im on mobile maybe im havin a typo

#

Viola, slash command

#

If u want to have them global, just remove the guild_ids thingie

#

U ok with this?

deft kestrel
#

Is it possible to defer an autocomplete function? I have a large list that it is getting from an endpoint and the time it takes exceeds the duration of the interaction

shell radish
#

note that you only need to return 25 values instead of the whole array.

deft kestrel
#

Ah, thank you

robust turret
hazy turret
edgy glen
#

If the user cant valid a command check in pycord, is it then possible to hide a command from a user?

As an example to an userslash command from a user which cant validate an command check?

shell radish
#

nope

edgy glen
#

Thank you anyway ^^

gaunt vale
#

Whats the correct way to use await bot.sync_commands() ? Im keep getting Failed to reload cogs.atlyr: 'NoneType' object has no attribute 'guild_ids' but doesnt matter if I add guild_ids= or commands= in the sync_command variable

Im also using this version py-cord-dev==2.5.0rc5

gaunt vale
little cobalt
#

Did you also have uninstalled py-cord?

gaunt vale
#

Yea both uninstall and build up venv from scratch too

little cobalt
#

Did you add a command to sync?

gaunt vale
# little cobalt Did you add a command to sync?

I've this, im new to py-cord but think its correct or really close to correct

    @commands.slash_command(name="reload", description="Reload a cog", guild_ids=[1084058095774355490])
    @commands.has_permissions(administrator=True)
    async def reload(self, ctx: discord.ApplicationContext, extension: str):
        try:
            self.bot.reload_extension(extension)
            command = self.bot.get_application_command(extension)
            await self.bot.sync_commands(commands=[command], guild_ids=[1084058095774355490])
            await ctx.respond(f"Reloaded {extension}")
        except Exception as e:
            await ctx.respond(f"Failed to reload {extension}: {e}")
little cobalt
#

is the file name and the command name the same?

gaunt vale
red mist
#

@little cobalt Can you give me a bot name? That's literally the only reason I havent made a good one yet.

#

and a fitting icon mybe

little cobalt
red mist
#

Well shit

gaunt vale
# little cobalt ?

The cog file is not same as the command names no if I understood correctly 😅

little cobalt
#

But you know what "NoneType" means?

gaunt vale
#

Yea it gets no value from guild_ids, it is specified in sync and the commands

lofty parcel
#

Remove the ctx.respond?

green kernel
#

Can you use custom emoji in a select menu?

lofty parcel
#

Yes

#

"Expected Interaction or BridgeContext"

#

You pass ctx.interaction

#

Not just ctx

little cobalt
#

something like ctx.interaction

green kernel
#

I get:

discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In data.components.0.components.0.options.0.emoji.name: Invalid emoji

when passing a custom emoji as a PartialEmoji

#

Should I cast str on it 🤔

lofty parcel
#

You can just pass it as <:emoji:id>

green kernel
#

I'd rather look into why than do the manual <:emoji:id> method because not all the emojis I have are custom

green kernel
#

I'll investigate further because there's no way the __str__ function is broken

deft bronze
#

how can i make loop/task to execute at specific time?

#

any examples in the web?

rugged lodgeBOT
#

Here's the background task example.

deft bronze
#

@lofty parcel

#

can i use pytz timeone into it?

lofty parcel
#

Try it and see

deft bronze
fiery fossil
#

If i have a dynamic buttons, eg, a button creates another view and that view has dropdown menus, etc, etc... do I need to create a random customid for each of those components? @lofty parcel

deft bronze
#

no

fiery fossil
#

For example, do those ids need to be completely unique per each creation

shell radish
#

unless it is a persistent view

fiery fossil
#

sorry, i am trying to implement persistent views

fiery fossil
#

😭

shell radish
#

it doesn’t have to be random

fiery fossil
#

Or can i simply just have "my_id1", "my_id2", and it doesn't matter how many people interact with it

deft bronze
rugged lodgeBOT
#

Here's the background task example.

deft bronze
#

im following it sadcat

shell radish
#

so 00:52:00 am UTC?

fiery fossil
#

Is it because PersistentViewBot() instantiates a unique hook by default?

#

Trying to wrap my head around why each interaction does not have to be a unique custom id

shell radish
fiery fossil
#

Yes, this is true - i know. but what if lets say, you and i both interact with it

#

We both have our ephemeral components (we see our own, ofc)

shell radish
#

that doesn't change anything

fiery fossil
#

if i restart the bot, will our owns stil work

deft bronze
shell radish
#

uhh no

deft bronze
shell radish
#

did you start the task

deft bronze
#

how to do so?

#

nvm

#

saw it

shell radish
#

given functionbasic: functionbasic.start()

deft bronze
#

idk how i miss that

#

💀

shell radish
#

reading is hard

fiery fossil
#

For every persistent view, I have to put it under async def setup_hook(self) -> None: right? @shell radish

fiery fossil
shell radish
#

you can do that

deft bronze
#

so i'll use utc

fiery fossil
#

Well, I am using pycord.. but I think I can still use this? Unless pycord has its own

#

I think I saw a youtube video where someone using pycord used persistence

shell radish
fiery fossil
#

Is there an example on how to implement persistent view with pycord?

rugged lodgeBOT
#

Here's the persistent example.

fiery fossil
#

aha.

valid panther
#

I'm making a jumbo command for emojis, but it only works with custom emojis. Does anyone know how we can do it for native discord emojis as well?

valid panther
#

Starting from a command ID, can I get a mention of the command?

lofty parcel
valid panther
valid panther
lofty parcel
valid panther
lofty parcel
#

So I guess you'd need to do some wonky stuff like trying to get an api to give you an image

#

Based off the emoji name or something

valid panther
#

okay, np

#

and it is possible to pass the command ids to comands. ? get_slash_command_by_id ?

lofty parcel
#

Wdym

deft kestrel
#

is there much difference when using default_permissions over has_guild_permissions? Just want to make sure

lofty parcel
#

default_permissions limit users to see the command

#

has_guild_permissions is just an internal check

deft kestrel
#

So should I use both or does it not really matter?

lofty parcel
#

Up to you I guess

deft kestrel
#

Just wanted to make sure theres no risk of someone without the permissions using the command with default_permissions

lofty parcel
#

It's always good to have an internal check.

deft kestrel
#

Alright and can that still be overridden with the server integration settings?

lofty parcel
#

You can't override internal checks

#

They're internal

steep cliff
#

Is it possible to use the once=True kwarg in the on_ready event of a subclassed bot?

wanton lance
#

I may oversee something, but is there still a clean way to retrieve the display name of a member if they did not set any nick name in a guild? I do not want the global username, which is lowercase but the displaying name. Yet member.display_name is the lowercase global username if there is not nick set. For example in my case I would like to retrieve 'MR.e' instead of 'matrix_exe' and do not want to set a nick for each guild first.

lofty parcel
#

?tag pomelo

limber wagonBOT
#

Before Pomelo-

member.name          -> username
member.nick          -> guild nick name
member.display_name  -> member.nick OR member.name

After Pomelo-

member.name          -> username
member.global_name   -> global display name (global nick name)
member.nick          -> guild nick name
member.display_name  -> member.nick OR member.global_name OR member.name
wanton lance
#

Ok, thanks for the info but my Member object unfortunately does not have a global_name which I apparently would like to retrieve in this case. Any ideas why?

lofty parcel
#

Because you might not be on the latest release

#

Uninstall py-cord and install py-cord-dev

wanton lance
#

ah, there is a dev package. Because I already checked that I have the newest py-cord 2.4.1. Will try the dev

#

works just fine, thanks for the quick support @lofty parcel

lapis dock
wanton lance
serene mirage
#

<Message id=1155014139773734924 channel=<TextChannel id=1152878856139718676 name='meme-subsissions' position=4 nsfw=False category_id=1066217740051939358 news=False> type=<MessageType.default: 0> author=<Member id=988436414490378292 name='banana_lol_7678' discriminator='0' bot=False nick=None guild=<Guild id=1066217739565420554 name="Katz's Destruction area" shard_id=0 chunked=True member_count=6>> flags=<MessageFlags value=0>>

how can i disable theese

olive sluice
#

How can I create an autocomplete with guild members' name? I've tried using [member.name for member in bot.get_all_members()] but the list is empty

arctic plover
arctic plover
#

or u mean all members of your bot?

#

not 1 guild only

olive sluice
#

1 guild is fine. But I've tried it and guild is not populated unless I ran it in on_ready first

#

And because my function is async it thrown me an error about guild being None

olive sluice
#

ok ill make a minimum working code. Give me a sec ❤️

solar salmon
#

I'm having issue with button.disabled doesn't work. No output error whatsoever.

class AcceptButton(discord.ui.View):

    def __init__(self, member, copied_embed, *items: Item, timeout: float | None = 180, disable_on_timeout: bool = False):
        self.member = member
        self.copied_embed = copied_embed 
        super().__init__(*items, timeout=timeout, disable_on_timeout=disable_on_timeout)

    @discord.ui.button(label="Accept", style=discord.ButtonStyle.success)
    async def accept_button(self, button, interaction):
        button.disabled = True
        button.label = "Accepted"
        await interaction.response.send_message(embeds=[self.copied_embed])
raw gyro
#

hi guys i want to give user display name but how ?

arctic plover
solar salmon
#

Alright will try thank you.

raw gyro
#

@arctic ploverbro

#

you can help me?

#

phew

olive sluice
#
from discord.commands import Option

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

bot = discord.Bot(intents=intents)

@bot.event
async def on_ready():
    global guild
    guild = bot.get_guild(put_guild_id_here)

    for guild in bot.guilds:
        print(guild)
        print(guild.id)

@bot.slash_command()
async def add_user(ctx, name: Option(str, "Enter the display name", require=True,
                                     autocomplete=discord.utils.basic_autocomplete(
                                         [member.name for member in guild.members]))):
    pass

TOKEN = "Put token here"
bot.run(TOKEN)
#

also I just realized that this wouldn't even work bc it will complain that guild is not defined

raw gyro
#

hi

raw gyro
#

@arctic ploverI forget which code we used to get the user's display name.

arctic plover
raw gyro
#

okay

#

thanks

olive sluice
arctic plover
olive sluice
#

I see that makes sense. Thank you

raw gyro
#

@arctic ploverhey bro I forget which code we used to get the user's nick.

#

pls help me

arctic plover
#

via guild.get_member(member_id)

#

and then use member.display_name property

limber wagonBOT
#

Before Pomelo-

member.name          -> username
member.nick          -> guild nick name
member.display_name  -> member.nick OR member.name

After Pomelo-

member.name          -> username
member.global_name   -> global display name (global nick name)
member.nick          -> guild nick name
member.display_name  -> member.nick OR member.global_name OR member.name
heavy sky
#

That shows how to get different member names/nicks ^

raw gyro
#

but member.nick is on this server

#

i need a global nick

heavy sky
#

if you want the global display name you can use member.global_name

#

but you need to either use the master branch or py-cord-dev for that

heavy sky
#

?tag install

limber wagonBOT
#

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

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

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

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

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

raw gyro
#

do i need upload?

#

ha

#

thanks bro

heavy sky
#

if you want to use py-cord-dev just uninstall py-cord and install py-cord-dev

raw gyro
heavy sky
#

discord.py can be used almost the same as pycord but with some differences only

raw gyro
#

Do I need to use member.global_name there to get the global name?

heavy sky
#

You should ask that in the discord.py server instead if you want to know

raw gyro
#

Thank you, I know this, but I found out that I was banned from there :)

heavy sky
raw gyro
heavy sky
#

Then we can't help you. This server is only for pycord support

raw gyro
#

But since they are almost similar, I don't mind.

raw gyro
rapid jackal
#

can I create a button with no label or set the column of a button?

shadow junco
#

I want to let the option type be text channels, but not all types of channels

@bot.command(name="移除新公告發送頻道", description="移除新公告發送頻道")
@commands.has_permissions(administrator = True)
@option('公告頻道', description='你要公告定期發送的頻道', type=SlashCommandOptionType.channel.text)
little cobalt
#

discord.TextChannel

#

@shadow junco

shadow junco
#

channel_types=ChannelType.text

#

this?

little cobalt
#

I dont know how it works with SlashCommandOptionType

#

with a normal option it would be discord.TextChannel

shadow junco
#

oh i found it

shadow junco
#

but it doesn't work

#

@little cobalt

sonic sorrel
#

What could be the reasons for my select menu showing an error, but working as intended? I still can't figure it out..

shell radish
sonic sorrel
shell radish
#

at least preferably

sonic sorrel
#

wait but i thought the callback is done after i select my items, not when the select menu appears?

shell radish
#

the original interaction that edited the message wasn’t acknowledged officially

atomic fern
#

do edit message necessary when disabling a button using button.disabled = True?

shell radish
sonic sorrel
# shell radish the original interaction that edited the message wasn’t acknowledged officially

i see, so i supposed to somehow edit my roll random modifier button in the callback? but this is not right..

class RandomModifierButton(discord.ui.View):
    def __init__(self):
        super().__init__(timeout=None)
        self.value: bool = False

    @discord.ui.button(label="Roll Random Modifier", style=discord.ButtonStyle.green,custom_id="persistent_view:roll")
    async def button_callback_yes(self, _, interaction):
        self.value: bool = True
        interaction.response.edit_message(view=None)  # ?
        self.stop()
sonic sorrel
#

took me long enough to realise i did not await that

#

thank you

opal hamlet
#

be like that eh

viscid depot
#

Hi! I attach images to the message and the use them in embeds. I don't want the images to show outside of the embed but sometimes they randomly appear. How to fix it?

opal hamlet
#

?tag persistent_view

limber wagonBOT
#

dynoError No tag persistent_view found.

#

dynoError No tag persistant found.

#

dynoError No tag persistant found.

opal hamlet
#

okay so i want to have a persistent view that i'll send to multiple users when a command is called(implementing a bounty system that asks for confirmation), that bounty gets an pending id(for the process of confirmation) which ill also use to access it in the Database, is there a way to "store" it in the view(there will obv. be different ones) besides just sending it in the message and scanning interaction.response.original_message().conent for the id?

lofty parcel
sly karmaBOT
opal hamlet
#

i have already put in too much thought into it to the point i lost track of my plans lol

lofty parcel
#

Then store store a dict based off the user ID using the message ID and then the value

shell radish
opal hamlet
#

ah looks like i havent put enough thought into it, my database atm doesnt even have a column for storing whther or not it was confirmed

#

i assume when i send a persistent view to multiple users and reattach it or whatever after restart it wont complain? the custom_id should work for multiple "instances" right?

lofty parcel
#

Yes

opal hamlet
#

good good

#

eh ill probably use a ulid.timestamp as id and set it as footer or stuff and read that

lofty parcel
#

Why..

opal hamlet
#

lazyness and being tired

#

you cant tell me youve never been there

shell radish
#

then sleep

#

¯_(ツ)_/¯

#

It’s not like you’re doing this for a hackathon or something

opal hamlet
#

no, let me be frustrated in peace

shell radish
#

(like I did with my discord bot)

#

(and somehow won best UX in a general hackathon)

opal hamlet
#

my bounty system will have a whopping user count of me and another guy to test it

opal hamlet
#

a dict wont do it but going off of message id is something proper

viscid depot
# lofty parcel .tag idw

I want to send an embed with an image in the top-right corner. The image is a local file. I attach it and then use it in the embed.
This method works most of the times, but occasionally fails. When that happens, the image is visible in the same message.

embed = discord.Embed(color=discord.Color.blue(), description=description)
path = f"images/talents/{filename}"
file = discord.File(path, filename=filename)
embed.set_thumbnail(url=f"attachment://{filename}")
tooltips.append((embed, file))
if len(tooltips) == 10 or index == len(results) - 1 or index == amount - 1:
    embeds, files = list(map(list, zip(*tooltips)))
    await context.respond(embeds=embeds, files=files)
sonic sorrel
#

Hi, I want to store user data but I just want to check if it's ok to do it like this, or if there's a more secure way or something. I have a userdata folder with files named based on user IDs. A file is created for a user if the user uses the /settings command. All the information that is stored in the file, is some basic non-personal parameters used in another command that personalises their experience.

lofty parcel
lofty parcel
opal hamlet
#

i mean storing user settings sounds okay to me

#

i personally recommend sqlite

sonic sorrel
#

so just like that

#

better to use a db yeah but this works for me right now with low user count

shell radish
opal hamlet
#

imo i would just use a sql database with a table called usersettings with columns: user_id, setting, value

viscid depot
shell radish
viscid depot
#

If you have a link explaing it or with an example, that would be helpful.

sonic sorrel
opal hamlet
#

Well a sqlite db is literally just a .db file

#

And SQL syntax isnt too hard to learn IMO

sonic sorrel
#

probably but, I gotta setup SQLite as well right? Or can it all be done in python?

opal hamlet
#

All python

#

Natively

#

Import sqlite3

#
with sqlite3.connect('path to your db') as con:
    c = con.cursor()
    c.execute("CREATE TABLE IF NOT EXISTS usersettings (user_id INTEGER NOT NULL, setting TEXT NOT NULL, value TEXT")
    con.commit()

@sonic sorrel

#

Thats for setting it up intially

#

I like to slap that into a def init_tablename():

little cobalt
#

I like to use MongoDB (NoSQL)

opal hamlet
#

I simply use what i have been using so far because i know how to use it

sonic sorrel
#

cool i will look into this more now

#

and to move between machines all you need to do is move the .db file? assuming i just put it next to main.py

opal hamlet
#

Yes

#

If the code has an active connection to the db overwriting on the target device gonna be a bit problematic but eh

#

Thats why closing connections is important!

sonic sorrel
#

well i just stop the code and override the .db file and go again?

opal hamlet
#

safest way

sonic sorrel
#

i wouldnt have tried any other way tbh

opal hamlet
#

Never challenge the computer god

sonic sorrel
#

komputer dumb only know 1 and 0

opal hamlet
#

iirc a basic settings tuple for a user would be kinda like

 usersettings = [row for row in c.execute("SELECT setting, value FROM usersettings WHERE user_id = ?",(user_id(a variable in your func))).fetchall()]```
#

That can then probably be turned into a dict and stuff

shell radish
#

for example

opal hamlet
#

IMO just upload it to a channel somewhere and copy the discord.attachment link

#

Already on discord that way

shell radish
opal hamlet
#

Oh

shell radish
#

because storage is expensive

#

at the scale for discord at least

opal hamlet
#

Yeah... i was wondering they didnt alread do that

opal hamlet
#

I mean each server probably has gigabytes of media on avg.(every server is a bit of an exaggeration but)

shell radish
#

like for every shitpost you send, discord has to handle that

#

which is a lot

viscid depot
opal hamlet
opal hamlet
shell radish
sonic sorrel
#

nah that aint real

opal hamlet
#

Ugh am i the only one that sees code after closing their eyes to sleep when they've been coding for a couple hours

shell radish
opal hamlet
#

Fair

#

Well depending on who you ask you are just biological code soooo

shell radish
#

according to some that is all just quack science

opal hamlet
#

Interesting

autumn gust
#

QQ: How to get information about a member (by either the object, or ID)

#

like, Username, Tag, Avatar Link etc. etc.

opal hamlet
#

simply user.avatar.url or stuff, user.display_name

opal hamlet
#

Alternatively ReadTheDocs

autumn gust
#

is there a list somewhere?

#

yeah asking for that, navigating PyCord's docs is like navigating a jungle

#

I can barely find what I'm looking for

#

and if I do, it's always just half of what I need

#

what in the world, there's a search bar?
I was going blind looking through pages for all this time and didn't notice the goddamn search bar

#

I'm so sorry lmao, I spent hours looking for things and I didn't even notice the search bar

opal hamlet
autumn gust
#

I can tunnel vision so hard sometimes even I'm surprised

opal hamlet
#

Yeah

autumn gust
#

that's revolutionary

#

I'm essentially just making a whitelist bot because why not

opal hamlet
#

Seachbars truly are innovative

autumn gust
#

hm, user.avatar how does that one show up?

#

as a link, or as an embed?

opal hamlet
#

Uhhhhhhhhhh

lofty parcel
sly karmaBOT
autumn gust
#

it says an asset

#

but

#

I assume it refers to an image?

lofty parcel
#

Asset is an asset.

#

.rtfm Asset

autumn gust
#

huh

#

neat

opal hamlet
#

url, or save

lofty parcel
#

"Represents a CDN asset on Discord."

autumn gust
#

so if I'm getting this right

#

uhhh no nevermind I am not

opal hamlet
#

Ah right sleep...

autumn gust
#

I have no idea what I could do to convert it to an url (or at least an embed)

opal hamlet
#

Are you familiar with oop?

autumn gust
opal hamlet
#

It literally has the url attribute

opal hamlet
autumn gust
#

oh so class stuff, well no

opal hamlet
#

The avatar url literally is user.avatar.url

autumn gust
#

well kinda, but not really

opal hamlet
#

It is a property of that object

autumn gust
#

huh.

lofty parcel
#

Member.avatar returns a discord.Asset which represents the avatar image, you access the url either the .url attribute

opal hamlet
#

Might need to str() it but dunno

autumn gust
lofty parcel
#

url already returns a str

opal hamlet
lofty parcel
#

url already returns a str

autumn gust
#

or uh

lofty parcel
#

It's redundant

autumn gust
#

at least that is

opal hamlet
autumn gust
#

speaking of, I've had this thing; what is the second variable supposed to be

opal hamlet
autumn gust
#

huh

#

so just silencing it with , _ is the way?

opal hamlet
#

_ just indicates that its trash you don't care about

lofty parcel
#

.rtfm on_member_join

sly karmaBOT
autumn gust
#

so it returns member... twice?

opal hamlet
#

Nah

little cobalt
#

only member

lofty parcel
#

It's just member

opal hamlet
#

It takes the second arg thats passed into it

little cobalt
#

member: discord.Member

lofty parcel
autumn gust
#

if I don't include , _ it throws a non-crash error

little cobalt
autumn gust
#

about uh, 1 argument but 2 provided

#

somehow

opal hamlet
autumn gust
opal hamlet
autumn gust
#

...yeah?

#

is it not supposed to be?

opal hamlet
#

Does it take self as arg?

autumn gust
#

wait

little cobalt
#

(self, member: discord.Member)

autumn gust
#

OH

lofty parcel
#

This is why you need to learn OOP

autumn gust
#

IT JUST CLICKED

opal hamlet
#

Yes....

autumn gust
#

NOW I KNOW WHY CLASSES ARE USEFUL AND NOT JUST GARBAGE

#

people who were explaining it to me were... pretty shit at doing so

opal hamlet
#

Lady's and gentlemen, he got it

autumn gust
#

so I only ever half understood classes

#

but I assume, class just spoon feeds each function with a variable that it provides, yeah?

opal hamlet
#

Uhhhh

#

You basically can assign a class variable with self.varname = value

autumn gust
#

ignore the flavour text, but this is what the mess™️ is rn

opal hamlet
#

And then access it with print(self.varname) or shit

autumn gust
#

ah, got it

#

contained global

#

essentially

#

so uhh, I assume move on_member_join out of the class?

#

or make a class of it's own?

opal hamlet
#

Also lets say you have

    def __init__(self):
        self.strvar = 'i am an attribute, or was it property?'``` 
You could initiate CoolClass as f.e. cc with cc = CoolClass() and then print(cc.strvar) and so on
autumn gust
#

neat

shell radish
opal hamlet
autumn gust
#

yes

opal hamlet
opal hamlet
autumn gust
opal hamlet
#

If its in a class it WILL receive a self as first, member is being used as self by the class

#

and _ is member

#

because theres no self

autumn gust
#

right

opal hamlet
#

I wonder, is self also a kwarg

#

Well don't care enough to find out

opal hamlet
shell radish
autumn gust
#

so essentialy, this piece of code is having an existentional crisis

#

so I have to remind it that it's self

#

got it, got it

opal hamlet
#

well it doesn't need to be called seld

autumn gust
#

never thought a piece of code could be going through what I'm going through/hj

shell radish
opal hamlet
#

its just that 'self' is called member and you are doing operations on self that you want to do on member

autumn gust
#

OH

shell radish
opal hamlet
#

Well yes but i meant self as whatever the fuck you call the self var/obj, and that got stored inside member

#

Ah god i should actually sleep, coherence is leaving my head

shell radish
#

you're not making much sense

opal hamlet
#

Yes

#

Well I know what i mean

#

Lol

#

I love the brains ability to understand concepts without combining them with any kind of words or other information you can properly communicate

#

So i just end up babbling some gibberish

shell radish
opal hamlet
#

Yeah

autumn gust
#

it's so jumbled that NO ONE not even themselves understand what it does

#

or how it does it

opal hamlet
#

but isnt self usually the first arg no matter what its called in the defs constructor(?)

shell radish
opal hamlet
#

Yes

autumn gust
#

would this work for sending something in one message on multiple lines

opal hamlet
#

Use \n for newline

autumn gust
#

oh.

shell radish
autumn gust
#

OH

#

THAT INDENTATION

opal hamlet
#

It was \n and not /n right? I usually do it by muscle memory on pc

shell radish
#

The indentation is also an issue on mobile

#

so I recommend just using \n

autumn gust
#

okay so

#

what's the display name thingy again

#

user.what?

#

display_name didn't work

opal hamlet
#

user.display_name

#

Huh

autumn gust
#

it returns back member object

opal hamlet
#

.rtfm member

lofty parcel
#

display_name doesn't return a member object

#

That makes no sense

autumn gust
opal hamlet
#

.rtfm user.display_name

autumn gust
#

my name is Normal Man, yet it returns back the_real.me

#

which is my tag

#

which is the exact same as the member object

lofty parcel
#

?tag pomelo

limber wagonBOT
#

Before Pomelo-

member.name          -> username
member.nick          -> guild nick name
member.display_name  -> member.nick OR member.name

After Pomelo-

member.name          -> username
member.global_name   -> global display name (global nick name)
member.nick          -> guild nick name
member.display_name  -> member.nick OR member.global_name OR member.name
autumn gust
#

these return the same thing

opal hamlet
#

What the fuck is pomelo? A major version overhaul or smth?

lofty parcel
autumn gust
#

do I need to import anything

lofty parcel
opal hamlet
#

discord preferrably

autumn gust
#

okay good

opal hamlet
#

Lol

autumn gust
#

what did I break

opal hamlet
#

Can you you show the whole def/func

autumn gust
lofty parcel
autumn gust
#

uhhhh

shell radish
#

Are you on 2.5.0rc5

autumn gust
#

how do I check again

shell radish
#

discord.__version__

lofty parcel
#

pip list

autumn gust
#

ah

opal hamlet
#

Would be too classic

autumn gust
#

I assume this is ancient

opal hamlet
autumn gust
#

no

#

I never had it

opal hamlet
#

Okay

#

Gud

shell radish
autumn gust
#

ahh... got it

#

is it stable-ish?

shell radish
#

yeah

autumn gust
#

aka it won't collapse because of a funny

#

huh

#

how do me install

shell radish
#

#library-updates

autumn gust
#

oh

opal hamlet
#

Hah ive been too lazy so far to update to dev...

#

Who needs to be up to date anyways

shell radish
#

@opal hamlet go to sleep. You're clearly not mentally ok rn

autumn gust
#

OH COME THE FUCK ON

lofty parcel
autumn gust
#

I was assuming what the * emant

shell radish
autumn gust
shell radish
#

so?

autumn gust
#

I assumed it was some self bs

lofty parcel
opal hamlet
#

Lmao

autumn gust
#

what does the star mean

shell radish
#

you also clearly don't know how python works

autumn gust
#

or asteriks

opal hamlet
#

Placeholder

autumn gust
#

...oh

opal hamlet
#

For potential args

autumn gust
opal hamlet
#

Ever seen *args, **kwargs

autumn gust
#

...not really

shell radish
#

great

opal hamlet
#

In f.e. def name(*args, **kwargs)

autumn gust
#

nope

opal hamlet
#

Ah

autumn gust
#

wait

shell radish
#

waiting

autumn gust
#

so, *args is essentialy just if * == 1:

#

and * can be ANYTHING you put in

opal hamlet
#

What

shell radish
#

no

autumn gust
#

well no that's what I got

opal hamlet
#

Its a potentially unlimited number of args

autumn gust
#

or is it full on *args

opal hamlet
#

Or an array/list of args

#

Wait no arrays aren't python native are they

autumn gust
#

so whatever you do def(abc) it checks abc if it's 1, def then it does the same and so on

opal hamlet
#

Don't 💀 me!

shell radish
#

*args means take these arguments and make them into an array named args

autumn gust
#

oooooooooh

#

and what that do

#

how could it be beneficial in like, any way

shell radish
#

just remove self, in your case

opal hamlet
#

You can do f.e. name = args[0]

autumn gust
#

oh

#

okay

autumn gust
shell radish
autumn gust
#

OH MY GOD

opal hamlet
#

And then age = args[1]

#

But ive never used that

autumn gust
#

oh so like

#

what's kwargs

opal hamlet
#

Keyword args

shell radish
autumn gust
#

ah

autumn gust
#

trial and erroring until it works

shell radish
#

this is more like shallow waters...

opal hamlet
shell radish
#

but yeah

autumn gust
lofty parcel
autumn gust
opal hamlet
#

I just suck at remembering names or terms for things

shell radish
opal hamlet
#

Ah yes

shell radish
#

shut

opal hamlet
autumn gust
#

same timezone let's gooo

opal hamlet
#

And i usually only do code until 2am, big difference

autumn gust
#

I'm running on an energy drink and like 4 different coffees

shell radish
#

🤥

opal hamlet
autumn gust
#

and the fact I get so scatterbrained when tired I forget to sleep

#

my head is pounding but code is the cure

opal hamlet
autumn gust
#

hmmmmm

sonic sorrel
#

@opal hamlet sorry to bother u, do u know how to manually add a row of user data to sqlite3 db? do i need a program to open the db file, or maybe in pycharm?

autumn gust
#

minor issue: why does my bot only send a message once

#

and then never again

opal hamlet
#

Can also be uhhh selected as standard app for .db which is CONVENIENT

opal hamlet
#

Is it supposed to send them multiple times from a loop?

autumn gust
#

if kicked, send message

#

it sent this only once

#

man it feels so raw without an avatar

#

but that's beside the point

opal hamlet
#

What exactly was it supposed to send besides that

autumn gust
opal hamlet
#

But why

#

Did you kick yourself again for testing?

sonic sorrel
opal hamlet
#

Did you add some nice traceback to your function?

opal hamlet
autumn gust
autumn gust
opal hamlet
autumn gust
#

it does everything nicely, but not the send message part

opal hamlet
autumn gust
opal hamlet
#

Maybe put the send before kick?

autumn gust
#

... oh

#

riiiight...

opal hamlet
#

Maybe discord is bitching that the member kinda doesn't exist or smth

autumn gust
#

I forgot that alt has dms from people blocked

opal hamlet
#

.....

#

Lmao

#

Nah but i personally like to wrap everything inside a function in
try:
except: traceback.print_exc()

#

Gotta import traceback first tho

lofty parcel
#

on_error listeners exist

opal hamlet
#

Hmhm

#

I just log every exception and call it a day

#

It'll be fineee

little cobalt
opal hamlet
#

Isn't it only for commands? Cuz im generally using it

little cobalt
#

that what you mean is on_command_error

opal hamlet
#

Ah

#

But what if on_error errors

#

Jk

little cobalt
#

anything

shell radish
little cobalt
#

only event?

#

mhm ok

opal hamlet
#

Logging tracebacks it is then.

frail ocean
#

are there some examples?

fickle salmon
frail ocean
rancid arrow
#

I have an option for a slash command as

person = discord.Option(input_type = discord.Member, name = "target", description = "Who you want to ask the question to", required = True)

but it's a string and not a discord.Member object and I don't know why

deft kestrel
rancid arrow
#

yeah i figured it out although im not particularly sure why it has to be a typehint

latent viper
#

is it possible to mention a command with an option already specified?

opal hamlet
#

do you mean something like autocomplete?

opal hamlet
#

async def complete_bounty(self, ctx:discord.ApplicationContext, target:Option(str, name_localizations={'de':'ziel'}), evidence:Option(discord.Attachment, name_localizations={'de':'beweis'})):
how would i limit evidence to attachments of type image or video?

#

would i need to do smth like py if not evidence.contentent_type == 'video': return

lost ocean
#

how do i fetch my bots top role in a server?

opal hamlet
#
from discord.utils import get
async def assignrole():
    role = 'rolename'
    gs = bot.guilds
    for g in gs:
        role = get(g.roles, name=role)
        if not role:
            await g.create_role(name=role)
            role = get(g.roles, name=role)
        if not role in g.me.roles:
            await g.me.add_roles(role)```
not *exactly* what you are looking for, but what i had laying around
#

i think the guild.me.roles would be key here

lost ocean
#

alr

#

nvm @opal hamlet

#

its ctx.guild.me.top_role

#

thanks anywyas

opal hamlet
#

lol its always something obvious you just never used before, eh?

latent viper
# opal hamlet do you mean something like autocomplete?

well.. kinda. When you mention a cmd called cmd it will look like /cmd and you can click it, then specify options etc. But I wonder if you can mention it like /cmd option:value so when it's clicked, it has the option filled already

opal hamlet
#

i think there should be some kind of default value of sorts

glass marsh
#

@bot.event
async def on_reaction_add(ctx, reaction, user):
    # Check if the message ID and reaction emoji match
    if reaction.message.id == 1155467049687072819 and str(reaction.emoji) == "✅":
        # Get the role object
        role = discord.utils.get(user.guild.roles, id=1155467114568745071)

        # Check if the user already has the role
        if role not in user.roles:
            # Add the role to the user
            await user.add_roles(role)

Not sure why this code doesnt do anything could someone point me in the right direction

sly karmaBOT
glass marsh
#

its meant to constantly listen for ✅ to be added as a reaction to a message and then its meant to add the role but it doesnt do anything no erroring bot has sufficient permissions everywhere and nothing happens

little cobalt
#

?tag intents

limber wagonBOT
#

Pycord Docs - Intents
Discord API Docs - Gateway Intents

import discord
from discord.ext import commands

# Get specific intents for fine control
intents = discord.Intents()
intents.emojis = True
intents.guilds = True
intents.messages = True  # Required for prefix commands!
...
# Get all non-priveliged intents; this excludes presences, members and message_content 
intents = discord.Intents.default()

# Set priveliged intents: these must be enabled on dev portal
intents.members = True
intents.presences = True
intents.message_content = True  # Required for prefix commands >= 2.0.0b5

# Get all intents; all intents must be enabled on dev portal.
intents = discord.Intents.all()

# Apply intents when creating your bot
bot = commands.bot(prefix="?", intents=intents)
glass marsh
#
intents = discord.Intents.all()

bot = discord.Bot()
client = discord.Client(intents=intents)

#

my intents are defined

#

and are enabled on the dev portal

clear aurora
#
embed.set_image(url='attachment://blogpost.png')
message = await channel.send(file=file, embed=embed)

How can I get the URL of the picture in the sent message?

glass marsh
#

or this

channel = discord.utils.get(client.get_all_channels(), id=1234567890)
message_url = await get_message_url(channel, 1234567890)
clear aurora
glass marsh
#
async def get_image_url(message):
    """Gets the URL of an image sent in a message.

    Args:
        message: The message containing the image.

    Returns:
        A string containing the URL of the image, or None if the message does not contain an image.
    """

    if not message.attachments:
        return None

    # Get the first attachment
    attachment = message.attachments[0]

    # Check if the attachment is an image
    if attachment.content_type not in ["image/png", "image/jpeg"]:
        return None

    # Return the URL of the image
    return attachment.url
lapis dock
glass marsh
#

i tried that still didnt work :(

lapis dock
glass marsh
#

nah its in the main bit

#

which is why im so confused on why it doesnt work

little cobalt
lapis dock
clear aurora
#

i think it is because the image is in the Embed?

autumn gust
#

hey, is client.latency the ping in ms?

little cobalt
lapis dock
#

It should be

lapis dock
autumn gust
autumn gust
#

oh yup I overlooked that

lapis dock
#

it was easy to miss

autumn gust
#

and it's at the end of them

#

I wonder, does everything from events have to be put under this?

#

and then, slash commands have to be put outside of this class, right?

lofty parcel
#

Because events are method in the bot class

autumn gust
little cobalt
autumn gust
#

or does it not matter

little cobalt
#

?tag clients

limber wagonBOT
#

dynoError No tag clients found.

little cobalt
#

?tag client

limber wagonBOT
#
discord.Client # just for events
discord.Bot # events + slash/user/msg commands
commands.Bot # above + prefixed commands
bridge.Bot # above + bridge commands (application commands and text commands in one)
lofty parcel
#

Because you create the command based off the class

#

@bot.command()

#

You can't do @self.command()

autumn gust
#

ah

#

I assume like this, or am I missing something

#

I'm enjoying the fact that doing all of this is going smoother with each day

lofty parcel
autumn gust
#

the class thingy, just like the discord.Client one

lofty parcel
#

You either use discord.bot or discord.client

#

You don't use both

autumn gust
#

oh, so replace the class Client(discord.Client) with class Client(discord.Bot)

#

instead of make a new class

glass marsh
autumn gust
#

oh.

#

I feel so dumb

#

well, now time to fail horribly at creating slash commands

lofty parcel
#

This is why you need to learn OOP x3rd time

autumn gust
cyan violet
#

.rtfm user

cyan violet
#

.rtfm PublicUserFlags

little cobalt
autumn gust
#

can somebody send a short template of a slash command since I'm getting nothing out of the docs

#

assuming I'm looking at the right thing(discord.SlashCommand)

rugged lodgeBOT
#

Here's the slash basic example.

autumn gust
#

ah

#

what did I do wrong

#

it worked a second ago and now it's having a stroke

little cobalt
#

Dont use discord.Client and discord.Bot at the same time

glass marsh
#

Im still having issue with my code

Im trying to have it when a message recieves a reaction of ✅ that they recieve a certain role
I have defined all my intents and when i react to the message nothing happens and i recieve no errors

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

bot = discord.Bot(
    intents=intents
)


#######

        @commands.Cog.listener()
        async def on_raw_reaction_add(reaction, user):
            # Check if the reaction is a white_check_mark emoji and the message ID is correct
            if str(reaction.emoji) == '✅' and reaction.message.id == 1155467049687072819:
                # Get the role by its ID
                role = user.guild.get_role(1155467114568745071)
                if role is not None:
                    # Add the role to the user
                    await user.add_roles(role)
                    print(f'Added role {role.name} to {user.display_name}')
autumn gust
#

that's the only class I have

little cobalt
#

Oh ok

autumn gust
#

that's the entire code for this class

little cobalt
#

Is it outside of the class?

autumn gust
#

yes

#

wait...

#

it was the client.slash_command() trying to use the previous thing

#

💀 my bad

#

hmmm, but the site uses @bot.slash_command and I'm forced to use @client.slash_command

#

what could be the thing

lofty parcel
#

Because you declared your class as Client

#

You don't copy the code exactly as the example

#

You understand and write yours

autumn gust
#

I assumed there was an error lol

#

any clue why this doesn't work

#

doesn't work as class Client(discord.Bot) either

#

no error just

#

silence

#

the bot itself is alive though

opal hamlet
#

How can i limit a command option attachment to img or video

autumn gust
#

I am going insane

#

on another note: while this is broken;
what does ctx mean?

#

is it just command whatever?

#

kinda like a command object

opal hamlet
#

abbreviation of context

autumn gust
#

oh

#

man

opal hamlet
#

being you know, the context of the command

autumn gust
#

oi Dnoxl

#

any idea how to fix the above issue

#

I think I might've accidentally lobotomised my bot and I have zero idea how I did that

opal hamlet
#

you dont need to subclass bot afaik

#

just remove the class Bot

autumn gust
#
class Bot(discord.Bot):
    async def on_ready(self):
        print(f"I'm alive, at {self.user}!")

    async def on_message(self, message):
        print(f"{str(message.author).rstrip('#0')}: {message.content}")

    async def on_member_join(self, member):
        userID = member.id
        channel = bot.get_channel(1155232310468280320)
        welcomeChannel = bot.get_channel(1130586203855540266) 
        getCurrentDate()
        userMention = member.id
        userAvatar = member.avatar.url
        userDisplayName = member.global_name
        userName = member.name
        userIDstring = str(userID)
        if userIDstring in whitelistIDs:
            await channel.send(f"{date_time} | `Traffic Syndicated for {userID}, recognised as {whitelistIDs[userIDstring]}`")
            await welcomeChannel.send(f"Greetings, {member.mention}")
        elif userIDstring in blockedUserIDs:
            await channel.send(f"## **{date_time}** | @autumn gust `Potentially Dangerous Traffic Blocked: {userID}, recognised as {blockedUserIDs[userIDstring]}`")
            await channel.send(f"Mention: **<@{userMention}>**\n Avatar: **<{userAvatar}>**\n Name: **{userName}**\n Display Name: **{userDisplayName}**")
            await member.send("You were kicked, reason: Banned on the Whitelist.")
            await member.kick(self, reason="Banned on Whitelist.")
        else:
            await channel.send(f"## **{date_time}** | `Remote Traffic Blocked: {userID}`")
            await channel.send(f" - Mention: **<@{userMention}>**\n - Avatar: **<{userAvatar}>**\n - Name: **{userName}**\n - Display Name: **{userDisplayName}**")
            await member.send("You were kicked, reason: Remote Traffic Blocked; Disconnected.")
            await member.kick(reason="Connection Denied.")
opal hamlet
#

un-indent on_ready

autumn gust
#

this is the entire class

#

class Client(discord.Bot): doesn't work either

opal hamlet
#

its not inside a Cog file is it?

autumn gust
#

no?

#

it's a .py file

opal hamlet
#

just get rid of the class