#discord-bots

1 messages ยท Page 881 of 1

warm plover
#

Nah I found my mistake thought wise

small igloo
#

:praise_the_sun: this work, ty

warm plover
#

HOLY SHOT I WAS RIGHT LMFAO

small igloo
warm plover
#

I KNEW IT

slate swan
#

weird maybe an internal error because you have declared the embed instance and youre sending it

warm plover
#

If item is "brewing stand" it'll make the statement false but it goes to the next one being an or since "brewing stand" isn't "sword" it'll return true!

warm plover
slate swan
#

i had a stroke reading my own sentence

warm plover
#

And/or are logic operators and requires everything to be true while or only requires one

maiden fable
#

The symmetry istg

slate swan
maiden fable
#

Indeed

slate swan
maiden fable
#

Common bug

slate swan
slate swan
#

RobinPepePoint

maiden fable
#

Lmao

slate swan
#

im outside your househeheheha

slate swan
maiden fable
#

Eh

slate swan
#

big pro02love

maiden fable
#

Stop. It.

slate swan
slate swan
unkempt canyonBOT
maiden fable
#

BTW Robin

#

Did u attend discord's event yesterday?

slate swan
#

guys

slate swan
spring flax
maiden fable
#

Yea

slate swan
#

why does go have a gopher and we dont have a cool cartoon snakegopher

spring flax
#

yeah it was most of what i already knew was coming so meh

small igloo
slate swan
spring flax
#

you can watch it on YouTube

maiden fable
sick birch
maiden fable
small igloo
spring flax
sick birch
#

im only in the server to get updates on new interaction features

small igloo
maiden fable
#

Lmao

maiden fable
#

Time to bother YouTube

spring flax
#

though actually I may just try to grow my bot now on top.gg or something or wait

warm plover
spring flax
#

that's unfortunate

spring flax
#

but, well, I already have the code, just need to replicate it to another bot account and wait

slate swan
slate swan
#

okay bye, good night borrywave

slate swan
warm plover
#

I'm a monster and just don't like coding in OOP I can I have I just prefer functional or whatever its called

slate swan
#

its already 6 am ๐Ÿ˜”

small igloo
slate swan
small igloo
spring flax
small igloo
sick birch
slate swan
sick birch
#

tell it to the other contributors

#

i only did the bot's status lmao

spring flax
spring flax
#

it was only one the top.gg? No word-of-mouth?

spring flax
maiden fable
#

Word of mouth was also there

slate swan
sick birch
spring flax
#

oh i see

#

ping command only in a cog lol

sick birch
#

indeed

#

it was more of a proof of concept than anything

spring flax
#

it only ahs one command?

sick birch
#

For now but they're going to implement all the event commands from @lament depot

maiden fable
sick birch
#

it wasn't me ๐Ÿ˜ญ

rose hazel
#

hey is there something where when someone deletes a message

warm plover
#

Yes

spring flax
#

!d discord.on_message_delete

unkempt canyonBOT
#

discord.on_message_delete(message)```
Called when a message is deleted. If the message is not found in the internal message cache, then this event will not be called. Messages might not be in cache if the message is too old or the client is participating in high traffic guilds.

If this occurs increase the [`max_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") parameter or use the [`on_raw_message_delete()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_message_delete "discord.on_raw_message_delete") event instead.

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

On_message_delete

jolly basalt
#

docs for drop downs?

rose hazel
#

can u show me an example

spring flax
unkempt canyonBOT
#

class disnake.SelectMenu```
Represents a select menu from the Discord Bot UI Kit.

A select menu is functionally the same as a dropdown, however on mobile it renders a bit differently.

Note

The user constructible and usable type to create a select menu is [`disnake.ui.Select`](https://docs.disnake.dev/en/latest/api.html#disnake.ui.Select "disnake.ui.Select") not this one.

New in version 2.0.
jolly basalt
#

ty

slate swan
rose hazel
#

ah

#

got it

sick birch
#

That should still carry over to the forks as well

slate swan
sick birch
#

Complements the documentation

slate swan
#

im jokingkek

slate swan
rose hazel
#

not working ๐Ÿ˜ฆ

slate swan
#

wdym

spring flax
#

what is not working?

rose hazel
#

im deleting messages and its not printing anytthing

warm plover
#

Oh God not cogs

slate swan
spring flax
#

!intenst

unkempt canyonBOT
#

Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default, discord.py has all intents enabled, except for the Members and Presences intents, which are needed for events such as on_member and to get members' statuses.

To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.

Next, in your bot 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

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

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

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

rose hazel
#

i have intents

slate swan
rose hazel
#

yes i have them

slate swan
#

then the message isnt in cache

sick birch
#

Did you load the cog?

rose hazel
#

how do iget it in there

#

yeeah

slate swan
# unkempt canyon

If the message is not found in the internal message cache, then this event will not be called.

sick birch
#

Well if you're not doing anything else wrong, then it's a caching problem

slate swan
#

yeah

warm plover
#

Try deleting a new message

sick birch
#

Though I'm almost sure there's something else wrong

rose hazel
#

hmm

#

i did i typed in messages and deleted them printed nothing

sick birch
#

And your bot has access to the channel?

rose hazel
#

ye

sick birch
#

Then it's most likely a caching issue which I still find unlikely

slate swan
#

try it many times it probably is a caching problem

rose hazel
#

actuall

#

it might not have access to the channel

sick birch
#

Yeah

rose hazel
#

on message isnt workign either

warm plover
#

Are you loading your cogs?

rose hazel
#

ah ur right

#

my cog isnt loaded ๐Ÿ˜

#

gonna try it now

sick birch
#

Yeah for things like message delete it's usually going to be something else

warm plover
rose hazel
#

yep its working now thanks guys

jolly basalt
sick birch
rose hazel
#

is it possible to get the author

warm plover
#

Message.author

rose hazel
#

who sent the message who deleted it

valid galleon
#

currently, i use this code to load in all my cogs(present in the cogs directory). But, is it possible to modify this to load cogs from multiple directories? i want to better organize my files

for cog in listdir(path.join(path.dirname(path.abspath(__file__)), "cogs")):
    if cog.endswith(".py"):
        client.load_extension(f"cogs.{cog[:-3]}")

    else:
        print(f'unable to load {cog[:-3]}')```
sick birch
#

The person who sent the message that was deleted or the moderator who deleted the message?

rose hazel
#

person

#

who created the message

#

and deleted it

sick birch
#

The person who sent the message can be found out by using message.author, unfortunately you can't figure out who deleted the message

rose hazel
#

thats okay

slate swan
spring flax
#

Not saying it is efficient, but there is a way you can find it

sick birch
# spring flax audit logs

I don't think audit logs show one-off deleted message, it's always been very unreliable in my experience

warm plover
sick birch
#

Sometimes it'll show that I deleted a single message but 90% of the time it doesn't

ancient wren
#

ive foudn it to be very realiable

sick birch
#

Audit logs?

rancid stump
#

i need to send a long message using my bot

anyway to format it rather then embed?

feral jacinth
feral jacinth
#

if you write all cmds in one file your bot will be slow

sick birch
rancid stump
#

this is one example

sick birch
#

That's not that bad, just send it as a regular message or embed

rancid stump
sick birch
#

Oh I see

valid galleon
rancid stump
sick birch
#

Then you'll probably want to send it as a text file or something of sorts because you can't send message > 2000 in length

sick birch
# valid galleon i'll try

Create a function that takes in a folder, it loads all the extensions within the folder. If it encounters a folder inside the folder, then call itself

warm plover
#

Yeah you could also store it as multiple strings and just send one at a time

rancid stump
jolly basalt
#

How do I implement code that does this
A button has the name of a user. When a person presses that button, a dm goes to that user

How do I do that

small igloo
#

timeout for bot.wait_for?

jolly basalt
#

when a person clicks 'lonely' a dm goes to me, etc

warm plover
#

Best bet is sending a file as others have recommended IMO

small igloo
small igloo
jolly basalt
#

what do i do in the callback function

small igloo
jolly basalt
small igloo
warm plover
#

Anyways im out hope I was of some use lmao

spring flax
unkempt canyonBOT
#

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

Tries to get a member from the cache with the given ID. If fails, it fetches the member from the API and caches it.

If you want to make a bulk get-or-fetch call, use [`get_or_fetch_members()`](https://docs.disnake.dev/en/latest/api.html#disnake.Guild.get_or_fetch_members "disnake.Guild.get_or_fetch_members").
spring flax
#

this exists

small igloo
small igloo
jolly basalt
#

my doubt is, how do i get the id into the callback function

#

btw, ik i write poor code. please dont make fun of me

small igloo
jolly basalt
#

;-;

small igloo
jolly basalt
spring flax
#

why are you fetching the member?

jolly basalt
#

to send a dm to them

small igloo
spring flax
#

role.members returns a list of members

#

!d disnake.Role.members

unkempt canyonBOT
spring flax
#

you have a list of member objects, iterate through and send them

#
role = #role object
members = role.members
for member in members:
  await member.send()
jolly basalt
jolly basalt
spring flax
#

give the full button in a codeblock

#

not screenshot please

jolly basalt
#
@bot.command(name = 'report', aliases = ['rep'])
async def reportgame(ctx):
    role = discord.utils.get(ctx.guild.roles, name="Bot Testers")
    members = role.members
    ids = [member.id for member in role.members]
    view = View()

    async def button_callback(interaction):
        user = bot.fetch_user(id)
        await interaction.response.send_message('Hi '+ user.name+ ' :wave:')
    
    for i in ids:
        user = await bot.fetch_user(int(i))
        b = Button(label = user.name, style=discord.ButtonStyle.green)
        b.callback = await button_callback(id = int(i))
        view.add_item(b)
    await ctx.send('Please select a moderator', view=view)
#

I havent written the rest cuz im stuck

#

you see the user = bot.fetch_user(id) in the callback?

spring flax
#

so what's id?

jolly basalt
#

how do i get that.

spring flax
#

okay wait so basically you want a button view and whichever buttion is pressed it DM's that memeber?

spring flax
#

the button label would be the name and discriminator or just the name of the member?

jolly basalt
small igloo
#
@duel.error
async def duel_error(ctx,error):
    if isinstance(error, commands.TimeoutError):
        cd = disnake.Embed(title="Timeout!",description="yes, timeout", color=ctx.author.color)
        await ctx.send(embed=cd)``` can i do thing like this :V
jolly basalt
#

everybody died ig

small igloo
jolly basalt
#

;-;

small igloo
#

ok ๐Ÿ—ฟ

jolly basalt
#

lmao

#

oh python gods, bless us with the solution

small igloo
#

lol

jolly basalt
#

sells soul to the python gods

jolly basalt
#

@spring flax u here?

small igloo
jolly basalt
#

im claiming a help channel

small igloo
#

ok, if i wanna use asyncio.TimeoutError, can i use something but not try and except, like @command.error()

jolly basalt
#

idrk

jolly basalt
#

@spring flax?, @sick birch?

#

anybody!?!?

#

they dipped

slate swan
#

what is this?

small igloo
slate swan
#

guys pls dont go ot?

jolly basalt
small igloo
jolly basalt
#

we did the same thing

spring flax
#

You know, you could really do with a little patience.

slate swan
small igloo
# slate swan for?

for a comand that goes timeout, but i want use like that except use try: except:

slate swan
small igloo
slate swan
#

ah

#

!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.9)"). 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.9)") 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.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.

This function returns the **first event that meets the requirements**...
slate swan
#

timeout kwarg lol

small igloo
#

excgep

#

excedep

#

ecprct

#

e x c p e t

jolly basalt
#

e p e c t

small igloo
#

e c x e p t

slate swan
#

except

small igloo
slate swan
slate swan
#

ah

small igloo
#

go to r/ihadastroke when

jolly basalt
slate swan
small igloo
small igloo
slate swan
#

it raises a exception by asyncio and not your lib

small igloo
slate swan
slate swan
#

on the button callback send a dm to the inter author

spring flax
#

can you please stop pinging people?

#

understand that people can be busy

jolly basalt
slate swan
#

!d disnake.Interaction.author

unkempt canyonBOT
spring flax
#

open a help channel and be patient

slate swan
#

on the callback dm

jolly basalt
#

i was tryna refer that message

jolly basalt
jolly basalt
#

if they click the first button, a dm goes to me and if they click the second button, a dm goes to Ava

jolly basalt
#
@bot.command(name = 'report', aliases = ['rep'])
async def reportgame(ctx):
    role = discord.utils.get(ctx.guild.roles, name="Bot Testers")
    members = role.members
    ids = [member.id for member in role.members]
    view = View()

    async def button_callback(interaction):
        user = bot.fetch_user(id) #how do i get the user id
        await interaction.response.send_message('Hi '+ user.name+ ' :wave:')
    
    for i in ids:
        user = await bot.fetch_user(int(i))
        b = Button(label = user.name, style=discord.ButtonStyle.green)
        b.callback = await button_callback(id = int(i))
        view.add_item(b)
    await ctx.send('Please select a moderator', view=view)
slate swan
spice basalt
#

why isn't this working

#
    @client.command()
    async def emojify (ctx,*,text):
      emojis = []
      for s in text.lower():
        if s.isdecimal():
          num2emo = {'0':'zero','1':'one','2':'two',
                    '3':'three','4':'four','5':'five',
          '6':'six','7':'seven','8':'eight','9':'nine'}
          emojis.append(f':{num2emo.get(s)}')
        elif s.isalpha():
          emojis.append(f'regional_indicator_{s}:')
        else:
          emojis.append(s)
      await ctx.send(''.join(emojis))
jolly basalt
#

#bot-commands

boreal ravine
#

at least give us an error

#

and define "not working"

spice basalt
slate swan
#

Akeno lemon_glass

#

imagine naming your api wrapper akeno totally not mehmmcat

maiden fable
#

Stop

slate swan
boreal ravine
spice basalt
#

why not?

boreal ravine
spice basalt
#

so you think i shouldn't indent it?

boreal ravine
#

no

#

I'm asking why it's indented

spice basalt
#

why wouldn't i indent it

boreal ravine
#

mate

#

do you want help or not?

spice basalt
#

i do

spice basalt
alpine furnace
#

@spice basalt Do other commands work

spice basalt
#

yes

spice basalt
#

why wouldn't i indent it even

boreal ravine
#

i just said why

alpine furnace
#

๐Ÿคทโ€โ™‚๏ธ then emojis must be empty.. try printing it

spice basalt
#

and yes i want help but even i don't know how to answer your question

alpine furnace
boreal ravine
#

just say why it's indented, simple

spice basalt
boreal ravine
#

bro what

spice basalt
#

indenting makes the code look clearer

maiden fable
#

Uhhh bro

slate swan
#

python depends on indentation levels

maiden fable
#

Python works on indents

spice basalt
#

yes also that

slate swan
spice basalt
#

i don't know why the guy keeps asking "why" is the function indented

keen talon
maiden fable
#

๐Ÿ˜‚

slate swan
spice basalt
maiden fable
#

That's an exception

keen talon
slate swan
spice basalt
keen talon
spice basalt
slate swan
keen talon
#

Noo ๐Ÿฅบ

spice basalt
#

there goes my question

slate swan
spice basalt
keen talon
cunning ice
#

when i use

member.mention

it says member not defined

#

altho i defined as

on_member_join(member):

#

why is it so ?

#

Also I used intents

boreal ravine
spice basalt
#

that's just how it works-

boreal ravine
#

show me your code above the emoji command

spice basalt
boreal ravine
#

thats why

#

unindent the command so that it's not inside the on_message event

haughty quartz
#
In 0.options.0.description: This field is required
In 0.options.1.description: This field is required
  warnings.warn(``` what's causing this??
```py
COVEROPTIONS = commands.option_enum(["album", "track", "artist"])
@bot.slash_command(name="cover", description="get a album's/ track's/ artist's picture on Spotify", guild_ids=[906881394859470879, 939488113045159956])
async def main(inter, options: COVEROPTIONS, name: str):
  #dostuff
#

using disnake

stoic gust
#

I'm developing a bot and I want to catch and handle exceptions thrown while it's running. But I cannot use try except because then I will have them everywhere and the code will not be readable. Is there a way for me to catch exceptions and handle them without try except.

spice basalt
haughty quartz
spice basalt
#

all of that line?

brazen raft
#

There are events for kinds of Discord errors, or you can attach specific functions to specific commands to handle the commands' errors

boreal ravine
#

yea

haughty quartz
boreal ravine
#

yea

haughty quartz
#

damn

#

that sucks but thanks!

#

do i reinstall or update?

boreal ravine
#

update

stoic gust
#

update

haughty quartz
#

kk

spice basalt
#

on line 43

stoic gust
haughty quartz
boreal ravine
spice basalt
stoic gust
boreal ravine
#

remove the second variable

haughty quartz
#

yes

stoic gust
spice basalt
#

yes?

haughty quartz
#

as rn u are deleting the first instance by reassigning it

spice basalt
haughty quartz
#

nope

boreal ravine
spice basalt
boreal ravine
#

use client instead of bot

spice basalt
boreal ravine
#

you already have it

stoic gust
#

depending on which library

spice basalt
boreal ravine
#

Any errors?

spice basalt
#

no

slate swan
#

you have an on_message event?

#

Also, you forgot to add a : in the start of append in the isalpha() condition

spice basalt
#

oops

spice basalt
slate swan
#

could I see that event's code?

spice basalt
spice basalt
slate swan
#

I don't see how on_message and on_ready are similar

spice basalt
#

oops

#

wrong screenshot

slate swan
#

I pinged you somewhere, check it

spice basalt
green bluff
#

oh

#

i realised whats wrong

slate swan
#

Used to do it until started using subclassed help

oblique adder
#

In which case should I use await fetch instead of get ? or should I use fetch instead of get in every place ?

slow fog
#

why dont people just use a regular import instead of cogs more easier and simple

#

the whole thing are useless but if you insist using it then use import

slow fog
#

i mean in general

green bluff
slow fog
#

no

#

thats the problem

#

most people that are coding discord.py doesnt know anything about python in general

#

cuz if you did you will use import immediately

slate swan
#

How do I fetch a category by it's name?

slate swan
unkempt canyonBOT
#

discord.utils.get(iterable, **attrs)```
A helper that returns the first element in the iterable that meets all the traits passed in `attrs`. This is an alternative for [`find()`](https://discordpy.readthedocs.io/en/master/api.html#discord.utils.find "discord.utils.find").

When multiple attributes are specified, they are checked using logical AND, not logical OR. Meaning they have to meet every attribute passed in and not one of them.

To have a nested attribute search (i.e. search by `x.y`) then pass in `x__y` as the keyword argument.

If nothing is found that matches the attributes passed, then `None` is returned.

Examples

Basic usage...
slate swan
#

!d discord.Guild.categories

unkempt canyonBOT
#

property categories: List[discord.channel.CategoryChannel]```
A list of categories that belongs to this guild.

This is sorted by the position and are in UI order from top to bottom.
boreal ravine
#

#bot-commands

maiden fable
#

Just use getch

haughty quartz
#

how can I check if someone reacted to my bot's message?

#

like the delete reaction thing that some bots use

maiden fable
#

!d discord.Message.reactions

unkempt canyonBOT
haughty quartz
#

that delete reaction

#

how can I code something like this

maiden fable
#

!d discord.on_reaction_add

unkempt canyonBOT
#

discord.on_reaction_add(reaction, user)```
Called when a message has a reaction added to it. Similar to [`on_message_edit()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_message_edit "discord.on_message_edit"), if the message is not found in the internal message cache, then this event will not be called. Consider using [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") instead.

Note

To get the [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") being reacted, access it via [`Reaction.message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Reaction.message "discord.Reaction.message").

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

Note

This doesnโ€™t require [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") within a guild context, but due to Discord not providing updated user information in a direct message itโ€™s required for direct messages to receive this event. Consider using [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") if you need this and do not otherwise want to enable the members intent.
maiden fable
#

This?

haughty quartz
#

I'll see what I can do, thx

final shard
#

Can not import name commands from discord.ext (unknown location)

maiden fable
final shard
maiden fable
#

Try doing pip install -U discord.py

final shard
#

Ok

#

Itโ€™s still happening

maiden fable
#

Try restarting yr ide

final shard
#

I restarted pc

crystal cargo
#

Hi guys I forcefully activate the sub-channel, but the user can download without joining the channel, what can I do?

CODE:
https://pastebin.com/7PVpNuGC

https://pastebin.com/WhYsZYjG
Used library pyrogram
*All required library imported

final shard
#

But still

maiden fable
#

Weird

final shard
#

I had to uninstall it to install next cord

#

Then I reinstalled after deleting nextcord

maiden fable
#

Ah nextcord

final shard
#

What should I do now

maiden fable
#

U need to do class Fun(commands.Cog) instead of class Fun

exotic kite
#
class Bot(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

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

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

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

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

class Utility(commands.Cog):
    def __init__(self, bot):
        self.bot = bot```
#

i have this

final shard
#

Wait now it works

maiden fable
#

Ayo why u using one file for all the cogs?

exotic kite
maiden fable
exotic kite
#

in my fun.py in cogs i have class Fun:

#

i change it to (commands.Cog)

#

?

#

tell pls @maiden fable

final shard
#

Can we change text colour

#

No ig

shell wing
#

i want to make an even for my bot ( priv bot) to delete any message send in a channel but except the emoji...like if a member sends a text message bot deletes it but if a member sends a emoji the bot doesnt delete it
is this possible ?

slate swan
#

brb

maiden fable
exotic kite
#

u just saved me, i was gonna delete my project;-;

maiden fable
#

!d discord.Message.mentions exist bruv

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.

maiden fable
#

Just saving u lines of code (I don't mind pings)

slate swan
slate swan
maiden fable
#

You almost ghost pinged me there lol

shell wing
#

hm alr

tight mica
#

huntr

slate swan
#

like this? awkward

maiden fable
#

Yea ashley?

slate swan
#

while sending the message you can just use allowed_mentions kwarg so even if the bot sends the message, noone gets pinged

maiden fable
slate swan
maiden fable
#

Is fine

slate swan
#

the bot will simply send @everyone without pinging anyone

maiden fable
maiden fable
slate swan
tight mica
maiden fable
#

Nvm I will just go away. Already on the verge of a mental breakdown

tight mica
#

same

carmine quarry
#

Hey guys I have a kind of interesting question. When I run the discord bot the program's at client.Run(), but I want to make something so that the bot sends a message at a given time. Any ideas how to do that? I tried schedule package, but I don't know where to place it, I tried it in on_ready event but it wasn't working. Do I need to make some kind of multi-threading, and if so how can I do that? (I'm kind of new to python, only programmed in c# and Java before)

#

Thanks, found something based on task loop, will implement it now ๐Ÿ˜„

maiden fable
#

@carmine quarry the tasks.loop takes in a time param

#

!d discord.ext.tasks.loop

unkempt canyonBOT
#

discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True, loop=...)```
A decorator that schedules a task in the background for you with optional reconnect logic. The decorator returns a [`Loop`](https://discordpy.readthedocs.io/en/master/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
maiden fable
#

It takes a list of datetime objects

carmine quarry
#

Exactly what I need, thanks ๐Ÿ™‚

round kernel
#

!warn 925079016174682213 Please respect peoples boundaries, if they ask you not to call them specific names/use specific emojis in reference to them. Please reframe from doing so, be civil and respect individuals. Continuing this further will lead to further action.

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: applied warning to @slate swan.

slate swan
#

Why warn for such a small thing juicy

round kernel
#

If you wish to discuss moderation action, please open a ticket with @novel apex

slate swan
#

uh sure

lament depotBOT
#
**What unique features does your bot contain, if any?**

Suggest more topics here!

maiden fable
slate swan
#

2 continuous pings peephappy

maiden fable
slate swan
maiden fable
#

Ratelimits?

slate swan
maiden fable
maiden fable
slate swan
maiden fable
#

I have used it once or twice

#

Luckily I never got ratelimited

slate swan
slate swan
maiden fable
#

Haha well, I'm only talking about hosting a discord bot on replit. I have used replit for other projects and am still using it

slate swan
#

lol

boreal ravine
boreal ravine
rocky trench
#

Warn happened in the past, new subject.

slate swan
#

alright

lament depotBOT
#
**What's one feature you wish more developers had in their bots?**

Suggest more topics here!

boreal ravine
#

someone needs to make a PR to add more topics

slate swan
#

what feature isnt there in any bot....

boreal ravine
#

these are getting ridiculously repetitive

maiden fable
boreal ravine
#

yes, it's quite obvious

maiden fable
#

Yea so, Daniel. Mind posting yr code?

carmine quarry
#

Hey, I asked about sending a a message at a specific time, and I now know that it can be solved using tasks loop, I tried to make a dummy test method, but for some reason it's not working. Does any1 have any idea?

maiden fable
#

Ah

#

Do u know about the datetime module?

carmine quarry
#

Yes its implemented

carmine quarry
spice basalt
#

how do i fix this

rocky trench
spice basalt
#

how do i define it

rocky trench
#

Can I see your commands.Bot line?

spice basalt
rocky trench
#

U used client right there, which means u would need @client.command()

maiden fable
spice basalt
#

ah

rocky trench
#

Replace client with bot, and it will work too

spice basalt
#

thank you

maiden fable
#

Better is to just do @client.command() imho

rocky trench
#

But it's up to you if u want to use bot or client

slate swan
#

๐Ÿคก ctrl+f "client" and replace it with bot

rocky trench
spice basalt
maiden fable
rocky trench
slate swan
rocky trench
#

Can u send ur full cr command @spice basalt

spice basalt
#

๐Ÿ˜”

maiden fable
#

Let's just tell everyone to do that from now on!

slate swan
rocky trench
#

No

slate swan
#

lol

maiden fable
#

Lmao imagine

slate swan
#

i know

spice basalt
#

help me TheBigStare

slate swan
maiden fable
rocky trench
spice basalt
rocky trench
#

U still use client right?

spice basalt
#

yes

rocky trench
#

client = commands.Bot?

slate swan
spice basalt
#

gay

slate swan
maiden fable
spice basalt
#

we live in a society

#

๐Ÿ˜”

rocky trench
#

And no errors?

spice basalt
#

no errors

#

replit wouldn't let me run if there were any errors

slate swan
#

show your bot constructor?

spice basalt
slate swan
#

WTFStare that emoji....

spice basalt
slate swan
spice basalt
#

screenshot where

slate swan
#

the place where you define your client var

spice basalt
maiden fable
#

@spice basalt do u have logging enabled?

#

U r probably ratelimited

slate swan
spice basalt
#

yes i do

slate swan
#

do you have client.process_commands in there?

spice basalt
#

no

rocky trench
#

That causes ur issue

slate swan
# spice basalt no
await client.process_commands(message)

use this at the end of the event

boreal ravine
#

didn't sarthak help you about this a couple hours ago

spice basalt
#

no

slate swan
#

poor him ๐Ÿ˜”

carmine quarry
unkempt canyonBOT
#

discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True, loop=...)```
A decorator that schedules a task in the background for you with optional reconnect logic. The decorator returns a [`Loop`](https://discordpy.readthedocs.io/en/master/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
slate swan
#

takes seconds minutes hours etc etc

carmine quarry
slate swan
#

oh nvm

rocky trench
#

Time probably means 11:00

boreal ravine
#

it takes a time kwarg too

slate swan
#

yeah I'm blind

rocky trench
#

Use a minute, minute = 1

slate swan
rocky trench
#

@spice basalt is ur issue fixed?

carmine quarry
spice basalt
spice basalt
slate swan
#
async def on_message(message):
  if whatever.author == uhh:
    return
  await client.process_commands(message)```
rocky trench
spice basalt
#

like ```py
@client.event
async def on_message(message):
if message.author == client.user:
return
await client.process_commands(message)

spice basalt
#

yes

slate swan
#

it'll work now maybe

carmine quarry
#

I feel so dumb xd

maiden fable
spice basalt
maiden fable
#

Run this in yr command prompt

maiden fable
spice basalt
#

how

slate swan
maiden fable
#

U r most probably ratelimited cz replit

slate swan
maiden fable
#

Tbh, the only thing I hate about dpy is cz u gotta enable logging to see if u r ratelimited or not

dull terrace
#

been doing nothing but bug fixes since i switched my bot to databases and started using classes and cleaned it up a lil

#

done 22 bug fixes so far today

maiden fable
#

Imagine getting yr console spammed with logs

slate swan
maiden fable
#

I once tried setting the logging level to the lowest and the VPS crashed lemon_pensive

maiden fable
dull terrace
maiden fable
dull terrace
maiden fable
#

Or that's what I think

spice basalt
slate swan
maiden fable
maiden fable
maiden fable
#

Yea

slate swan
dull terrace
#

this how i handle ratelimiting, called every time they press a button or use a command

maiden fable
slate swan
maiden fable
#

I would instead just agree that u r right and I have just forgot about stuffs

maiden fable
#

And other bots as in, other people's bots who are using the same replit machine as yours

spice basalt
boreal ravine
#

why are you using replit to host your discord bot?

maiden fable
#

Now run it

spice basalt
maiden fable
#

Try running the cmd

spice basalt
#

still no output

maiden fable
#

Show the console

spice basalt
#

nothing changed?

maiden fable
#

Like there's nothing printed on the console?

spice basalt
maiden fable
#

Ayo what the

#

Show yr code in a screenshot

spice basalt
boreal ravine
#

His code probably does same thing

honest vessel
#

ah ye

spice basalt
maiden fable
# spice basalt

Did u add the await client.process_commands in the on_message?

spice basalt
honest vessel
#

kek

maiden fable
#

There ya go

honest vessel
#

there it is its wrong indentation

spice basalt
#

tf?

honest vessel
#

its inside the if statement

spice basalt
#

what's the "right" indentation

honest vessel
#

moveitto left

spice basalt
#

ah

#

so

@client.event
async def on_message(message):
  if message.author == client.user:
    return
await client.process_commands(message)
honest vessel
#

si

spice basalt
#

like that?

spice basalt
honest vessel
#

well

@client.event
async def on_message(message):
  if message.author == client.user:
    return
  await client.process_commands(message)
spice basalt
honest vessel
#

it should be same indentation as if

spice basalt
honest vessel
#

yes

maiden fable
#

Yea

spice basalt
#

so i should move them to the left by one block?

honest vessel
#

that looks fine

maiden fable
#

No keep everything like that

spice basalt
#

tf?

spice basalt
honest vessel
#

!indentations

honest vessel
spice basalt
#

it works now

#

thank you

#

also can i add UTF-8 into this as well?

honest vessel
#

arentit already?

spice basalt
#

oh it does accept emojis

honest vessel
#

si

#

bot can talk even if its timedout? ๐Ÿ˜„

spice basalt
#

i gave it administrator

honest vessel
#

ah

spice basalt
slate swan
#

rip nitro ๐Ÿ˜”

honest vessel
#

hah against ToS?

slate swan
maiden fable
slate swan
slate swan
maiden fable
#

What the

honest vessel
#

lol?

maiden fable
#

Tried contacting discord support?

slate swan
honest vessel
#

nvr change settingsdrunk

spice basalt
#

aren't you the ashleyy from a few minutes before?

slate swan
spice basalt
#

yes

slate swan
#

anyways imma go study and then contact discord support later, enjoy

unkempt canyonBOT
slate swan
#

lol

maiden fable
#

Cya

honest vessel
#

@slate swani dont think discord can/will help with f2a lost acc's

slate swan
#

Traceback (most recent call last):
File "C:\Users\hackt\OneDrive\Escritorio\Protech\main.py", line 42, in <module>
@client.slash(description="Pong!")
AttributeError: 'Bot' object has no attribute 'slash'
PS C:\Users\hackt\OneDrive\Escritorio\Protech> python main.py
Traceback (most recent call last):
File "C:\Users\hackt\OneDrive\Escritorio\Protech\main.py", line 43, in <module>
@slash.slash(description="Pong!")
AttributeError: module 'slash' has no attribute 'slash'

#

I need help

maiden fable
#

Try doing @slash.slash_command(...)

dull terrace
#

and make sure you have slash = SlashCommand(client, sync_commands=True)

maiden fable
#

What lib u using tho

dull terrace
#

if you're using discord_slash

slate swan
# dull terrace and make sure you have ```slash = SlashCommand(client, sync_commands=True)```

Traceback (most recent call last):
File "C:\Users\hackt\OneDrive\Escritorio\Protech\main.py", line 43, in <module>
@slash.slash_command(description="Pong!")
AttributeError: module 'slash' has no attribute 'slash_command'
PS C:\Users\hackt\OneDrive\Escritorio\Protech> python main.py
Traceback (most recent call last):
File "C:\Users\hackt\OneDrive\Escritorio\Protech\main.py", line 9, in <module>
slash = SlashCommand(client, sync_commands=True)
NameError: name 'client' is not defined

maiden fable
#

bot, not client

dull terrace
#

are you using client or bot

slate swan
#

client

dull terrace
#

what did you define this as

slate swan
#

PS C:\Users\hackt\OneDrive\Escritorio\Protech> python main.py
Traceback (most recent call last):
File "C:\Users\hackt\OneDrive\Escritorio\Protech\main.py", line 9, in <module>
slash = SlashCommand(client, sync_commands=True)
NameError: name 'client' is not defined
PS C:\Users\hackt\OneDrive\Escritorio\Protech> python main.py
Traceback (most recent call last):
File "C:\Users\hackt\OneDrive\Escritorio\Protech\main.py", line 12, in <module>
slash = SlashCommand(bot, sync_commands=True)
NameError: name 'bot' is not defined
PS C:\Users\hackt\OneDrive\Escritorio\Protech>

dull terrace
#

it should be client if that's what it's defined as

#

and you're defining slash after you define client?

#

this should work, works for me

slate swan
#

ty!

dull terrace
#

you're welcome

slate swan
#
async def ping(ctx):
    embed = discord.Embed(title="Pong!", description=f":ping_pong: Client latency: ``{round(client.latency * 1000)}ms``")
    await ctx.send(embed=embed)```
#

is good?

spice basalt
#

what's the indentation error?

dense swallow
dense swallow
#

nah, name is optional

#

otherwise it takes async def name

dull terrace
#

ohh nice

dire folio
spice basalt
slate swan
#

yea slash no working idk why

dense swallow
#

is it global?

spice basalt
#

it still says there's an indentation error

dense swallow
#

if so wait 1-2 hours to register

spice basalt
slim ibex
#

use aiohttp, requests is blocking

dense swallow
slim ibex
#

!blocking

unkempt canyonBOT
#

Why do we need asynchronous programming?
Imagine that you're coding a Discord bot and every time somebody uses a command, you need to get some information from a database. But there's a catch: the database servers are acting up today and take a whole 10 seconds to respond. If you do not use asynchronous methods, your whole bot will stop running until it gets a response from the database. How do you fix this? Asynchronous programming.

What is asynchronous programming?
An asynchronous program utilises the async and await keywords. An asynchronous program pauses what it's doing and does something else whilst it waits for some third-party service to complete whatever it's supposed to do. Any code within an async context manager or function marked with the await keyword indicates to Python, that whilst this operation is being completed, it can do something else. For example:

import discord

# Bunch of bot code

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

What does the term "blocking" mean?
A blocking operation is wherever you do something without awaiting it. This tells Python that this step must be completed before it can do anything else. Common examples of blocking operations, as simple as they may seem, include: outputting text, adding two numbers and appending an item onto a list. Most common Python libraries have an asynchronous version available to use in asynchronous contexts.

async libraries
The standard async library - asyncio
Asynchronous web requests - aiohttp
Talking to PostgreSQL asynchronously - asyncpg
MongoDB interactions asynchronously - motor
Check out this list for even more!

spice basalt
#

it still says there's an error

distant pendant
#

Hey, I made a Temporary Voice Discord Bot. Its working well, but if you change the name of the channel a few times it wont delete the voice channel.

slate swan
#

use the ID to identify those channels instead of channel names

honest shoal
#

how can I make required permissions for a command such that the author can bypass it if they have admin permissions the first one is @has_any_role()

slim ibex
maiden fable
#

That still doesn't fix the indent error lmao

slim ibex
#

^ itโ€™s probably from code above

spice basalt
#

wait nevermind

slate swan
#

!d discord.ext.commands.check_any

distant pendant
unkempt canyonBOT
#

@discord.ext.commands.check_any(*checks)```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if any of the checks passed will pass, i.e. using logical OR.

If all checks fail then [`CheckAnyFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckAnyFailure "discord.ext.commands.CheckAnyFailure") is raised to signal the failure. It inherits from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").

Note

The `predicate` attribute for this function **is** a coroutine.

New in version 1.3.
spice basalt
#

it works now, i left an unfinished client.command

honest shoal
#

oh thanks

slim ibex
slate swan
stoic gust
#

can I somehow cause slash commands to be registered after starting the bot?
it's just that my bot first registers the slash of the command, then loads all the cogs, and only then re-registers the slash of the command
And it turns out that he first removes all slashes and then adds them

proven pendant
#

hi, I know how to code few things for discord bot...but im not sure how I can connect my bot to the project/code/file where I have coded the stuff. Can someone help me with it? (Im new to coding python)

boreal ravine
distant pendant
slate swan
slate swan
slate swan
dense swallow
#

you do need some basic python knowledge to go forward

spice basalt
#

yes

honest shoal
slate swan
proven pendant
slate swan
honest shoal
#

oh

slate swan
slate swan
#

and run your code with the token in it

proven pendant
slate swan
proven pendant
slate swan
proven pendant
slate swan
slate swan
#

same thing

slate swan
gaunt ice
slate swan
#

bot/client.run("your token")

proven pendant
slate swan
slate swan
gaunt ice
gaunt ice
#

untick the oauth2 code grant

slate swan
proven pendant
slate swan
# gaunt ice

its unticked by default until someone plays with it

proven pendant
slate swan
#

discord rn :rocket>

gaunt ice
#

lol

slate swan
#

i cant create inv link

#

um

gaunt ice
#

show ur options

#

in d portal

slate swan
slate swan
#

is option to inv and all but at the end this

slate swan
#

wait you have 0AUTH turned on

slate swan
gaunt ice
#

yus

slate swan
slate swan
slate swan
gaunt ice
#

hm

slate swan
gaunt ice
#

untick it?

slate swan
gaunt ice
#

ok

spice basalt
#

how do i define it

gaunt ice
#

show code

spice basalt
slate swan
#

i fix i think

slate swan
gaunt ice
#

why -

spice basalt
#

shit

slate swan
spice basalt
#

typo

gaunt ice
#

dles it work?

slate swan
#

i thought u had roles lol and then i found out

gaunt ice
#

lol

slate swan
#

is no working is running bot and invite working but slashs nope

maiden fable
#

What

gaunt ice
#

hm

slate swan
spice basalt
#

can i make the embed color be the user's name color?

slate swan
#

@slate swan in slashs is not working and no showing

spice basalt
#

no i mean the embed color depends on the user using the command

slate swan
#
async def ping(ctx):
    embed = discord.Embed(title="Pong!", description=f":ping_pong: Client latency: {round(client.latency * 1000)}ms")
    await ctx.send(embed=embed)```
spice basalt
#

oh-

slate swan
slate swan
#

dms

buoyant igloo
#

Yo guys how do u get individual variables for individual people using databases?

spice basalt
#

how do i do that

gaunt ice
#

ask sister google

slate swan
#

Library: PyCord

How'd I check that the Member who selected an option from a Select component is the same Member who initiated the Interaction?

Basically, I want so that only the person who started the interaction can select stuff and not someone else.

hushed galleon
unkempt canyonBOT
#

property colour: discord.colour.Colour```
A property that returns a colour denoting the rendered colour for the member. If the default colour is the one rendered then an instance of [`Colour.default()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Colour.default "discord.Colour.default") is returned.

There is an alias for this named [`color`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member.color "discord.Member.color").
gaunt ice
#

forget what i said

slate swan
#

it's a callback function for the Select class

hushed galleon
#

you're using Views right

#

you can store the user inside your view class and then compare it during interaction_check()

spice basalt
slate swan
#

use an instance of the Member object

hushed galleon
#

i was referring to the color attribute of a Member object, i.e. the member you want the color of

slate swan
spice basalt
slate swan
slate swan
spice basalt
#

ah so i don't need the () for that

slate swan
#

nope

spice basalt
slate swan
# spice basalt

use an instance of the Member object, not the object itself

hushed galleon
# slate swan snippet?
class MyView(discord.ui.View):
    def __init__(self, user_id: int):
        super().__init__()
        self.user_id = user_id

    async def interaction_check(self, interaction):
        # if this method returns False then no callback is executed;
        # you could also respond to the interaction here as well
        return interaction.user.id == self.user_id```
slate swan
hushed galleon
spice basalt
#

also how do i choose the embed's color just normally?

#

just the hex?

honest vessel
#

disnake.Embed(colour=0x000000)

rocky trench
#

Or if u want it to look better, color=(0x000000)

spice basalt
spice basalt
#

should it be just color=(0xffffff)?