#discord-bots

1 messages · Page 216 of 1

hexed dagger
#

Okay

keen talon
#

!d discord.Role

unkempt canyonBOT
#

class discord.Role```
Represents a Discord role in a [`Guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild "discord.Guild")...
keen talon
#

Use this as a type hint

hexed dagger
#

I don't understand

#

Apprentky it's not able to find role

#

At remove role but the role name is valid

keen talon
#

wait a min lemme turn on my laptop

hexed dagger
#

Okay

shrewd fjord
#

This is what he meant

keen talon
#

What lib are you using

shrewd fjord
#

Whatever you pass on role args, it will be converted to Role object

hexed dagger
naive briar
#

What

keen talon
keen talon
shrewd fjord
hexed dagger
#

I read the wrong thing

keen talon
unkempt canyonBOT
hexed dagger
#

I have 2.2

keen talon
#

Lib name

hexed dagger
#

It says 1.7 in my toml file

#

But it yodates to 2.2

hexed dagger
keen talon
#

Lib name not version

naive briar
#

Names and versions are different

hexed dagger
#

How do I see name

keen talon
#

Oh lol

hexed dagger
#

Oh

smoky sinew
#

what does your toml file look like

hexed dagger
smoky sinew
#

doesn't that mean you are using v1 instead of v2

#

update that to say ^2.2.2 @hexed dagger

#

and do poetry install

hexed dagger
#

Also I think I figured out where thr mistake is

#

It's not updating role_id1

#

To the correct arg1

#

That'd why it can't assign as role 0 is everyone

#

Oh I am fucking stupid

#

It's caused I break if one of them is found

#

Omfg kill me

#

It still doesn't work

#

Even though they are the same

smoky sinew
#

does the role have a space

slate swan
#
@bot.command()
async def coins(ctx , user: discord.Member):
    embed = discord.Embed(title=user.name, description=":money_with_wings:", color=0x00ff00)
    
   
    await ctx.send(embed=embed)

hey how to do like if there is no argument then show ctx.author.name

#
discord.ext.commands.errors.MissingRequiredArgument: user is a required argument that is missing.
austere prairie
slate swan
#
async def coins(ctx, user: discord.Member = commands.Author):
``` works too
shrewd fjord
#

!d discord.ext.commands.parameter

unkempt canyonBOT
#

discord.ext.commands.parameter(\*, converter=..., default=..., description=..., displayed_default=...)```
A way to assign custom metadata for a [`Command`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command")'s parameter.

New in version 2.0.

Examples

A custom default can be used to have late binding behaviour.

```py
@bot.command()
async def wave(ctx, to: discord.User = commands.parameter(default=lambda ctx: ctx.author)):
    await ctx.send(f'Hello {to.mention} :wave:')
shrewd fjord
#

This too works xd

unkempt canyonBOT
#

discord/ext/commands/parameters.py lines 256 to 260

Author = parameter(
    default=attrgetter('author'),
    displayed_default='<you>',
    converter=Union[Member, User],
)```
slate swan
#

why would you redefine something that's already defined by the lib SXFSylviaGlasses_Maomao

unkempt mauve
naive briar
#

What is that even supposed to do

#

Show the full code

unkempt mauve
#

and put both the text together

#

like this:

Text 1 = ABC
Text 2 = DEF

iron turret
#

Im trying to make a ticket bot for my server. I wrote code that uses a /launch command that sends an embed with a button. When the button is pressed a channel is created and it will mention you in that channel if you try and press the button again it will not create a channel, and it does work but not the way it is supposed to. it create 3 channels at once and it creates 3 more when you press the button again.

#

Ticket Button Code:

class ticket_launcher(discord.ui.View):
  def __init__(self) -> None:
      super().__init__(timeout = None)

  @discord.ui.button(label = "Create a ticket", style = discord.ButtonStyle.blurple, custom_id = "ticket_button")
  async def ticket(self, interaction: discord.Interaction, button: discord.ui.Button):
        ticket = utils.get(interaction.guild.text_channels, name = f"ticket-for-{interaction.user.name}-{interaction.user.discriminator}")
        if ticket is not None: await interaction.response.send_message(f"You already have a ticket open at {ticket.mention}!", ephemeral=True)
        else:
            overwrites = {
                interaction.guild.default_role: discord.PermissionOverwrite(view_channel = False),
                interaction.user: discord.PermissionOverwrite(view_channel = True, send_messages = True, attach_files = True, embed_links = True),
                interaction.guild.me: discord.PermissionOverwrite(view_channel = True, send_messages = True, read_message_history = True)
            }
            channel = await interaction.guild.create_text_channel(name = f"ticket-for={interaction.user.name}-{interaction.user.discriminator}", overwrites=overwrites, reason = f"Ticket for {interaction.user}")
            await channel.send(f"{interaction.user.mention} created a ticket!")
            await interaction.response.send_message(f"Ive opened a ticket for you at {channel.mention}!", ephemeral=True)

Launch Command:

@tree.command(guild = discord.Object(id=no), name = 'launch', description='Launches the ticketing system')
async def launch(interaction: discord.Interaction):
    embed = discord.Embed(title = "If you need support, click the button below and create a ticket!", color = discord.Color.red())
    await interaction.channel.send(embed = embed, view = ticket_launcher())
    await interaction.response.send_message("Ticketing system launched!", ephemeral=True)
shrewd fjord
#

I dont see any problem right there 🗿

unkempt mauve
naive briar
#

Send the full code

sinful thistle
#

!pypi disnake

unkempt canyonBOT
sinful thistle
#

what is the difference?

#

please dm me for help

naive briar
#

Difference of what

sinful thistle
iron turret
#

like its working but not how its suppsoed to

#

i can send a recording of what it does

naive briar
#

You probably have my instances of the bot running

iron turret
#

??

naive briar
#

Or multiple on_message listeners calling process commands

vocal snow
#

their implementations of interactions and some other things are different

sinful thistle
vocal snow
#

both are python packages and hence will follow python syntax

sinful thistle
#

coz ima got a big bot i am lloking to migrate it for more slash commands

sinful thistle
slate swan
#

dont

slate swan
#

they both are 2 different libraries

vocal snow
#

it also supports slash commands

#

if that's what your requirement is

sinful thistle
vocal snow
#

sure

sinful thistle
vocal snow
#

why?

sinful thistle
vocal snow
#

doesn't work how?

#

are you getting an error?

#

it's best you always post your code and error if something isn't working

#

!paste

unkempt canyonBOT
#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

sinful thistle
#

no it just doesnt know what to send

#

Actually I and my friend are working on a bot and he thinks he needs both types of command in one file and he asked his senior he said to use disnake

vocal snow
#

I mean if you already have discord.py code why would you move to disnake and waste time doing so much refactoring

slate swan
#

in d.py there is something like hybrid command i belive

sinful thistle
slate swan
#

i might be wrong tho i dont use d.py daily

vocal snow
#

what are you expecting from us exactly

#

it's absolutely possible to have slash commands and normal text commands with discord.py

#

you can use the hybrid command interface as suggested above, or make separate callbacks for both

sinful thistle
#

how can you give me example

sinful thistle
#

i am checking

#

k thx

round jewel
#

what actually is the point of cogs because it just seems like a more complicated way of commands

slate swan
round jewel
slate swan
#

yeah i would say

proper plume
#

Hello everyone, yesterday I spoke with a guy about embed constructors without cogs, and he said cogs is a great way to organize the bot. Can please anyone tell me about cogs?

vocal snow
#

in essence, a Cog is a subclass of discord.ext.commands.Cog that can be hot loaded

#

you can define commands and event handlers inside it, and hence use it to categorize your bot's features

unkempt mauve
#

https://paste.pythondiscord.com/qufawuxera

Issue: the bot is supposed to return values of the two variables (verses_list, verses_list1) but not returning the other variable's value (in the for loop inside the chapter function), rather, it is returning the first variable's value into the other variable's value place.

mighty pilot
#

hey guys, this is part of my code for a giveaway bot that was working before but now it is not. its saying member is not defined here and im not sure what to define it as to get it working properly again. if i remember correctly the purpose was to see if the user is a part of the guild. so they have a user and a member account
userlist2 = [user async for user in newmsg.reactions[0].users() if isinstance(user, Member) and any(role.id in roleids for role in user.roles)]

shrewd fjord
unkempt canyonBOT
#

@shrewd fjord :x: Your 3.11 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 1, in <module>
003 |     print(this_is_not_defined)
004 |           ^^^^^^^^^^^^^^^^^^^
005 | NameError: name 'this_is_not_defined' is not defined
shrewd fjord
#

!e
this_is_defined="Spook"
print(this_is_defined)

unkempt canyonBOT
#

@shrewd fjord :white_check_mark: Your 3.11 eval job has completed with return code 0.

Spook
mighty pilot
#

I think I fixed it. Defined Member as discord.Member

shrewd fjord
mighty pilot
#

Thanks

shrewd fjord
#

Np

shrewd fjord
#

I think it will be response1.json()

#

Should have checked the code again 💀

unkempt mauve
shrewd fjord
#

xd

unkempt mauve
shrewd fjord
#

Noice

shrewd fjord
#

!d discord.NotFound

unkempt canyonBOT
#

exception discord.NotFound(response, message)```
Exception that’s raised for when status code 404 occurs.

Subclass of [`HTTPException`](https://discordpy.readthedocs.io/en/latest/api.html#discord.HTTPException "discord.HTTPException")
shrewd fjord
#

!d discord.errors.NotFound

unkempt canyonBOT
#

exception discord.NotFound(response, message)```
Exception that’s raised for when status code 404 occurs.

Subclass of [`HTTPException`](https://discordpy.readthedocs.io/en/latest/api.html#discord.HTTPException "discord.HTTPException")
shrewd fjord
#

Both works tho xd

#

But since it's actually hidden so u should use NotFound

unkempt mauve
#

hm

#

i actually dont care about that line sk

shrewd fjord
#

lol

unkempt mauve
shrewd fjord
tough lance
#

Too fast to press send

uneven apex
#

if my bot tries to create many channels at once, how many channels can we create before getting rate limited?

slate swan
runic whale
#

Hi all - working on getting my bot command to spit out a random row from a MySQL database. Everything works on the backend, however, not seemingly getting the bot to communicate properly (no results returned). Have made great strides thanks to the helpful folks in this channel, but reached another impasse! When I replace the query variable with the string 'test,' it works no problem. Any suggestions on how to modify my code to achieve this would be most appreciated! Thanks in advance!

bot = interactions.Client(token=TOKEN)

loop = asyncio.get_event_loop()

@bot.command(
    name="2kplayer",
    description="Work in progress",
    scope=GUILD_ID,
)
async def my_first_command(ctx: interactions.CommandContext):
    conn = await aiomysql.connect(
        host='127.0.0.1',
        user='root',
        password='root',       
        db='dominion_data',
        loop = loop
    )
    cur = await conn.cursor()
    await cur.execute('SELECT first_name, last_name, team_name FROM players_2k22 AS t1 JOIN (SELECT player_id as player_id_t2 FROM players_2k22 ORDER BY RAND() LIMIT 1) as t2 ON t1.player_id=t2.player_id_t2 LIMIT 1;')
    query = await cur.fetchone()
    # df = pd.read_sql(query, engine)
    await ctx.send(query)    
    await cur.close()
    conn.close()

bot.start();
runic whale
shrewd fjord
#

Also make sure to not forget to commit the database on the backend part, most people forget it kek

runic whale
shrewd fjord
#

xd

runic whale
#

thanks for your time, will take a look at integrating this 🙂

shrewd fjord
#

Okay

#

Actually fetchone should have atleast return 1 record

#

Maybe it's the problem with executing query

runic whale
#

yeah, i believe i tried fetchall, but want to try again to be sure

#

to be clear, everything works on the sql side and when i eliminate the bot from the equation it runs ok in python, meaning the row gets returned in the output randomly every time i execute

shrewd fjord
#

Also I dont think ; this matters anyway

#

Except for a sql file and u should quote the query with ""

runic whale
#

essentially trying to refresh the query when the command triggers

#

yeah ; is my sql habit haha

shrewd fjord
#

Ohk

runic whale
shrewd fjord
#

Or answer 🗿

runic whale
shrewd fjord
#

Np

slate swan
#

So my task.loop in my giveaway commnad does not loop it like i tried printing 1 and it printed only once.
on my vscode it works but in the hosting it doesnt.
No error either

    @tasks.loop(seconds=5)
    async def giveawayCheck(self):


        async with self.bot.db.cursor() as cursor:
            await cursor.execute("SELECT time, prize, message, channel, guild, participants, winners, finished FROM giveaways")
            data = await cursor.fetchall()
            if data:
                for table in data:
                    time, prize, message, channel, guild, participants, winners, finished = table[0], table[1], table[2], table[3], table[4], table[5], table[6], table[7]
                    if not finished:
                        if pyTime.time() >= time:
                            guild = self.bot.get_guild(guild)
                            channel = guild.get_channel(channel)
                            if guild or channel is not None:
                                try:
                                    participants = json.loads(table[5])
                                except:
                                    participants = []
                                if not len(participants) == 0:  
                                    if len(participants) < winners:
                                        winner = random.choices(participants, k=len(participants))
                                    else:
                                        winner = random.choices(participants, k=winners)
        
                                    if winner is not None:
                                        em = nextcord.Embed(title="Giveaway Results", description=f"{', '.join([guild.get_member(int(i)).mention for i in winner])} has won the giveaway for `{prize}` ![giveaway](https://cdn.discordapp.com/emojis/1042167233830469632.webp?size=128 "giveaway")")
                                        await channel.send(f"{', '.join([guild.get_member(int(i)).mention for i in winner])}",embed=em)
                                        await cursor.execute("UPDATE giveaways SET finished = ? WHERE guild = ? AND prize = ? AND message = ?", (True, guild.id, prize, message))
                                        msg = await channel.fetch_message(message)
                                        newEm = nextcord.Embed(title="Giveaway Ended", description=f"{', '.join([guild.get_member(int(i)).mention for i in winner])} has won `{prize}` ![giveaway](https://cdn.discordapp.com/emojis/1042167233830469632.webp?size=128 "giveaway") ![giveaway](https://cdn.discordapp.com/emojis/1042167233830469632.webp?size=128 "giveaway") ![giveaway](https://cdn.discordapp.com/emojis/1042167233830469632.webp?size=128 "giveaway")", color=0x4b99bd)
                                        newEm.set_footer(text=f"Enters - {len(participants)}")
                                        await msg.edit(embed=newEm)
                                else:
                                    await cursor.execute("UPDATE giveaways SET finished = ? WHERE guild = ? AND prize = ? AND message = ?", (True, guild.id, prize, message))
                                    msg = await channel.fetch_message(message)
                                    newEm = nextcord.Embed(title=f"{prize} Giveaway Ended", description=f"No one has joined the giveaway", color=0x4b99bd)
                                    await msg.edit(embed=newEm)
                                    em = nextcord.Embed(title=f"{prize} Giveaway Ended", description="No one has joined the giveaway", color=0x4b99bd)
                                    await channel.send(embed=em)
        await self.bot.db.commit()```
slate swan
#

the giveaway?

shrewd fjord
#

The loop

slate swan
#

@commands.Cog.listener()
async def on_ready(self):
await self.bot.wait_until_ready()
await asyncio.sleep(2)
print("Database Staus: Online")
self.giveawayCheck.start()
print("Giveaway Loop: Online")

shrewd fjord
#

I see

#

Hm..

#

Maybe it's taking time to return the data and again looping?

#

Can you add
print("started") on the top of loop
And print("ended") bottom of the loop?

slate swan
#

yes

shrewd fjord
#

Try and check on the hosting

slate swan
shrewd fjord
#

Maybe it's bot able to fetch datas from database thus blocking it

slate swan
#

its weird

shrewd fjord
#

Maybe json.load doing weird stuff lol

shrewd fjord
#

You have error handler bru

slate swan
#

yep

shrewd fjord
#

Try doing
except Exception as e:
print(e)

#

Check the error

slate swan
#

okay

fast musk
#

or fix your error handler which is probably the most important thing to do

shrewd fjord
#

Yep

queen venture
#

idk whats the error

slate swan
#

!intents

unkempt canyonBOT
#
Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. Various features of discord.py rely on having particular intents enabled, further detailed in its documentation. Since discord.py v2.0.0, it has become mandatory for developers to explicitly define the values of these intents in their code.

There are standard and privileged intents. To use privileged intents like Presences, Server Members, and Message Content, you have to first enable them in the Discord Developer Portal. In there, go to the Bot page of your application, scroll down to the Privileged Gateway Intents section, and enable the privileged intents that you need. Standard intents can be used without any changes in the developer portal.

Afterwards in your code, you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:

from discord import Intents
from discord.ext import commands

# Enable all standard intents and message content
# (prefix commands generally require message content)
intents = Intents.default()
intents.message_content = True

bot = commands.Bot(command_prefix="!", intents=intents)

For more info about using intents, see discord.py's related guide, and for general information about them, see the Discord developer documentation on intents.

queen venture
#

i got them already

slate swan
#

first of all i dont see any intents there and second thing we cant help on projects that may break law

#

!ytdl

unkempt canyonBOT
#
Our youtube-dl, or equivalents, policy

Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.

For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:

The following restrictions apply to your use of the Service. You are not allowed to:

1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service;  (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;

3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;

9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
slate swan
#

hi guys

#

i bought a vps and hosted my bot on it

#

and i want to know how to host it h24/7

#

could you help me ?

#

@cedar smelt can u help with sql ?

slate swan
slate swan
#

the vps must be on

#

not your pc

slate swan
#

let's try

slate swan
#

you can change name of the output file

#

rest leave it as it is

#

& means it runs in the background

#

okay

#

and > means to save all output to the file after

#

in this case named output.txt

#

oh

#

@slate swan uh ?

slate swan
#

or instead of python try py, py3, python3

naive briar
#

Great

slate swan
#

ok

lyric iris
#

hi I need help. I am about to have a stroke......

#

How can I make my python code copy "Dopey ean", "FAT AND FURI0U3", "iX latics" from this discord message

slate swan
lyric iris
slate swan
smoky sinew
lyric iris
slate swan
#

i will check if i turn off my pc, it still work

slate swan
smoky sinew
lyric iris
#

i made one already

slate swan
#

when this command is there in the code, whenever i use a command, the bot does not reply or respond. but whenever i remove this code, it works. what might be the issue?

@bot.event
async def on_message(message):
    if message.author.bot:
        return  # ignore messages from bots

    channel = message.channel
    channel_id = str(channel.id)

    mycursor = db.cursor(buffered=True)

    # check if the channel has the channel_type as "roleplay"
    mycursor.execute("SELECT channel_type FROM channel WHERE channel_id = %s", (channel_id,))
    result = mycursor.fetchone()
    if not result or result[0] != "roleplay":
        return  # ignore non-roleplay channels

    # check if the user has an ID in the users table
    user_id = str(message.author.id)
    mycursor.execute("SELECT * FROM users WHERE id = %s", (user_id,))
    result = mycursor.fetchone()
    if not result:
        await channel.send("It is preferable that you use the -createid command before proceeding with the roleplay.")
        return

    # check if the user is on cooldown
    if bot.user_cooldown.has_cooldown(user_id):
        return

    # calculate the payment amount based on the message length and characters used
    message_content = message.content
    payment = 10
    if len(message_content) > 20:
        payment += 5 * ((len(message_content) - 20) // 10)
    if '"' in message_content:
        payment += 10
    if '*' in message_content:
        payment += 20

    # update the user's amount and apply the cooldown
    mycursor.execute("UPDATE users SET amount = amount + %s WHERE id = %s", (payment, user_id))
    db.commit()
    bot.user_cooldown.update(user_id)

    # process regular commands
    await bot.process_commands(message)```

there are no errors either
naive briar
#

There are no commands in this thing

#

Not in my definition anyway

slate swan
smoky sinew
slate swan
#

test

slate swan
# smoky sinew do you have any other on_messages

i changed it into a listener but still, to no avail:

@bot.listen('on_message')
async def roleplay_money(message):
    if message.author.bot:
        return  # ignore messages from bots

    channel = message.channel
    channel_id = str(channel.id)

    mycursor = db.cursor(buffered=True)

    # check if the channel has the channel_type as "roleplay"
    mycursor.execute("SELECT channel_type FROM channel WHERE channel_id = %s", (channel_id,))
    result = mycursor.fetchone()
    if not result or result[0] != "roleplay":
        return  # ignore non-roleplay channels

    # check if the user has an ID in the users table
    user_id = str(message.author.id)
    mycursor.execute("SELECT * FROM users WHERE id = %s", (user_id,))
    result = mycursor.fetchone()
    if not result:
        await channel.send("It is preferable that you use the -createid command before proceeding with the roleplay.")
        return

    # check if the user is on cooldown
    if bot.user_cooldown.has_cooldown(user_id):
        return

    # calculate the payment amount based on the message length and characters used
    message_content = message.content
    payment = 10
    if len(message_content) > 20:
        payment += 5 * ((len(message_content) - 20) // 10)
    if '"' in message_content:
        payment += 10
    if '*' in message_content:
        payment += 20

    # update the user's amount and apply the cooldown
    mycursor.execute("UPDATE users SET amount = amount + %s WHERE id = %s", (payment, user_id))
    db.commit()
    bot.user_cooldown.update(user_id)```
#

i mean, hey at least this time the commands work

#

but this piece of code itself, eh does nothing

quick nebula
smoky sinew
#

only coroutines

quick nebula
smoky sinew
#

it's also @Bot.command()

#

not @Bot.command

quick nebula
#

oh sorry i just forget that🤦‍♂️🤦‍♂️

slate swan
#

i already found a fix but now the issue is that the main purpose of the command is not working at all

quick nebula
slate swan
#

You might run into performance issues down the line if you're making a database call for each message that gets sent

#

well, that's kind of true but i'm willing to make adjustments

cloud dawn
#

The amount of messages that have to get send would be incredibly high.

karmic nimbus
#

how do I add who made the changes in on_member_update?
like edited by who

slate swan
#

how to custom colors with messages like that ?

test
slate swan
#

okay thanks

naive umbra
slate swan
slate swan
#

bookmarked

#

@naive umbra i didn't really understand the message, could you just tell me how to make a message like that ?

test (in green) ・ test (in red)
slate swan
naive umbra
#
Test
#

works?

slate swan
#
\u001b[0;40m\u001b[1;32mThat's some cool formatted text right?
\u001b[1;40;32mThat's some cool formatted text right?
#

does not for me

slate swan
#

what did you input

naive umbra
slate swan
#

ah okay

#

my bad

naive umbra
slate swan
#
test```
#

shush kinda fire

#
[0;31mTest
slate swan
naive umbra
#
Test
Test
Test
Test
Test
Test
Test
Test
Test
naive umbra
slate swan
slate swan
#

copy it from my message above

#

okok

naive umbra
#

```ansi
Test
Test
Test
Test
Test
Test
Test
Test
Test
```

Test
Test
Test
Test
Test
Test
Test
Test
Test
slate swan
#
[031mTest
#

oh yeah

#

thanks

lone ivy
#

Hello, i'm wanting to store my own data instead of relying on an API (for various reasons). The data I want to store will be pokemon related data (pokemon data, region data, gym leaders, team rocket, items, moves and their effects, etc). What would be a good way to store my own data, I've heard that dictionaries and nested dictionaries created with the use of making instances of classes (like class Pokemon, class Abilities, class Types, etc).

I am new*ish to python, so could use a little nudge in the right direction (yes i know this is not quite a beginner friendly project, but never the less I intend to keep at it)

upbeat otter
#

That's just more processing and more storage consumption

lone ivy
#

thank you, i appreciate it ❤️

lone ivy
# upbeat otter That's just more processing and more storage consumption

from the little research i did, key word little so if you have any extra info to give that'd be great, but I need a multi processor and a lot of ram, well i have a multi core processor and i have 31 free GB of RAM, would that be enough just for the testing of my bot, once I plan on making the bot public, it will be converted to an actual hosting service

left dew
#

do bots need to be verified to do this?

lone ivy
#

i greatly appreciate the info

cloud dawn
left dew
#

how are they made?

#

or what are they called

cloud dawn
#

How is what made?

#

Oh that

#

Using the scopes on the dev site.

left dew
#

oh

smoky sinew
#

if you send it inside a discord server it will be in-app

left dew
#

yea do i need a domain for it

smoky sinew
left dew
#

yes

smoky sinew
#

you need these two scopes

#

and you don't need a domain but you will need some kind of http server

upbeat otter
#

Every single kb is precious 😳

left dew
slate swan
smoky sinew
#

the above ones handle this

left dew
#

oooh okay

#

so i know i have to host it w a local server or whatever but idk how to

#

https://yourdomainhere.com/discordauth

#

like that

slate swan
#

i need heeelp

#

I'm using python to run a discord bot and i got a damn error that says ModuleNotFoundError: No module named discord_components'
i try to download the module by pip i do the py -m pip install discord_components
but it gives this error and there is no module such as discord-components

ERROR: No matching distribution found for discord-components```
slate swan
smoky sinew
slate swan
#

i'm trying to run a py file and it says this

#
    from discord_components import *
ModuleNotFoundError: No module named 'discord_components'```
slate swan
#

well

#

!d discord.ui.View

unkempt canyonBOT
#

class discord.ui.View(*, timeout=180.0)```
Represents a UI view.

This object must be inherited to create a UI within Discord.

New in version 2.0.
#

Hey @slate swan!

You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.

slate swan
balmy bobcat
#

hi, how can my bot send a message to another channel? I use slash commands

slate swan
#

easiest way will be to use bot.get_channel(id)

balmy bobcat
#

then I use send_message?

slate swan
#

yes you assign it to a varriable

#

and send

#
channel = bot.get_channel(12345)
await channel.send("...")
smoky sinew
#

InteractionResponse.send_message only works in the current channel

balmy bobcat
smoky sinew
#

you would just use channel.send

balmy bobcat
#

thank you

slate swan
#

how to make dnd bot activity please ?

smoky sinew
#

await bot.change_presence(status = discord.Status.dnd)

slate swan
#

anyone know aioqlite?

Error binding parameter 3: type 'tuple' is not supported

try:
            async with self.bot.db.cursor() as c:
                await c.execute(f"SELECT * FROM customcommand1 WHERE user_id = ? AND trigger = ? AND message = ?", (ctx.author.id, trigger, message,))
                check = await c.fetchone
                if check is not None:
                    await c.execute("UPDATE customcommand1 SET user+id = ? AND trigger = ? AND message = ?", (ctx.author.id, trigger, message,))
                    await self.bot.db.commit()
                elif check is None:
                    await c.execute("INSERT INTO customcommand1 VALUES (?, ?, ?)", (ctx.author.id, trigger, message,))
                    await self.bot.db.commit()
                await success(ctx, f'Successfully **set** your message to **{message}** & trigger to **{trigger}**')
        except Exception as e:
            print(e)
            await error_message(ctx, "There was an **error** proccessing this command. Check your message and try again")```
smoky sinew
#

put an asterisk before the tuple

slate swan
#

thats what i did

smoky sinew
#

where is it in your code then

slate swan
#

ohh you said asterisk

#

i thought you meant something else

slate swan
#

@smoky sinew

slate swan
#

hey

#

i want to add footer to my embed please

#
await ctx.respond(embed = discord.Embed(title = "", description = f"", color = ))
#

@slate swan

smoky sinew
#

.set_footer is a method that does not return anything so you will have to use this

embed = discord.Embed(...)
embed.set_footer(...)
await ctx.reply(embed=embed)
slate swan
#

a

smoky sinew
#

you could do this though

class CustomEmbed(discord.Embed):
    def set_footer(self, *args, **kwargs):
        super().set_footer(*args, **kwargs)
        return self

then you can use

await ctx.reply(embed=CustomEmbed(...).set_footer(...))
smoky sinew
#

you can do the same thing

rancid sparrow
#

Is it possible someone can help me with my Discord bot that I host. Python using Ubuntu, had a bot Dev but he went MIA for months and really trying to finish something he started. Possible DM so itll be easier to communicate? Thanks

dusty tree
#
note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for lavasnek_rs
Failed to build lavasnek_rs
ERROR: Could not build wheels for lavasnek_rs, which is required to install pyproject.toml-based projects
#

any1 able to help w this?

#

It says "cant find rust compiler" eventhough its installed

slate swan
#

Can anyone help me with this
I have been trying to do something with numbers rn using isdigit() method to identify nums but i want to identify expression like additions and multiplications too, such as 4*5.

unkempt canyonBOT
#
Our youtube-dl, or equivalents, policy

Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.

For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:

The following restrictions apply to your use of the Service. You are not allowed to:

1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service;  (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;

3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;

9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
smoky sinew
#

of course there is probably an easier way

#

maybe use something like ast

slate swan
smoky sinew
#

i guess that could work too

slate swan
#

however i did have to use eval() function which bothers me if someone tried to mess with the code

smoky sinew
#

yeah no definitely don't use eval

#

you can easily read anything like the token

slate swan
#

What do I do now? Is there something that calculates only maths expressions?

slate swan
#

Does literal_eval() makes the same risk ?

naive briar
#

!e ask the error

import ast

print(ast.literal_eval("1+1"))
unkempt canyonBOT
#

@naive briar :x: Your 3.11 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 3, in <module>
003 |     print(ast.literal_eval("1+1"))
004 |           ^^^^^^^^^^^^^^^^^^^^^^^
005 |   File "/usr/local/lib/python3.11/ast.py", line 110, in literal_eval
006 |     return _convert(node_or_string)
007 |            ^^^^^^^^^^^^^^^^^^^^^^^^
008 |   File "/usr/local/lib/python3.11/ast.py", line 109, in _convert
009 |     return _convert_signed_num(node)
010 |            ^^^^^^^^^^^^^^^^^^^^^^^^^
011 |   File "/usr/local/lib/python3.11/ast.py", line 83, in _convert_signed_num
... (truncated - too many lines)

Full output: https://paste.pythondiscord.com/owawayicit.txt?noredirect

dusty tree
smoky sinew
#

😮

#

what's your source

smoky sinew
#

@dusty tree

dusty tree
smoky sinew
dusty tree
#
bot = lightbulb.BotApp(
    TOKEN,
    prefix=lightbulb.when_mentioned_or(PREFIX),
    intents=INTENTS,
    cache_settings=CACHE,
    help_slash_command=True,
    ignore_bots=True,
    case_insensitive_prefix_commands=True,
    logs={
        "version": 1,
        "incremental": True,
        "loggers": {
            "hikari": {"level": "INFO"},
            "lightbulb": {"level": "INFO"},
        },
    },
)
smoky sinew
#

what's the full code

dusty tree
#
import os
import aiohttp
import hikari
import lightbulb
import concurrent.futures
from random import choice
from utils.quotes import statuses
from lightbulb.ext import tasks
from utils.const import INTENTS, CACHE, TOKEN, PREFIX

bot = lightbulb.BotApp(
    TOKEN,
    prefix=lightbulb.when_mentioned_or(PREFIX),
    intents=INTENTS,
    cache_settings=CACHE,
    help_slash_command=True,
    ignore_bots=True,
    case_insensitive_prefix_commands=True,
    logs={
        "version": 1,
        "incremental": True,
        "loggers": {
            "hikari": {"level": "INFO"},
            "lightbulb": {"level": "INFO"},
        },
    },
)

tasks.load(bot)

@bot.listen()
async def on_starting(event: hikari.StartingEvent) -> None:
    bot.d.aio_session = aiohttp.ClientSession()
    bot.d.process_pool = concurrent.futures.ProcessPoolExecutor()

@bot.listen()
async def on_stopping(event: hikari.StoppingEvent) -> None:
    await bot.d.aio_session.close()
    bot.d.process_pool.shutdown(wait=True)

bot.load_extensions_from("./extensions/", must_exist=True, recursive=True)
bot.load_extensions_from("./meta/", must_exist=True, recursive=True)


if __name__ == "__main__":
    if os.name != "nt":
        import uvloop
        uvloop.install()

    bot.run(
        status=hikari.Status.ONLINE,
        activity=hikari.Activity(
            name=choice(statuses),
            type=hikari.ActivityType.WATCHING)
    )
smoky sinew
dusty tree
#

okok

#

syill sends same error for line 13

smoky sinew
#

can you show utils.const?

#

where are you getting TOKEN from??

dusty tree
#

the token is getting pulled from my env file

smoky sinew
#

did you load the .env file first?

#

!pypi python-dotenv

unkempt canyonBOT
dusty tree
#

yes I already have that one

smoky sinew
dusty tree
#
import os
import dotenv
import hikari
from hikari import Intents
from hikari.impl.config import CacheSettings
from hikari.api.config import CacheComponents

dotenv.load_dotenv()

#
# MAIN BOT RELATED
#

GUILDS = (
        875986914367385600,
        617173140476395542,
        793239269723471902,
        535677066138353674,
        570976409452019722
)

PREFIX = [
        "v!",
        "V!"
        ]

INTENTS = (
        Intents.GUILDS                      |
        Intents.GUILD_MEMBERS               |
        Intents.GUILD_MESSAGES              |
        Intents.GUILD_VOICE_STATES          |
        Intents.MESSAGE_CONTENT             
)


CACHE = CacheSettings(components=
        CacheComponents.GUILDS              |
        CacheComponents.GUILD_CHANNELS      |
        CacheComponents.ME                  |
        CacheComponents.MEMBERS             |
        CacheComponents.MESSAGES            |
        CacheComponents.ROLES               |
        CacheComponents.VOICE_STATES    
)

TOKEN = os.getenv("BOT_TOKEN")
#

ight

#

well fixed main problem, the bbot goes live

#

I forgot I had added previous guilds I tested

slate swan
#

does anyone know how i can show time like this where when you hover over it it shows info

unkempt canyonBOT
#

discord.utils.format_dt(dt, /, style=None)```
A helper function to format a [`datetime.datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "(in Python v3.11)") for presentation within Discord.

This allows for a locale-independent way of presenting data using Discord specific Markdown...
slate swan
smoky sinew
#

remove the style=None part, that's just part of the function signature

smoky sinew
#

where it says "2 days ago" etc

slate swan
smoky sinew
#

as a string

#

you can't just put a random letter in because python doesn't recognize it

mint walrus
#

How do I make the bot have like a custom rich presence like playing then blank blank

smoky sinew
mint walrus
#

Which ever one that shows the example I gave

smoky sinew
#

!d discord.Game

unkempt canyonBOT
#

class discord.Game(name, **extra)```
A slimmed down version of [`Activity`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Activity "discord.Activity") that represents a Discord game.

This is typically displayed via **Playing** on the official Discord client.

x == y Checks if two games are equal.

x != y Checks if two games are not equal.

hash(x) Returns the game’s hash.

str(x) Returns the game’s name.
smoky sinew
#

await bot.change_presence(activity=discord.Game(...))

mint walrus
#

Dm me

smoky sinew
#

why

slate swan
#

is it possible to name commands with space in their name, im using pycord and it throws an error if i try to do so.

smoky sinew
#

shift is a subcommand of work

slate swan
#

oh ok im unaware of that concept

slate swan
#

Is their any problem with multiple discord bot instances so long as they respond to different stuff?

#

I need some functions to be very responsive so they are on a vps

#

but I also have some functions that involve re-encoding and upscaling video which needs to run on my home server because I can't afford a GPU compute datacenter server and it's already too slow with a 3060ti.

#

so long as I only use the commands rewrite for one instance it should be fine right?

#

and use on-message for the other

drifting arrow
#

How do I disable a button?

#
@discord.ui.button(label="Notes Previous", style=discord.ButtonStyle.red)
    async def notes_previous(self, interaction: discord.Interaction, button: discord.ui.Button):
        button.disabled = True
        if self.pagenumber == 0:
            self.pagenumber = len(self.notes) - 1
        else:
            self.pagenumber = self.pagenumber - 1
        embed = self.setembed(self.pagenumber)
        await interaction.response.edit_message(embed=embed, view=self)
``` This doesnt seem to work D:
#

I want to be able to disable it if there's no notes.

#

nvm figured it out ;D

drifting arrow
#

Is it possible to put buttons on new rows? 🤔

glad cradle
#

Do you mean like reorder buttons? or put buttons on new rows?

naive briar
#

Yes?

drifting arrow
#

Yes

#

so instead of:
[button1] [button2]
i have:
[button1]
[button2]

drifting arrow
#

Basically I want to be able to have multiple rows for my buttons ;D

#

using discord.ui.view

smoky sinew
#

!d discord.ui.button

unkempt canyonBOT
#

@discord.ui.button(*, label=None, custom_id=None, disabled=False, style=<ButtonStyle.secondary: 2>, emoji=None, row=None)```
A decorator that attaches a button to a component.

The function being decorated should have three parameters, `self` representing the [`discord.ui.View`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.ui.View "discord.ui.View"), the [`discord.Interaction`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.Interaction "discord.Interaction") you receive and the [`discord.ui.Button`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.ui.Button "discord.ui.Button") being pressed.

Note

Buttons with a URL cannot be created with this function. Consider creating a [`Button`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.ui.Button "discord.ui.Button") manually instead. This is because buttons with a URL do not have a callback associated with them since Discord does not do any processing with it.
smoky sinew
#

row parameter

#

@drifting arrow

drifting arrow
#

;o

#

Ty ty @smoky sinew

#

I set the row but it doesnt seem to do anything 😦

#

D: still all 1 row

naive briar
#

What did you set them to then

drifting arrow
#

Serverbans is row 2,
Notes is row 1
And profile is row 3

smoky sinew
#

it’s from 0 to 4

drifting arrow
#

Yes I am keeping them within the 5 row limit

#

but it doesnt work ;-;

smoky sinew
#

yes but they start at 0

drifting arrow
#
async def sort_buttons(self):
        for child in self.children:
            if type(child) == discord.ui.Button:
                if child.label == "Profile":
                    child.row = 0
                    child.visible = False
                    child.disabled = True
                if child.label == "Notes Previous" or child.label == "Notes Next":
                    print("NOTES BUTTON!!")
                    print(child)
                    child.row = 1
                    print(child)
                    if not self.notes:
                        child.disabled = True
                        child.visible = False
                if child.label == "Serverbans Previous" or child.label == "Serverbans Next":
                    child.row = 2
                    if not self.serverbans:
                        child.disabled = True
                        child.visible = False
                if child.label == "Cheetos Previous" or child.label == "Cheetos Next":
                    child.row = 3
                    if not self.cheetos:
                        child.disabled = True
                        child.visible = False
#
<Button style=<ButtonStyle.success: 3> url=None disabled=False label='Notes Next' emoji=None row=None>
<Button style=<ButtonStyle.success: 3> url=None disabled=False label='Notes Next' emoji=None row=1>
smoky sinew
#

why not set them in the decorator

drifting arrow
#

coz i am not smart

#

brb.

#

Much better

#

;D

dusty tree
#

any1 who could explain to me when you'll be eligble for active dev batch?

naive briar
#

Make a bot with slash command then use it

#

That's it

slate swan
#

Then fill a form for it and you get it

dusty tree
slate swan
#

When filling a form for the badge

#

You select the application and server

dusty tree
#

ko

slate swan
#

hi besties i am working on a command in which the main task is to ensure that people get access to channel or not. so like if parameter is None, then it gives or takes away access for everyone.

same thing for discord member and roles. but no matter how much i try this garbage doesn't work:

unkempt canyonBOT
#

Hey @slate swan!

You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.

slate swan
gusty flax
#

if access is None, it doesn't remove those perms?

slate swan
gusty flax
#

And do you know if the Member has read_messages

uneven apex
#

i have added certain members of my server in a private channel of my server
if i use py await channel.set_permissions(role, overwrite=overwrite)
new overwrite has removes access from that channel from that role
will this overwrite also affect the members i have added to the channel?
i am using dpy

tough lance
#

@vale wing Hey sorry for the ping but can you link to your docker article

tough lance
#

Thanks

vale wing
#

Top jokes non-developers will never understand

drifting arrow
gusty flax
#

R u doing any setup in on_ready @drifting arrow

drifting arrow
#

Am I not suppose to @gusty flax ? 🤔

gusty flax
drifting arrow
#

im sending some buttons to a channel 😄

gusty flax
drifting arrow
#

well it's calling a function, but essentially yes.

gusty flax
#

I think thats fine

shell wing
#

Is easy-pil still used ?

drifting arrow
gusty flax
drifting arrow
#

lemme check if i forgot to async..

#

all async 🤔

#

!paste

smoky sinew
#

rcon bot

gusty flax
cinder tulip
#

Uh, I am trying to make my discord bot play music from youtube-dl, but i get a long error that says that it's not able to extract the id or something so it asks me to run a "--verbose" command.
this is my code:

@client.command()
async def play(ctx, url):
    voice_channel = ctx.author.voice.channel
    try:
        await voice_channel.connect()
    except:
        pass
    with youtube_dl.YoutubeDL() as ydl:
        info = ydl.extract_info(url, download = False)
    URL = info['formats'][0]['url']
    voice_client = ctx.guild.voice_client
    if not voice_client.is_playing():
        voice_client.play(discord.FFmpegPCMAudio(url))

@client.command()
async def leave(ctx):
    voice_client = ctx.guild.voice_client
    if voice_client.is_connected():
        await voice_client.disconnect()
#

also the latest version of youtube-dl is "2021.12.17" soooo I can't really update it or anything.

unkempt canyonBOT
#
Our youtube-dl, or equivalents, policy

Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.

For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:

The following restrictions apply to your use of the Service. You are not allowed to:

1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service;  (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;

3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;

9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
cinder tulip
#

:(

vale wing
slate swan
#

hello I cant install discord-components

vale wing
vale wing
drifting arrow
vale wing
#

Are you

slate swan
drifting arrow
vale wing
#

Running from one script?

drifting arrow
#

no

vale wing
#

Yeah that's what I wanted

#

Okay I don't really see any blocking code but perhaps this isn't your only file

vale wing
slate swan
#

Is there anyway to make a bot join a vc with gateway and make it stream something particular

vale wing
#

Stream what exactly? Audio or video?

#

Latter is not possible

tough lance
#

I have a question, I have a server with 3vCores 3.8GHz each. My bot is in 11k servers with high commands usage (2-5 commands per second). Is it normal that my CPU usage is cranked at 98-100%? Or something must be wrong with my code?

drifting arrow
#

das a few servers there bob

vale wing
tough lance
#

Memory usage is fine

vale wing
#

I feel like this is usage for all python processes

#

Although don't know

#

Is the bot not isolated

vale wing
tough lance
vale wing
#

Yeah

tough lance
tough lance
#

I mean. its required and I don't do just one thing

slate swan
#
  1. commit message is not required
#
  1. thats why you commit every small change
#

but if thats just solo project and you dont care too much thats fine

tough lance
#

yea

unkempt canyonBOT
#

cogs/cards.py lines 80 to 83

r1 = [id for id in piclis if data[id]["rarity"]==1]
r2 = [id for id in piclis if data[id]["rarity"]==2]
r3 = [id for id in piclis if data[id]["rarity"]==3]
r4 = [id for id in piclis if data[id]["rarity"]==4]```
vale wing
#

The whole function is full of list comps

#

Time complexity of this construction is O(4n) but can be made O(n)

shell wing
vale wing
#

I think the load might be because of those unoptimized lists operations, if lists are big enough

vale wing
shell wing
#

cause the ocde example im using and learning is using it

vale wing
#

!pypi pillow

unkempt canyonBOT
shell wing
#

would their be any changes in the code ?

vale wing
#

Yeah

#

Because it is not "easy"

shell wing
#

dam 😭

vale wing
#

It actually isn't hard

shell wing
#
background = Editor(Canvas((900, 300), color="#141414"))
                profile_picture = await load_image_async(str(member.avatar.url))
                profile = Editor(profile_picture).resize((150, 150)).circle_image()

                poppins= Font.poppins(size=40)
                poppins_small = Font.poppins(size=30)

                card_right_shape = [(600, 0), (750, 300), (900, 300), (900, 0)]

                background.polygon(card_right_shape, color="##FFFFFF")
                background.paste(profile, (30, 30))

                background.rectangle((30, 220), width = 650, height = 40, color="#FFFFFF")
                background.bar((30, 220), max_widht=650, height=40, percentage=user_data["percentage"], color="#282828", radius=20)
                background.text((200, 40), user_data["name"], font=poppins, color="#FFFFFF")
                background.rectangle((200, 100), width=350, height=2, fill="#FFFFFF")
                background.text((200, 100),
                                f'Level - {user_data["Level"]} | XP - {user_data["xp"]}/{user_data["next_level_xp"]}',
                                font = poppins_small,
                                color = "#FFFFFF"
                                )
#

the changes in this would be ?

vale wing
#

You need to look at pillow's docs

smoky sinew
#
class CogView(discord.ui.View):
    def __init__(self, *, cogs: Mapping[str, commands.Cog]) -> None:
        self.cog_select = discord.ui.Select(
            custom_id="cog", placeholder="Choose a cog..."
        )

        for cog in cogs:
            self.cog_select.options.append(discord.SelectOption(label=cog[0]))

        self.add_item(self.cog_select)
#

what's wrong with this

fading marlin
#

you've got no super().__init__(...)

smoky sinew
#

thanks

fading marlin
#

:)

slate swan
winged notch
#

I search french dev for an idea

#

Dm me

gusty flax
#

If it is discord.Member

unkempt canyonBOT
#

Hey @signal wraith!

You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.

signal wraith
#

So.. I wanted to create a discord bot that would automatically create a thread when this specific bot sent a message in a specific channel, I asked Chatgpt and went through many errors and finally stopped getting errors, But I think chatgpt is outdated (with 2021 threads) So please help me fix this:
https://paste.pythondiscord.com/qefavowede

smoky sinew
#

i cannot read it like this

signal wraith
#

uh what-

smoky sinew
#

do you know how python indentation works

signal wraith
#

no 😔

wild hearth
#

Are questions about self bots using DISCUM or discord.py-self aloud here?

smoky sinew
#

no

slate swan
wild hearth
#

Unfortunate

#

If anyone has an experience using this and is willing to DM me I would appreciate it.

velvet compass
slate swan
slate swan
#

-mycommand

#

Hi. I'm having an issue getting my bot to get the right params with a class.

class Memery_Bot(commands.Bot):
    def __init__(self):
        self.config = Config("config.json")
        intents = discord.Intents.all()
        super().__init__(command_prefix='m!', intents=intents)
        self.add_command(self.cmd_info)

    def start_bot(self):
        super().run(self.config.token)

    async def on_ready(self):
        print('Bot is ready.')

    async def on_command_error(self, ctx, error):
        print(error)
        if isinstance(error, commands.MissingRequiredArgument):
            await ctx.send(f"Missing required argument: {error.param}")

    @commands.command(name='info')
    async def cmd_info(self, ctx):
        print(ctx)
        await ctx.send(
            f'``Current Criteria:\n\tMaximum clip length: {self.config.max_clip_length}'\
            f'\n\tRequired Upvotes: {self.config.required_upvotes}\n\tRequired Downvotes: {self.config.required_downvotes}``'
        )

    @commands.group(name="configure", invoke_without_command=True)
    @commands.has_permissions(administrator=True)
    async def configure(self, ctx):
        await ctx.send('You have perms.')
    

    async def on_message(self, message):
        ...

        # Otherwise process commands
        await super().process_commands(message)

Command raised an exception: TypeError: Memery_Bot.cmd_info() missing 1 required positional argument: 'ctx'

smoky sinew
#

is it possible to even parent commands to commands.Bot?

slate swan
#

um

#

I thought so?

smoky sinew
#

maybe make a separate cog for the commands

class CoreCog(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

class DiscordBot(commands.Bot):
    async def setup_hook(self):
        await self.add_cog(CoreCog(self))
slate swan
#

do cogs with with on_message though?

smoky sinew
#

yeah they should

slate swan
#

aight will do thx

smoky sinew
#

as long as you use process commands

slate swan
#

yep

#

do discord bots have the same rules as users for emotes within a server or...?

slate swan
smoky sinew
slate swan
#

because since my class is the bot so I call that with CoreCog(super())

#

oh

smoky sinew
slate swan
#

Oh thats one other thing. should I be using super() or self?

smoky sinew
slate swan
#

Ok I will change it throughout the program

stone gate
slate swan
#

should run() still be super()?

smoky sinew
slate swan
#

def start_bot(self):
super().run(self.config.token)

stone gate
smoky sinew
stone gate
#
    async def weight(interaction, weight: int): ```

i get an error at this line, i think its right? but i might be wrong
smoky sinew
#

what is the error?

#

if you're using a cog, you will probably want self as an argument

stone gate
#
    await client.load_extension("commands.admin")
  File "/home/container/.local/lib/python3.10/site-packages/discord/ext/commands/bot.py", line 1013, in load_extension
    await self._load_from_module_spec(spec, name)
  File "/home/container/.local/lib/python3.10/site-packages/discord/ext/commands/bot.py", line 938, in _load_from_module_spec
    raise errors.ExtensionFailed(key, e) from e
discord.ext.commands.errors.ExtensionFailed: Extension 'commands.admin' raised an error: IndentationError: unexpected indent (admin.py, line 19)```
smoky sinew
#

remove the indent then

#

on that line

slate swan
#

your function is indented

#

and decorator is not

#

decide which should be indented or outdented

stone gate
#

aight, let me see

#

now i get this one

discord.ext.commands.errors.ExtensionFailed: Extension 'commands.admin' raised an error: TypeError: parameter 'interaction' is missing a type annotation in callback 'mytag'

smoky sinew
#

what is your code like

stone gate
#

this is the mytag part

smoky sinew
#

huh, is that in a cog or not

stone gate
#

yes, it is

slate swan
#

@smoky sinew thank you very much. Works now and much cleaner with it split into a separate cog

stone gate
#

i removed the "self" argument on the def and it worked lmao

smoky sinew
stone gate
#

it is though

#

and the bot turned on, but it doesnt load any of the commands of that cog

smoky sinew
#

can you show the full code

stone gate
#

yeah sure

#

gimme a sec

smoky sinew
#

yeah you have to indent all of those commands to match the indentation of the class

#

and add self back in

stone gate
#

how should i indent it?

smoky sinew
#

one sec

stone gate
#

thanks

smoky sinew
#

to here

stone gate
#

im assuming that this is just for the async def weight?

#

oh no, its for everything

smoky sinew
#

it's not technically in the class if you don't indent it

slate swan
#

!indent

unkempt canyonBOT
#
Indentation

Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.

Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.

Example

def foo():
    bar = 'baz'  # indented one level
    if bar == 'baz':
        print('ham')  # indented two levels
    return bar  # indented one level

The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.

Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines

More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation

stone gate
sick birch
smoky sinew
sick birch
#

De-dent it one step so it's within the class but not within the the function

smoky sinew
#

the red line is where the code should begin

sick birch
#

All the "async def" and "def"s should be lined up

#

Also should probably use an asynchronous database connector but that's a whole 'nother can of worms

stone gate
#

this is so weird, when i indent it on the editor, the paste page does not read it, and when i indent it on the page it over indents

#

oh i think i got it

#

ok i see what the problem was, thanks

keen niche
#

what library can get timezones and give times?

smoky sinew
keen niche
#

thx

slate swan
#

can you change a tasks time?

#

I currently have

    @tasks.loop(minutes=interval)    

where interval is a class variable of the cog

#

But does that actually do anything if I change it after?

#

guessing not...

#

Is their any way I can change the time of the task loop?

smoky sinew
#

i think it is passed by value, not by reference so if you change the variable nothing will happen

slate swan
#

yea

#

I found it.

keen niche
#

is a discord bot that logs chat against discord TOS? like as long as i dont use it for malicious intent, is it fine with the TOS?

slate swan
#

That's basically one of the most common functions of discord bots

#

to log in case of deleted messages

keen niche
#

yea but they recently changed tos about bots so im not sure if its banned or not

#

just double checking is all

slate swan
#

hum idk then. I would think not

#

At the very least how would they tell

keen niche
#

idk, but they changed some stuff coz of the mee6 drama. cant remember what they changed tho

echo wasp
#

hi, I am trying to use @app_commands.Cooldown but get this error py Traceback (most recent call last): File "C:\Users\grand\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 441, in _run_event await coro(*args, **kwargs) File "E:\My_stuff\Discord bots\everything bot prod\bot.py", line 62, in on_ready await bot.load_extension("cogs.fun") File "C:\Users\grand\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 1013, in load_extension await self._load_from_module_spec(spec, name) File "C:\Users\grand\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 938, in _load_from_module_spec raise errors.ExtensionFailed(key, e) from e discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.fun' raised an error: TypeError: 'Cooldown' object is not callable

smoky sinew
#

you can't use a class as a decorator it's not callable

echo wasp
#

thank you

stone gate
#

does int has a value limit? im trying to use it to store user ids but trying to do it with someone, lets say 477706869704491341 (this isnt their real user id) discord asks me to use a real integer

worthy heart
smoky sinew
#

try it

#

!e ```py
print(999 ** 999)

unkempt canyonBOT
#

@smoky sinew :white_check_mark: Your 3.11 eval job has completed with return code 0.

3680634882592232678947008400605218658383382320373532046559596214370256093004722315301038736145051752186913452575898963911303931894479697716458323821923660765366311320017761759779321786587036607784657658118308278769820141240229486719756781317249580644279499028104989732710307877167814674195241800407343989969529308325089341169459661201767351208231519597795368522900903774525022369908394534167906404561164711397515467500486021892910286409705747626001859502261382445301874892116158640211353120779120188446307803074622052528077377576720943206923731010325174595184975240151201651667241898167663972478241753948020282281600271006239988736674357990730546189068554604883514266113106340234890442918605103523019124266084888074623121265902068304137826645542604112663788666266537557636277965690829317856456008162368911681417749932674881717021721910727310692168816682946256794926961489769998687156714408742064272120567173730996397111689011974404165902265241927828428964154146116881873912320483277389658202659340931
... (truncated - too long)

Full output: https://paste.pythondiscord.com/ugelukidip.txt?noredirect

smoky sinew
#

@stone gate

echo wasp
# smoky sinew you can't use a class as a decorator it's not callable

I tried what you said and got this error py Traceback (most recent call last): File "C:\Users\grand\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 441, in _run_event await coro(*args, **kwargs) File "E:\My_stuff\Discord bots\everything bot prod\bot.py", line 62, in on_ready await bot.load_extension("cogs.fun") File "C:\Users\grand\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 1013, in load_extension await self._load_from_module_spec(spec, name) File "C:\Users\grand\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 938, in _load_from_module_spec raise errors.ExtensionFailed(key, e) from e discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.fun' raised an error: AttributeError: module 'discord.ext.commands' has no attribute 'checks'
code

    @app_commands.command(description= "Beg people to give you coins")
    @app_commands.checks.cooldown(1,45)
    async def beg(self, interaction: discord.Interaction):```
stone gate
#

i actually used str since im not using it for any maths or anything, i just want the UID to match between the user and the database

smoky sinew
stone gate
#

me? ye

echo wasp
smoky sinew
#

it's never going to exceed a few digits

stone gate
unreal geyser
#

I am trying to create a response from the bot that includes buttons. I am taking data from a database and want to display each database row as 1 button. I am able to create the buttons using a for loop in the list created by fetchall() but now how do I attach each newly created button a function.

@bot.command()
async def cancel(ctx):
    sql = 'SELECT * FROM `orders` WHERE USER_ID = ' + '"' + str(ctx.author.id) + '"' + ' AND STATUS = "ORDERED"'
    cursor.execute(sql)
    list = cursor.fetchall()
    
    CancelEmbed = discord.Embed(title="CLICK A NUMBER TO CANCEL!", color=discord.Color.red())
    view = discord.ui.View()
    
    
    for order in list:
        button = discord.ui.Button(label=order["NUMBER"])
        #need to add every new created button a function or some lines of code to run.
        #will work with some api. every number has its own ID and will get info based on the number clicked                  which will send and receive info based on the individual ID.
        view.add_item(button)
        
        await ctx.send(embed=CancelEmbed, view=view)

when playing around with button.callback i could get some results but not what i was looking for. I would get 1 function for all the buttons created.

unreal geyser
#

can someone help?

echo wasp
# smoky sinew can you show your imports
import os
import discord
import time
import datetime
import asyncio
import random
import json
from discord.ext import commands
from discord import app_commands
unreal geyser
#

ive been stuck here 2 days now

unkempt canyonBOT
#

add_item(item)```
Adds an item to the view.

This function returns the class instance to allow for fluent-style chaining.
smoky sinew
#

also as a side-note you should use an async database library

#

oh my bad i didn't see you already had that

unreal geyser
#

I am getting the buttons.

#

with the correct numbers from the database

#

just want to add a function that when i click on a button it sends an api request to the site to actually cancel the site. i have the api code ready. im just stuck at actually implemeting the buttons with functions

smoky sinew
#

you have to add a callback to the function

echo wasp
smoky sinew
#
class PhoneNumberButton(discord.ui.Button):
    def __init__(self, *, number: str) -> None:
        super().__init__(label=number)
        self.number = number
    
    async def callback(self, interaction: discord.Interaction) -> None:
        pass
        # custom logic here

@unreal geyser

unreal geyser
#

how to link that to the buttons? and thanks for the help

smoky sinew
#

you don't "link" it you just replace discord.ui.Button with PhoneNumberButton in your code

unreal geyser
#

oh yeah right thanks. will give it a try right now

smoky sinew
#

and then when it's clicked, the custom logic gets ran and you have access to the number variable

stone gate
#

im

#

SO bad at indentations lmao

#

nvm, i just realized i used both tabs and spaces

plain solstice
#

Nice to meet you. Let me explain: I have an idea for a discord bot/app with AI integrations that would have GREAT potential. I would like to ask you if you are open to becoming a co-founder, in order to create a full-fledged startup! Let me know ! DM opened 🙂

tiny ibex
#

Hey uhm can someone tell me how I can identify consecutive messages

#

Uh I am bad at english but to get the idea

#

The 2 messages I sent above should be identified as just 1 message

#

And yeah you get the idea

smoky sinew
#

you want to get notified when a user posts twice?

tiny ibex
#

UH idk how to explain

smoky sinew
tiny ibex
smoky sinew
#

why

#

and use them where

tiny ibex
#

Cuz I want to I guess

smoky sinew
#

what

sick birch
#

What's the threshold interval between the messages?

tiny ibex
stone gate
#

i get the following error:
discord.app_commands.errors.CommandInvokeError: Command 'industria' raised an exception: NotFound: 404 Not Found (error code: 10062): Unknown interaction

https://paste.pythondiscord.com/mijekeruco this is the command giving the error

sick birch
tiny ibex
#

I am so sorry, I am bad at english

sick birch
smoky sinew
sick birch
#

Yeah but then you have edge cases like, what happens if another user in another server sends a message?

#

And you have to deal with cache sizes too (which is why i asked about the interval)

tiny ibex
smoky sinew
foggy merlin
#

is there a way to get a members default name? member.display_name gives nicknames too

stone gate
tiny ibex
sick birch
foggy merlin
stone gate
sick birch
#
await interaction.defer()
# do something that takes a long time
await interaction.followup.send(...)
stone gate
#

so if i think that:

# Check if the building status is an integer
            if isinstance(building_status, int):
                # Get the current day value from the 'list' sheet
                current_day = self.list_sheet.acell('B1').value
                
                # Subtract the current day value from the building status value
                value = building_status - int(current_day)
                
                # Add the message to the embed
                embed.add_field(name=f'Building {building_id}', value=f'{building_type}\nLevel: {building_level}\nFaltan {value} días para que se construya')
            else:
                # Add the message to the embed
                embed.add_field(name=f'Building {building_id}', value=f'{building_type}\nLevel: {building_level}\nStatus: {building_status}')```

will take too long, i just move it inside the defer?
tiny ibex
#

So... the text message should be like

User 1 :-
Hello

hlfl

kjdxgbrkzd```

```User 2:-
hello

gkhkgr

kgrh```

```yaml
User 1:-
grgb

ebf```



The output should be 
```yaml
User 1 :-
Hello hlfl kjdxgbrkzd

User 2 :-
hello gkhkgr kgrh

User 1 :-
grgb ebf```
#

If this makes any sense

sick birch
tiny ibex
#

The 1 line leave means a new message BTW

stone gate
sick birch
#

See if you can implement caching to speed that up

#

Redis is cool

stone gate
#

something like this?

echo wasp
#

hi, I am getting this error when having amount described and is in the async def

echo wasp
naive briar
#

Type hint

smoky sinew
#

you used equals instead of a semicolon

#

that's the wrong syntax

naive briar
#

Basic Python

echo wasp
#

fun.. Why did vscode not catch it?

uneven hearth
#

is it possible to have an argument that contains a list of all the server members who are having a certain role? exactly like discord.member, just presents only those who have a certain role

smoky sinew
naive briar
#

It's not an error that it would know

echo wasp
#

how do I make a value default to one if not specified in app_commands?

smoky sinew
#

equals..

echo wasp
naive briar
#

Yes?

smoky sinew
#

sure

ionic garden
#

are view button rows 0-indexed or 1-indexed

smoky sinew
#

but it would be Optional[int]

smoky sinew
ionic garden
#

kk

echo wasp
naive briar
smoky sinew
#

you annotate it as Optional[int]

naive briar
#

Why

#

Not like it's gonna be none

smoky sinew
#

things with defaults always get typed as Optional

#

actually nvm

#

since it's not none

ionic garden
#

however, the "exit" button always appears in the front

#

and i can't set the column of a button...

naive briar
#

What

#

That's the whole class?

#

Of course, it will only appear on the first row

ionic garden
#

when i inherit it & add some buttons, this is what happens
i want it to be on the right instead of on the left
is this possible?

naive briar
#

Define it after buttons that you want it to be behind

ionic garden
#

there's the problem

#

it's in an inherited class because i have like 10 other views with this exit button

naive briar
#

What

sick birch
ionic garden
#

how so?

sick birch
#

Maybe create a helper function that takes any view and just appends the "Exit" button to the back

ionic garden
#

i also have an interaction_check that's the same across every view

sick birch
#

You might also be able to call super().__init__ of your child class after you've added all the buttons

#
class ChildView(AdventureTemplate):
  def __init__(...):
    self.add_item(...)
    super().__init__(...)
#

Just take a guess here, not 100% sure if that'd work

ionic garden
#

maybe have a function that you set w/ setattr but

#

that seems very scuffed

echo wasp
#

How do I check for permission in app_commands?

echo wasp
echo wasp
echo wasp
vale wing
#

Pretty sure all command errors are in discord.ext.commands

#

However you use discord.app_commands

echo wasp
#

yes becasue i'm migrating

#
@purge.error
    async def sendback(self, interaction: discord.Interaction, error: app_commands.CommandError):
        if isinstance(error, commands.MissingPermissions):  
          await interaction.response.send_message(f"{ctx.author.mention}You do not have permissions to do this command.")
vale wing
#

Yeah it is commands.CommandError assuming you have commands imported

vale wing
#

Not the app_commands

echo wasp
#

ok

flat basin
#

i am new to python and have made a battleship game but am getting errors

#

can someone please help me if i send them the code?

#

wrong chat sorry

vocal hazel
#

I have my bot hosted on a digital ocean droplet and have for awhile, just wondering what I'm able to implement to allow me to see error codes for the bot so that I can debug when something goes wrong? Would a remote IDE connected to the server help with this?

echo wasp
vocal hazel
echo wasp
smoky sinew
#

using the logging module

vocal hazel
vocal hazel
echo wasp
#

stupid question but I want to use commands.MinimalHelpCommand in slash commands how would I do that I know of the way to use the prefix for it but not using slash commands.

echo mural
#

!d discord

unkempt canyonBOT
#

In order to work with the library and the Discord API in general, we must first create a Discord Bot account.

Creating a Bot account is a pretty straightforward process.

karmic nimbus
#

how do i add changed by <who> in on_member_update?

shrewd apex
echo mural
#

How can I learn to make complex bots?

worthy heart
prime gull
worthy heart
#

is it possible to make a purge command within slash command?

prime gull
#

you can create your own check to compare purged messages

glossy edge
quick nebula
#

how can i download numpy and pandas
i use them for my discord bot
to use bot i need to install them

quick nebula
naive briar
#

Termux have a package for numpy

#

Run pkg install python-numpy to install it

shrewd fjord
unkempt canyonBOT
#

discord.on_member_update(before, after)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member") updates their profile.

This is called when one or more of the following things change...
shrewd fjord
#

It takes before and after

#

before is the Member object with its previous properties (before updating something) and after is the after properties (after updating something) both will return Member object

#

!d discord.Member

unkempt canyonBOT
#

class discord.Member```
Represents a Discord member to a [`Guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild "discord.Guild").

This implements a lot of the functionality of [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User").

x == y Checks if two members are equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User") instances too.

x != y Checks if two members are not equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User") instances too.

hash(x) Returns the member’s hash.

str(x) Returns the member’s name with the discriminator.
karmic nimbus
uneven hearth
#

is it possible to have an argument that contains a list of all the server members who are having a certain role? exactly like discord.member, just presents only those who have a certain role

modest pond
#

i tried ctx.target.delete and shows the same error but the code works if do some normal send am i using delete in a wrong way here

#

what i am doing to get into the if statement is get the mention in the embed get the id on it and check if the person is the same person as the one who run the message command

#

that part works but the delete or edit doesnt

vale wing
# echo mural How can I learn to make complex bots?

You can look at my template, it contains useful tools for development of "complex" bots using disnake and postgres database https://github.com/Exenifix/disnake-bot-template-postgres

GitHub

A template for speeding up development of discord bots using disnake and postgresql - GitHub - Exenifix/disnake-bot-template-postgres: A template for speeding up development of discord bots using d...

shrewd fjord
glad cradle
vale wing
#

I mean if that's just your opinion well it's your opinion, but if there really are some objective things that could be changed for better I can take that into consideration

naive briar
#

What

vale wing
#

Variable store plugin is something from 2050s

#

Oh I just leaked I am a time traveller

#

Well happens

#

Anyways perhaps you mean a database?

glad cradle
modest pond
#

you can go for mysql.connector sqlite

#

depends

vale wing
#

You need to learn SQL (it's easy) and then use one of databases. Personally I recommend sqlite and postgres, latter is harder to setup but more feature-rich

winged coral
#

bot is normally in root since it's effectively main.py

#

having your entrypoint file is fine but it's normally in the same directory as your more abstract entry

slate swan
#

i agree to disagree, if you're talking about a bot instance, yeah it should preferably be in the main file, but having a bot class ( especially one that has highly been modified through subclass) should be in a folder where you keep your objects/other utils

vale wing
#

And that's pretty common practice isn't it

#

For python

slate swan
#

same

shrewd fjord
vale wing
#

Bobux bot developers meeting

sick birch
#

Me when

#

When the uhhh

#

bobux

cloud dawn
#

It highly depends on where tot store certain files since everything in one root quickly becomes a lot if you're going to use docker

left dew
#

im trying to log invites and get an error with this code:
discord.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions
Code:

  guild = bot.get_guild(GUILD_ID)
  for guild in bot.guilds:
    invites[guild.id] = await guild.invites()
def find_invite_by_code(invite_list, code):
  for inv in invite_list:     
      if inv.code == code:      
        return inv```
#

seems that the error is coming from here invites[guild.id] = await guild.invites()

slate swan
#

You must have manage_guild to get this information.

#

Your bot is probably missing that permission.

left dew
#

oh is that something i have to edit within the application?

slate swan
#

No, just grant your bot the permissions it needs in your server's role settings.

left dew
#

oh

#

it has admin

slate swan
#

if so could be your issue.

#

It's quoted from the discord.py docs, it is referring to the bot's permissions, I should have made that more clear.

cloud dawn
left dew
#

huh

#

i figured out the problem

slate swan
#

how can I loop through all the posts in a forum channel?

tired pollen
unkempt canyonBOT
stone gate
#

How do i create command categories?

graceful ermine
#

Hey

#

How could I add reactions to embed?

#

@bot.slash_command(name="training", description="request a training!") 
async def training(interaction: nextcord.Interaction, training: str = SlashOption(name="training", choices={"Hopeful: Induction Ceremony": "Hopeful: Induction Ceremony", "Initiate: Combat Instruction": "Initiate: Combat Instruction", "Neophyte: Lore Instruction ": "Neophyte: Lore Instruction", "Acolyte I: Disciplinary Assessment": "Acolyte I: Disciplinary Assessment", "Acolyte I: The Bloodletting": "Acolyte I: The Bloodletting", "Acolyte II: Lore Recitation": "Acolyte II: Lore Recitation", "Acolyte II: The Gathering": "Acolyte II: The Gathering", "Acolyte III: Advanced Tactics": "Acolyte III: Advanced Tactics", "Acolyte III: The Proving": "Acolyte III: The Proving"})):
    embed = nextcord.Embed(title="Training request!",
                          description=f"Training: {training}",
                          colour=nextcord.Colour.green())
    embed.add_field(name="by", value=interaction.user)
    embed.set_thumbnail(url='https://cdn.discordapp.com/attachments/1086053799845703741/1086057416195579954/TSE_DarkCouncil.png')
    
    # Send the message and add a reaction
    message = await interaction.response.send_message(embed=embed)
    await message.add_reaction('👍')
#

I get an error when I add a reaction

#
Ignoring exception in command <nextcord.application_command.SlashApplicationCommand object at 0x0000022221D83890>:
Traceback (most recent call last):
  File "C:\Users\berka\AppData\Local\Programs\Python\Python311\Lib\site-packages\nextcord\application_command.py", line 890, in invoke_callback_with_hooks
    await self(interaction, *args, **kwargs)
  File "C:\Users\berka\Desktop\customer 2\main.py", line 33, in training
    await message.add_reaction('👍')
          ^^^^^^^^^^^^^^^^^^^^
AttributeError: 'PartialInteractionMessage' object has no attribute 'add_reaction'

The above exception was the direct cause of the following exception:

nextcord.errors.ApplicationInvokeError: Command raised an exception: AttributeError: 'PartialInteractionMessage' object has no attribute 'add_reaction'```
fading marlin
#

send_message doesn't return the whole message that was sent. You have to fetch the original message and add the reaction that way

graceful ermine
#

@fading marlin

fading marlin
#

I already got pinged when you replied... no need to tag me again

fading marlin
#

Looking at nextcords documentation, you can fetch the message from the partialmessage you received

graceful ermine
fading marlin
#

That is the fetch function

graceful ermine
#

I know but in my VScode it says I need to define it

fading marlin
#

You're calling message.fetch(), right?

graceful ermine