#discord-bots

1 messages Β· Page 156 of 1

shrewd fjord
#

;-;

#

happy ending

severe mural
#

yeah 1 hour search google and youtube nothing solution sigh.

shrewd fjord
#

sedge

severe mural
#

@shrewd fjord oh sorry final last example "delete" error

#

think is await interaction.response.send_delete?

#

example maybe.

severe mural
#

await interaction.delete() found maybe is "await interaction.delete()"?

shrewd fjord
#

what thing u want to delete?

#

message or what

severe mural
#

discord.app_commands.errors.CommandInvokeError: Command 'update-manager-channel-testing' raised an exception: AttributeError: 'NoneType' object has no attribute 'delete'

#

think is "await interaction.delete()"?

shrewd fjord
#

await interaction.reponse.send_message(...,delete_after=15)

severe mural
#

hmm ok moment think.

severe mural
shrewd fjord
severe mural
#

await interaction.response.send_message("Update Success βœ…" (delete_after=15))

shrewd fjord
#

final

severe mural
#

maybe?

shrewd fjord
#

await interaction.response.send_message("Update Success βœ…",delete_after=15)

severe mural
#

ah i see learn ok.

#

ok.

shrewd fjord
#

!d discord.InteractionResponse.send_message

unkempt canyonBOT
#

await send_message(content=None, *, embed=..., embeds=..., file=..., files=..., view=..., tts=False, ephemeral=False, allowed_mentions=..., suppress_embeds=False, delete_after=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Responds to this interaction by sending a message.
severe mural
shrewd fjord
#

@severe mural

severe mural
#

@shrewd fjord uhh error

#

discord.app_commands.errors.CommandInvokeError: Command 'update-manager-channel-testing' raised an exception: InteractionResponded: This interaction has already been responded to before

slate swan
#

you can't respond more than once

shrewd fjord
unkempt canyonBOT
#
Certainly not.

No documentation found for the requested symbol.

shrewd fjord
#

......

severe mural
#

Yeah moment...

shrewd fjord
#

ok whatever u need to use followup to send another msg

severe mural
#

give again code once.

#

is final rest ok

severe mural
shrewd fjord
#

!d discord.Interaction.followup

unkempt canyonBOT
shrewd fjord
#

oh now makes sense aight

severe mural
#
@discord.app_commands.checks.has_role("Channels Manager")
async def update_manager_channel(interaction, suggest: discord.TextChannel, giveaway: discord.TextChannel, role: discord.Role):
    settingMessage = await interaction.response.send_message("Updating channels....πŸ”„")

    cur.execute("SELECT * FROM x WHERE x = %s",
                (str(interaction.guild.id),))
    exist_channels = cur.fetchone()
    await asyncio.sleep(1)
    print(exist_channels)

    if not exist_channels == None:
        cur.execute("UPDATE x SET x = %s, x = %s, x = %s WHERE x = %s",
                    (suggest.id, giveaway.id, role.id, interaction.guild.id))
    else:
        cur.execute("INSERT INTO x (x , x , x , x ) VALUES(%s, %s, %s, %s)", (str(
            suggest.id), str(giveaway.id), str(role.id), str(interaction.guild.id)))

    con.commit()

    #await settingMessage.delete()
    settingMessage = await interaction.response.send_message("Update Success βœ…",delete_after=15)
    #await asyncio.sleep(15)
    #await successMessage.delete()```
severe mural
shrewd fjord
#

settingMessage = await interaction.response.send_message("Update Success βœ…",delete_after=15)
To
await interaction.followup.send("Update Success βœ…",delete_after=15)

#

or u can use
await interaction.response.edit_message(content="Update Success βœ…",delete_after=15)

#

if this throws up any error use followup

severe mural
#

Correct!

#

and error discord.app_commands.errors.CommandInvokeError: Command 'update-manager-channel-testing' raised an exception: TypeError: send() got an unexpected keyword argument 'delete_after'

polar dawn
#

Hi. How do I load a cog that contains slash commands in it located in a folder named cogs?
I always get this error:

   await self.add_cog(cogs.Slash(self))
NameError: name 'cogs' is not defined

Here's what I tried:

def __init__(self) -> None:
        super().__init__(command_prefix=get_prefix, intents=intents, case_insensitive=True, help_command=None)
        
    async def setup_hook(self) -> None:
        await self.add_cog(cogs.Slash(self))
        self.tree.copy_global_to(guild=discord.Object(id=id))
        await self.tree.sync()
severe mural
shrewd fjord
shrewd fjord
severe mural
#

sorry think...

#

settingMessage = await interaction.followup.send("Update Success βœ…",edit_message())

naive briar
unkempt canyonBOT
#

await load_extension(name, *, package=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Loads an extension.

An extension is a python module that contains commands, cogs, or listeners.

An extension must have a global function, `setup` defined as the entry point on what to do when the extension is loaded. This entry point must have a single argument, the `bot`.

Changed in version 2.0: This method is now a [coroutine](https://docs.python.org/3/glossary.html#term-coroutine "(in Python v3.11)").
severe mural
#

maybe my bad haha

severe mural
severe mural
#

is correct??

severe mural
#

ahh

polar dawn
severe mural
#

Ok done testing.

naive briar
shrewd fjord
#

!d discord.InteractionResponse.edit_message

unkempt canyonBOT
#

await edit_message(*, content=..., embed=..., embeds=..., attachments=..., view=..., allowed_mentions=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Responds to this interaction by editing the original message of a component or modal interaction.
naive briar
#

If you loaded it, it will be registered

shrewd fjord
#

wait edit_message doesnt have delete_after xddd

severe mural
#

OH

polar dawn
severe mural
#

damn..

shrewd fjord
#

settingMessage = await interaction.response.send_message("Update Success βœ…",delete_after=15)
To
await interaction.channel.send("Update Success βœ…",delete_after=15)

severe mural
severe mural
#

oh remove settingMessage ?

#

correct?

shrewd fjord
severe mural
#

ok

shrewd fjord
#

await interaction.channel.send("Update Success βœ…",delete_after=15)

#

this has to be work xd

severe mural
#

@shrewd fjord

#

yeah but no have edit.. and remove..

naive briar
#

!d discord.Interaction.edit_original_response

unkempt canyonBOT
#

await edit_original_response(*, content=..., embeds=..., embed=..., attachments=..., view=..., allowed_mentions=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Edits the original interaction response message.

This is a lower level interface to [`InteractionMessage.edit()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.InteractionMessage.edit "discord.InteractionMessage.edit") in case you do not want to fetch the message and save an HTTP request.

This method is also the only way to edit the original message if the message sent was ephemeral.
severe mural
severe mural
#

confuse keke

shrewd fjord
severe mural
shrewd fjord
severe mural
#

@naive briar sorry is error.

naive briar
severe mural
naive briar
severe mural
shrewd fjord
#

message = await interaction.original_response()
await message.edit(content="blah blah")
await message.delete(delay=15)

#

now u can do whatever u want

naive briar
shrewd fjord
#

!d discord.Interaction.original_response

unkempt canyonBOT
#

await original_response()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Fetches the original interaction response message associated with the interaction.

If the interaction response was a newly created message (i.e. through [`InteractionResponse.send_message()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.InteractionResponse.send_message "discord.InteractionResponse.send_message") or [`InteractionResponse.defer()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.InteractionResponse.defer "discord.InteractionResponse.defer"), where `thinking` is `True`) then this returns the message that was sent using that response. Otherwise, this returns the message that triggered the interaction (i.e. through a component).

Repeated calls to this will return a cached value.
shrewd fjord
#

ig both works πŸ˜‚

shrewd fjord
severe mural
#

same delete_after"

#

sigh.

shrewd fjord
naive briar
unkempt canyonBOT
#

Please provide the full traceback for your exception in order to help us identify your issue.
While the last line of the error message tells us what kind of error you got,
the full traceback will tell us which line, and other critical information to solve your problem.
Please avoid screenshots so we can copy and paste parts of the message.

A full traceback could look like:

Traceback (most recent call last):
  File "my_file.py", line 5, in <module>
    add_three("6")
  File "my_file.py", line 2, in add_three
    a = num + 3
        ~~~~^~~
TypeError: can only concatenate str (not "int") to str

If the traceback is long, use our pastebin.

severe mural
#

await interaction.original_response("Update Success βœ…")
await message.edit()
await asyncio.sleep(15)
await message.delete()

#

probably idea

#

KEKW think error.

naive briar
#

It doesn't take arguments

severe mural
naive briar
#

Put your things that you want to edit in the edit meth

shrewd fjord
#

just copy paste it my guy

naive briar
#

Just read maybe

severe mural
#

where is code?

shrewd fjord
#

i mean not fully copy paste xd

#

copy paste is always bad

shrewd fjord
polar dawn
severe mural
shrewd fjord
severe mural
# shrewd fjord nice ig

nope discord.app_commands.errors.CommandInvokeError: Command 'update-manager-channel-testing' raised an exception: TypeError: edit() takes 1 positional argument but 2 were given

naive briar
#

Anyways, spoonfeeding doesn't help anyone

severe mural
shrewd fjord
#

edited again check

severe mural
#

spooky good.

shrewd fjord
severe mural
severe mural
shrewd fjord
#

nice

severe mural
#

done exist!

shrewd fjord
severe mural
#

i see "content="..."

naive briar
#

You wouldn't learn to solve your own problems by copy pasting

shrewd fjord
#

u gotta understand ur self

severe mural
#

yeah okay ya done

#

thanks. no prooblem. check investigate idea and learn.

#

you rest spooky nd catgal.

shrewd fjord
#

always check the docs related to ur problem

severe mural
#

okay.

shrewd fjord
#

;-;

severe mural
#

t:t

#

i see maybe is "interaction.author" @naive briar ?

naive briar
#

!d discord.Interaction.user

unkempt canyonBOT
severe mural
#

ohh

#

correct?

shrewd fjord
severe mural
#

ahh

#

ok!

#

AttributeError: 'Member' object has no attribute 'avatar_url'

#

hmmm there is "text=f"BY: {interaction.user} - ID: {interaction.user.id}", icon_url=interaction.user.avatar_url)"

#

"async def suggestion(interaction, message: str):"

naive briar
#

!d discord.User.avatar

unkempt canyonBOT
#

property avatar```
Returns an [`Asset`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Asset "discord.Asset") for the avatar the user has.

If the user does not have a traditional avatar, `None` is returned. If you want the avatar that a user has displayed, consider [`display_avatar`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User.display_avatar "discord.User.display_avatar").
naive briar
#

!d discord.Asset.url

unkempt canyonBOT
severe mural
shrewd fjord
severe mural
severe mural
#

is correct but error confuse.

shrewd fjord
#

avatar_url is before v2.0

severe mural
#

uhh but not "avatar_url?

#

ahh.

shrewd fjord
#

it has changed to avatar now

naive briar
severe mural
#

ok thx

#

await message2.delete(delay=30)
AttributeError: 'NoneType' object has no attribute 'delete'

#

do not understand but my alredy same before

#

hmmm!

shrewd fjord
#

catglal u tell ;-;

naive briar
#

response.send_message doesn't return the sent message

shrewd fjord
#

use original_response()

severe mural
#

hh

shrewd fjord
#

to delete it

severe mural
#

ahh i see not response, important "original"?

#

ahh i see.

#

@shrewd fjord @naive briar think example first: response.send_message later other all any original_response()

#

is correct?

shrewd fjord
#

then catch the message ussing original_response()

#

then delete it

severe mural
#

i see.

#

and error lol

shrewd fjord
#

first send the message

#

await interaction.response.send_message("your message")

#

then catch it with message2 variable

#

like earlier time

#

message2=interaction.original_response()

#

kind of like that

severe mural
#

hmm

#

yes correct there andd... ah i see moment check

#

is okay all hmm

shrewd fjord
#

;-;

severe mural
#

werid hmm

#

look there is other: message = await suggest_channel.send(embed=imgembed)

#

"suggest_channel = await client.fetch_channel(str(exist_channels[1]))"

shrewd fjord
#

hm?

shrewd fjord
#

and then convert exist_channels to int

severe mural
shrewd fjord
#

just telling xd

severe mural
shrewd fjord
slate swan
#
@bot.event
async def on_ready():
    print(f"{bot.user.name} is online!")
    setattr(bot, "db", await aiosqlite.connect("main.db"))
    async with bot.db.cursor() as cursor:
        await cursor.execute("CREATE TABLE IF NOT EXISTS bank (wallet INTEGER, bank INTEGER, maxbank INTEGER, user INTEGER)")

async def create_balance(user):
    async with bot.db.cursor() as cursor:
        await cursor.execute("INSERT INTO bank VALUES (?, ?, ?, ?)", (0, 100, 2736652635562362, user.id,))
    await bot.db.commit()
    return

async def get_balance(user):
    async with bot.db.cursor() as cursor:
        await cursor.execute("SELECT wallet, bank, maxbank FROM bank WHERE user = ?", (user.id,))
        data = await cursor.fetchone()
        if data is None:
            await create_balance(user)
            return 0, 100, 2736652635562362
        wallet, bank, maxbank = data[0], data[1], data[2]
        return wallet, bank, maxbank


async def update_wallet(user, amount: int):
    async with bot.db.cursor() as cursor:
        await cursor.execute("SELECT wallet FROM bank WHERE user = ?", (user.id,))
        data = await cursor.fetchone()
        if data is None:
            await create_balance(user)
            return 0
        await cursor.execute("UPDATE bank SET wallet = ? WHERE user = ?", (data[0] + amount, user.id,))
    await bot.db.commit()

@bot.command(aliases=['bal'])
async def balance(ctx, member: nextcord.Member = None):
    if not member:
        member = ctx.author
        wallet, bank, maxbank = await get_balance(member)
        em = nextcord.Embed(title=f"{member.name}#{member.discriminator}'s Balance")
        em.add_field(name="Wallet", value=wallet)
        em.add_field(name="Bank", value=f"{bank}/{maxbank}")
        await ctx.send(embed=em)

error:

shrewd fjord
#

read error

slate swan
#

i did but there is

#

await cursor.execute("CREATE TABLE IF NOT EXISTS bank (wallet INTEGER, bank INTEGER, maxbank INTEGER, user INTEGER)")

shrewd fjord
#

u sure?

slate swan
#

uhhh when u ask that so not rlly '

shrewd fjord
#

hmm cool

slate swan
#

oh okay

severe mural
#
    await message.delete(delay=30)
    await message.add_reaction("βœ…")
    await message.add_reaction("❌")

    is_cancelleds = False

    message2 = await interaction.original_response(f"{interaction.user.mention}, your suggestion has been successfully submitted! Check <#{exist_channels[1]}>")
    if is_cancelleds == True:
        return
    await message2.delete(delay=30)```
shrewd fjord
severe mural
#

hmhm think confuse sigh.

severe mural
#

have tthink steal code KEKW

shrewd fjord
#

await interaction.response.send_message(f"{interaction.user.mention}, your suggestion has been successfully submitted! Check <#{exist_channels[1]}>")
message2=await interaction.original_response()

#

see not that hard

severe mural
#

oh

#

important not message2 remove

#

and down one yes?

#

hmm i see.

#

Correct?

shrewd fjord
severe mural
shrewd fjord
#

check

severe mural
#

ok

#

@shrewd fjord thanks

#

okay finish rest next soon help, okay my sleep.

#

thx.

shrewd fjord
#

;-; c ya

severe mural
#

n.n

limpid hemlock
#

Hi Guys I am currently working on a Discord bot that is communicating with an AI.
After running main.py I am getting redirected in an inkognito browser but always receive an error:

E:\XXX\DiscordBot\XXX>python3 main.py
Traceback (most recent call last):
File "E:\XXX\DiscordBot\XXX\main.py", line 1, in <module>
from src import bot
File "E:\XXX\DiscordBot\XXX\src\bot.py", line 3, in <module>
from src import responses
File "E:\XXX\DiscordBot\XXX\src\responses.py", line 32, in <module>
chatbot = Chatbot(config, conversation_id=None)
File "C:\Users\XXX\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\revChatGPT\revChatGPT.py", line 112, in init
self.refresh_session()
File "C:\Users\XXX\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\revChatGPT\revChatGPT.py", line 358, in refresh_session
raise ValueError(
ValueError: No session_token, email and password or Authorization provided

could someone assist me with that? πŸ™‚

shrewd fjord
#

No session_token, email and password or Authorization provided

#

provide this informations

tropic estuary
#

can anyone help me make database for a bot

shrewd fjord
limpid hemlock
#

config.json
{
"discord_bot_token":"XXX",
"session_token": ""
}

tropic estuary
#

and store image on it

shrewd fjord
#

btw my new id

tropic estuary
shrewd fjord
tropic estuary
shrewd fjord
shrewd fjord
#

!pip revChatGPT

unkempt canyonBOT
tropic estuary
#

or something else

#

ncm

#

nvm

shrewd fjord
silent ermine
#

So for datetime , when doing <t:β€”β€”β€”β€”> or what ever it is, I put the datetime as utc

#

So in utc is says in 5 minutes but for me (est) it would say like in 5 hours

#

Any way to just make it say it’s in 5 minutes for any time zone?

#

And I have another question, my embed formatting is perfect on computer but it is screwed up on mobile

naive briar
#

Try in UTC

silent ermine
naive briar
#

<t:1671106902:R>

#

Does that say in 4 minutes

silent ermine
#

Yes

naive briar
#

!d discord.utils.utcnow

unkempt canyonBOT
#

discord.utils.utcnow()```
A helper function to return an aware UTC datetime representing the current time.

This should be preferred to [`datetime.datetime.utcnow()`](https://docs.python.org/3/library/datetime.html#datetime.datetime.utcnow "(in Python v3.11)") since it is an aware datetime, compared to the naive datetime in the standard library.

New in version 2.0.
naive briar
#

Try that

silent ermine
#

Well I can’t use that because I set the datetime value or the user sets it

naive briar
silent ermine
#

So like the bot takes date and time and converts that

#

The timing is correct for utc just the datetime for others like etc is kinda wrong

naive briar
#

!d datetime.datetime.astimezone

unkempt canyonBOT
#

datetime.astimezone(tz=None)```
Return a [`datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "datetime.datetime") object with new [`tzinfo`](https://docs.python.org/3/library/datetime.html#datetime.datetime.tzinfo "datetime.datetime.tzinfo") attribute *tz*, adjusting the date and time data so the result is the same UTC time as *self*, but in *tz*’s local time.

If provided, *tz* must be an instance of a [`tzinfo`](https://docs.python.org/3/library/datetime.html#datetime.tzinfo "datetime.tzinfo") subclass, and its [`utcoffset()`](https://docs.python.org/3/library/datetime.html#datetime.datetime.utcoffset "datetime.datetime.utcoffset") and [`dst()`](https://docs.python.org/3/library/datetime.html#datetime.datetime.dst "datetime.datetime.dst") methods must not return `None`. If *self* is naive, it is presumed to represent time in the system timezone.

If called without arguments (or with `tz=None`) the system local timezone is assumed for the target timezone. The `.tzinfo` attribute of the converted datetime instance will be set to an instance of [`timezone`](https://docs.python.org/3/library/datetime.html#datetime.timezone "datetime.timezone") with the zone name and offset obtained from the OS.
silent ermine
# unkempt canyon

So if let’s say the datetime for utc is 16726263663 (not real)

#

Lets say that’s in 8 minutes for utc

#

If I use that , will it say in 8 minutes for est?

naive briar
#

You wouldn't know without experimenting

silent ermine
naive briar
#

!d datetime.timezone.utc

unkempt canyonBOT
upbeat otter
#

Reasons I never made a video is because it's just too much of an effort πŸ˜” and I'm ass lazy

#

a gist is easier to make πŸ’€

rare echo
tropic estuary
gusty shard
#

message1

gusty shard
#

how can get the info of message that replied message1

#

or the info of message that message2 replied to

rare echo
#

!d discord.ext.commands.Bot.wait_for

unkempt canyonBOT
#

wait_for(event, /, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Waits for a WebSocket event to be dispatched.

This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.

The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.11)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.11)") for you in case of timeout and is provided for ease of use.

In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.11)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/latest/api.html#discord-api-events) for a list of events and their parameters.

This function returns the **first event that meets the requirements**...
rare echo
#

third times the charm

gusty shard
#

sorry i didnt get it

#

im pretty new to this stuff

rare echo
#

basically bot.wait_for('message', check=?) will wait for the user presumably the author which you add to a check, to send a message which you can take in through something like
msg2 = bot.wait_for...
then ms2.content would be the user response

slate swan
#

Do you have a ready main file?

slate swan
#

import discord
from discord.ext import commands

bot = commands.Bot(command_prefix='')

@bot.event
async def on_message(message):
if message.content.lower() == "bigger":
await message.channel.send("Please don't say that")

bot.run('token')

Why is this simple code not working at all?

vocal snow
#

!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.

slate swan
#

Why did they make it more complicated than it used to be?

vocal snow
#

who is "they"

slate swan
#

Whoever makes this

rare echo
#

lol

vocal snow
#

what is "this"

slate swan
#

Didn't the stuff i wrote used to work?

vocal snow
slate swan
#

Not sure

vocal snow
slate swan
#
intents = discord.Intents.default()
intents.messages = True

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

@bot.event
async def on_message(message):
    # only respond to messages that are not from the bot itself
    if message.author == bot.user:
        return

    if message.content.lower() == "bigger":
        await message.channel.send("Please don't say that")
#

Its still wrong?

#

I think you might be after message_content, not messages

#

intents.message_content = True
AttributeError: 'Intents' object has no attribute 'message_content'

vocal snow
slate swan
#

Man i messed my entire python up trying to install stable diffusion

#

Its all out of order now and outdated

#

It works now. Thanks

lucid latch
#
##Button###
class Button(discord.ui.View):
    @discord.ui.button(label="▢️", style=discord.ButtonStyle.green)
    async def resume_button(self, button, interaction: discord.Interaction): 
        global is_playing
        bot.voice_clients[0].resume()
        is_playing = True
    @discord.ui.button(label="πŸ›‘", style=discord.ButtonStyle.red)
    async def pause_button(self, button, interaction: discord.Interaction):
        global is_playing
        bot.voice_clients[0].pause()
        is_playing = False
    @discord.ui.button(label="⏭️", style=discord.ButtonStyle.blurple)
    async def skip_button(self, button, interaction: discord.Interaction):
        global queue
        if bot.voice_clients[0].is_playing():
            if len(queue) > 1:
                bot.voice_clients[0].stop()
                try:
                    await music()
                except:
                    pass
                
        if bot.voice_clients[0].is_paused():
            if len(queue) > 1:
                bot.voice_clients[0].stop()
                del queue[0]
                try:
                    await music()
                except:
                    pass```
#

when i press the btn, it says interaction failed but it works

vocal snow
lucid latch
#

yhea..

#

how can i respond to interaction??

#

i don't know how to 😦

full marten
#

is there something wrong with this command?

vocal snow
full marten
#
import discord
from discord.ext import commands
from discord import app_commands


class TicTacToeButtons(discord.ui.View):
    def __init__(self, *, timeout=180):
        super().__init__(timeout=timeout)

    @discord.ui.button(label="", style=discord.ButtonStyle.gray, emoji='<1052937074015211610>')
    async def my_button(self, interaction:discord.Interaction, button:discord.ui.Button):
        await interaction.response.send_message(content=f"You clicked me!!")


class TicTacToe(commands.Cog):
    def __init__(self, bot: commands.Bot):
        self.bot = bot
    
    @commands.Cog.listener()
    async def on_ready(self):
        print('TicTacToe.py is ready!')

    @app_commands.command(name='tic-tac-toe', description='Play Tic-Tac-Toe Game!')
    async def click(self, interaction: discord.Interaction):
        await interaction.response.send_message('Message with a Button', view=TicTacToeButtons())


async def setup(bot: commands.Bot):
    await bot.add_cog(TicTacToe(bot))```
vocal snow
unkempt canyonBOT
#

class discord.InteractionResponse```
Represents a Discord interaction response.

This type can be accessed through [`Interaction.response`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.Interaction.response "discord.Interaction.response").

New in version 2.0.
naive briar
#

What's the problem

#

Not just ask what's wrong with the code

full marten
#

the application doesn't respond

naive briar
#

Which one

#

Slash or button

full marten
#

consequently, button doesn't work to

naive briar
#

Did you get any exceptions

full marten
#

@naive briar

naive briar
#

This isn't valid format

#

And consider setting up logging if you don't have one or not running by bot.run

lucid latch
full marten
lucid latch
#

like this sir?

full marten
#

i don't understand the formats in the docs

rare echo
full marten
rare echo
#

name = emoji name

#

id = emoji id

#

or you can use (windows key + .) windows emojis

#

so <:emoji_name:emojiid>

naive briar
#

Probably

full marten
#

i understand now dude

#

thanks you

full marten
full marten
rare echo
upbeat otter
full marten
upbeat otter
#

No, that was genuine

full marten
#

I getting this error now

#

but i think if i what can it be

vale wing
uneven apex
#

can we have a custom event for a discord bot?
what im trying to do is make a user pay on my website and then according to the amount paid; give them a role in my server

full marten
#

i getting the same error now

#

"The application did not respond"

vale wing
uneven apex
rocky rain
#

What happened to help-cherries or any help- for that matter?

full marten
#

My command

vale wing
#

I typically embed API into bot

full marten
#
import discord
from discord.ext import commands
from discord import app_commands


class TicTacToeButtons(discord.ui.View):
    def __init__(self, *, timeout=180):
        super().__init__(timeout=timeout)

    @discord.ui.button(label="", style=discord.ButtonStyle.gray, emoji=':heavy_minus_sign:')
    async def my_button(self, interaction:discord.Interaction, button:discord.ui.Button):
        await interaction.response.send_message(content=f"You clicked me!!")


class TicTacToe(commands.Cog):
    def __init__(self, bot: commands.Bot):
        self.bot = bot
    
    @commands.Cog.listener()
    async def on_ready(self):
        print('TicTacToe.py is ready!')

    @app_commands.command(name='tic-tac-toe', description='Play Tic-Tac-Toe Game!')
    async def click(self, interaction: discord.Interaction):
        await interaction.response.send_message('Message with a Button', view=TicTacToeButtons())


async def setup(bot: commands.Bot):
    await bot.add_cog(TicTacToe(bot))```
uneven apex
naive briar
#

Can you send the error from your terminal or something

#

!traceback

unkempt canyonBOT
#

Please provide the full traceback for your exception in order to help us identify your issue.
While the last line of the error message tells us what kind of error you got,
the full traceback will tell us which line, and other critical information to solve your problem.
Please avoid screenshots so we can copy and paste parts of the message.

A full traceback could look like:

Traceback (most recent call last):
  File "my_file.py", line 5, in <module>
    add_three("6")
  File "my_file.py", line 2, in add_three
    a = num + 3
        ~~~~^~~
TypeError: can only concatenate str (not "int") to str

If the traceback is long, use our pastebin.

vale wing
#

And then add roles

#

Although that's kinda bad for security

uneven apex
#

umm yea

vale wing
#

So better to embed API

full marten
uneven apex
full marten
full marten
vale wing
#

Nvm

#

That's just everything in one place I failed to notice

full marten
#

main?

vale wing
winged linden
#

verified = ":verified:"

await interaction.response.send_message(f"{verified}Successfully Verified You{verified}", ephemeral=True)

Anyone know why it looks like this?

vale wing
#

The button goes first

winged linden
#

The emoji is animated

#
verified = "<:verified: 1050462690700689409>"

looks like this without the space

#

discord just converted it automatically

winged linden
#

bot.get_emoji(id) ?

vale wing
#

Yeah

winged linden
#

Alright thanks

full marten
somber sky
#

How would I do if len(role.members) > then a variable with a number: do something, when I do that code it doesn’t do anything

vale wing
#

Actually might be different in dpy I am unsure

#

!d discord.ui.Button.callback

vale wing
#

!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.
vale wing
#

🧐

somber sky
#

Trying to put a limit to role

#

Like an amount of people that can be in it

#

And if it’s bigger then the limit

#

Then it’ll do something

vale wing
#

Smh why everything's not like in disnake

full marten
rare echo
#

does role.members actually do that?

somber sky
#

Do what

winged linden
somber sky
#

It tells you how many people are in the role

vale wing
vale wing
full marten
winged linden
vale wing
#

!d discord.Intents.emojis

unkempt canyonBOT
winged linden
#
intents=discord.Intents(messages = True, guilds = True)
        intents.members = True
full marten
#

the way i did it is correct

rare echo
winged linden
#

I forgot why I did it like this

full marten
# full marten the way i did it is correct

@vale wing

    @discord.ui.button(style=discord.ButtonStyle.gray, emoji=':heavy_minus_sign:')
    async def my_button(self, interaction:discord.Interaction, button:discord.ui.Button):
        await interaction.response.send_message(content=f"You clicked me!!")
vale wing
winged linden
#

the messages and guilds intent need to be defined no?

#

wait nevermind thats message content

rare echo
#

!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.

somber sky
winged linden
bright wedge
#

Let's see what we have πŸ‘“

rare echo
#

what is RC?

rare echo
#

where is this? a command or event?

vale wing
somber sky
#

I put RC = (β€œ2”) at the top of my code where this is no commands, and the code itself is in a command

rare echo
#

can you show the whole cmd?

rare echo
#

an int, not a str

somber sky
#

Ohhh

winged linden
#
verified = bot.get_emoji(1050462690700689409)


await interaction.response.send_message(f"{verified}Successfully Verified You{verified}", ephemeral=True)
#

still getting this

vale wing
#

Like when do you define verified

winged linden
#

the interaction is in a slash command

#

i define verified at the start

vale wing
#

You can't

winged linden
#

before any commands

vale wing
#

Can't get emoji before bot is ready and got cache

rare echo
#

x) , get the emoji at the top of the command

winged linden
#

k

#

I could also just put them in onready no?

vale wing
#

I wouldn't consider it a good idea

winged linden
#

alr

winged linden
#

I put it at the top of the command

#
@tree.command(name = "verify", description = "Verification command", guild = discord.Object(id = bot.guild_id))
async def verify(interaction: discord.Interaction):
    verified = bot.get_emoji(1050462690700689409)

    user = interaction.user
    age = discord.utils.utcnow() - user.created_at
    if age.days > 14:

        role = interaction.guild.get_role(bot.verified_role)
        await user.add_roles(role)
        await interaction.response.send_message(f"{verified}Successfully Verified You{verified}", ephemeral=True)

        channel = interaction.guild.get_channel(bot.welcome_channel)
        ping = await channel.send(user.mention)
        time.sleep(5)
        await ping.delete()

    else:
        await interaction.response.send_message("Sorry Your Account Age Is Too Low To Be Verified", ephemeral=True)
vale wing
#

Could you like share the whole command and new intents definition

winged linden
#
class aclient(discord.Client):
    def __init__(self):
        intents = discord.Intents.default()
        intents.members = True

        super().__init__(intents=intents)


    async def on_ready(self):
        print(f"We have logged in as {self.user}.")
vale wing
#

Mk seems legit

winged linden
#

maybe i need to sync

vale wing
#

But what kind of tutorial uses those naming conventions

winged linden
#

tutorial?

vale wing
#

aclient bad class naming convention

#

Should be UpperCamel

winged linden
#

AClient

#

?

vale wing
#

Articles are rarely included

winged linden
#

oh

vale wing
#

MyClient better

winged linden
#

does it matter

#

isn't it just a name lol

rare echo
#

technically it doesnt matter but its bad practice

winged linden
#

ok

#

but back to the code, still confused on why it doesn't work considering I also get no errors

vale wing
#

Tbh I am confused too

#

Intents are enabled, the emoji getting is correct

winged linden
#

is it because its an animated emoji?

vale wing
#

You either use wrong class for bot or the ID is in correct

winged linden
#

checked both

rare echo
#

why are you using get_emoji instead of <:name:id> ? did i miss that

winged linden
#

that didnt work earlier

#

also
bot = aclient()

winged linden
#

but I also had emoji intents disabled then

rare echo
#

how did you have it?

winged linden
#

maybe If I revert back it might work

vale wing
#

@winged linden for animated emojis it's <a:name:id> but weird that get_emoji doesn't work

winged linden
#

yeah no it still doesnt work using the string

somber sky
# rare echo an int, not a str

@slash.slash(description='Sign a player.')
async def sign(ctx, user: discord.Member):
  FORole = discord.utils.get(ctx.guild.roles, name="Franchise Owner")
  GMRole = discord.utils.get(ctx.guild.roles, name="General Manager")
  HCRole = discord.utils.get(ctx.guild.roles, name="Head Coach")
  Eligible = discord.utils.get(ctx.guild.roles, name="Eligible")
  channel = bot.get_channel(Transactions)
  teams = discord.utils.find(lambda r: r.name in nflRoleListNames, ctx.author.roles)
  signembed = discord.Embed(title='Franchise Signing', description =f'{teams.mention} have **signed** {user.mention}`{user}`\n\n > **Coach:** {ctx.author.mention}`{ctx.author}`\n> **Roster:** {len(teams.members)}/{RC}',timestamp = datetime.datetime.utcnow())
  signembed.set_footer(icon_url = ctx.author.avatar_url, text='{}'.format(ctx.author))
  signembed.set_author(name=f"{ctx.guild.name} Transactions", icon_url=f"{ctx.guild.icon_url}")
  if any(role in [FORole, GMRole, HCRole] for role in ctx.author.roles):
      if any(role.name in nflRoleListNames for role in ctx.author.roles): 
            await user.add_roles(teams) 
            await ctx.send(f"Signed {user.mention}", hidden=True)
            msg = channel.send(embed=signembed)

      if len(teams.members) > RC:
       await ctx.send(f"You have the maximum amount of players on your team.")
       await channel.msg.delete()
       await user.remove_roles(teams)```

Why doesn’t the team role remove?
rare echo
#

how you read this is astonishing

winged linden
#

fr

rare echo
winged linden
rare echo
#

that and i cant see RC defined anywhere

winged linden
#

yeah

rare echo
#

presuming its still 2, you just...

winged linden
#

I beg of you to add space between your lines

rare echo
#

yeah haha lemme clean this real quick

winged linden
#

but yeah i dont see RC being defined so thats probably the issue

somber sky
#

Because it’s defined at the top of the code

#

It’s still detecting that’s it’s over the limit it’s just not removing the rope

#

Role

winged linden
#

is the amount greater than rc

somber sky
#

If it’s over the limit it shouldn’t give the person the role it should remove it but it isn’t

rare echo
#

you should run the check prior to adding the role

somber sky
#

The rc is 1 and the amount on the role is 2

rare echo
#

check if the team is full before adding user to the team

somber sky
#

It says it’s over the limit but it still adds the role

rare echo
#
if len(teams.members) >= RC:
    await ctx.send(f'{ctx.author.mention} You have reached the roster cap of {RC} players.')
    return
else:
    if any(role in [FORole, GMRole, HCRole] for role in ctx.author.roles):
        if any(role.name in nflRoleListNames for role in ctx.author.roles):
            await user.add_roles(teams)
            await ctx.send(f"Signed {user.mention}", hidden=True)
            msg = channel.send(embed=signembed)
#

oh god discord formatting why

#

but something similar to this

#

if the team is max, do nothing, otherwise add the user to the team

#

no reason in adding the user to the team if youll take them off 2 seconds later

somber sky
#

If I don’t put remove it’ll still add the role

rare echo
#

wdym?

#

if you are checking prior if the team is full then adding the role should never execute

#

if you add them then check if the team is full you are just creating more work on yourself

alpine oar
#

yo guys does anyone know how to purge msgs

bright wedge
unkempt canyonBOT
#
Certainly not.

No documentation found for the requested symbol.

shrewd apex
#

!d discord.TextChannel.purge

unkempt canyonBOT
#

await purge(*, limit=100, check=..., before=None, after=None, around=None, oldest_first=None, bulk=True, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Purges a list of messages that meet the criteria given by the predicate `check`. If a `check` is not provided then all messages are deleted without discrimination.

You must have [`manage_messages`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") to delete messages even if they are your own. Having [`read_message_history`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") is also needed to retrieve message history.

Changed in version 2.0: The `reason` keyword-only parameter was added.

Examples

Deleting bot’s messages...
alpine oar
shrewd apex
#

show ur command

alpine oar
#

its

#

!c

#

not an c just !

shrewd apex
#

wtf

#

this is out of my league πŸšΆβ€β™‚οΈ

vocal snow
alpine oar
vocal snow
#

πŸ‘

alpine oar
#

ty tho

slate swan
#

guys if anyone knows blox flip or rblx wild dm me.

slate swan
#

Is it related to Discord bots?

rare echo
slate swan
slate swan
rare echo
#

send what you have, i remember asking you about this and you couldnt really provide me with your method of "predicting"

white citrus
#

my timeout command timeouted 1h longer than it should

somber sky
# rare echo wdym?

i wasn't home, it worked thanks, but once more question

@slash.slash(description='Sign a player.')
async def sign(ctx, user: discord.Member):
  FORole = discord.utils.get(ctx.guild.roles, name="Franchise Owner")
  GMRole = discord.utils.get(ctx.guild.roles, name="General Manager")
  HCRole = discord.utils.get(ctx.guild.roles, name="Head Coach")
  Eligible = discord.utils.get(ctx.guild.roles, name="Eligible")
  channel = bot.get_channel(Transactions)
  teams = discord.utils.find(lambda r: r.name in nflRoleListNames, ctx.author.roles)
  signembed = discord.Embed(title='Franchise Signing', description =f'{teams.mention} have **signed** {user.mention}`{user}`\n\n > **Coach:** {ctx.author.mention}`{ctx.author}`\n> **Roster:** {len(teams.members)}/{RC}',timestamp = datetime.datetime.utcnow())
  signembed.set_footer(icon_url = ctx.author.avatar_url, text='{}'.format(ctx.author))
  signembed.set_author(name=f"{ctx.guild.name} Transactions", icon_url=f"{ctx.guild.icon_url}")
  if len(teams.members) >= RC:
    await ctx.send(f'You have reached the roster cap of {RC} players.', hidden=True)
  if Eligible not in user.roles:
    await ctx.send("You cannot sign this player, he is not eligible", hidden=True)
  if teams in user.roles:
    await ctx.send(f"This user is already signed to the {teams.mention}", hidden=True)
    return
  else:
    if any(role in [FORole, GMRole, HCRole] for role in ctx.author.roles):
        if any(role.name in nflRoleListNames for role in ctx.author.roles):
            await user.add_roles(teams)
            await ctx.send(f"Signed {user.mention}", hidden=True)
            await channel.send(embed=signembed)``` 

in the part 

`if teams in user.roles:
    await ctx.send(f"This user is already signed to the {teams.mention}", hidden=True)`

it only sends the message when he is on your team, how would i make it where  it would say it when the user is on any team? Hard to explain
#

it does that because teams is looking for the teama the author is holding

#

so how would i make it where it just looks for the teams in generaal

rare echo
#

not sure i fully get what you mean

#

you want to check all teams even if the user doesnt have them?

#

or you want it to say "the user is already signed to {the users team}"

somber sky
#

so pretty much, right now when i run it, if someone else tries to sign him even if hes on a differeent team it'll go through

#

it only sends the message when the owner of the team hes on tries it

#

so im trying to make it where the bot says that message when someone tries to sign him when hes already on a team

rare echo
#

so you want to make it send that message when someone else tries to add him?

#

instead of the owner of the team he is currently on

somber sky
#

if hes on a team alrrady

rare echo
#

yes

somber sky
rare echo
#

so you can check if he has any of the team roles (presumably through a list) and if one does exist then just send the message

(else: add him)

#

wait

#
if teams in user.roles:
    await ctx.send(f"This user is already signed to the {teams.mention}", hidden=True)
    return```
somber sky
#

i already have that

rare echo
#

yeah thats what im saying

somber sky
#

it only tells that to the owner

#

like

#

it only sends the message if the owner of the team that user is on uses it

#

if someone else that isnt the owner of the team hes on it'll sign them

rare echo
#

ahh i see

#
 teams = discord.utils.find(lambda r: r.name in nflRoleListNames, ctx.author.roles)``` its because you are checking the roles of the message author
#

so you essentially need to do this but without checking the author

#

if the user they are mentioning have any of the roles in x (i think nflRoleListNames) then send the message

somber sky
rare echo
#

probably make another one for the users roles, and one with the authors role

rare echo
somber sky
#

yea ik i will

#

teams2 = discord.utils.find(lambda r: r.name in nflRoleListNames)

#

so like something likee that?

rare echo
#

might want to name better x) but sure

somber sky
#

wym

rare echo
#

something like author_team_check idk

#

might get lost looking at the var names

somber sky
rare echo
#

well you still want to check the roles of the user

#

just the user they are trying to sign not the author running sign command

somber sky
#

so how would i do that then

rare echo
#

well

#

in py teams = discord.utils.find(lambda r: r.name in nflRoleListNames, ctx.author.roles) you are checking the author

#

so now, you need to check the user instead

somber sky
#

so ctx.user.roles?

rare echo
#

so something like

teams2 = discord.utils.find(lambda r: r.name in nflRoleListNames, user.roles)```
#
async def sign(ctx, user: discord.Member):```
because you are getting the user here
somber sky
#

lol that just did the same thing it did befor for some reason

rare echo
#

whats the full error?

somber sky
#

it only says that if the owner of the team hes on runs it

#

no error it just doees that

#

ohhh

#

nvm im dumb

#

i didnt change the if teams in user.roles

rare echo
#

πŸ‘

somber sky
#

wth, now the eligible part doesn;t work lol

somber sky
rare echo
#

it stopped working?

somber sky
#

yes lol

rare echo
#

show updated code

somber sky
#
@slash.slash(description='Sign a player.')
async def sign(ctx, user: discord.Member):
  FORole = discord.utils.get(ctx.guild.roles, name="Franchise Owner")
  GMRole = discord.utils.get(ctx.guild.roles, name="General Manager")
  HCRole = discord.utils.get(ctx.guild.roles, name="Head Coach")
  Eligible = discord.utils.get(ctx.guild.roles, name="Eligible")
  channel = bot.get_channel(Transactions)
  teams = discord.utils.find(lambda r: r.name in nflRoleListNames, ctx.author.roles)
  teams2 = discord.utils.find(lambda r: r.name in nflRoleListNames, user.roles)
  signembed = discord.Embed(title='Franchise Signing', description =f'{teams.mention} have **signed** {user.mention}`{user}`\n\n > **Coach:** {ctx.author.mention}`{ctx.author}`\n> **Roster:** {len(teams.members)}/{RC}',timestamp = datetime.datetime.utcnow())
  signembed.set_footer(icon_url = ctx.author.avatar_url, text='{}'.format(ctx.author))
  signembed.set_author(name=f"{ctx.guild.name} Transactions", icon_url=f"{ctx.guild.icon_url}")
  if len(teams.members) >= RC:
    await ctx.send(f'You have reached the roster cap of {RC} players.',hidden=True)
  if teams2 in user.roles:
    await ctx.send(f"This user is already signed to the {teams2.mention}",hidden=True)
  if Eligible not in user.roles:
    await ctx.send("You cannot sign this player, he is not eligible", hidden=True)
    return
  else:
    if any(role in [FORole, GMRole, HCRole] for role in ctx.author.roles):
        if any(role.name in nflRoleListNames for role in ctx.author.roles):
            await user.add_roles(teams)
            await ctx.send(f"Signed {user.mention}", hidden=True)
            await channel.send(embed=signembed)```
#

you see eligiblee?

#

that stopped working

rare echo
#

wdym by stopped working

somber sky
#

like

#

it still signs the player

#

but its not supposed to

rare echo
#

does it send the message?

somber sky
#

yes

#

sends the message but still signs

rare echo
somber sky
#

i tried moving the 2 commnds

#

for some reason the 1st command thats there doesnt work

#

like in that code that i sent teams 2 didnt work

#

but if i put eligible first

#

then eligible doesnt work

#

thene teams2 does

#

confusing

rare echo
#

add return to bottom of teams2 if

#

it might be because teams2 is in the role but eligible also isnt

#

so its firing both of them

somber sky
#

so at thee bottom both of them?

#

or just one

rare echo
#

py is going through the if statements from top to bottom, if it doesnt have return at the bottom itll simply check the next if

#

return stops it from running through the if statements

#

i mean you realistically could add it to all 3 seeing as once one of them is true everything should stop

somber sky
#

yea it completely works now, I put return after all 3 if statements

#

thanks

rare echo
#

np

glossy flame
#

async def dm(ctx, user:discord.Member):

#

i just came back to edit my code after a long break

#

what is stored in 'user'?

#

i want my bot to DM me when a certain member is pinged, so i need to use myself instead of user

split forge
#

hello someone can help me?

glossy flame
cold sonnet
#

how do you format different timestamps on discord

#

eh got it

#

can you not put a timestamp in an embed footer?

glossy flame
#
async def on_message(message):
  if "poo" in message.content:
    S = await message.guild.fetch_member(675798876858482731)
    C = await message.guild.fetch_member(687722271225151494)
    print(C, S)
    STEEL_DM = await S.create_dm()
    await STEEL_DM.send(message.author + " pinged C in" + message.channel+ " just now!")```
how do i peacefully get a member 😭
lone cliff
#

Where can i host multiple bots for free/cheap price?

fading marlin
unkempt canyonBOT
#

class discord.Embed(*, colour=None, color=None, title=None, type='rich', url=None, description=None, timestamp=None)```
Represents a Discord embed.

len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.

bool(b) Returns whether the embed has any data set.

New in version 2.0.

x == y Checks if two embeds are equal.

New in version 2.0...
fading marlin
glossy flame
alpine cove
#

dont you have to specify your event

#

bot.listen("message")

#

or just use @bot.event

glossy flame
#

doesnt async def on_message specify it

alpine cove
#

or acutally

#

nvm ur right

glossy flame
#

ok

alpine cove
#

or actually

#

im not quite sure

glossy flame
alpine cove
#

!d discord.Member.display_name

unkempt canyonBOT
#

property display_name```
Returns the user’s display name.

For regular users this is just their username, but if they have a guild specific nickname then that is returned instead.
alpine cove
unkempt canyonBOT
#

property name```
Equivalent to [`User.name`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User.name "discord.User.name")
glossy flame
#

leme just send full

#
async def on_message(message):
  if "ok" in message.content:
    S = message.guild.get_member(675798876858482731)
    C = message.guild.get_member(687722271225151494)
    print(type(C), S)
    STEEL_DM = await S.create_dm()
    await STEEL_DM.send(message.author + " pinged C in" + message.channel+ " just now!")```
alpine cove
#

yea

#

or user.mention

#

!d discord.Member.mention

unkempt canyonBOT
glossy flame
#

instead of what

glossy flame
#

how can u mention a member in DMs

#

im not sure thats the problem

alpine cove
#

it is lmao

glossy flame
#

i tested it by changing the message to just "hi" and it gave same error

alpine cove
glossy flame
#

nvm ur right

glossy flame
alpine cove
#

np

glossy flame
#

wait

fading marlin
glossy flame
alpine cove
fading marlin
#

use f strings instead of concatenation

alpine cove
#

^

glossy flame
#

ok

#

im not doubting u but can u explain why

#

its just so i know how my own code works

fading marlin
#

f strings automatically make whatever object "string compatible"

glossy flame
#

i dont like having parts of my code where i dont understand why im usin it

fading marlin
#

plus it just looks a lot better than string concatenation, and it's probably more readable

slate swan
#

hi

boreal vine
#

Hi, im making a discord bot with pycord but im running into a weird issue. For some reason the commands do not show and work for all users, its just work to users that have administration perms. Do anyone run into that issue? I can't find the proble

slate swan
#

Can you send a code sample?

rare echo
#

i was going to say sync but then the admin thing threw me for a loop pikathink

boreal vine
# slate swan Can you send a code sample?
 @bot.slash_command(name="status", description="Use this command to verify if your VIP role is registred")
 async def status(ctx):
    println(ctx.author.name)
    await ctx.respond(embed=Responses.place_holder())
slate swan
#

oh, it's probably the server integration restricting who can use the slash commands

boreal vine
#

I check and everything seems to be fine. Do you know what perms i should look?

#

I did a check and there are a few different perms. But i don't know if they are related to slash commands

kind trellis
#

How do I make a custom error handler for app commands?

boreal vine
#

try and catch

#

or if you want throw new error you can probably do it, and it will be like a normal error

kind trellis
#

That's not why I need it

#

I have an app command producing an error and the error gets eaten

full marten
#

!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.
full marten
#

!d discord.ui.button edit emoji

#

hmm

#

:(

slate swan
# full marten !d discord.ui.button edit emoji

You can assign a new emoji to button.emoji at any time and the new emoji will display when you next update the view.
e.g self.next_page.emoji = '![frogg](https://cdn.discordapp.com/emojis/956517710865526855.webp?size=128 "frogg")'

dusk pumice
#

What's difrent with display_name and name?

#

Is display_name nick?

slate swan
dusk pumice
#

(Opps sorry for the ping)

slate swan
slate swan
dusk pumice
#

πŸ‘

somber sky
#

how would I make a command where i can set channels? Example: /setchannel (channel id) and then I can use the channel for like application commands and stuff

pearl slate
#

hello i am in need of help. im trying to code a bot for discord but I cannot figure out how to make a /set channel command and /set role command. if someone could help that would be amazing.

bright wedge
pearl slate
bright wedge
#

you will need to store 2 things

#

the guild id and the channel id or role id

pearl slate
#

yes

#

please help me

bright wedge
#

lets create the set channel first

#

what db you are using?

pearl slate
#
@bot.slash_command(description= "Set Franchise Owner role")
async def foroleset(interaction):
        await interaction.send('Successfully set Franchise Owner role', ephemeral=True)```
#

library?

bright wedge
#

!pip aiosqlite

unkempt canyonBOT
pearl slate
#

i use nextcord

bright wedge
#

you can use aiosqlite for this simple use

pearl slate
#

okay

naive briar
#

He's talking about database

pearl slate
#

oh

bright wedge
#

db = database

pearl slate
#

so wdym by database

naive briar
#

English 100

bright wedge
#

we need to store theses ids in db

pearl slate
#

okay

#

how do i make one

bright wedge
#

go read how aiosqlite works!

bright wedge
pearl slate
#

okay

bright wedge
#

or you can use

#

!pip asqlite

unkempt canyonBOT
pearl slate
#

i see

#

which one is better?

bright wedge
#

i never use asqlite but i will

pearl slate
#

or which one do u recommend

bright wedge
#

so go for the aiosqlite for now

pearl slate
#

so i do pip install aiosqlite

bright wedge
#

asqlite is from Danny (the developer of discord.py lib)

pearl slate
#

ok

bright wedge
#

go read and do some tests how works

#

how to create your first db file, create tables etc...

pearl slate
#

okay i somewhat understand it now

bright wedge
#

before we continue

pearl slate
bright wedge
#

how to create a db file?

#

please use the async method

pearl slate
#

ok

#
async with aiosqlite.connect(...) as db:
    await db.execute("INSERT INTO some_table ...")
    await db.commit()

    async with db.execute("SELECT * FROM some_table") as cursor:
        async for row in cursor:```
#

is this how you create it?

bright wedge
#

run this code!

#

and see the results!

pearl slate
#

ok

#

errors

bright wedge
#

so

naive briar
#

Your IDE is probably high if there's none

bright wedge
#

you will need a async function

#

like

#
import asyncio

async def main():
  async with aiosqlite.........


asyncio.run(main())
pearl slate
#

ok

bright wedge
#

but!

#

you can use this in your on_ready event!

#
@bot.event
async def on_ready():
    async with aiosqlite.connect('database.db') as db:
pearl slate
bright wedge
#

so lets learn step by step what we are doing

pearl slate
#

ok

bright wedge
#

but

#

just for know why im doing that!

pearl slate
#

ok

bright wedge
#

Rule 8
Help people learn how to do the assignment without doing it for them.

pearl slate
#

understandable

bright wedge
#

first goal: understand what we are doing
second goal: finish the project

#

got this?

pearl slate
#

okay

#

got it

bright wedge
#
@bot.event
async def on_ready():
    async with aiosqlite.connect('database.db') as db:
        pass

this will create your database file (if not exist)

pearl slate
#

okay so i got an error

bright wedge
#

about the path?

pearl slate
bright wedge
#

import aiosqlite πŸ˜›

pearl slate
#

i did

bright wedge
#

you install it?

pearl slate
#

wait

bright wedge
#

run the code (vsc need restart after installing module)

pearl slate
#

fixed

#

i installed it

bright wedge
#

run

pearl slate
#

no errors

bright wedge
#

so you will find a database.db file

#

in your bot folder

pearl slate
#

no

bright wedge
#

in your disk maybe?

pearl slate
bright wedge
#

can we create a new bot?

pearl slate
#

yea

bright wedge
#

remove everything from your bot, lets create it from the start.

#

keep only the bot = commands.Bot
and bot.run

pearl slate
#

there

#

i made it

bright wedge
pearl slate
#

this is what i have

bright wedge
#

good

#
@bot.event
async def on_ready():
    async with aiosqlite.connect('database.db') as db:
        pass

this will create your database file (if not exist)

pearl slate
#

it made the file

bright wedge
#

now install the "Sqlite Viewer" in vsc extensions

#

for can view the db file (good for tests atm)

pearl slate
#

installed

bright wedge
#

great

#

lets create our first table

#

you know what database table is?

pearl slate
#

no i do not

mighty pilot
#

can i make a command in my code run another command as part of it? like if i have async def question which is its own command, could i create a command which calls that command, then starts a 24h loop and runs it once every 24h

bright wedge
#

go read it and comeback!

bright wedge
#

!d discord.ext.commands.Bot.get_context then get the context

unkempt canyonBOT
#

await get_context(origin, /, *, cls=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Returns the invocation context from the message or interaction.

This is a more low-level counter-part for [`process_commands()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.process_commands "discord.ext.commands.Bot.process_commands") to allow users more fine grained control over the processing.

The returned context is not guaranteed to be a valid invocation context, [`Context.valid`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Context.valid "discord.ext.commands.Context.valid") must be checked to make sure it is. If the context is not valid then it is not a valid candidate to be invoked under [`invoke()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.invoke "discord.ext.commands.Bot.invoke").

Note

In order for the custom context to be used inside an interaction-based context (such as [`HybridCommand`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.HybridCommand "discord.ext.commands.HybridCommand")) then this method must be overridden to return that class...
mighty pilot
#

ah so it cant be done with a slash command itd have to by hybrid at least

pearl slate
#

okay so the table is made to store the data of all the ids people put in there and the other commands they use can be stored in there

mighty pilot
#

i did and it just printed the command object as text lol

#

<discord.app_commands.commands.Command object at 0x7fa753849b20>

bright wedge
#

lets create our first table!

pearl slate
#

okay

bright wedge
unkempt canyonBOT
#
Naw.

No documentation found for the requested symbol.

pearl slate
#
async with aiosqlite.connect(...) as db:
    await db.execute("INSERT INTO some_table ...")
    await db.commit()

    async with db.execute("SELECT * FROM some_table") as cursor:
        async for row in cursor:
            ...``` this is the code i said earlier
mighty pilot
#

invoked_with?

bright wedge
#

that will run your
async def help command

mighty pilot
#

huh, alright thanks

bright wedge
#

πŸ™‚

mighty pilot
#

yea ill play with that lol

slate swan
#

are you looking for the slash help command or prefix one lol?

slate swan
pearl slate
slate swan
mighty pilot
#

thats not at all it. trying to trigger an app command from another command

pearl slate
bright wedge
pearl slate
#
CREATE TABLE [IF NOT EXISTS] [schema_name].table_name (
    column_1 data_type PRIMARY KEY,
       column_2 data_type NOT NULL,
    column_3 data_type DEFAULT 0,
    table_constraints
) [WITHOUT ROWID];```
bright wedge
#
@bot.event
async def on_ready():
    async with aiosqlite.connect('database.db') as db:
        await db.execute("""
        CREATE TABLE IF NOT EXISTS ids(
            test TEXT
            )
            """)
#

what you think that will do?

pearl slate
#

it will connect to database and create a table within the folder

bright wedge
#

table name?

#

tables are stored in database file*

pearl slate
#

i have no clue

bright wedge
#

run it!

pearl slate
#

also i might have to go to bed like very soon since i have school tmrw

bright wedge
#

we can continue tomorrow!

pearl slate
bright wedge
bright wedge
#

using

await db.commit()
#

add it

pearl slate
bright wedge
#

press the X to close it

#

and open it again

#

"Open anyway" and select sqlite viewer

pearl slate
bright wedge
#

show me the code please

pearl slate
bright wedge
#

move commit one tab right

#

same line with execute

#

and remove the first on_ready event!

pearl slate
shrewd fjord
#

on_ready event can't be 2

#

Use setup_hook instead

slate swan
#

w on ready event πŸ—Ώ

bright wedge
#

and dont show bot token!

#

delete the image and reset token

shrewd fjord
#

Setup_hook is the same as on_ready, on_ready can be triggered multiple time on bot's lifespan while setup_hook triggers while bot starts

pearl slate
#

@bright wedge im going to have to go now. im going to go to bed. i will continue this tmrw. i have spare second period so i can do it then.

#

thank you for helping me so far

bright wedge
pearl slate
#

also accept my friend request so i can reach out to you more often

shrewd fjord
#

O.o

bright wedge
#

good night sir!

mighty pilot
#

do you still use ctx in a hybrid command

naive briar
#

Yes

pearl slate
mighty pilot
#

im trying to invoke a hybrid command from another command, when i try i get a TypeError: argument of type 'HybridCommand' is not iterable my command doesnt ask for any arguments though

unkempt canyonBOT
#

Please provide the full traceback for your exception in order to help us identify your issue.
While the last line of the error message tells us what kind of error you got,
the full traceback will tell us which line, and other critical information to solve your problem.
Please avoid screenshots so we can copy and paste parts of the message.

A full traceback could look like:

Traceback (most recent call last):
  File "my_file.py", line 5, in <module>
    add_three("6")
  File "my_file.py", line 2, in add_three
    a = num + 3
        ~~~~^~~
TypeError: can only concatenate str (not "int") to str

If the traceback is long, use our pastebin.

mighty pilot
#

easier said than done, cant copy/paste from my vm

naive briar
#

Then it's a weird terminal

#

Eh, just screenshot the traceback or something

#

You can setup logging that logs the exception to a file later

mighty pilot
#

yea its super annoying. one sec

#

its telling me the error is in the on_ready, but all im doing there is starting a loop, which i want to run the hybrid command then wait 24 hours

naive briar
#

Is the question variable a string

#

!d discord.ext.commands.Bot.get_command

unkempt canyonBOT
#

get_command(name, /)```
Get a [`Command`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") from the internal list of commands.

This could also be used as a way to get aliases.

The name could be fully qualified (e.g. `'foo bar'`) will get the subcommand `bar` of the group command `foo`. If a subcommand is not found then `None` is returned just as usual.

Changed in version 2.0: `name` parameter is now positional-only.
naive briar
mighty pilot
#

oh it needs to be a string not the command

#

hybrid command doesnt exist for some reason

#

doesnt have to be synced right?

#

for the text command at least

keen dust
#

in your on_ready function

mighty pilot
#

ok, still cant get it working regardless of syncing

keen dust
#

whats the error?

mighty pilot
#

just that it cant be found

keen dust
#

show the code

mighty pilot
#

in my on_ready i have await bot.tree.sync()

keen dust
#

oh thats why