#discord-bots
1 messages Β· Page 882 of 1
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.
Get rid of ur discord.color stuff
okay
So u have color = (whateverhex)
!d discord.User.color
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").
Gg!
wp
rin
mentioning someone to get their username replaced with "you"?
how do i do that
username = username or "you"
the mentioned target's name
! discord-components
how then
username = user.name if user is not None else "you"
that is supposed to be?
make user an optional param
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)
@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)```
just use another bot?
ah
hopefully it helped:)
it doesnt work for "you"
yes
and he needs the user which is mentioned, not author
Alright here
yes i want it to say "you" when no one is mentioned
done
async def cr(ctx, *, user: discord.Member = None):
then this
you can use user: discord.member
@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)```
ah
thats wrong again, wont work for you
yes
do this bro.
what's this issue in send()?
you could use a startup task and perform your check there
those parameters need to be used to construct an AllowedMentions object
e.g. py discord.AllowedMentions(everyone=False)
Might as well set you as the default value in the function definition
go over the ids again after the bot is online?
oh great idea
i wont do it, you may need to do some other checks before just sending you
i can just make another command for mentioning another user
i didnt know how to
but i want it to give an error message when no one's mentioned like this then
?
i'll just make a separate command for mentioning others
ok

rip forgot what it was
!d discord.ext.commands.Command.error
@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.
....
Hm?
just for that?
!d discord.ext.commands.Bot.on_command_error ?
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.
then I just need to add allowed_mentions=users in send() and they won't get mentions right?
no no, nothing
if you assigned the AllowedMentions object to a variable named users sure
ok but how do i make it send an error message when no one's mentioned

just check if the member is none, if it is then use an if statement in the command itself saying that member is none or anything you like
!d discord.ext.commands.check @spring flax
@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").
!d discord.ext.commands.MissingRequiredArgument
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")
compare the instance of error with this class
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
!d isinstance
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).
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

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))
@slate swan :white_check_mark: Your eval job has completed with return code 0.
001 | True
002 | False
"text" is a string so comparing it with str in isinstance will get you True, and False for integer
so
if isinstance(`.cru` is for others, `.cru @Cute Yaya`, use `.cr` for yourself, `.cr`., commands.MissingRequiredArgument):
but how do i require a mention?
thats now how you do it
how would i pass a list into has_any_role?
it just checks the condition, you respond with ctx.send/reply inside the if
has_any_role(role1, role2)
or has_any_role(*[role1, role2])

so I can do it like this?
so then what about the commas?
which means function(*[a, b]) will become function(a, b)
at this point just learn basic python π€·ββοΈ
!e print(" a", " b" , " c") # do you see a comma here?
@slate swan :white_check_mark: Your eval job has completed with return code 0.
a b c
you wont see them in prints..
how do i get a member's id with a member object
lemme show an example of how it actually works in #bot-commands
property id```
Equivalent to [`User.id`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.id "discord.User.id")
Im so stupid bro what
i know the basics 
Doing *list_of_roles is the same as doing id1, id2, id3
That emoji is cute π€£
why
you know what's cuter?
what do you have to gain from saying that even
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))
Yea, so passing in None means no restriction(s) on using the command
!e *None
@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
this tho
yeah it'll then check manage_guild
you can pass in an empty list if data is None
just change the return to return data or [] and u will be fine
but if there's no data won't it return []?
Yea
yea, and on unpacking it , it would be NOne
that is what we want, so that it won't error
if data:
return data ?
No need
actually , NO
!e *[] # will raise an error too
@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
!e *[None]
@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
Ayo what the
just put in some random numbers there lol return data or [1] and youll be fine
Wait lemme see something
!e
def a(*b):
print(b)
l1 = [1, 2, 3]
l2 = []
a(*l1)
a(*l2)
@maiden fable :white_check_mark: Your eval job has completed with return code 0.
001 | (1, 2, 3)
002 | ()
See, Python fixes the issue automatically
π€¨ hm
oh i see
has_any_role won't be able to call permission_check's predicate with the correct arguments for you, so you should use has_any_role inside your permission_check instead
didn't you forget to close a bracket
i just wrote the code here so I didn't really pay attention to that
ohk
async def has_log_role():
async def predicate(ctx):
# do your db query here
role_id: int
# re-use the predicate that has_any_role provides
role_predicate = commands.has_any_role(role_id).predicate
return await role_predicate(ctx)
return commands.check(predicate)
# then what you write for your command:
@commands.check_any(has_log_role(), ...)```
i honestly didn't get this
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
but why can't I use the other one exactly?
what's an EOL?
oh wait so I need to have to await it first for it to return the list and unpack it with *list
u forgot a quotation mark
you can't type a newline directly when using single quotes
it either has to be represented as the escape character \n or replaced with triple quotes """ for a multi-line string
ah
mind telling me what the role_id : int does?
its just a type annotation for clarity in my snippet
if you were to run the code it wouldnt actually assign any variable
but not inside the parameters of command decorator, since python immediately runs the inner code
thanks, it works
>>> @some_decorator(print('hello world'))
... def foobar():
... print('foobar')
hello world```
do accounts which have been hacked by bots get member.bot true?
uh no, discord won't recognize them as bots
so there's no way to get if that were to happen right?
.bot can only tell if the user is registered as a bot in the application site, while user bots just look like regular users
anybody know how i can host my discord bot 24/7 easily for free?
its in visual studio
They are still user accounts
@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
!e
(float(input("How are you"))
@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
!e
(float(input("How are you")))
@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
any one have any thoughts on the discord dev survey
All I have is "wtf is discord dev survey"
hmm go to the dashboard i got a link to it there
how to get member's tag with member object again my brain froze
filling it up rn
you mean their discriminator?
str(member).rsplit('#')[-1]
i see i dont know what to write for how to improve discord
gimme option to fetch a single role
hahaha
because i guess only the people to make the api thing know what they want rest find it easy
Isn't that `member.discriminator``
no, fetch a role
hmm 1 sec
i know i can use disnake.utils.get but why not fetch directly?
!d disnake.Member.discriminator
No documentation found for the requested symbol.
Ah
Then it's a property in discord.js probably
you can use fetch_roles and do what you want
!d disnake.User.discriminator
The userβs discriminator. This is given when the username has conflicts.
ah, there it is
Aha!
Ah the docs are broken
How?
because disnake.Member.discriminator is the same as disnake.User.discriminator in the docs
it references it
How is that wrong?
Use a free host
property discriminator```
Equivalent to [`User.discriminator`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.discriminator "discord.User.discriminator")
hard to find one
wtf
pls help me
disnake is just built different ig
Google exists for a reason
pls
yes it's still ahrd tho
The docs are broken
run py -m pip install discord.py in your cmd line
yes
Use a fork of the library.
thats what hunter said
i have install
use disnake if you can
but he doesnt work
No. Railway, heroku, AWS & more exist
most ppl here use disnake/nextcord
Install it first
Are you using a virtual environment (venv)?
discord.py also
like?
self host ig
pls
That's your text editor
That's not what I was asking
Try setting up a virtual environment and see if it fixes the issue
pycharm
Railway, heroku, AWS (theres a free tier) & more. There are pros and cons to using free hosts though if you weren't already aware
i want help
is it worth making a discord bot?

I gave you help
It depends
Try using a venv and see if it fixes it
ok, so if im trying to get better at python n programming in general should i create a discord bot/
i dont understand !!!!
yea sure don't steal code though since you won't get better if you steal code π
agreed, thanks!
Try asking how to setup a venv in #python-discussion or #βο½how-to-get-help
go to dm @final iron
No

Read my previous message
!venv
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
read this ez
Imagine not anaconda smh
Imagine not using notepad
Imagine not console
we should stop before someone does !ot/!rule 7 πΏ
HOW TO AUTO CREEATE SQL DATABASE
imagine not using jarvide the builtin ide πΏ
yeah but itβs kinda dead and itβs for discord.py
research shcema.sql
you can just execute a schema
Damnit bro why does everything have to be so complicated
Is it possible to create a SQL database name with a f string
well if you want you can just execute CREATE IF NOT EXISTS TABLE table_name (...) in your on_ready
WOAH WAIT THATS ACTUALLY PRETTY SMART
stop with the caps jesus christ
hey guys!
im getting a strange error when trying to install Pycord on my mac
does anyone know what the issue is?
thanks :))
do you have git installed?
Β―_(γ)_/Β―
to install from git one tends to require git
π³ or just dont use pycord
very true
use disnake with disnake-debug ahem
do i need GitPython?
even more true
who knows Β―_(γ)_/Β―
you need to install git
ah ok
i don't get why people make slash commands even though their bot is in 75 < servers 
just search for download git on google and you can install it from the git website
future planning mate
also, slash commands are depressing to make and use as well and thats what everyone wants
i hate slash commands
true
they ruin everythin
you ruin everything? o.O
fuck discord
you said they not me 
did discord remove the bot tokens rn?
Disnake debug 
What's that π
What
!pypi disnake-debug
lol
idk why theres no copy button
disnake debug is some genius project made by some random genius
is there one for you?
i aspire to make something like disnake-debug
idk, cba to check
all good
fuck dude i just spilt protein drink all over my electronics
ouch
disnake-debug/cog.py lines 105 to 107
await cursor.execute(
f"Select commands from blacklist where {key}=?", (value[0],)
)```
lets use both f strings and placeholders together <3
you cant use a placeholder for a where
.format
well its just an ID anyways
disnake-debug/cog.py lines 209 to 210
"timestamp": datetime.now().strftime("%m/%d/%Y, %H:%M:%S"),
"raw timestamp": datetime.now(),```
!d datetime.datetime.timestamp
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.
^ just a suggestion
you have to be joking me
this protein drink went into my fucking powerpack
its gone everywehere
π
nahhh this is so fucked
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)
Send the full traceback
And don't name your Bot instance client
discord.Client exists
can anyone link me the raw api for creating a channel?
hi, so when I ran this very simple code for discord bot (python)
it shows "invalid syntax"
how do I fix it?
Code 
have valid syntax
code is
from discord.ext import commands
bot = commands.Bot(command_prefix='.')
@bot.command()
async def hello(ctx):
await ctx.reply('Hello!')
bot.run('bot token')```
i-
restart IDE
eww bts stan
yup, or maybe she forgot to save
im not wrong
you're wrong
I saved it
tell me where the syntax error is bozo
ooki one sec
tysm it worked!
ππΏ
:thumbsup_tone7:
https://discord.com/developers/docs/resources/guild#create-guild-channel
POST /guilds/{guild.id}/channels
Integrate your service with Discord β whether it's a bot or a game or whatever your wildest imagination can come up with.
Thank you.
make yourself a hand out of literal coal
make a photo of it

then upload it to discord
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
w h a t
exactly, i'm confused
w h a t
one liner bot
#esoteric-python on your bike
he used (exec) for it iirc
yes
why the hell would you do that
if you're making a discord bot have to make it legit one line
This is a certified JavaScript moment
easy one liner: ```py
import('discord').Client().run('token')
now add a command to that
show the second line
π€£
with a bot?
__import__('discord.ext.commands').Bot().run('token')
```?
yes
no
just with ;
no
why no
!e if 1: if 2: print(".")
@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
nice
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>
?discrim
disnake
show your bot defination
client = ?
how did you import commands?
it is there in the traceback, 'Bot has no....'
you imported everything from discord why do you think it will work
replace all discord with disnake
how do i make a command require a role?
they call their commands.Bot variable client
!d discord.ext.commands.has_role
@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")
use this decorator as a check
can you give me an example?
@bot.command()
@discord.ext.commands.has_role(rolename)
async def foo(ctx):
pass
@bot.command()
@commands.has_role(roleid/rolename)
async def command(context):
...```
you cant use the decorator that way, sadly
change. the. activity. and. status. in your bot constructor
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 "ΰΆ"
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
???
why don't you just unban the user directly
why not like this?

- u can't
you can
so

- useless code
- slow
it takes me 5 seconds at most
I'm a fast typer
so what
if "uwu" in message.content:
return await message.reply(...) #use return if you have multiple if statements
im not here on arguing about unban, I here for a solution
you really think you can get the iD and also "unban" someone in under 5 seconds?
any errors?
okay
how i can make that slashs cmds work in all servers without a db
langauge 
- what library are you using?
- why would you even need a db lol
why not
if message.content.startswith('amogus'):
await message.channel.send(ΰΆ)
well
Like it unbans but no message
syntax
They want it when amongus appears anywhere in the message,. not just the start
they said if the messsge contains
oh ok

i wanted anywhere in the message 
hmm
ΰΆ undefined
???
nice one
can some one help?
@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...
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").
disnake.
Or PyCord
get out of here
Don't recommend pycord
what if i dont
pycord and nextcord are shit
Use disnake. That's what the python bot uses
easy for idiots like me
why are you like this? just let them recommend it
I request elaborate explanation with examples from both wrappers
hello
Why would I let them recommend an inferior fork and not say anything about it
let him also give his opinion
just use rin
no?
It's not an opinion, it's a wrapper I know of.
shut
I just thought to mention its name

why is it "inferior"
Use disnake
my point still stands
disnake
How?
hikari is nice
nextcord and pycord do nothing productive
They haven't ported over yet iirc
are you dumb
It's still a work in progress, so technically they haven't used it yet
pycord is like pushing your code directly with just a "it works" check, ignoring the code quality and bugs
disnake makes various checks including code quality, and more
look at the src you'll get it
read its source code before saying anything
Yes
if you want something like discord.py and simple (idk about that) use nextcord. If you want something used popular go for disnake...


They're switching over. That should be enough
yes

How is disnake not simple?
Thank you for being the first one to answer my request
why not make the request yourself 
just use discord.py
disnake not simple for idiots like me
It's the same level of difficulty as nextcord
Where are the tests for disnake? I don't see any unit testing other than a test bot
Tell me how it's harder
nah
disnake is kinda overrated tbh hikari, pincer and rin need more clout 
yes
Rin is kind of dead, I've been way to busy
disnake has lot more range
How is it harder?
quit your job i want rin out already
idk im idiot
Lucas πΏ
Unless I find a co-maintainer rin will probably never finish
If you don't even know how it's harder why say it is?
isnt blanket your co maintainer 
you cant judge someone via their opinions
Was on lefi but not on rin, he's making his own programming lang
hunter
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
hunter is smart and he knows his stuff
what programming language is he making
private repo Β―_(γ)_/Β―
like I tried the change but my code didnt work
I know for sure though it's compiled as he has shown me some ASM
yea
That doesnt make it harder lmao
andy try asking hunter
I need someone with a similar coding style to me
cringe
Just because you can't change your fork without editing your code at all doesn't mean the fork is hard
talk to lemon
black line length 120
nahi tere baap ka server hai?
4. Use English to the best of your ability. Be polite if someone speaks English imperfectly.
120 is a bit to long, I'm using 90 for the codebase
π
no speak ingliz
Off-topic channel: #ot2-never-nesterβs-nightmare
Please read our off-topic etiquette before participating in conversations.

Might checkout revolt API π³ maybe port rin over to there
revolt?
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
whats revolt
Basically discord but actually privacy respecting
pog
yes you do
it must have the scope on before joining a guild
i want something to replace discord

revolt
I was saying my expriences, I don't think that thats an argument.... Clicking things is not "PYTHONIC" way, Its how discord is
Revolt π
do command
on_member_join()
work on bots ?
this accounts only from 2016 or smthin
2016 is pretty close to OG, discord was released 2015
My original was at 2015 this one is 2017 iirc
crap this is 2017
???
!d discord.on_member_join
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.
You mean the event?
if it doesn't work youll need intents
no i mean does this command work when a bot joins the server
wait you ment a bot and not the boy oops
ok tq
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
why isn't this working?, i want my bot to reply like this (also how do i add "your mom" before the embed?)
message from 2018
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
I'm looking at the API right now, perhaps I will be porting rin over to revolt π³
this is the current output
are you sure about that ?
?
ill help
why wouldnt it?
!pypi revolt
ok tq
rip
It's not final, we'll see

!pypi revolt-py
I'm thinking of the name rain or something with an r
i don't like this, the chat is too alive


This is basically just a discord.py clone though π
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

Not sure if there is a client, but there is a website
still lying to yourself?
whats the website
wdym?
cope
revolt.chat
thanks
what is even happening
discord bot help
i doubt that 

help me
me too, but chat name ..
ot but are any of you guys in the python server that hunter made on revolt?
u can put "your mom" in embed description or title
!ot πΏ
Off-topic channel: #ot2-never-nesterβs-nightmare
Please read our off-topic etiquette before participating in conversations.
nope didn't even knew hunter had revolt
i don't want that 
you cant put raw text as a part of embed
no
want or not want, know a bit of discord api
pretty sure he made an account in august-december
i want it to output like this
.send("text", embed=embed)
god damnit why is everyone og and im hearing about this now
o
mhm nice
thank you
your welcome
@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
what
I'de like to add a patreon to my bot, how do I do this?
do you know what is python and discord.py and what is difference between them
yes
why are people so hostile smh
you didn't even know that a text can go with an embed 

π embed title and embed descriptions exist
i-
he said separate text to the embed
i had traumatic experience creating slash commands with disnake

use pycord
explain wdym by tramatic?
you were unable to simply copy paste the code for a normal command and turn it into a slash one?
what is issue with ur current code tho
he probably was missing the scope
No
no i didnt forger that scope
Good ol' days when the only active helpers in this channel were me, hunter, krypton, sarthak, andy, sebkuip and robin 
then you were doing something wrong because if you so everything correctly its easy
but some idiot couldnt normally write out the slash commands in older version so i had to update lib π€¬
what about scoopy
how do i fix this?
await message.channel.send("your mom", embed=embed)
ctx isnt an attribute lol
seiff too yes
content is a positional arg
ah
remove the period a coroutine needs await which is a space
but now look whos here me
the output
wait i already added this
i already did that 
your setting a footer to nothing
theres no Embed class instance so what are you setting the footer to
@spice basalt noob you should create embed and set footers before defining it in message
is it possible to run another async function in parallel along with discord.py's event loop?
your mom gay
yeah my mother is woman so she loves men
he did made a Embed just not an instance so the real noob here is you

no how could you call methods to embed if you didnt define it as a variable
You're sending 2 embeds
you call it directly to the class and not its instance
this is called gaycode
someone is mad
how
please dont be homophobic
LOL
not in this server sorry
since when any reference to gays is homophobia
!ot
Off-topic channel: #ot2-never-nesterβs-nightmare
Please read our off-topic etiquette before participating in conversations.
you said gaycode as code having no class instances is bad?
yeah i removed it
ye cuz this type of syntax is used by gays
Why are you creating a variable in brackets
using gaycode as a negative is homophobic ... ?
What...?
<@&831776746206265384> this isnt very friendly
i can't tell if you're actually stupid or just messing around 

2nd option better

You're assuming a variable in brackets
!warn 347365756301737994 using gay as a pejorative is not acceptable in this server
:incoming_envelope: :ok_hand: applied warning to @feral jacinth.
Why?
is it not necessary?
im not sure how making no class instance is bad
No
then how should i put it
Without brackets?
By not typing brackets?
your instruction is clear, it's just that it isn't to me
Just assign the variable like you normally do
bro how
By not pressing the bracket key on your keyboard?
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)
which variable


me?
yes


How can I make my bot send a message after every 25 messages?
!d discord.ext.tasks.loop
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").
this is the decorator you want
no
wdym no
he said messages not 25 minutes or seconds
messages
lul
and I didn't even drink
maybe use on_message and set a counter to where if it hits 25 you send a message
never heard
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
sounds intimidating
time to fix the library
might as well use it
omfg
raise NotImplementedError jesus christ
you cant even send messages, great library
now you got me
Yo guys how to get user id
I'm downloading it
actually m not sure if you can send a message yet
user
Would bot.get_user() work?
how can I keep a count on them?
Yes
Like
user = bot.get_user()
It should
either just a variable if your bot's script does never restart
or a database if it does
variable will be fine
!d disnake.on_message
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.
how do i make my bot reply only when a message is specifically "no u"?
only if it's completely "no u"
Why isn't the .db file created on git? (sqlite3, and git is linked to heroku)
it won't work if it's a no u, no u a, or a no u a
thank you
That does what?
skipping a number of messages
coz I'm not getting any idea about keeping them in a variable
Why isn't the .db file created on git? (sqlite3, and git is linked to heroku)
Which wrapper are you using?
oh I want that a message should be sent after every 25 messages
no, its for time
Well, there was some discord.py function to wait for payloads
its add_reaction() on the context
can we wait for multiple messages here?
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
like
if message.content == "gay":
return await message.send('just like your mom')
where should i put it
what's return await mean

message.channel.send
store the send method in a variable, then use the add_reaction method on variable as a send method returns a Message object
python moment
no i mean where i should put add_reaction()
the problem is I'm messing up with the variable there
can you give me an example?
msg = await message.channel.send()
await msg.add_reaction(whatever_emoji)```
how can I store the amount of messages
arigato
also it should be the emoji's iD, right?
its alright
@bot.command()
async def idk(ctx):
messages = []
num_to_receive = 25
while len(messages) < num_to_receive:
message = await bot.wait_for("message", check=lambda _: True)
messages.append(message)
await ctx.send(messages)
where ping
noooo, the <:name:id> format or the unicode
what for num_to_receive var
It's a name for the sake of being a name
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'))
wait so i can't react custom emotes like !BroKiss?
You can use a literal integer, I don't care
and messages is gonna reset everytime
on every message
No it's not
make a bot variable at the start of the code
wait nevermind, i just realized what you said
yep
the bot variable you make is gonna be an int
and just raise it on_message
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
lol you can
Which is probably bad. You probably want an actual check function to check if the message is from the same user, or from the same guild or something
ok but why is it a list
I thought it would be an on_message
appreciatable, you get things faster than most of us
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
@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')
```I want such an event, the bot is only in 1 guild and should store every message
yeah, this is the one where messages resets
I want it to reset after every 25
so you have the line where you define bot
yes
oh
How to get user id in discord.py
why have wait for? doesnt on_message already wait for a websocket event?
property id```
Equivalent to [`User.id`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.id "discord.User.id")
The userβs unique ID.
that wait_for came from a command version of this
I thought they wanted a command
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?
no...
how do i add the person i mentioned's username in a command in my bot?
can I spoonfeed
no
no
bot.messages = []
bot.num_to_receive = 25
@bot.event
async def on_message(message):
if len(bot.messages) < bot.num_to_receive:
messages.append(message)
just explain

why list 
Idk what else
int
it is possible, right?
Don't they want to do something with those messages though
no
Well then
just send a message after 25 messages
It doesnβt get the user id, it gives this:
<property object at 0x7efe82be5b80>
what is messages on last line
a = 1
a += 1
how hard is it
My human mistake
Should be bot.messages
Anyway, you need an int variable
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
ye
where
bot.messages = 0
@bot.event
async def on_message(message):
bot.messages += 1
if bot.messages == 25:
#do something
ISN'T THIS THE PERSON YOU MENTIONED?
bro i mean in my bot
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
that's a command i made on another bot

Yeah fair
Though, you need to reset the counter
you will try to spare every possible memory in your bot once you only get 1GB RAM to host it
will this keep adding the messages?
i showed it to make you see what i mean
bot.messages = 0
@bot.event
async def on_message(message):
bot.messages += 1
if bot.messages == 25:
#do something
bot.messages = 0
ok testing
bot.messages = 0
@bot.listen()
async def on_message(message):
bot.messages += 1
if bot.messages >= 25:
await message.channel.send("25 messages have been sent")
bot.messages = 0
don't even know what to put the stress on
@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>
bot.listen() sure =< no
oops
What did you mean to do?
= is the right operator
ok
To send the user id
oh



