#discord-bots

1 messages ยท Page 176 of 1

clear elm
#

no

#

idk how to add one

#

can u help me?

loud junco
#

what is this

#

wait im dumb

#

forgot = bot ๐Ÿ’€

slate swan
loud junco
#

ya ik

#

where is the part where i dont need to import bot everywhere

slate swan
#

self.bot.database_handler ....

loud junco
clear elm
#

how do i add a database ๐Ÿ˜ญ im so sorry im not that advanced

loud junco
clear elm
#

im not hosting the bot, im making the bot for sometone

loud junco
clear elm
#

vs code

loud junco
#

๐Ÿ’€

clear elm
#

๐Ÿ˜ญ

#

idk what ur talking abt

loud junco
#

if u are using replit i will say json
but bro i dont think vs code have database

#

KEKW

clear elm
#

i can ig

slate swan
clear elm
#

im like so confused

slate swan
#

self.bot.database_handler will give you the database class

#

access the method directly

loud junco
#

change it here?

clear elm
#

@slate swan what am i supposed t oput for the value in the embed at the top?

slate swan
#

yes

slate swan
#

i can't help if you have no idea about that

#

or atleast a dictionary

loud junco
#

record the data on a piece of paper

#

u can create ur own language from there ๐Ÿ‘

#

or remove the progress.database

slate swan
#

self.bot.database_handler

loud junco
#

huh

#

dbfunc = self.bot.aosdnosifk?

loud junco
slate swan
#

yes....

loud junco
slate swan
#

show the fetchvalue function

loud junco
#

wait self.bot?

slate swan
#

ya...

loud junco
#

๐Ÿ’€ whats wrong with me today AHHHHHHHHHH

#

just what is going on

shrewd apex
#

dont think injection is possible there

loud junco
#

BRUH

shrewd apex
#

also asyncpg has a fetchval already

loud junco
#

3 weeks of time wasted

shrewd apex
#

why making a new one

loud junco
shrewd apex
#

instead of .fetch use .fetchval

loud junco
#

whats the dif

shrewd apex
#

it returns the first object

loud junco
#

oo

shrewd apex
#

u wont have to do [0]

loud junco
#

so how do i force inject this

#

i dont care if i ts forearm even leg works

shrewd apex
#
    async def fetchval(self, query: str, *args: t.Any) -> t.Any:
        assert self._pool is not None
        async with self._pool.acquire() as conn:
            return await conn.fetchval(query, *args)

here is mine

loud junco
shrewd apex
loud junco
#

someone help me to inject
;-;

slate swan
#

you can use fstring for declaring the table name

shrewd apex
#

use a f string

slate swan
#

nothing wrong in it

#

but yeah use placeholder for arguments

#
@bot.slash_command(name="editchannel", description="A command to quickly edit your channels!")
@default_permissions(administrator=True)
@commands.cooldown(1, 3, commands.BucketType.user)
async def editchannel(ctx, editname:Option(str, "Input new channel name.", required=True)):
    await channel.edit(name=editname)
    em = discord.Embed(title="Channel Name Changed!", description=f"You channel name has been changed to, {ctx.channel.name}")
    em.set_footer(icon_url = ctx.author.avatar, text=f"Invoked by {ctx.author.name}")
    await ctx.respond(embed=em)```

My slash command, does not work. im using pycord

edit channel name
loud junco
loud junco
naive briar
#

It does

shrewd apex
naive briar
#

Execute with the query

loud junco
#

ok im dumb but

naive briar
#

Just the query var

loud junco
#

2 trials and fked both of them up equally hard

naive briar
shrewd apex
loud junco
#

oo

#

nah nah everyone has their first time

shrewd apex
#

lol that was a comment

#

not code i sent

#

i meant string1 becomes your new query string

loud junco
#

๐Ÿ’€

#

i thought execute is a keyword

shrewd apex
#

and u use that to execute

loud junco
#

yeye got it now

loud junco
#

i have been here for 1 year but is still dumb af ๐Ÿ’€

shrewd apex
#

how it dosent work

loud junco
#

icon_url = ctx.author.avatar
am i dumb or something

#

does thing work like this

slate swan
naive briar
#

Nothing works in pycord

naive briar
#

And provide an error with the question next time

slate swan
loud junco
#

ctx.channel ig

shrewd apex
#

ctx.channel.edit and u have to respond in 3 secs so either send a message first then edit or defer then send a message

shrewd apex
slate swan
loud junco
#

havent be so desperate to get bot's reply before

#

do i change everything to string in database

#

something like playerid = string type

#

or do i need to add int() on the thing

naive briar
#

Show code

loud junco
#

i added str() and int()

naive briar
#

And what's the code

loud junco
#

wait mb i thought i send it ๐Ÿ’€

loud junco
#

still same error

shrewd apex
#

there is no $2 in the code

#

u have $3 change it

loud junco
#

i feel like smashing table now ;-;

#

what is this

slate swan
#

fetchval returns a string

#

( or whatever the data type was )

#

why would you use [item] on it again

shut willow
#

what options are there to create a selection list on slash command other than using an Enum list?

loud junco
#

๐Ÿ’€ its supposed to output 0

slate swan
#

how did you call the function

loud junco
slate swan
#

you can't use placeholder for column name too

#
await self.bot.db.fetchval(f"SELECT {item} FROM {tablename} WHERE playerid = $1", userid)```
crimson mauve
#

What error are you getting?

#

I have no idea what "same" is

#

Just show the error

#

I need the entire traceback

#

await ctx.send(mess_channel, embed=embed)

#

!d discord.abc.Messageable.send

unkempt canyonBOT
#
await send(content=None, *, tts=False, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, ...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Sends a message to the destination with the content given.

The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.

To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/latest/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.11)") of [`File`](https://discordpy.readthedocs.io/en/latest/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.

To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.11)") of [`Embed`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
crimson mauve
#

What are you adding mess_channel into the send for?

#

the channel the command is being run in?

#

That's what the ctx is for.

#

!d discord.ext.commands.Context

unkempt canyonBOT
#
class discord.ext.commands.Context(*, message, bot, view, args=..., kwargs=..., prefix=None, command=None, invoked_with=None, invoked_parents=..., invoked_subcommand=None, ...)```
Represents the context in which a command is being invoked under.

This class contains a lot of meta data to help you understand more about the invocation context. This class is not created manually and is instead passed around to commands as the first parameter.

This class implements the [`Messageable`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.Messageable "discord.abc.Messageable") ABC.
amber ether
#

Idk why but this wont work?

#

!d help

unkempt canyonBOT
#

help()``````py

help(request)```
Invoke the built-in help system. (This function is intended for interactive use.) If no argument is given, the interactive help system starts on the interpreter console. If the argument is a string, then the string is looked up as the name of a module, function, class, method, keyword, or documentation topic, and a help page is printed on the console. If the argument is any other kind of object, a help page on the object is generated.

Note that if a slash(/) appears in the parameter list of a function when invoking [`help()`](https://docs.python.org/3/library/functions.html#help "help"), it means that the parameters prior to the slash are positional-only. For more info, see [the FAQ entry on positional-only parameters](https://docs.python.org/3/faq/programming.html#faq-positional-only-arguments).

This function is added to the built-in namespace by the [`site`](https://docs.python.org/3/library/site.html#module-site "site: Module responsible for site-specific configuration.") module.
shrewd apex
unkempt canyonBOT
shrewd apex
#

make sure u have the correct library installed

amber ether
shrewd apex
#

u don't

#

u have a mirror

slate swan
#

reinstall it then

amber ether
amber ether
slate swan
#

you got the code from somewhere that isn't discord.py

amber ether
slate swan
#

bot.slash_command isn't a thing in the library

amber ether
#

this used to work

#

i used pycord is ti connected?

slate swan
#

you might have been using some fork

amber ether
#

its tree_command?

slate swan
amber ether
#

oh

slate swan
#

bot.tree.command

#

most things won't work you'll have to rewrite your code for slash Commands

slate swan
#

Because client.commands is what enables slash commands

slate swan
#

show me your code !paste

amber ether
#

i used a fork of discord.py that bot.slash_commands but o forgot the name

slate swan
#

!pastebin

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.

slate swan
#

without token

amber ether
#

aight

slate swan
#

hmm

fresh notch
#

how do i send back what the user sent

slate swan
#

I have to go @amber ether maybe someone else will find it.

crimson mauve
fresh notch
#

for example if i say hi i want it to send hi back

amber ether
#

^

fresh notch
#

just copy the user

amber ether
fresh notch
#

no not that

fresh notch
crimson mauve
unkempt canyonBOT
#

discord.on_message(message)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Message "discord.Message") is created and sent.

This requires [`Intents.messages`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.messages "discord.Intents.messages") to be enabled.

Warning

Your botโ€™s own messages and private messages are sent through this event. This can lead cases of โ€˜recursionโ€™ depending on how your bot was programmed. If you want the bot to not reply to itself, consider checking the user IDs. Note that [`Bot`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot") does not have this problem.
amber ether
#

i used a fork of discord.py that bot.slash_commands but o forgot the name
anyone?

fresh notch
#

i have that

amber ether
crimson mauve
unkempt canyonBOT
#

class discord.Message```
Represents a message from Discord.

x == y Checks if two messages are equal.

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

hash(x) Returns the messageโ€™s hash.
naive briar
fresh notch
# amber ether wdym?

i just want it to send whatever is sent in chat

if i say hi it says hi back
if i say bye it says bye back

essentially what im asking for is to copy paste the text

naive briar
#

Reading the error would have told you that

crimson mauve
unkempt canyonBOT
amber ether
fresh notch
amber ether
#

:/

crimson mauve
fresh notch
amber ether
slate swan
naive briar
#

Reading the docs would have told you that

fresh notch
#

they're set to true

crimson mauve
fresh notch
#
import discord
from discord.ext import commands

intents = discord.Intents.default()
intents.members = True
intents.messages = True
bot = commands.Bot(command_prefix='-', intents=intents, help_command=None,)

@bot.event
async def on_ready():
    print('up and running')
    
@bot.listen()
async def on_message(message):
    if message.author == bot.user:
        return
    embed = discord.Embed(color=0x00ff00)
    mLink = message.jump_url
    embed.add_field(name="Jump", value=f"[Go to message!]({mLink})", inline=False)
    embed.add_field(name="Message", value=message.content, inline=False)
    await message.channel.send(embed=embed)
naive briar
#

message_content intent

#

READING THE DOCS would have told you that

radiant root
radiant root
#

, help_command=None,)

fresh notch
amber ether
#

i used a fork of discord.py that bot.slash_commands but o forgot the name
please helllpp

crimson mauve
crimson mauve
amber ether
#

ofc

#

integer is a number/numeric and string is used to put things on "

crimson mauve
amber ether
#

i dont think its related to my question..

crimson mauve
# amber ether this is my new problem lmfao

I see your problem here, your traceback is flat out telling you what needs fixed. But I'm not even sure you would understand if I told you what it was. No shade on you, you just don't understand the terminology well enough for us to even help you with this.

shrewd apex
#

and u would need them at some point

#

except maybe presence intent

#

also dev portal as well

shrewd apex
#

it has slash commands now

amber ether
#

and i forgot things on python bc of school

shrewd apex
#

i dont think it gonna work with the fork either

#

also there were 10s of forks if not even more

#

if u have the env still u can try checking

amber ether
#

i've used a fork before i wrote the code.

shrewd apex
#

lol in short there are tons of forks

#

how are we supposed to know

#

and even now almost all libs have bot.slash_command for syntax

crimson mauve
shrewd apex
#

they are forks from the main lib after all

crimson mauve
#

So feel free to use the fork, just don't get upset when no one has any idea what you are talking about

slate swan
#

how do you make it send a embed?

crimson mauve
#

send(embed=embed)

slate swan
#

then what?

crimson mauve
#

That's all, but before you send it, you have to make the Embed.

slate swan
#

yea, how do i do that?

#

im new to coding, sorry

crimson mauve
naive briar
#

You should at least have some OOP knowledge before trying discord.py

slate swan
#
async def say(ctx, *what):
    await ctx.send(" ".join(what))```
#

instead of ctx.send which is a plain message, i want a embed

crimson mauve
#

!d discord.Embed

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...
slate swan
#

thank you

naive briar
#

!d discord.TextChannel.send

slate swan
#

also, how would I make it so the users input would decide what the embed says for example ?say hi bye the bot responds with hi bye in the embed?

crimson mauve
#
Embed = discord.Embed(title="Top Shelf")
await Embed.set_thumbnail(url="https://img.izismile.com/img/img2/20091118/funny_crazy_faces_25.jpg")
ctx.send(embed=Embed)
naive briar
#

Take an argument and use it to create the embed

naive briar
crimson mauve
cloud cairn
#

Anyone got any ideas why the command work but doesn't show in the "slash command menu"

import discord
from discord.ext import commands

intents = discord.Intents().all()
client = commands.Bot(command_prefix='/', intents=intents)

@client.command()
async def hello(ctx):
    await ctx.send('Hello!')


client.run(TOKEN)
naive briar
#

That's not how you create slash commands

cloud cairn
#

Well that could be the problem then hehe ๐Ÿ˜…

crimson mauve
shrewd apex
upbeat otter
upbeat otter
#

I'm just trolling pepeShy

cloud cairn
#

lol

upbeat otter
#

that's not how you make them

#

check the channel pins

crimson mauve
crimson mauve
#

have fun reading.

upbeat otter
#

lmao

#

it's not maintained either pepe_exit

#

ok zippy pepe_exit

crimson mauve
upbeat otter
#

๐Ÿ’€

crimson mauve
#

Well, would you have posted that if I didn't post anything?

#

lol

slate swan
#

ash's guide is much more brief compared to the other one, why? cuz the first one talks more about what not to do than what can you do

crimson mauve
#

ยฏ_(ใƒ„)_/ยฏ

#

Good to know

slate swan
#

its moreover focused on syncing

crimson mauve
#

My point still stands, If I didn't post what I did. I don't think Ash would have ever posted that to correct me and would have just left the new person hanging.

#

Like I said, I just love Cunningham's law.

upbeat otter
crimson mauve
#

But you have fun, I'm off for now.

slate swan
#

maybe, not a point of argument lol

upbeat otter
upbeat otter
upbeat otter
slate swan
#

i just got back from class shush

upbeat otter
young dagger
#

How do I store the url for an embed?

upbeat otter
young dagger
upbeat otter
young dagger
# upbeat otter oh well you can grab the message link using `discord.Message.jump_url`

Like this?

        # Get the link of the embed
        action_log = embed.url

        # Send the embed to the channel
        await channel.send(embed=embed)

        # Insert warning document into the warnings collection
        warnings_collection.insert_one({"case_id": case_id, "user_id": member.id, "reason": actual_reason, "moderator_id": ctx.author.id, "timestamp": timestamp, "action_log": action_log})```
upbeat otter
young dagger
upbeat otter
upbeat otter
#

ok

cunning marsh
#

Hello

#

What library can be used to create a bot that automatically sends Reddit posts to Discord?

#

I want when i posted on my Reddit account, it will also be posted on Discord with bot

young dagger
#

Should I change error handler:

@modlogs.error
async def modlogs_error(ctx, error):
    if isinstance(error, commands.MemberNotFound):
        await ctx.send(f"I could not find the user {error.argument}")```

to

```python
    if isinstance(error, discord.ext.commands.errors.MemberNotFound):
naive briar
#

Same thing

young dagger
# naive briar Same thing

The first one gives me errors, the second one actually sends out the message that it couldn't find the user.

#

Do you know why?

slate swan
#

because commands is a sub-package, it cannot be accessed directly

young dagger
slate swan
#

it is the same thing but you cannot use it without import explicitly

#
import discord
discord.ext.commands.MemberNotFound
# wont work
from discord import ext
ext.commands.MemberNotFound
# wont work
from discord.ext import commands
commands.MemberNotFound
# will work
young dagger
lucid pulsar
#

hello guys i am begginer at discord.py bot is there any resourses to learn?

slate swan
#

what error

#

if that a slash command?

young dagger
slate swan
#

what error does it raise?

slate swan
#

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

lucid pulsar
crimson mauve
crimson mauve
lucid pulsar
#

also python in general

crimson mauve
#

Not saying you can't do it, but it's going to be harder than it need to be when ask you about a function you made and you respond with "What's a function?"

lucid pulsar
lucid pulsar
#

is arrangement of funcs make difference?

crimson mauve
#

Yes.

lucid pulsar
#

what func should i start by and end?

crimson mauve
#

See? this is why I gave you that link for the basics.

lucid pulsar
unreal iron
#

hi, how do create a slash command when a bot will respond with a message and react to it with emoji

crimson mauve
crimson mauve
#

Good luck, I know it can be hard.

young dagger
# slate swan what error does it raise?
[2023-01-10 17:00:44] [ERROR   ] discord.client: Ignoring exception in on_message
Traceback (most recent call last):
  File "C:\Users\Gamer\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\ext\commands\bot.py", line 1349, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\Gamer\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\ext\commands\core.py", line 1015, in invoke
    await self.prepare(ctx)
  File "C:\Users\Gamer\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\ext\commands\core.py", line 932, in prepare
    await self._parse_arguments(ctx)
  File "C:\Users\Gamer\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\ext\commands\core.py", line 839, in _parse_arguments
    transformed = await self.transform(ctx, param, attachments)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Gamer\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\ext\commands\core.py", line 709, in transform
    return await run_converters(ctx, converter, argument, param)  # type: ignore
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Gamer\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\ext\commands\converter.py", line 1340, in run_converters
    return await _actual_conversion(ctx, converter, argument, param)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Gamer\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\ext\commands\converter.py", line 1222, in _actual_conversion
    return await converter().convert(ctx, argument)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Gamer\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\ext\commands\converter.py", line 262, in convert
    raise MemberNotFound(argument)
discord.ext.commands.errors.MemberNotFound: Member "39538538" not found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Gamer\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\ext\commands\core.py", line 211, in wrapped
    ret = await coro(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Gamer\Desktop\blitz.py", line 1338, in modlogs_error
    if isinstance(error, commands.MemberNotFound):
                         ^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Command' object has no attribute 'MemberNotFound'

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

Traceback (most recent call last):
  File "C:\Users\Gamer\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\client.py", line 409, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\Gamer\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\ext\commands\bot.py", line 1394, in on_message
    await self.process_commands(message)
  File "C:\Users\Gamer\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\ext\commands\bot.py", line 1391, in process_commands
    await self.invoke(ctx)  # type: ignore
    ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Gamer\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\ext\commands\bot.py", line 1353, in invoke
    await ctx.command.dispatch_error(ctx, exc)
  File "C:\Users\Gamer\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\ext\commands\core.py", line 635, in dispatch_error
    await injected(ctx, error)  # type: ignore
    ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Gamer\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\ext\commands\core.py", line 217, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Command' object has no attribute 'MemberNotFound'
lucid pulsar
crimson mauve
young dagger
onyx rapids
#
import random

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

client = discord.Client(intents=intents)

@client.event
async def on_ready():
    print(f'Je bent ingelogd als: {client.user}')

@client.event
async def on_message(message):
    if message.author == client.user:
        return

    if message.content.startswith('!hello'):
        await message.channel.send('Hello, world!')

client.event
async def on_message(message):
    if message.author == client.user:
        return

    if message.content.startswith('!help'):
        await message.channel.send('!help, laat dit zien')
        await message.channel.send('!dice, Rol een getal tussen de 1 en 6.')
        await message.channel.send('!echo, Herhaal wat je zegt.')


@client.event
async def on_message(message):
    # we do not want the bot to reply to itself
    if message.author == client.user:
        return

    if message.content.startswith('!echo'):
        # the user wants the bot to echo a message
        # get the message to echo by removing the '!echo' prefix and the channel mention
        message_to_echo = message.clean_content[6:]
        # send the message
        await message.channel.send(message_to_echo)


@client.event
async def on_message(message):
    if message.author == client.user:
        return

    if message.content.startswith('!dice'):
        result = random.randint(1, 6)
    await message.channel.send(f"You rolled a {result}")

client.run('token')```

my bot can only run !dice. When I put that command in the comment, the echo works
naive briar
#

You keep overriding the event

onyx rapids
#

how do I fix that

naive briar
#

And use commands.Bot if you want to make prefix commands

crimson mauve
naive briar
onyx rapids
naive briar
#

Wrong reply, whatever

slate swan
#

use the name argument in the @command decorator

young dagger
upbeat otter
young dagger
upbeat otter
young dagger
young dagger
# upbeat otter yeah

Is it recommended to use if isinstance(error, commands.MemberNotFound): anyway?

#

I mean instead of if isinstance(error, discord.ext.commands.errors.MemberNotFound):

upbeat otter
#

yeah ofc

vocal snow
#

It's the same thing just easier to read

young pendant
#

Hey, I've got a question
I programmed a Bot and a former friend of mine invited the bot
Since I don't want this bot to be on his server, I want it to leave the server
how can I do that?

slate swan
unkempt canyonBOT
#

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

Leaves the guild.

Note

You cannot leave the guild that you own, you must delete it instead via [`delete()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild.delete "discord.Guild.delete").
shut lava
#

I am trying to send an embedded message every day at specific time. This is the code I am using.

@client.event
async def on_ready():
    channel = client.get_channel(931582403015737457)

async def job():
    content = get_content()
    word=get_word(content[0].text)
    embed = discord.Embed(title=f"{content[0].text}", description=f"-> {content[1].text}\n-> {content[2].text}\n", color=0x00ff00)
    embed.add_field(name="", value=f"[Google it!](https://www.google.com/search?q={word})")
    await channel.send(embed=embed)

schedule.every().day.at("22:20").do(job)

while True:
    schedule.run_pending()
    time.sleep(1)```

I am getting the following warning at the specified time:
`RuntimeWarning: coroutine 'job' was never awaited
  self._run_job(job)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback`

Except this nothing happens.

How can I fix this? Or what other way can I use except schedule module?
cloud dawn
#

!d discord.ext.tasks.Loop

unkempt canyonBOT
#

class discord.ext.tasks.Loop```
A background task helper that abstracts the loop and reconnection logic for you.

The main interface to create this is through [`loop()`](https://discordpy.readthedocs.io/en/latest/ext/tasks/index.html#discord.ext.tasks.loop "discord.ext.tasks.loop").
shut lava
steep totem
#

Hey! Is it possible to send an image thats created by the script to a discord webhook without downloading it? My script makes matplotlib graphs, and i want to send them to a webhook, without downloading them..

manic knoll
slate swan
slate swan
fading marlin
vale wing
steep totem
vale wing
#

Like discord.File(plot_io, filename="plot.png")

manic knoll
#

i know thats a tree command

#

but i have a hard time with the rest of the coding

steep totem
slate swan
#

you are welcome

steep totem
cloud dawn
steep totem
manic knoll
#

could someone help me code something like this im very new

cloud dawn
manic knoll
#

i know how to start the command off but everything else is a blur

#

@client.tree.command

steep totem
cloud dawn
manic knoll
#

so that is basically like you ping a user and it will send a specific message like โ€œyouโ€™ve been offeredโ€

manic knoll
cloud dawn
#

Have you tried anything?

manic knoll
#

im very new to coding this type of language im currently a lua developer but im confused on everything but starting the command

manic knoll
cloud dawn
#

Do you have one command working?

manic knoll
#

yea

#

it tells me what my ping is

#

its also a slash command

cloud dawn
#

Could you show that command?

manic knoll
#

yep

steep totem
#

@manic knoll this is a pretty nice and beginner friendly tutorial: https://www.youtube.com/watch?v=jh1CtQW4DTo

Hey!
Thanks for watching today's video, I hope you enjoyed and joined my discorddd... also thanks for 2.63K subscribers!!

LINKS -
Join my Discord - https://discord.gg/twHW4UUJGq

Learn Bot Dev - https://youtu.be/e9SYmj1QF8I

Learn Nextcord Slash Commands - https://www.youtube.com/watch?v=yCZMhkSQjCE

Thanks if you read all ...

โ–ถ Play video
#

recommend watching this

manic knoll
cloud dawn
manic knoll
#

yep

cloud dawn
steep totem
cloud dawn
manic knoll
#

yep

manic knoll
# cloud dawn Could you share the code?
async def offer(interaction: discord.Interaction):
    bot_latency = round(client.latency * 1000)
    await interaction.response.send_message(f"Pong! {bot_latency} ms.")```
unkempt canyonBOT
#

Thanks to discord.py, sending local files as embed images is simple. You have to create an instance of discord.File class:

# When you know the file exact path, you can pass it.
file = discord.File("/this/is/path/to/my/file.png", filename="file.png")

# When you have the file-like object, then you can pass this instead path.
with open("/this/is/path/to/my/file.png", "rb") as f:
    file = discord.File(f)

When using the file-like object, you have to open it in rb ('read binary') mode. Also, in this case, passing filename to it is not necessary.
Please note that filename must not contain underscores. This is a Discord limitation.

discord.Embed instances have a set_image method which can be used to set an attachment as an image:

embed = discord.Embed()
# Set other fields
embed.set_image(url="attachment://file.png")  # Filename here must be exactly same as attachment filename.

After this, you can send an embed with an attachment to Discord:

await channel.send(file=file, embed=embed)

This example uses discord.TextChannel for sending, but any instance of discord.abc.Messageable can be used for sending.

cloud dawn
#

He doesn't have a location nor an url.

slate swan
#

read the part below, you can just use attachment://file.png

cloud dawn
slate swan
cloud dawn
#

That could work since File also accepts IO bytes.

slate swan
#

yeah any bufferable io

cloud dawn
#

Learned something new :)

manic knoll
#

well

#
async def offer(interaction: discord.Interaction):
    await interaction.response.send_message(f"")```
#

so far im coding

#

the tree part

#

but how do i code something like where im able to ping a user

cloud dawn
#

You don't need to provide a "/" in the name.

manic knoll
#

oh ok

slate swan
# unkempt canyon

in hikari you could just do hikari.Embed().set_image(hikari.Bytes(your bytes, "file.png")) ๐Ÿคบ

manic knoll
cloud dawn
manic knoll
#

would i need to do a value?

#

oooohhhh

cloud dawn
#

If a value is set then that is the default value.

steep totem
slate swan
#

ignore the above part

#

you need the part below

#

you already have the file prepared, now create an embed and use embed.set_image(url="attachments://plot.png")

#

note that you'll have to send both the embed and file

manic knoll
steep totem
cloud dawn
#

Then we got the member, now we need to add it to the string using an f-string.

steep totem
#
plot_io = io.BytesIO()
plt.savefig(plot_io, format="png")
plot_io.seek(0)

embed = discord.Embed()
# Set other fields
embed.set_image(url="attachments://plot.png")
manic knoll
#

oh so i would basically have to remove "async def offer interaction" etc and replace it with the new one?

manic knoll
#

kk

#

ok now

#

what else

#

@cloud dawn

manic knoll
#

i kinda need help with f strings

steep wedge
cloud dawn
unkempt canyonBOT
#

Creating a Python string with your variables using the + operator can be difficult to write and read. F-strings (format-strings) make it easy to insert values into a string. If you put an f in front of the first quote, you can then put Python expressions between curly braces in the string.

>>> snake = "pythons"
>>> number = 21
>>> f"There are {number * 2} {snake} on the plane."
"There are 42 pythons on the plane."

Note that even when you include an expression that isn't a string, like number * 2, Python will convert it to a string for you.

cloud dawn
# manic knoll i kinda need help with f strings
@client.tree.command(name="offer", description="Where Head Coaches offer players")
async def offer(interaction: discord.Interaction, member: discord.Member) -> None:
    await interaction.response.send_message(f"{member.mention} has been offered by {interaction.user.mention}!")
``` Here is it with the right f-string.
manic knoll
#

OHHHH

#

WAIT THE "F" IS A STRING?

cloud dawn
#

f-string aka format- string

manic knoll
#

OHHH

#

SO BASICALLY LOOKING LIKE THIS

cloud dawn
#

Yes, also reduce the caps.

crimson mauve
#

You are coming along well.

slate swan
#

that will do the same

manic knoll
#

thanks man no where without you or panda

manic knoll
cloud dawn
steep totem
cloud dawn
#

Everything needs proper testing.

steep totem
#

i dont define it anywhere here

plot_io = io.BytesIO()
plt.savefig(plot_io, format="png")
plot_io.seek(0)

embed = discord.Embed()
# Set other fields
embed.set_image(url="attachments://plot.png")
manic knoll
#

!!!!!! IT WORKED

#

thank you so much

cloud dawn
#

You can offer yourself lol.

slate swan
manic knoll
#

Lol yea we need to change that

#

can i add you?

slate swan
#

it had the file name saved as plot.png

cloud dawn
manic knoll
#

ok so

steep totem
cloud dawn
slate swan
#

now send both the embed and the file

#

filename="plot.png"*

manic knoll
#

another thing is we need to first make sure you have a role named "head coach" if not then you wont be able to offer anyone it should give you a error saying "you are not a head coach"

manic knoll
steep totem
manic knoll
manic knoll
#

ok so how would i start the if statement

steep totem
#

finally, thank you very much @slate swan ๐Ÿฅฐ

slate swan
#

no problem

manic knoll
#

ok added it

cloud dawn
manic knoll
#

added

cloud dawn
# manic knoll ok so how would i start the if statement
@client.tree.command(name="offer", description="Where Head Coaches offer players")
async def offer(interaction: discord.Interaction, member: discord.Member) -> None:
    msg = f"{member.mention} has been offered by {interaction.user.mention}!"

    if interaction.user.id == member.id:
        msg = f"Hey {member.mention}! You cannot offer yourself."

    await interaction.response.send_message(msg)
manic knoll
#

wwwwwwwwwwwwwwwwww

cloud dawn
#

Can you also offer bots?

manic knoll
#

no but i dont think anyone is going to even try that

#

lol

cloud dawn
#

Okay, as for the role, do you know how the get the role id?

#

In Discord itself.

manic knoll
#

nah

cloud dawn
#

Discord identifies channels, users, messages and roles using a role ID. Role IDs can be used in conjunction with bots or embeds to directly point to the appropriate section in Discord. Including ID information when embedded can greatly improve the experience of navigating through your Discord server.

โ–ถ Website: https://slurptech.com
โ–ถ Discord S...

โ–ถ Play video
slate swan
#

Go to settings and enable developer mode thing

manic knoll
#

after enabling what else

slate swan
#

Then right click role id

#

And tap copy id

upbeat otter
manic knoll
#

still not showing me

#

@slate swan

cloud dawn
upbeat otter
upbeat otter
cloud dawn
#

He would've been done if he'd watch the video...

manic knoll
#

ok got it

upbeat otter
#

assuming genders in 2023

manic knoll
#

bruh

cloud dawn
#

It*

slate swan
slate swan
manic knoll
#

i got it

#

now @cloud dawn

slate swan
#

Right click on my user and it says copy id correct?

manic knoll
#

yep

slate swan
#

Then it's working

manic knoll
#

ik

cloud dawn
slate swan
cloud dawn
# manic knoll now <@169790484594556928>
@client.tree.command(name="offer", description="Where Head Coaches offer players")
async def offer(interaction: discord.Interaction, member: discord.Member) -> None:
    msg = f"{member.mention} has been offered by {interaction.user.mention}!"

    if 807415650778742785 in [role.id for role in member.roles]:
        msg = f"Sorry, but you don't have the head coach role to perform this command."
    elif member.bot:
        msg = f"You cannot offer bots since they are sentient beings, thus are immortal."
    elif interaction.user.id == member.id:
        msg = f"Hey {member.mention}! You cannot offer yourself."

    await interaction.response.send_message(msg)
cloud dawn
sick birch
#

What's goin on up here ๐Ÿคจ

slate swan
fading marlin
#

Oh and hi everyone! ๐Ÿ‘‹

cloud dawn
cloud dawn
cloud dawn
cloud dawn
manic knoll
#

didnt work sadly

cloud dawn
manic knoll
#

yea

#
async def offer(interaction: discord.Interaction, member: discord.Member) -> None:
    msg = f"{member.mention} has been offered by {interaction.user.mention}!"

    if 1062450539595567275 in [role.id for role in member.roles]:
        msg = f"Sorry, but you don't have the head coach role to perform this command."
    elif member.bot:
        msg = f"You cannot offer bots since they are sentient beings, thus are immortal."
    elif interaction.user.id == member.id:
        msg = f"Hey {member.mention}! You cannot offer yourself."

    await interaction.response.send_message(msg)```
cloud dawn
#

Any errors?

manic knoll
#

nope

cloud dawn
#

Hmm

#

@fading marlin Any idea?

fading marlin
#

What's the issue?

cloud dawn
#

Doesn't work, @manic knoll right?

manic knoll
#

is it the to many capitals

#

yes

cloud dawn
fading marlin
#

"Doesn't work" doesn't really help :/
What isn't working? Is the command not appearing? Have you synced? Is the command not sending the appropriate respond?

manic knoll
#

@cloud dawn

fading marlin
#

You're supposed to answer that silly lol

cloud dawn
#

๐Ÿ˜‚

manic knoll
#

half of the command is working like the offer part

#

but

#

i dont have the head coach role which is the part that isnt working

#

@fading marlin

cloud dawn
#

What is the reponse when you don't have the head coach role?

manic knoll
#

theres none

#

it still shows that you have been offered

slate swan
#

Should it not be:

if 1062450539595567275 not in [role.id for role in member.roles]:
        # . . .
cloud dawn
#

Oh yeah

slate swan
#

(Not my code but I'm guessing 1062450539595567275 is the head coach role ID)

cloud dawn
#
@client.tree.command(name="offer", description="Where Head Coaches offer players")
async def offer(interaction: discord.Interaction, member: discord.Member) -> None:
    msg = f"{member.mention} has been offered by {interaction.user.mention}!"

    if not member.get_role(1062450539595567275):
        msg = f"Sorry, but you don't have the head coach role to perform this command."
    elif member.bot:
        msg = f"You cannot offer bots since they are sentient beings, thus are immortal."
    elif interaction.user.id == member.id:
        msg = f"Hey {member.mention}! You cannot offer yourself."

    await interaction.response.send_message(msg)
manic knoll
#

WORKED

fading marlin
#

fwiw, Member.get_role exists and does what you're doing in the first if

fading marlin
#

I'm just nitpicking lmao. You can probably shorten the first statement with if not member.get_role(...):

manic knoll
#

OK

#

so now

fading marlin
#

How do I acknowledge an interaction?

manic knoll
#

now

#

we make a embed

#

wait

#

wait yes we make a embed that sends to the person we offered dms

#

@cloud dawn

upbeat otter
crimson mauve
cloud dawn
unkempt canyonBOT
#

is_done()```
[`bool`](https://docs.python.org/3/library/functions.html#bool "(in Python v3.11)"): Indicates whether an interaction response has been done before.

An interaction can only be responded to once.
upbeat otter
#

okay now im uncertain about the question

fading marlin
#

You still have to send a response afterwards though. I'm talking in the context of buttons and modals. I'm pretty sure you don't have to respond with anything, you can just acknowledge (god that's a hard word to type) it

unkempt canyonBOT
#
Naw.

No documentation found for the requested symbol.

fading marlin
#

Hmm perhaps if I edit_message without doing anything?

crimson mauve
#

ยฏ_(ใƒ„)_/ยฏ

fading marlin
#

!d discord.InteractionResponse lmao

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.
cloud dawn
crimson mauve
cloud dawn
manic knoll
#

ok so im just gonna make a embed real quick

fading marlin
#

I'm making a modal with a single text input field. In the text input you should input something that you want to write to a shell's stdin. What would be a proper label for the text input?

manic knoll
#
        conf_embed.add_field(name="Offered:", value=f"{member.mention} has been kicked from this server by {ctx.author.mention}.", inline=False)
 
        await ctx.send(embed=conf_embed)```
#

@cloud dawn

#

welp

#

holdon

#

wait

#

actually how would a put a embed into this @cloud dawn

crimson mauve
#

here ya go, I'll just give you what I'm using.

    class TestInput(discord.ui.Modal, title="Quiz"):
        Guess = discord.ui.TextInput(label="What is your guess?", placeholder="????", style=discord.TextStyle.short,
                                     required=True, max_length=20)
        async def on_submit(self, interaction: discord.Interaction,):
            await interaction.response.defer()
fading marlin
#

pardon me but, what

crimson mauve
fading marlin
crimson mauve
#

What's the text input for?

fading marlin
#

you write stuff that'll be forwarded to a shell/bash process' stdin

crimson mauve
#

label="you write stuff that'll be forwarded to a shell/bash process' stdin"

Label is just the text that shows up right above the text input

fading marlin
#

yeah, ik, but I need something more simple/short

#

for instance the modal's title is named "Write to stdin"

crimson mauve
#

Ah, conveyance problems.
What kind of people are going to be using this, normal users or people that know what they are doing?

fading marlin
#

hopefully people that know what they're doing

crimson mauve
#

Then get technical

fading marlin
#

I just need a simple label that I can use ๐Ÿ˜ญ

crimson mauve
#

To: Shell/Bash

#

ยฏ_(ใƒ„)_/ยฏ

fading marlin
#

hmm, that'll probably have to do

#

thanks!

#

now to work on the logic ๐Ÿ˜”

fading marlin
#

as in wait_for?

shrewd apex
#

y modal ๐Ÿ˜”

shrewd apex
fading marlin
shrewd apex
#

just a sec I'll link u to docs

fading marlin
#

oh no

shrewd apex
fading marlin
#

hmm, perhaps, but then again I don't think you know the entire context

shrewd apex
#

ik in disnake in dpy iirc it was contextmenu

fading marlin
#

oh

#

no that's not gonna work unfortunately

shrewd apex
#

why not?

fading marlin
#

you can only have up to 5 (last time I checked), it's for an extension that I'm working on, and you have to have a shell session active to be able to write

#

plus the Modal really isn't that complicated

class StdinManager(discord.ui.Modal):
    stdin: discord.ui.TextInput = discord.ui.TextInput(label="To stdin:")

    def __init__(self, process: Process, /):
        super().__init__(title="Write to the process' stdin")
        self.subprocess = process.process

    async def on_submit(self, interaction: discord.Interaction, /) -> None:
        self.subprocess.stdin.write(f"{self.stdin.value}\n")
        await interaction_response(...)  # TODO: do
shrewd apex
#

sure but still dont see the reason not to use a message command just having 5 is not a problem unless u have other plans for it and for the shell session its easy to write a class or function and have it return the output made one eval command similar way before

fading marlin
#

while I'm at it, does anyone know what args I should pass to TextInput[...]? is it the modal or something else?

#

oh you're in the dpy server

shrewd apex
#

thats nice

fading marlin
#

idk, adding a context menu will probably only make it a lot more complicated

#

meanwhile I can just add a button next to the kill thingy and send the modal there

#

it's probably more friendly in terms of UX imo

fading marlin
#

yup, ty :D

unkempt canyonBOT
#

discord/ui/text_input.py line 50

V = TypeVar('V', bound='View', covariant=True)```
fading marlin
#

yeah, I just found it weird since text inputs won't always have views?

manic knoll
#

can anyone help me code this to put a embed inside of it

#
@client.tree.command(name="offer", description="Where Head Coaches offer players")
async def offer(interaction: discord.Interaction, member: discord.Member) -> None:
    msg = f"{member.mention} has been offered by {interaction.user.mention}!"

    if not member.get_role(1062450539595567275):
        msg = f"Sorry, but you don't have the head coach role to perform this command."
    elif member.bot:
        msg = f"You cannot offer bots since they are sentient beings, thus are immortal."
    elif interaction.user.id == member.id:
        msg = f"Hey {member.mention}! You cannot offer yourself."

    await interaction.response.send_message(msg)
#

@fading marlin

blazing condor
#

you can use the discord.Embed class to create an embed, and then use the add_field method to add fields to the embed.

shut elk
#

@shrewd apex it sitll does:

manic knoll
shut elk
#

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

shut elk
shut elk
#

can anyone let me know why

potent spear
#

hence the "unknown message" error

shut elk
#

no msg is being deleted

potent spear
eager hill
#

how would i add a description for this member.mention?

ionic garden
#

so i want a slash command to take a list of numbers

#

is there any way for this to be possible?

potent spear
eager hill
#

how would i do that

unkempt canyonBOT
#

examples/app_commands/basic.py line 62

@app_commands.describe(text_to_send='Text to send in the current channel')```
subtle jolt
#

getting this unknown interaction error when using interaction.response.defer but not sure why

Code:

class Select(discord.ui.Select):
    def __init__(self, session, name, user):
        self.session = session
        self.name = name
        self.user = user
        options=[
            discord.SelectOption(label="Overall"),
            discord.SelectOption(label="Solos"),
            discord.SelectOption(label="Doubles"),
            discord.SelectOption(label="Threes"),
            discord.SelectOption(label="Fours")
            ]
        super().__init__(placeholder="Select a mode",max_values=1,min_values=1,options=options)
    async def callback(self, interaction: discord.Interaction):
        await interaction.response.defer() # <-------------------------------------------------------- HERE
        mode = self.values[0].lower()
        refined = self.name.replace('_', r'\_')
        message = await interaction.original_response()
        if not interaction.user.id == self.user:
            await interaction.followup.send(content=f"{refined}'s {mode} session:", file=discord.File(f'{os.getcwd()}/database/{self.name}.png'),ephemeral=True)
        else:
            await interaction.edit_original_response(content=f"{refined}'s {mode} session:", attachments=[discord.File(f'{os.getcwd()}/database/activerenders/{message.id}/{mode}.png')])

class SelectView(discord.ui.View):
    def __init__(self, session, name, user, *, timeout = 300):
        super().__init__(timeout=timeout)
        self.add_item(Select(session, name, user))

    async def on_timeout(self) -> None:
        self.clear_items()
        await self.message.edit(view=self)
#

Error:

Traceback (most recent call last):
  File "C:\Users\Lenovo User\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\ui\view.py", line 425, in _scheduled_task
    await item.callback(interaction)
  File "c:\Users\Lenovo User\Desktop\LifeAsPy\Hypixel Api\SessionStats\ui.py", line 41, in callback
    await interaction.response.defer()
  File "C:\Users\Lenovo User\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\interactions.py", line 636, in defer
    await adapter.create_interaction_response(
  File "C:\Users\Lenovo User\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\webhook\async_.py", line 218, in request
    raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction```
potent spear
subtle jolt
rare echo
#

how can i call a function infinitely in a command?

fading marlin
#

do you want an answer other than a while True loop?

rare echo
#

well i have a function, in there is a while x, which x will be true, but when it is true its only executing once and not actually looping

fading marlin
#

then you've got something exiting the loop

#

why do you need a while loop anyway?

rare echo
#

updating an embed

fading marlin
#

hmm sounds more like a duty for tasks than a while loop

rare echo
fading marlin
#

you should update it each time a new song is played then

rare echo
fading marlin
#

well you have a queue right? maybe you can dispatch an event once an item from the queue is removed (assuming that's how it works)

rare echo
#

yeah i can see that but are you saying with tasks? because right now im trying to get this to work with a just nowplaying command,

run cmd, message is sent with current song, update it when next starts

so im stuck on how to execute something to start essentially checking if that happens, which is why i was using a loop prior

fading marlin
#

hmm, that makes stuff a bit more complicated

rare echo
#

how so?

#

or whats the easy way out here

fading marlin
#

if you want an easy way, just don't update the message. Let users execute the now playing command whenever they want to know what's currently playing

rare echo
#

thats no fun

#

x)

fading marlin
#

I feared so

#

could you send what you currently have?

rare echo
#

haha

#

uhh i mean

#

theres nothing solid right now, its kind of all over the place with testing

#

its basically just

run cmd, send the now playing, then i was attempting a loop to edit the message with new info every 3 seconds for testing

fading marlin
#

do you at least have some sort of play command that adds the song to a queue?

rare echo
#

yes

fading marlin
#

ok, I guess we can start from there

rare echo
#

there is a queue, and i can check when a new song is played

#

its just a looping problem right now, as when i have a while True within a cmd its just running through once and quitting, even if calling it as a function

fading marlin
rare echo
#

but how am i to call that, either in a command, or when a song is added to queue ( which is still a command )

#

because it would either need to be called each song, or start once a command is sent, which in my mind are both loops anyway

fading marlin
#

can you send the code for your command that adds a new song?

rare echo
#

its just creating a queue bound to server id, with track info which i can globally use, nothing special

fading marlin
#

yeah but like, what type of queue? is it a custom class? is it a datatype?

rare echo
#

its just through lavalink, its not custom or anything

fading marlin
#

it would be helpful to see the code, otherwise I'm just gonna be guessing stuff

eager hill
#

How would i count the amount of times a member was mentioned?

fading marlin
#

in a single message?

sick birch
#

jinx

fading marlin
#

lol

eager hill
#

in an entire channel

fading marlin
#

yikes, no good

sick birch
#

That's gonna take a while

eager hill
#

lmme be more specific holdon

sick birch
#

Please

eager hill
#

so whenever someone runs a slash command itll @ them and then i want it to add that to a running counter, so the goal is the user runs the slash command and the bot says "this person has been mentioned x amount of times now!"

eager hill
fading marlin
#

is it temporary? is it guild-specific?

eager hill
#

yeah temporary

#

and itll be channel specific

fading marlin
#

you could probably use a dictionary and an on_message

eager hill
# fading marlin you could probably use a dictionary and an on_message

would it not work using slash commands? ```py
@app_commands.describe(vote='Your vote')
async def vot(interaction: discord.Interaction, vote: Literal['Duwap', 'Astro']):

astroID = '@eager hill'
if vote == "Astro":
    # await interaction.response.send_message()

    await interaction.response.send_message(f'You voted {astroID}')
    votes = len(discord.Member.mention)
    await interaction.response.send_message(f'{astroID} has {votes} votes')
something like this?
fading marlin
#

Sure, but you can't respond to an interaction twice

eager hill
#

alright so lemme remove the astro has votes

eager hill
fading marlin
#

discord.Member.mention is a property of an instance of the class discord.Member. When instantiated, Member.mention returns the formatted way to mention a user (e.g. <@531961974972481536>), not the amount of times the user has been mentioned

eager hill
#

ohhh

#

so it doesnt return the amount of times the user has been mention but how could i get the amount a user has been mentioned?

fading marlin
#

on_message

eager hill
blazing condor
#

watcha trying to do @eager hill

fading marlin
unkempt canyonBOT
#

A list of Member that were mentioned. If the message is in a private message then the list will be of User instead. For messages that are not of type MessageType.default, this array can be used to aid in system messages. For more information, see system_content.

Warning

The order of the mentions list is not in any particular order so you should not rely on it. This is a Discord limitation, not one with the library.

real badger
#

how do I remove a user from timeout?

slate swan
#

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

#

whats is that

#

problem

naive briar
unkempt canyonBOT
#

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

Applies a time out to a member until the specified date time or for the given [`datetime.timedelta`](https://docs.python.org/3/library/datetime.html#datetime.timedelta "(in Python v3.11)").

You must have [`moderate_members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.moderate_members "discord.Permissions.moderate_members") to do this.

This raises the same exceptions as [`edit()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member.edit "discord.Member.edit").
naive briar
#

!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
#
async def clear_error(ctx, error):
    if isinstance(error, commands.MissingRequiredArgument):```
I'm doing this as a command handler instead of doing `commands.MissingRequiredArgument` is there a way I can see what argument is missing so I can say something specific based on the argument that's missing
naive briar
#

Just use commands.MissingRequiredArgument, why do you want to change it

slate swan
#

I want to see the specific argument missing that's what I'm asking

naive briar
#

!d discord.ext.commands.MissingRequiredArgument.param

unkempt canyonBOT
slate swan
#

appreciate it

slate swan
#

no, error.param

#

I switch t hat with commands.MissingRequiredArguments.param or "arg"

#

commands.....

#

it should look like this py if error.param.name == "arg": ...

#

ahh

#

do I change anything if I have * before a variable so like *text

#

nope

#

ai

vernal finch
#

!d

#

!intents

#

class

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: applied mute to @onyx rapids until <t:1673423042:f> (10 minutes) (reason: newlines rule: sent 119 newlines in 10s).

The <@&831776746206265384> have been alerted for review.

vale wing
#

Happens

daring olive
#

!unmute 433691548543090698

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: pardoned infraction mute for @onyx rapids.

daring olive
#

!paste sorry about that, please use this ๐Ÿ‘‡๐Ÿป

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.

onyx rapids
clear elm
#

what does discord.ext.commands.errors.CommandInvokeError: Command raised an exception: UnboundLocalError: local variable 'channel' referenced before assignment mean?

naive briar
clear elm
#

and how do i fix it?

naive briar
#

!e

def fn(b: bool):
    if b:
        var = 1

    print(var)

fn(False)
unkempt canyonBOT
#

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

001 | Traceback (most recent call last):
002 |   File "<string>", line 7, in <module>
003 |   File "<string>", line 5, in fn
004 | UnboundLocalError: cannot access local variable 'var' where it is not associated with a value
naive briar
#

If b isn't true, the variable var wouldn't exist

#

This isn't even out of basic Python knowledge

clear elm
#

oh

#

lol that was super easy to fix lol, thanks

onyx rapids
vale wing
#

I mean how tf is it possible not to understand that, it even tells you what you need to do to fix it

naive briar
#

Some people just don't want to read

slate swan
slate swan
primal token
#

Bro is five years ahead of us

brazen raft
primal token
#

It does, it just has skill issues

shrewd apex
quick gust
#

messages that are how old, cannot be deleted by channel.purge?

#

actually lemme check the docs

naive briar
#

14 days

quick gust
#

thanks

swift acorn
#

Hey! I have been facing a new issue with my bots recently, it keeps giving me the error that member or user object has no attribute avatar_url, although it did before and used to work just fine, any solutions?

quick gust
#

avatar.url

#

changed in... 1.7+?

#

not sure but yeah

brazen raft
#

Changed in 2

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").
winged musk
slate swan
#

hello i'd like to do a Vinted Bot but first i need an API Key

#

i dont find where to get it

#

they dont have website

upbeat otter
crimson mauve
slate swan
#

i do the bot as a discord bot

upbeat otter
#

well ok, how does your issue have anything to do with this channel

upbeat otter
#

your question does not belong here pepecri

slate swan
#

and where can i ask so

crimson mauve
# slate swan wdym

This is for Discord, why are you expecting us to know anything about vinted?

slate swan
#

...

#

nvm

crimson mauve
upbeat otter
#

rip

crimson mauve
#

LMAO, https://www.vinted.fr/forum-rules

Hope you know French.

upbeat otter
upbeat otter
slate swan
upbeat otter
#

imagine

crimson mauve
#

YA, imagine still following that stupid "French is bad" meme in 2023.

upbeat otter
#

when did that become a meme sc_peepoWtf

naive briar
#

It's not just a meme if it's real

upbeat otter
#

๐Ÿ’€

crimson mauve
quick gust
#

this channel got a lot more hostile ever since zippy started talking

crimson mauve
quick gust
#

okaay

naive briar
#

The problem can't always solve itself

#

Or even ever

quick gust
#

he left lmao

quaint epoch
#

Give a dozen minutes and a piece of paper with a pen it's pretty easy to figure out nearly all of that token. You better reset it. Is it really that hard to change the string to "TEST" before taking a screenshot?

quick gust
quaint epoch
#

It's just double click, ctrl-x and TEST

quick gust
#

talking about the former part

#

not, replacing it with test

quaint epoch
#

There are exceptions

#

In a server with 200k members?

slate swan
#

Hello i need help

quick gust
#

from discord.ext

slate swan
quick gust
#

share it

slate swan
quick gust
#

commands.Bot

naive briar
#

!d discord.ext.commands.Bot

unkempt canyonBOT
#

class discord.ext.commands.Bot(command_prefix, *, help_command=<default-help-command>, tree_cls=<class 'discord.app_commands.tree.CommandTree'>, description=None, intents, **options)```
Represents a Discord bot.

This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client") and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client") you can do with this bot.

This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality to manage commands.

Unlike [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client"), this class does not require manually setting a [`CommandTree`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.CommandTree "discord.app_commands.CommandTree") and is automatically set upon instantiating the class.

async with x Asynchronously initialises the bot and automatically cleans up.

New in version 2.0.
hushed galleon
#

discord.Bot is something you'd see in pycord iirc

slate swan
#

hey peoples

#

i created a script which fetches memes from reddit and makes video compilation

#

i want to deploy it online so the program works online forever

#

how can i do so

quick gust
mystic lance
#

whats the problem

#

the token i deleted for the picture

slate swan
mystic lance
shrewd apex
#

there is no method get_db_data

#

the method is in the cog

#

u are using self instance of the view

young dagger
#

How can I make it find users that are not in the server but existing in the database?

# Modlogs command
@client.command(name = 'modlogs')
async def modlogs(ctx, member: discord.Member = None):```
onyx rapids
young dagger
fading marlin
fading marlin
fading marlin
#

You can use a listener like you were doing 2 functions above, or process_commands in the event

young dagger
# fading marlin You can use `discord.User` instead

But this will not work with the error handling?

@modlogs.error
async def modlogs_error(ctx, error):
    if isinstance(error, discord.ext.commands.errors.MemberNotFound):
        await ctx.send(f"I could not find the user {error.argument}.")```
fading marlin
#

Try it and see

young dagger
fading marlin
#

It raises UserNotFound instead. Your other errors are probably being eaten somewhere

onyx rapids
fading marlin
#

No, not your commands, your event

onyx rapids
#

ohh

onyx rapids
fading marlin
#

Looks good to me ๐Ÿคท

upper root
#

Hey guys I have a problem. I've been coding some slash commands recently and finished one, although I am trying to create a new slash commands but everytime I restart the bot the second command do not show at all. Only the first one I've made show but not the second one

#
@client.tree.command(name="hello", description="Create a new ")
@app_commands.checks.has_role(ADMIN_ROLE)
async def releases(itr: discord.Interaction, releasee: str, namee: str):
    print(releasee)
    print(namee)

The command is really basic as its the second one and im simply trying to make it appear

young dagger
onyx rapids
upper root
fading marlin
# onyx rapids

You don't have any command called echo in the snippet you sent ๐Ÿค”

#

Also, you have an event and a command with the same function name

#

Commands don't take a message object, they take in a Context object. They don't take in the client either

upper root
#

@fading marlin Thank you hahah, forgot to sync man โค๏ธ

fading marlin
#

No problem

onyx rapids
#

but what line do I need to change to what?

young dagger
#

Thanks @fading marlin

fading marlin
#

Sure thing

unreal iron
#

Hi, How do I make my bot add multiple reaction at the same time?

onyx rapids
# fading marlin ^

Might be because english isnt my first language, but idk how the solve it

cold sonnet
#
await message.add_reaction()
await message.add_reaction()
#

it's reaction_add innit

#

!d discord.Message.add_reaction

unkempt canyonBOT
#

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

Adds a reaction to the message.

The emoji may be a unicode emoji or a custom guild [`Emoji`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Emoji "discord.Emoji").

You must have [`read_message_history`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") to do this. If nobody else has reacted to the message using this emoji, [`add_reactions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.add_reactions "discord.Permissions.add_reactions") is required.

Changed in version 2.0: `emoji` parameter is now positional-only.

Changed in version 2.0: This function will now raise [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "(in Python v3.11)") instead of `InvalidArgument`.
cold sonnet
#

it's add_reaction

unreal iron
#

that works but can I make it at the same time?

cold sonnet
#

no, it takes one

potent spear
errant pecan
#

Who can help ? My bot does not respond to messages and does not give out the participant's level for them and does not write about it in the chat. Just please don't throw me a link to the documentation for this module

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.

potent spear
#

you can't read docs apparently
You just want the docs read out FOR you