#discord-bots

1 messages Β· Page 882 of 1

honest vessel
#

!d discord.Embed

unkempt canyonBOT
#

class discord.Embed(*, colour=Embed.Empty, color=Embed.Empty, title=Embed.Empty, type='rich', url=Embed.Empty, description=Embed.Empty, 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.

Certain properties return an `EmbedProxy`, a type that acts similar to a regular [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") except using dotted access, e.g. `embed.author.icon_url`. If the attribute is invalid or empty, then a special sentinel value is returned, [`Embed.Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty").

For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") for you.
rocky trench
#

Get rid of ur discord.color stuff

spice basalt
#

okay

rocky trench
#

So u have color = (whateverhex)

honest vessel
#

!d discord.User.color

unkempt canyonBOT
#

property color: discord.colour.Colour```
A property that returns a color denoting the rendered color for the user. This always returns [`Colour.default()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Colour.default "discord.Colour.default").

There is an alias for this named [`colour`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.colour "discord.User.colour").
spice basalt
#

it works now

rocky trench
#

Gg!

honest vessel
#

wp

spice basalt
#

can i make something like this with my bot?

#

like

grim oar
#

rin

spice basalt
#

mentioning someone to get their username replaced with "you"?

spice basalt
#

how do i do that

grim oar
#

username = username or "you"

spice basalt
#

the mentioned target's name

exotic kite
#

! discord-components

spice basalt
#

like this

exotic kite
#

Its ez!

spice basalt
#

how then

grim oar
#

username = user.name if user is not None else "you"

spice basalt
#

that is supposed to be?

grim oar
#

make user an optional param

stone moon
#

if a muted user leaves and rejoins my discord (to bypass getting muted) when my bot is offline, how could i make it so that when it is back online it will assign the muted role? (right now i have muted user ids stored in a file and upon rejoining it checks if their id is in the file)

exotic kite
# spice basalt how then
@bot.command([aliases='coolrate'])
async def cr(ctx, user: discord.Member):
    embed = discord.Embed(
        title = 'Cool Rate Command',
        description = f'**{user}** is {random.randrange(101)}% cool! :sunglasses: ',
        color = discord.Color.green()
    )
    await ctx.author.send(embed=embed)```
spice basalt
#

just use another bot?

exotic kite
#

hopefully it helped:)

grim oar
#

it doesnt work for "you"

spice basalt
#

yes

grim oar
#

and he needs the user which is mentioned, not author

exotic kite
spice basalt
#

yes i want it to say "you" when no one is mentioned

exotic kite
#

done

grim oar
#

async def cr(ctx, *, user: discord.Member = None):

exotic kite
#
@bot.command([aliases='coolrate'])
async def cr(ctx, user: discord.Member):
    embed = discord.Embed(
        title = 'Cool Rate Command',
        description = f'**{user}** is {random.randrange(101)}% cool! :sunglasses: ',
        color = discord.Color.green()
    )
    await ctx.author.send(embed=embed)```
spice basalt
#

ah

grim oar
#

thats wrong again, wont work for you

spice basalt
#

yes

grim oar
honest shoal
#

what's this issue in send()?

hushed galleon
hushed galleon
#

e.g. py discord.AllowedMentions(everyone=False)

maiden fable
kindred epoch
grim oar
spice basalt
stone moon
spice basalt
#

but i want it to give an error message when no one's mentioned like this then

spice basalt
grim oar
#

ok

slate swan
#

rip forgot what it was

maiden fable
#

!d discord.ext.commands.Command.error

unkempt canyonBOT
#

@error```
A decorator that registers a coroutine as a local error handler.

A local error handler is an [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") event limited to a single command. However, the [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") is still invoked afterwards as the catch-all.
slate swan
#

....

maiden fable
#

Hm?

maiden fable
unkempt canyonBOT
#

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

The default command error handler provided by the bot.

By default this prints to [`sys.stderr`](https://docs.python.org/3/library/sys.html#sys.stderr "(in Python v3.9)") however it could be overridden to have a different implementation.

This only fires if you do not specify any listeners for command error.
honest shoal
slate swan
hushed galleon
#

if you assigned the AllowedMentions object to a variable named users sure

honest shoal
#

yes

#

thanks

spice basalt
# unkempt canyon

ok but how do i make it send an error message when no one's mentioned

kindred epoch
maiden fable
#

!d discord.ext.commands.check @spring flax

unkempt canyonBOT
#

@discord.ext.commands.check(predicate)```
A decorator that adds a check to the [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") or its subclasses. These checks could be accessed via [`Command.checks`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command.checks "discord.ext.commands.Command.checks").

These checks should be predicates that take in a single parameter taking a [`Context`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Context "discord.ext.commands.Context"). If the check returns a `False`-like value then during invocation a [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure") exception is raised and sent to the [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") event.

If an exception should be thrown in the predicate then it should be a subclass of [`CommandError`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CommandError "discord.ext.commands.CommandError"). Any exception not subclassed from it will be propagated while those subclassed will be sent to [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error").
slate swan
unkempt canyonBOT
#

exception discord.ext.commands.MissingRequiredArgument(param)```
Exception raised when parsing a command and a parameter that is required is not encountered.

This inherits from [`UserInputError`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.UserInputError "discord.ext.commands.UserInputError")
slate swan
#

compare the instance of error with this class

spice basalt
#

how

unkempt canyonBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

slate swan
#

!d isinstance

unkempt canyonBOT
#

isinstance(object, classinfo)```
Return `True` if the *object* argument is an instance of the *classinfo* argument, or of a (direct, indirect, or [virtual](https://docs.python.org/3/glossary.html#term-abstract-base-class)) subclass thereof. If *object* is not an object of the given type, the function always returns `False`. If *classinfo* is a tuple of type objects (or recursively, other such tuples) or a [Union Type](https://docs.python.org/3/library/stdtypes.html#types-union) of multiple types, return `True` if *object* is an instance of any of the types. If *classinfo* is not a type or tuple of types and such tuples, a [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "TypeError") exception is raised.

Changed in version 3.10: *classinfo* can be a [Union Type](https://docs.python.org/3/library/stdtypes.html#types-union).
slate swan
# unkempt canyon

for who-ever sent it
isinstance is not really a too basic thing for a beginner to learn when they are un-aware about OOP

spice basalt
slate swan
# spice basalt <a:stressed:871091980329971712>

you can just do if isinstance(error, commands.MissingRequiredArgument): to check if the error was related to a missing arguments

for the isinstance part , its a pretty simple and handy thing to learn, suppose you have a variable/data and you want to check if its of the type you want , you can just isinstance(data, object_type), which can either be True or False

#

for example if i do isinstance("text", str) it will be True

#

!e py print(isinstance("text", str)) print(isinstance("text", int))

unkempt canyonBOT
#

@slate swan :white_check_mark: Your eval job has completed with return code 0.

001 | True
002 | False
slate swan
#

"text" is a string so comparing it with str in isinstance will get you True, and False for integer

spice basalt
#

so

if isinstance(`.cru` is for others, `.cru @Cute Yaya`, use `.cr` for yourself, `.cr`., commands.MissingRequiredArgument):
#

but how do i require a mention?

slate swan
#

thats now how you do it

spring flax
#

how would i pass a list into has_any_role?

slate swan
#

it just checks the condition, you respond with ctx.send/reply inside the if

slate swan
spring flax
slate swan
#

the * is used to unpack a list

spring flax
#

so then what about the commas?

slate swan
#

which means function(*[a, b]) will become function(a, b)

kindred epoch
slate swan
unkempt canyonBOT
#

@slate swan :white_check_mark: Your eval job has completed with return code 0.

 a  b  c
slate swan
#

you wont see them in prints..

stone moon
#

how do i get a member's id with a member object

slate swan
#

lemme show an example of how it actually works in #bot-commands

unkempt canyonBOT
#

property id```
Equivalent to [`User.id`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.id "discord.User.id")
stone moon
#

Im so stupid bro what

maiden fable
keen talon
spice basalt
#

why

slate swan
#

you know what's cuter?

spice basalt
spring flax
#

would anything error if data is None?


def permission_check():
    async def predicate(ctx):
        async with bot.db.execute("SELECT role_id FROM messagelogs WHERE guild_id = ? AND command = ?", (ctx.guild.id, str(ctx.command.name))) as cursor:
            data = await cursor.fetchone()
        return data
    return commands.check(predicate)
#########
@bot.command()
@commands.check_any(commands.has__any_role(*permission_check(), commands.has_permissions(manage_guild))
slate swan
#

nope

#

it will just return None ( void)

maiden fable
#

Yea, so passing in None means no restriction(s) on using the command

slate swan
#

!e *None

unkempt canyonBOT
#

@slate swan :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 1
002 | SyntaxError: can't use starred expression here
slate swan
#

this tho

spring flax
slate swan
#

you can pass in an empty list if data is None

maiden fable
slate swan
#

return data or []

#

hm

spring flax
maiden fable
#

Yea

slate swan
#

yea, and on unpacking it , it would be NOne

maiden fable
#

that is what we want, so that it won't error

honest vessel
#

if data:
return data ?

maiden fable
#

No need

slate swan
#

!e *[] # will raise an error too

unkempt canyonBOT
#

@slate swan :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 1
002 | SyntaxError: can't use starred expression here
maiden fable
unkempt canyonBOT
#

@maiden fable :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 1
002 | SyntaxError: can't use starred expression here
maiden fable
#

Ayo what the

slate swan
#

just put in some random numbers there lol return data or [1] and youll be fine

maiden fable
#

Wait lemme see something

#

!e

def a(*b):
    print(b)
l1 = [1, 2, 3]
l2 = []
a(*l1)
a(*l2)
unkempt canyonBOT
#

@maiden fable :white_check_mark: Your eval job has completed with return code 0.

001 | (1, 2, 3)
002 | ()
maiden fable
#

See, Python fixes the issue automatically

slate swan
#

🀨 hm

spring flax
#

oh i see

hushed galleon
cold sonnet
spring flax
cold sonnet
#

ohk

hushed galleon
hushed galleon
#

by doing has_any_role(permission_check()), you are passing a function to has_any_role instead of what it's designed to handle, role ids/names

spring flax
#

but why can't I use the other one exactly?

spice basalt
#

what's an EOL?

spring flax
#

oh wait so I need to have to await it first for it to return the list and unpack it with *list

spice basalt
maiden fable
spice basalt
#

i didn't?

#

is it because of this?

#

in the description?

hushed galleon
#

you can't type a newline directly when using single quotes

spice basalt
#

ah yeah, i wanted to start a new line

#

how do i echo?

hushed galleon
#

it either has to be represented as the escape character \n or replaced with triple quotes """ for a multi-line string

spice basalt
#

ah

spring flax
hushed galleon
#

its just a type annotation for clarity in my snippet

#

if you were to run the code it wouldnt actually assign any variable

hushed galleon
spice basalt
#

thanks, it works

hushed galleon
#
>>> @some_decorator(print('hello world'))
... def foobar():
...     print('foobar')
hello world```
spring flax
#

do accounts which have been hacked by bots get member.bot true?

hushed galleon
#

uh no, discord won't recognize them as bots

spring flax
#

so there's no way to get if that were to happen right?

hushed galleon
#

.bot can only tell if the user is registered as a bot in the application site, while user bots just look like regular users

exotic kite
#

anybody know how i can host my discord bot 24/7 easily for free?

#

its in visual studio

maiden fable
exotic kite
#

?

#

!e
(float(input("How are you")

unkempt canyonBOT
#

@exotic kite :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 1
002 |     (float(input("How are you")
003 |           ^
004 | SyntaxError: '(' was never closed
exotic kite
#

!e
(float(input("How are you"))

unkempt canyonBOT
#

@exotic kite :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 1
002 |     (float(input("How are you"))
003 |     ^
004 | SyntaxError: '(' was never closed
exotic kite
#

!e
(float(input("How are you")))

unkempt canyonBOT
#

@exotic kite :x: Your eval job has completed with return code 1.

001 | How are youTraceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | EOFError: EOF when reading a line
maiden fable
#

Not gonna work

#

Also #bot-commands

oak warren
#

any one have any thoughts on the discord dev survey

brazen raft
oak warren
#

hmm go to the dashboard i got a link to it there

stone moon
#

how to get member's tag with member object again my brain froze

maiden fable
quaint epoch
stone moon
#

?

#

i didnt see

quaint epoch
#

str(member).rsplit('#')[-1]

oak warren
quaint epoch
oak warren
#

because i guess only the people to make the api thing know what they want rest find it easy

brazen raft
oak warren
#

!d discord.Guild.get_role

#

@quaint epoch ^^

quaint epoch
oak warren
#

hmm 1 sec

quaint epoch
#

i know i can use disnake.utils.get but why not fetch directly?

quaint epoch
unkempt canyonBOT
#
Nope.

No documentation found for the requested symbol.

brazen raft
#

Ah

quaint epoch
#

tf

#

time to hit the docs

brazen raft
#

Then it's a property in discord.js probably

oak warren
quaint epoch
#

!d disnake.User.discriminator

unkempt canyonBOT
quaint epoch
#

ah, there it is

brazen raft
#

Aha!

maiden fable
#

Ah the docs are broken

quaint epoch
#

ig it sorta makes sense for the user?

#

because users don't have nicks, members do

final iron
oak warren
# final iron How?

because disnake.Member.discriminator is the same as disnake.User.discriminator in the docs

#

it references it

final iron
#

How is that wrong?

final iron
#

The discriminator will always be the same

#

!d discord.Member.discriminator

unkempt canyonBOT
#

property discriminator```
Equivalent to [`User.discriminator`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.discriminator "discord.User.discriminator")
quaint epoch
quaint epoch
spark cloud
#

pls help me

oak warren
#

disnake is just built different ig

boreal ravine
spark cloud
#

pls

quaint epoch
final iron
#

The docs are broken

quaint epoch
spark cloud
#

yes

brazen raft
oak warren
spark cloud
#

i have install

quaint epoch
#

use disnake if you can

spark cloud
#

but he doesnt work

boreal ravine
quaint epoch
#

most ppl here use disnake/nextcord

boreal ravine
final iron
spark cloud
#

visual studio code

#

i have install

boreal ravine
spark cloud
#

what is the problem pls

#

i have install

#

pls

exotic kite
oak warren
#

self host ig

spark cloud
#

pls

final iron
spark cloud
#

but pls help me

final iron
#

That's not what I was asking

spark cloud
#

i dont use environnement

#

what is the problem

final iron
#

Try setting up a virtual environment and see if it fixes the issue

spark cloud
#

pycharm

boreal ravine
# exotic kite like?

Railway, heroku, AWS (theres a free tier) & more. There are pros and cons to using free hosts though if you weren't already aware

spark cloud
#

i want help

boreal ravine
#

dude

#

can you be patient a bit

stoic galleon
#

is it worth making a discord bot?

boreal ravine
final iron
boreal ravine
final iron
#

Try using a venv and see if it fixes it

stoic galleon
spark cloud
boreal ravine
#

yea sure don't steal code though since you won't get better if you steal code πŸ‘

stoic galleon
#

agreed, thanks!

final iron
spark cloud
#

go to dm @final iron

final iron
#

No

spark cloud
#

😩

#

PLS I WANT HELPPPPPPPPPPp

boreal ravine
final iron
slate swan
#

!venv

unkempt canyonBOT
#

Virtual Environments

Virtual environments are isolated Python environments, which make it easier to keep your system clean and manage dependencies. By default, when activated, only libraries and scripts installed in the virtual environment are accessible, preventing cross-project dependency conflicts, and allowing easy isolation of requirements.

To create a new virtual environment, you can use the standard library venv module: python3 -m venv .venv (replace python3 with python or py on Windows)

Then, to activate the new virtual environment:

Windows (PowerShell): .venv\Scripts\Activate.ps1
or (Command Prompt): .venv\Scripts\activate.bat
MacOS / Linux (Bash): source .venv/bin/activate

Packages can then be installed to the virtual environment using pip, as normal.

For more information, take a read of the documentation. If you run code through your editor, check its documentation on how to make it use your virtual environment. For example, see the VSCode or PyCharm docs.

Tools such as poetry and pipenv can manage the creation of virtual environments as well as project dependencies, making packaging and installing your project easier.

Note: When using Windows PowerShell, you may need to change the execution policy first. This is only required once:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

slate swan
#

read this ez

final iron
#

Imagine not anaconda smh

boreal ravine
#

imagine not using a web editor that has no type checkers

final iron
#

Imagine not using idle

#

πŸ—Ώ

boreal ravine
#

Imagine not using notepad

final iron
#

Imagine not console

boreal ravine
#

we should stop before someone does !ot/!rule 7 πŸ—Ώ

final iron
#

Yes

#

πŸ—Ώ

buoyant igloo
#

HOW TO AUTO CREEATE SQL DATABASE

manic wing
#

imagine not using jarvide the builtin ide πŸ—Ώ

buoyant igloo
#

yeah but it’s kinda dead and it’s for discord.py

manic wing
#

you can just execute a schema

buoyant igloo
#

Damnit bro why does everything have to be so complicated

#

Is it possible to create a SQL database name with a f string

manic wing
buoyant igloo
manic wing
grand shell
#

hey guys!
im getting a strange error when trying to install Pycord on my mac
does anyone know what the issue is?
thanks :))

slate swan
#

do you have git installed?

grand shell
#

ohhh

#

i might not acutally

#

give me a second πŸ˜‚

slate swan
#

Β―_(ツ)_/Β―

manic wing
#

to install from git one tends to require git

slate swan
#

😳 or just dont use pycord

manic wing
#

very true

slate swan
#

use disnake with disnake-debug ahem

grand shell
#

do i need GitPython?

manic wing
manic wing
slate swan
grand shell
#

ah ok

boreal ravine
#

i don't get why people make slash commands even though their bot is in 75 < servers dehd

slate swan
#

just search for download git on google and you can install it from the git website

slate swan
#

also, slash commands are depressing to make and use as well and thats what everyone wants

manic wing
#

i hate slash commands

boreal ravine
#

true

manic wing
#

they ruin everythin

boreal ravine
#

same

#

yea

manic wing
boreal ravine
#

fuck discord

boreal ravine
slate swan
#

did discord remove the bot tokens rn?

keen talon
keen talon
final iron
manic wing
unkempt canyonBOT
#

A visual debugging extension for disnake discord bots including easy blacklisting, evaluation, echoing and much more!

slate swan
#

like there no copy token no more

manic wing
slate swan
#

can u pls explain

#

are they updating?

manic wing
#

idk why theres no copy button

manic wing
slate swan
manic wing
#

i aspire to make something like disnake-debug

manic wing
slate swan
#

all good

manic wing
#

fuck dude i just spilt protein drink all over my electronics

slate swan
#

ouch

unkempt canyonBOT
#

disnake-debug/cog.py lines 105 to 107

await cursor.execute(
    f"Select commands from blacklist where {key}=?", (value[0],)
)```
slate swan
#

lets use both f strings and placeholders together <3

manic wing
kindred epoch
#

.format

slate swan
#

well its just an ID anyways

unkempt canyonBOT
#

disnake-debug/cog.py lines 209 to 210

"timestamp": datetime.now().strftime("%m/%d/%Y, %H:%M:%S"),
"raw timestamp": datetime.now(),```
slate swan
#

!d datetime.datetime.timestamp

unkempt canyonBOT
#

datetime.timestamp()```
Return POSIX timestamp corresponding to the [`datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "datetime.datetime") instance. The return value is a [`float`](https://docs.python.org/3/library/functions.html#float "float") similar to that returned by [`time.time()`](https://docs.python.org/3/library/time.html#time.time "time.time").

Naive [`datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "datetime.datetime") instances are assumed to represent local time and this method relies on the platform C `mktime()` function to perform the conversion. Since [`datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "datetime.datetime") supports wider range of values than `mktime()` on many platforms, this method may raise [`OverflowError`](https://docs.python.org/3/library/exceptions.html#OverflowError "OverflowError") for times far in the past or far in the future.

For aware [`datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "datetime.datetime") instances, the return value is computed as:

```py
(dt - datetime(1970, 1, 1, tzinfo=timezone.utc)).total_seconds()
```   New in version 3.3.

Changed in version 3.6: The [`timestamp()`](https://docs.python.org/3/library/datetime.html#datetime.datetime.timestamp "datetime.datetime.timestamp") method uses the [`fold`](https://docs.python.org/3/library/datetime.html#datetime.datetime.fold "datetime.datetime.fold") attribute to disambiguate the times during a repeated interval.
slate swan
#

^ just a suggestion

manic wing
#

you have to be joking me

#

this protein drink went into my fucking powerpack

#

its gone everywehere

final iron
#

πŸ˜”

manic wing
#

nahhh this is so fucked

craggy cloak
#

Expecting property name enclosed in double quotes: line 18 column 1 (char 406)

What is wrong here? ^^^

#

This is line 18

client = commands.Bot(command_prefix='cs!', intents=intents)

final iron
#

And don't name your Bot instance client

#

discord.Client exists

slate swan
#

can anyone link me the raw api for creating a channel?

proven pendant
#

hi, so when I ran this very simple code for discord bot (python)
it shows "invalid syntax"
how do I fix it?

keen talon
#

Code pithink

manic wing
#

have valid syntax

proven pendant
proven pendant
slate swan
#

eww bts stan

slate swan
manic wing
cold sonnet
proven pendant
cold sonnet
#

tell me where the syntax error is bozo

proven pendant
proven pendant
cold sonnet
#

πŸ‘πŸΏ

manic wing
#

:thumbsup_tone7:

boreal ravine
cold sonnet
#

make a photo of it

boreal ravine
cold sonnet
#

then upload it to discord

scarlet aurora
#

SyntaxError: Non-UTF-8 code starting with '\xe2' in file C:\Users\llVll\Desktop\TMG SB (Not ready for distribution)\main.py on line 2, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details why am i getting this error

scarlet aurora
#

exactly, i'm confused

manic wing
#

um

#

how are you running this file and what are the contents of this file?

scarlet aurora
#

a discord bot

#

and i turned it into 1 line

manic wing
slate swan
#

one liner bot

manic wing
slate swan
#

he used (exec) for it iirc

scarlet aurora
#

yes

manic wing
#

why the hell would you do that

#

if you're making a discord bot have to make it legit one line

sick birch
#

This is a certified JavaScript moment

boreal ravine
#

easy one liner: ```py
import('discord').Client().run('token')

manic wing
#

now add a command to that

boreal ravine
#

no need

#

a bot is a bot troll

keen talon
cold sonnet
#
__import__('discord.ext.commands').Bot().run('token')
```?
manic wing
#

yes

cold sonnet
#

technically

#

you can make everything a one liner

manic wing
#

no

cold sonnet
#

just with ;

manic wing
#

no

cold sonnet
#

why no

manic wing
#

!e if 1: if 2: print(".")

unkempt canyonBOT
#

@manic wing :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 1
002 |     if 1: if 2: print(".")
003 |           ^^
004 | SyntaxError: invalid syntax
manic wing
#
  • you cant decorate with ;
#
  • you cant make functions
#
  • you cant do a lot of shit
cold sonnet
#

nice

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 71, in <module>
@client.slash_command(description="Bot Latency")
AttributeError: 'Bot' object has no attribute 'slash_command'
PS C:\Users\hackt\OneDrive\Escritorio\Protech>

silent musk
#

?discrim

slate swan
#

i need help pls πŸ˜”

#

what library are you using

slate swan
slate swan
#

client = ?

#

how did you import commands?

slate swan
slate swan
# slate swan

you imported everything from discord why do you think it will work

#

replace all discord with disnake

spice basalt
#

how do i make a command require a role?

slate swan
slate swan
unkempt canyonBOT
#

@discord.ext.commands.has_role(item)```
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 the member invoking the command has the role specified via the name or ID specified.

If a string is specified, you must give the exact name of the role, including caps and spelling.

If an integer is specified, you must give the exact snowflake ID of the role.

If the message is invoked in a private message context then the check will return `False`.

This check raises one of two special exceptions, [`MissingRole`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingRole "discord.ext.commands.MissingRole") if the user is missing a role, or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") if it is used in a private message. Both inherit from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").

Changed in version 1.1: Raise [`MissingRole`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingRole "discord.ext.commands.MissingRole") or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") instead of generic [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure")
slate swan
#

use this decorator as a check

spice basalt
#

can you give me an example?

slate swan
#
@bot.command()
@commands.has_role(roleid/rolename)
async def command(context):
  ...```
spice basalt
#

ah

#

thanks

slate swan
cold sonnet
# slate swan

change. the. activity. and. status. in your bot constructor

spice basalt
#

can i make my bot reply if a message contains a certain word in any parts?

#

for example, if a message contains "amogus", it'll reply with "࢞"

cosmic agate
#

hi

@bot.command()
@commands.has_permissions(administrator = True)
async def unban(ctx, *, member=None):
    if member == None:
        await ctx.reply(embed=discord.Embed(title="Unban", description="Who should I unban buddy?", colour=discord.colour.random()))
    else:
        banned_users = await ctx.guild.bans()
        member_name, member_discriminator = member.split("#")

        for ban_entry in banned_users:
            user = ban_entry.user
            
            if (user.name, user.discriminator) == (member_name, member_discriminator):
                await ctx.guild.unban(user)
                await ctx.reply(embed=discord.Embed(title="Unban", description=f'I have successfully unbanned {user.mention}.', colour=discord.colour.random(),
                url=f"https://c.tenor.com/VyQ4o7hyjs0AAAAC/im-back-toby-mcguire.gif"))
                return
#

when i try to unban it unbans but does not give message

cosmic agate
#

???

boreal ravine
cosmic agate
cosmic agate
boreal ravine
#

you can

cold sonnet
boreal ravine
cosmic agate
#

yes

spice basalt
#

it takes me 5 seconds at most

cosmic agate
#

I'm a fast typer

spice basalt
#

so what

boreal ravine
cosmic agate
#

im not here on arguing about unban, I here for a solution

spice basalt
slate swan
#

how i can make that slashs cmds work in all servers without a db

boreal ravine
#

langauge worry_frog

boreal ravine
cosmic agate
boreal ravine
#

well

cosmic agate
pliant gulch
#

They want it when amongus appears anywhere in the message,. not just the start

boreal ravine
#

they said if the messsge contains

cosmic agate
#

oh ok

boreal ravine
spice basalt
cosmic agate
#

hmm

cosmic agate
#

???

cold sonnet
#

nice one

cosmic agate
#
@bot.command()
@commands.has_permissions(administrator = True)
async def unban(ctx, *, member=None):
    if member == None:
        await ctx.reply(embed=discord.Embed(title="Unban", description="Who should I unban buddy?", colour=discord.colour.random()))
    else:
        banned_users = await ctx.guild.bans()
        member_name, member_discriminator = member.split("#")

        for ban_entry in banned_users:
            user = ban_entry.user
            
            if (user.name, user.discriminator) == (member_name, member_discriminator):
                await ctx.guild.unban(user)
                await ctx.reply(embed=discord.Embed(title="Unban", description=f'I have successfully unbanned {user.mention}.', colour=discord.colour.random(),
                url=f"https://c.tenor.com/VyQ4o7hyjs0AAAAC/im-back-toby-mcguire.gif"))
                return
``` Hi, this  is unban code but when you unban, it does it but no message...
unkempt canyonBOT
#

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

Unbans this member. Equivalent to [`Guild.unban()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.unban "discord.Guild.unban").
cosmic agate
#

a preference,,,

#

wont help

manic wing
#

disnake.

brazen raft
#

Or PyCord

manic wing
final iron
cosmic agate
#

what if i dont

manic wing
#

pycord and nextcord are shit

final iron
#

Use disnake. That's what the python bot uses

cosmic agate
boreal ravine
brazen raft
cosmic agate
#

hello

final iron
cosmic agate
slate swan
#

just use rin02comfy

boreal ravine
brazen raft
#

It's not an opinion, it's a wrapper I know of.

slate swan
#

shutmadpepe

brazen raft
#

I just thought to mention its name

slate swan
final iron
final iron
#

Use disnake

boreal ravine
manic wing
#

disnake

final iron
slate swan
#

hikari is nice02comfy

manic wing
#

nextcord and pycord do nothing productive

pliant gulch
boreal ravine
pliant gulch
#

It's still a work in progress, so technically they haven't used it yet

slate swan
boreal ravine
#

read its source code before saying anything

final iron
cosmic agate
#

if you want something like discord.py and simple (idk about that) use nextcord. If you want something used popular go for disnake...

boreal ravine
slate swan
final iron
boreal ravine
brazen raft
slate swan
#

why not make the request yourself 02comfy

cosmic agate
final iron
pliant gulch
final iron
#

Tell me how it's harder

slate swan
#

disnake is kinda overrated tbh hikari, pincer and rin need more clout 02comfy

pliant gulch
#

Rin is kind of dead, I've been way to busy

cosmic agate
#

disnake has lot more range

final iron
slate swan
cosmic agate
final iron
#

Lucas πŸ—Ώ

pliant gulch
final iron
slate swan
cosmic agate
#

you cant judge someone via their opinions

pliant gulch
#

Was on lefi but not on rin, he's making his own programming lang

slate swan
honest shoal
#

I have a problem with my custom evaluate command py @bot.command() async def evaluate(ctx, *, code): str_obj = io.StringIO() try: with contextlib.redirect_stdout(str_obj): exec(code) except Exception as e: return await ctx.send(f"\`\`\`{e.__class__.__name__}: {e}\`\`\`") await ctx.send(f'\`\`\`{str_obj.getvalue()}\`\`\`') await/async does not work in it how can I make them work? when I try it I get this error console SyntaxError: 'await' outside function

slate swan
#

hunter is smart and he knows his stuffMarinAngry

manic wing
#

what programming language is he making

pliant gulch
#

private repo Β―_(ツ)_/Β―

cosmic agate
pliant gulch
#

I know for sure though it's compiled as he has shown me some ASM

boreal ravine
final iron
slate swan
#

andy try asking hunter02comfy

pliant gulch
#

I need someone with a similar coding style to me

manic wing
exotic kite
final iron
#

Just because you can't change your fork without editing your code at all doesn't mean the fork is hard

slate swan
manic wing
exotic kite
#

nahi tere baap ka server hai?

unkempt canyonBOT
#

4. Use English to the best of your ability. Be polite if someone speaks English imperfectly.

pliant gulch
slate swan
#

😭

exotic kite
#

no speak ingliz

unkempt canyonBOT
slate swan
pliant gulch
#

Might checkout revolt API 😳 maybe port rin over to there

cosmic agate
#

First of all , I didnt scream , second, judging me via the way i do things even if yours is better? I think that everyone has their Pros and cons, I don't care if youre not in the mood, you started it

slate swan
#

whats revolt02comfy

pliant gulch
#

Basically discord but actually privacy respecting

slate swan
#

yes you do

#

it must have the scope on before joining a guild

manic wing
#

i want something to replace discord

slate swan
manic wing
#

with a better api and no slash commands

#

so i can be og on it

boreal ravine
cosmic agate
#

I was saying my expriences, I don't think that thats an argument.... Clicking things is not "PYTHONIC" way, Its how discord is

pliant gulch
cunning ice
#

do command

on_member_join()

work on bots ?

manic wing
#

this accounts only from 2016 or smthin

pliant gulch
#

2016 is pretty close to OG, discord was released 2015

#

My original was at 2015 this one is 2017 iirc

manic wing
#

crap this is 2017

final iron
unkempt canyonBOT
#

discord.on_member_join(member)``````py

discord.on_member_remove(member)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") leaves or joins a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").

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

You mean the event?

slate swan
#

if it doesn't work youll need intents

cunning ice
slate swan
#

wait you ment a bot and not the boy oops

cunning ice
#

ok tq

manic wing
# pliant gulch Revolt 😏

if revolt does take over i'd make a shit ton of stuff for it (like bots, potentially api wrappers), i wanna be on top of the trends

spice basalt
#

why isn't this working?, i want my bot to reply like this (also how do i add "your mom" before the embed?)

exotic kite
#

message from 2018

cosmic agate
#

bro by going to discord and doing stuff will only limit my knowledge, Even if it is complicated, I would learn something which is complicated

slate swan
#

sorry i had a bit of trouble reading the message

pliant gulch
cunning ice
cosmic agate
#

?

slate swan
manic wing
#

!pypi revolt

unkempt canyonBOT
cunning ice
manic wing
#

rip

pliant gulch
boreal ravine
#

!pypi revolt-py

unkempt canyonBOT
pliant gulch
#

I'm thinking of the name rain or something with an r

spice basalt
#

i don't like this, the chat is too alive

boreal ravine
pliant gulch
cosmic agate
#

youre not making sense, I need a code that should send a message when a person is unbanned via code, but the message in my code does not come

spice basalt
manic wing
#

how tf do you even download reovlt

#

whats the website for it

pliant gulch
#

Not sure if there is a client, but there is a website

manic wing
#

whats the website

boreal ravine
#

Don't bother with chat apps that don't respect your privacy. Revolt is a brand new chat platform designed around you.

cosmic agate
spice basalt
#

cope

pliant gulch
boreal ravine
#

thanks

slate swan
#

what is even happeninghmmcat

cosmic agate
slate swan
cosmic agate
boreal ravine
#

ot but are any of you guys in the python server that hunter made on revolt?

feral jacinth
unkempt canyonBOT
slate swan
spice basalt
feral jacinth
#

you cant put raw text as a part of embed

slate swan
#

no

feral jacinth
boreal ravine
spice basalt
slate swan
manic wing
feral jacinth
spice basalt
slate swan
feral jacinth
#

@spice basalt can i ask why do u set footer and image to an already sent embed

#

instead of doing that before sending the message

spice basalt
#

what

neat pagoda
#

I'de like to add a patreon to my bot, how do I do this?

feral jacinth
spice basalt
#

yes

slate swan
#

why are people so hostile smhMarinAngry

spice basalt
slate swan
feral jacinth
spice basalt
#

i-

slate swan
feral jacinth
slate swan
feral jacinth
#

use pycord

slate swan
#

wut

slate swan
#

you were unable to simply copy paste the code for a normal command and turn it into a slash one?

feral jacinth
slate swan
#

he probably was missing the scopepithink

final iron
feral jacinth
boreal ravine
#

Good ol' days when the only active helpers in this channel were me, hunter, krypton, sarthak, andy, sebkuip and robin dehd

slate swan
feral jacinth
slate swan
feral jacinth
boreal ravine
slate swan
#

content is a positional arg

slate swan
slate swan
spice basalt
slate swan
#

re-run the bot when

spice basalt
#

wait i already added this

spice basalt
slate swan
#

your setting a footer to nothing

#

theres no Embed class instance so what are you setting the footer to02comfy

feral jacinth
#

@spice basalt noob you should create embed and set footers before defining it in message

prime crystal
#

is it possible to run another async function in parallel along with discord.py's event loop?

feral jacinth
slate swan
spice basalt
feral jacinth
final iron
slate swan
slate swan
feral jacinth
manic wing
feral jacinth
slate swan
#

not in this server sorry02comfy

feral jacinth
#

since when any reference to gays is homophobia

final iron
#

!ot

unkempt canyonBOT
slate swan
spice basalt
feral jacinth
final iron
manic wing
final iron
slate swan
spice basalt
slate swan
slate swan
final iron
tall dust
unkempt canyonBOT
#

:incoming_envelope: :ok_hand: applied warning to @feral jacinth.

final iron
#

Why?

spice basalt
slate swan
#

im not sure how making no class instance is bad02comfy

final iron
spice basalt
#

then how should i put it

final iron
#

Without brackets?

spice basalt
#

how

final iron
#

By not typing brackets?

spice basalt
#

your instruction is clear, it's just that it isn't to me

final iron
#

Just assign the variable like you normally do

spice basalt
final iron
#

By not pressing the bracket key on your keyboard?

spice basalt
#
if "who" in message.content:
    (embed = discord.Embed(title= "libtard owned", color=(0xffffff)))

    embed.set_footer(text='owned epic style 😎')
    embed.set_image(url='https://cdn.discordapp.com/attachments/866704237098565652/907551142496579624/IMG-2476bf9dc989a216f89847248550c305-V.png')
    await message.channel.send("your mom", embed=embed)
spice basalt
spice basalt
#

wait you actually disappeared

slate swan
spice basalt
spice basalt
#

😩

slate swan
#

me?AG_RemThonk

spice basalt
#

yes

slate swan
spice basalt
hallow tangle
#

How can I make my bot send a message after every 25 messages?

cold sonnet
#

!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").
cold sonnet
#

this is the decorator you want

kindred epoch
#

no

cold sonnet
#

wdym no

kindred epoch
#

he said messages not 25 minutes or seconds

cold sonnet
#

minutes kwarg

#

silly

#

or seconds=25*60

kindred epoch
#

huh

#

dud he said messages

cold sonnet
#

oh god

#

I misread both messages

hallow tangle
#

messages

kindred epoch
#

lul

cold sonnet
#

and I didn't even drink

kindred epoch
#

maybe use on_message and set a counter to where if it hits 25 you send a message

manic wing
#

you know what my favourite part of the revolt.py lib is? you cant send messages

manic wing
#
File "/home/Caeden/Github/RevoltGPB/__main__.py", line 8, in on_message
    await message.channel.send("hi how are you")
  File "/home/Caeden/.local/lib/python3.10/site-packages/revolt/messageable.py", line 60, in send
    message = await self.state.http.send_message(await self._get_channel_id(), content, embed_payload, attachments, reply_payload, masquerade_payload)
TypeError: object str can't be used in 'await' expression
manic wing
#

time to fix the library

cold sonnet
#

might as well use it

manic wing
#

omfg

#

raise NotImplementedError jesus christ

#

you cant even send messages, great library

cold sonnet
#

now you got me

buoyant igloo
#

Yo guys how to get user id

cold sonnet
#

I'm downloading it

manic wing
#

actually m not sure if you can send a message yet

buoyant igloo
sick birch
buoyant igloo
hallow tangle
#

how can I keep a count on them?

sick birch
buoyant igloo
#

Like
user = bot.get_user()

sick birch
#

It should

cold sonnet
#

or a database if it does

hallow tangle
#

!d disnake.on_message

unkempt canyonBOT
#

disnake.on_message(message)```
Called when a [`Message`](https://docs.disnake.dev/en/latest/api.html#disnake.Message "disnake.Message") is created and sent.

This requires [`Intents.messages`](https://docs.disnake.dev/en/latest/api.html#disnake.Intents.messages "disnake.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://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.Bot "disnake.ext.commands.Bot") does not have this problem.
cold sonnet
#

disnake

#

man of culture

hallow tangle
#

I'm just confused here

#

is there any after or something?

cold sonnet
#

no

#

cuz of commands?

spice basalt
#

how do i make my bot reply only when a message is specifically "no u"?

#

only if it's completely "no u"

cold sonnet
#

on_message

#

if message.content == "no u":

tardy atlas
#

Why isn't the .db file created on git? (sqlite3, and git is linked to heroku)

spice basalt
spice basalt
brazen raft
hallow tangle
#

coz I'm not getting any idea about keeping them in a variable

brazen raft
#

I think there's wait_for or something

#

You can specify a limit

tardy atlas
#

Why isn't the .db file created on git? (sqlite3, and git is linked to heroku)

brazen raft
#

Which wrapper are you using?

hallow tangle
brazen raft
#

Oh.

#

discord.py had task loops

hallow tangle
#

no, its for time

spice basalt
#

how do i make my bot react to a message?

#

fail

#

fail again

brazen raft
#

Well, there was some discord.py function to wait for payloads

hallow tangle
brazen raft
#

You could have a variable that you can increase

#

To count

hallow tangle
brazen raft
#

It waits for the first message that fits the check

#

If it's any message, you would have to increment the variable and return True from the check

spice basalt
#

where should i put it

spice basalt
slate swan
cold sonnet
spice basalt
hallow tangle
slate swan
hallow tangle
spice basalt
#

also it should be the emoji's iD, right?

slate swan
brazen raft
spice basalt
#

where ping

slate swan
cold sonnet
brazen raft
#

It's a name for the sake of being a name

slate swan
#

Hi. I am trying to make a discord.py QOTD bot for my friend's server. I tried running the code and making it where it would send a message if the hour is 13 (1PM for most people). I tried running it a few times (since during the time running it, it was 1PM for me), but nothing happened. Did I do something wrong in this code?

from datetime import datetime
import os
import discord

client = discord.Client()

@client.event
async def on_ready():
  print("The bot is online!")
  
@client.event
async def bot_works(ctx):
  channel = discord.utils.get(ctx.guild.channels, name='general')
  channel = channel.id()
  
  now = datetime.now()
  now = now.hour
  if now == 13:
    await channel.send('test') # this is just a test message
  else:
    await channel.send('nothin') # also a test message

if __name__ == '__main__':
  client.run(os.getenv('TOKEN'))
spice basalt
brazen raft
#

You can use a literal integer, I don't care

cold sonnet
#

on every message

brazen raft
#

No it's not

cold sonnet
#

make a bot variable at the start of the code

spice basalt
cold sonnet
#

the bot variable you make is gonna be an int

spice basalt
#

i'm confused now PepeStare

cold sonnet
#

and just raise it on_message

brazen raft
#

After you call the command, it logs the next 25 messages and sends them as a Python list of the reprs of the message objects

slate swan
spice basalt
brazen raft
cold sonnet
#

ok but why is it a list
I thought it would be an on_message

slate swan
brazen raft
#

I have written code that is correct for discord.py and its bot and commands system

#

So I used a bot command instead of the on_message bot event

hallow tangle
cold sonnet
#

yeah, this is the one where messages resets

hallow tangle
#

I want it to reset after every 25

cold sonnet
#

so you have the line where you define bot

hallow tangle
#

yes

cold sonnet
#

directly under that, make a variable inside bot

#

bot.messages = 0

hallow tangle
#

oh

cold sonnet
#

and you can raise this variable by one on_message

#

bot.messages += 1

buoyant igloo
slate swan
unkempt canyonBOT
#

property id```
Equivalent to [`User.id`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.id "discord.User.id")
slate swan
unkempt canyonBOT
cold sonnet
#

that wait_for came from a command version of this

brazen raft
#

I thought they wanted a command

hallow tangle
#
bot.messages+=0

@bot.event
async def on_message(message):
    messages = []
    num_to_receive = 25
    while len(messages) < num_to_receive:
        k = await bot.wait_for("message", check=lambda _: True)
        messages.append(k)
    await ctx.send('ok')```So is this ready?
cold sonnet
#

the command would work

#

but it's an unnecessary list

spice basalt
#

how do i add the person i mentioned's username in a command in my bot?

cold sonnet
#

can I spoonfeed

slate swan
#

no

hallow tangle
brazen raft
hallow tangle
#

just explain

spice basalt
brazen raft
#

Idk what else

cold sonnet
#

int

spice basalt
brazen raft
#

Don't they want to do something with those messages though

cold sonnet
#

no

brazen raft
#

Well then

cold sonnet
#

just send a message after 25 messages

buoyant igloo
hallow tangle
slate swan
#

a = 1
a += 1
how hard is it

brazen raft
#

Should be bot.messages

#

Anyway, you need an int variable

silk mauve
#

discord.commands.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'Interaction' object has no attribute 'add_reaction'

#

msg = await ctx.respond(embed=embed)
await msg.add_reaction("here my emoji:")

#

Thats my code

hallow tangle
hallow tangle
cold sonnet
#
bot.messages = 0
@bot.event
async def on_message(message):
    bot.messages += 1
    if bot.messages == 25:
        #do something
hallow tangle
spice basalt
#

bro i mean in my bot

brazen raft
#
bot.messages = 0
bot.num_to_receive = 25
@bot.event
async def on_message(message):
    if bot.messages < bot.num_to_receive:
        bot.messages += 1
    else:
        ...  # do something
        bot.messages = 0
spice basalt
brazen raft
#

Though, you need to reset the counter

cold sonnet
#

you will try to spare every possible memory in your bot once you only get 1GB RAM to host it

hallow tangle
spice basalt
cold sonnet
#
bot.messages = 0
@bot.event
async def on_message(message):
    bot.messages += 1
    if bot.messages == 25:
        #do something
        bot.messages = 0
brazen raft
#

Tias

#

Try it
and SEE

hallow tangle
#

ok testing

slate swan
cold sonnet
buoyant igloo
#

@bot.command()
async def test(ctx):
  user = discord.User.id
  await ctx.send(user)

(! Is my prefix)

When I run !test

It gives:

<member 'id' of 'BaseUser' objects>

slate swan
cold sonnet
#

=> is unnecessary aswell

#

that 1 byte is one thing I'll need in my life

slate swan
hallow tangle
#

ok

buoyant igloo
cold sonnet