#discord-bots
1 messages · Page 741 of 1
so the only way i can create ephermal messages r through buttonsa
!pypi disnake
oh so i can?
you can only send ephemeral msgs on a interaction
so yes buttons and slash commands and i think drop downs as well
yea so can i make it with disnake
yeah
and can ephermal messages contain buttons
no
you can send a ephemeral msg on a interaction so on a button press yes you can send a msg
so when i do a / command
an ephermal message pops up and it contains its own buttons for other ephermal messages is that allowed
yes its possible
well its really easy just change the word discord to disnake every where and youll be good
for buttons and slash commands the git repo has it
oh okay so i just search up tutorial on disnake
theirs examples in the git repo which ive gaved you just now
oh so in async def u write everything u want in the function
async def autocomplete(
inter: disnake.CommandInteraction,
language: str = commands.Param(autocomplete=autocomplete_langs),
):
its just like a command yes but with different arg and a different decorator
and youll have to add application commands to your bot perms
oh ok then
and is it for a plublic bot?
nope private
because global slash commands take 1day iirc to register in all guilds if its private use the test_guilds kwarg and add the guild id or guilds
!d disnake.ext.commands.Bot
class disnake.ext.commands.Bot(command_prefix=None, help_command=<default-help-command>, description=None, **options)```
Represents a discord bot.
This class is a subclass of [`disnake.Client`](https://docs.disnake.dev/en/latest/api.html#disnake.Client "disnake.Client") and as a result anything that you can do with a [`disnake.Client`](https://docs.disnake.dev/en/latest/api.html#disnake.Client "disnake.Client") you can do with this bot.
This class also subclasses [`GroupMixin`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.GroupMixin "disnake.ext.commands.GroupMixin") to provide the functionality to manage commands.
should i do pip install disnake
yes
restart your vsc
ok nice
if you need to rewrite your bot just use find and replace in your vsc
find and replace?
yes in your vsc
wdym rewrite
like change all the keywords discord to disnake
wait i have to do that
to not do it manually just use find and replace which is in the edit tab in vsc
yes
oh so do i even have to do that with commands that do not use disnake
so bad 1 day lmao
¯_(ツ)_/¯
@slate swan do i have to change it to disnake in this command
which doesnt use disnake
no ofc not
ok wait
you will need to rewrite it for some parts though
like?
if the slash command will be in the same file or bot as that command yes
just change discord to disnake and your done
i gave an example
find and replace
how
dont forget to turn on notifications
🧍♂️
thats me
today imma switch to disnake too ig, i hate rewritting over 10k lines of code
use find and replace smh😠
I still need assistance with this. All methods given to me didn't work
yeah but i don't have the message intent, so i will need to switch to full slash commands + buttons, better rewrite it from the ground than replacing stuff here and there, but ofc, mostly it will be kinda copy paste but in a new fashion kek
pretty easy
all my bots are unverified so idrc about slash commands
im just doing it for the ephermal messages lol
have you read my msgs?
yes
ive answered you already
so can i just do it
@green bluff
@hard trail
i just wanted to paste the link to the docs damn
i hate when i get ignored
hehe
can i send ephermal messages just like this
no
or do i have to do like interaction.response
slash commands dont have context
they have interactions
READ THE GITHUB EXAMPLE I GAVE

SORRT

which ONE THERE ARE like 5 different files
read the file name
too much spoonfeeding already 
i do not know what converters injecting n stuff means BRUH I HAVE NO CLUE WHATS HAPPENING

if i start a spoonfeeding company i would be rich by now
ive answered all of your questions
good idea, damn
gonna become rich with your idea thank you
give me 80percent of the company or else i will sue you
bruh
here a basic command
@bot.slash_command()
async def greet(interaction: disnake.CommandInteraction):
await interaction.send("hello", ephemeral=True)
cant spoonfeed you more
i agree
ok finally some doc to read
i gaved you examples 
yea that basic command was a good exampl

but the dcument u gave me with words written everywhere

@hoary cargo one was good aswell

i mean its just one page to follow
simple and on point ez
i only give the best examples
i don't agree 

what's the point in giving an example if the person who needs it don't understand nothing from it 
thats like learning how to drive i cant show you examples if you understand nothing about it
yeah i think so
since its a slash command
ok nice


then you do basic stuff until you are capable to understand something
thats the point
omg thats so cool now i could mute people without doing !mute and no-one would even know
cool
they will know though
if you really want to mute without no one knowing about, just use the timeout thing
or use a private channel😱
fair
wait to use buttons do i need to download discord.ui or something
no
!d disnake.ui.View
class disnake.ui.View(*, timeout=180.0)```
Represents a UI view.
This object must be inherited to create a UI within Discord.
New in version 2.0.
you just need to subclass View
with no one knowing not even my friends who r owners of the server with admin perms
then just do it yourself 
cooler to type it
lol

thats just creepy🚶
no its not
yes it is🏃
maybe history
like timeouts and bans and others
just use audit log
no
yes
🧠
bruh
¯_(ツ)_/¯
inter in disnake is basicaly ctx in dpy 
wdym no, they act as context
interaction is the interaction of the command and ctx is the context of the command
wdym why, why it should be bad
wdym by until now
because basically it's a new library apart from dpy, meaning it still has some particularities even if it's a fork, since i will code mainly slash, buttons and stuff, it's new thing to learn
not really new as its a fork of dpy
only new things are buttons, slash commands, dropdowns and timeout and more which arent that hard to learn
maybe buttons can be difficult and dropdowns the others are easy
get channel ?
nope
!d disnake.ext.commands.Bot.getch_user
await getch_user(user_id, *, strict=False)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Tries to get the user from the cache. If fails, it tries to fetch the user from the API.
what does getch do?
Tries to get the obj from the cache. If fails, it tries to fetch the obj from the API
let's say someone does a command with a file attached to it, is there a way for me to potentially download that?
or view the contents of it
(file as in like a txt or an exe)
!d discord.Message.attachments
A list of attachments given to a message.
!d discord.ext.commands.Context.message
The message that triggered the command being executed.
Hey @slate swan!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
hey(
use the pasting service or the format option
My code is 11K characters ...
any error?
wait
its just a syntax error?
maybe (, but I don't understand where to fix it (
whats your version of dpy?
python?
discord.py version
Coding on the phone damn

what?..(
i think it was in 2.0 which is avater.url not sure
something i could never do
Same tbh
I don't remember which version

The funny thing is that I'm Russian👍
you have to import discord
thats fine
It was obvious
your about me
yes, imported the library
okay now do it
what?
alright
discord.py can you directly import by name?
yes
import discord.py
from discord.ext import commands

say a user has 2 mutual guilds with a bot, but is not in the guild the command is ran in. if i were to do (prefix)userinfo (user id of user not in this guild but shares mutuals with the bot), how can i have the bot get the user information from any of the mutual guilds (preferably one they are boosting, if any)? ive already constructed a way to tell if a user is a member or user, not exactly sure how id put that to work however in this instance

hello
Or just discord
so ive created an on_message command but my other commands arent running

get the guild
What should I do in a situation? (
the mutual guild?
show me the command
yes the one your trying to get the info from
You shouldn't have commands in on_message
so ive created an on_message command but my other commands arent running
why
can I send the code in a file to you in private messages? (
no just the command function
lets say the users in 2 mutual guilds and is boosting one of them, how can i check for the one theyre boosting and ignore all others? and if they arent boosting any, then to ignore that check
more exactly what "command" do you have
get the one theyre boosting from
would i use a for loop?
just get the guild
@hoary cargo on message delete word basically banned words
!d discord.ext.commands.Bot.get_guild
get_guild(id, /)```
Returns a guild with the given ID.
check for the words with on_message
?
@slate swan pls accept invite friends(
sorry i mostly dont accept friend requests :((
check the msg content with the on_message event
i'm send my code( as a file, I just don't think I can handle ((I ask you for help (
and what r you trying to acheive by doing this

send me the function only
❤️
okay
this chat so confusing

🚶
@slate swan
@client.command()
async def reg(ctx, id:int = None):
if id is None or id < 1000000000 or id > 999999999:
embed = discord.Embed(title='Ошибка при регистрации!', color=0xfffafa, description=f'Причина: Используйте команду в формате {prefix}reg [ID].\nP.S. ID должен состоять из 8 символов.')
embed.set_footer(text=f'Запросил {ctx.author}.', icon_url=ctx.author.avatar_url)
await ctx.send(embed=embed)
try:
await reg.reset_cooldown(ctx)
except:
pass
elif c.execute(f"SELECT id FROM faceit WHERE id = {ctx.author.id}").fetchone() is None and c.execute(f"SELECT idd FROM faceit WHERE idd = {id}").fetchone() is None:
c.execute(f"INSERT INTO faceit VALUES ({ctx.author.id}, {id}, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0)")
conn.commit()
guild = client.get_guild()
tolvl = guild.get_role(930244338481520640)
try:
await ctx.author.add_roles(tolvl)
except:
pass
embed = discord.Embed(title='Вы успешно зарегистрировались!', color = 0xfffafa, description=f'Ваш ID в игре Standoff 2 - {id}.')
embed.set_footer(text=f'Запросил {ctx.author}.', icon_url=ctx.author.avatar_url)
await ctx.send(embed = embed)
elif c.execute(f"SELECT id FROM faceit WHERE id = {ctx.author.id}").fetchone() != None:
embed = discord.Embed(title='Ошибка при регистрации!', color=0xfffafa, description=f'Причина: Вы уже зарегистрированы под ID - {c.execute(f"SELECT idd FROM faceit WHERE id = {ctx.author.id}").fetchone()[0]}'
embed.set_footer(text=f'Запросил {ctx.author}.', icon_url=ctx.author.avatar_url)
await ctx.send(embed=embed)
try:
await reg.reset_cooldown(ctx)
except:
pass
elif c.execute(f"SELECT idd FROM faceit5 WHERE idd = {id}").fetchone() != None:
embed = discord.Embed(title='Ошибка при регистрации!', color=0xfffafa, description=f'Причина: На данный ID уже зарегистрирован пользователь {client.get_user(c.execute(f"SELECT id FROM faceit WHERE idd = {id}").fetchone()[0])}.\nЕсли этот ID принадлежит вам, то сообщите в администрацию.')
embed.set_footer(text=f'Запросил {ctx.author}.', icon_url=ctx.author.avatar_url)
await ctx.send(embed=embed)
try:
await reg.reset_cooldown(ctx)
except:
pass
:incoming_envelope: :ok_hand: applied mute to @green bluff until <t:1641863245:f> (9 minutes and 59 seconds) (reason: discord_emojis rule: sent 42 emojis in 10s).

!unmute 735757517765869589
:incoming_envelope: :ok_hand: pardoned infraction mute for @green bluff.
ok sorry never knew that was rule
hey mina long time no see
Damn
ah i see

@slate swan why do u always use 
idk
@slate swan well, what is there (?
Just make a list with the banned words
Like x = []
Then check if the message content contains the stuff you put in x if it does then delete the message, it shouldn't block the rest of the bot though
may i see how it looks in your phone?
and make it so it wont delete if the author is the bot
screenshot?
yeah
But why the bot would say a banned word though
¯_(ツ)_/¯
echo command
this is too long a function for my screen, I can send a file (
just send me where the error appears
Check line 183 I guess 
maybe theres something wrong above it
can I send the code in a file?
no like i want to see what the editor shows or underlines
does your editor underline syntax errors?
no. Unfortunately
ic
let me see it again
Message returns the message object
does it make sense
nope
@slate swan
but how do i send message
then why do it?
You need a special attribute to see the content (wink wink) of a message
naughty dog
sus
🚶
hi
Nah im fine
@slate swan check please (
what do i do now
message.content
will rn
Change your nickname to something pingable please
?...
how do i send the message
It is pingable though
see
Check the rules
LMAO I THOUGHT OKIMII SENT IT
LMFAO
what type of name is that
my name is pingable right?
well im not sure as why i see nothing wrong
they can still ban you with your id lol
duck
message.channel.send
technically, it isnt invisible
It has blank characters
its a bunch of question marks
<@&831776746206265384> ^nick name
Theres no point arguing about this
wait wait
!ot
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
it not invisible
keep it ot please
Its question marks in boxes
Probably unnecessary
!superstar 742545653028225035
:incoming_envelope: :ok_hand: applied superstar to @lime gazelle until <t:1641867237:f> (59 minutes and 59 seconds).
Your previous nickname, , was so bad that we have decided to change it. Your new nickname will be Adele.
You will be unable to change your nickname until <t:1641867237:f>. If you're confused by this, please read our official nickname policy.
please change it to something visible
iit is visible bruh
yeah but i dont want you guys fighting
its a bunch of question marks
Reasonable

pls dont say i have to change my pfp now
it renders differently on different platforms, we can continue in a @novel apex if you have further questions
strange..
yeah
lovely emoji
@slate swan Can you send the code?
!d discord.abc.Messageable.send
await send(content=None, *, tts=None, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, view=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message to the destination with the content given.
The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.
To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.
To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
Bro im not going to make it invisible, according to you
its weird because i see nothing wrong with it and his dpy version uses those attrs which i think 2.0 is different
So, the new timeout feature, what does it do?
it just mutes people which makes them not be able to interact with the guild
It's a kindof , inbuilt mute system
!d disnake.Member.timeout
await timeout(*, duration=..., until=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Times out the member from the guild; until then, the member will not be able to interact with the guild.
Exactly one of `duration` or `until` must be provided. To remove a timeout, set one of the parameters to `None`.
You must have the [`Permissions.moderate_members`](https://docs.disnake.dev/en/latest/api.html#disnake.Permissions.moderate_members "disnake.Permissions.moderate_members") permission to do this.
New in version 2.3.
Thank you
disnake has it already
Disnake on top
How would I allow the user to input minutes and hours instead of seconds in a timeout command?
you can do
def function(time: float) -> float:
return print(time * 60.0)
1 will do 1min
@client.command()
async def reg(ctx, id:int = None):
if id is None or id < 1000000000 or id > 999999999:
embed = discord.Embed(title='Ошибка при регистрации!', color=0xfffafa, description=f'Причина: Используйте команду в формате {prefix}reg [ID].\nP.S. ID должен состоять из 8 символов.')
embed.set_footer(text=f'Запросил {ctx.author}.', icon_url=ctx.author.avatar_url)
await ctx.send(embed=embed)
try:
await reg.reset_cooldown(ctx)
except:
pass
elif c.execute(f"SELECT id FROM faceit WHERE id = {ctx.author.id}").fetchone() is None and c.execute(f"SELECT idd FROM faceit WHERE idd = {id}").fetchone() is None:
c.execute(f"INSERT INTO faceit VALUES ({ctx.author.id}, {id}, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0)")
conn.commit()
guild = client.get_guild()
tolvl = guild.get_role(930244338481520640)
try:
await ctx.author.add_roles(tolvl)
except:
pass
embed = discord.Embed(title='Вы успешно зарегистрировались!', color = 0xfffafa, description=f'Ваш ID в игре Standoff 2 - {id}.')
embed.set_footer(text=f'Запросил {ctx.author}.', icon_url=ctx.author.avatar_url)
await ctx.send(embed = embed)
elif c.execute(f"SELECT id FROM faceit WHERE id = {ctx.author.id}").fetchone() != None:
embed = discord.Embed(title='Ошибка при регистрации!', color=0xfffafa, description=f'Причина: Вы уже зарегистрированы под ID - {c.execute(f"SELECT idd FROM faceit WHERE id = {ctx.author.id}").fetchone()[0]}'
embed.set_footer(text=f'Запросил {ctx.author}.', icon_url=ctx.author.avatar_url)
await ctx.send(embed=embed)
try:
await reg.reset_cooldown(ctx)
except:
pass
elif c.execute(f"SELECT idd FROM faceit5 WHERE idd = {id}").fetchone() != None:
embed = discord.Embed(title='Ошибка при регистрации!', color=0xfffafa, description=f'Причина: На данный ID уже зарегистрирован пользователь {client.get_user(c.execute(f"SELECT id FROM faceit WHERE idd = {id}").fetchone()[0])}.\nЕсли этот ID принадлежит вам, то сообщите в администрацию.')
embed.set_footer(text=f'Запросил {ctx.author}.', icon_url=ctx.author.avatar_url)
await ctx.send(embed=embed)
try:
await reg.reset_cooldown(ctx)
except:
pass
?
and please dont say that :))
Or just write directly the hours in seconds 
🧠
isn't it message.channel.send() ?
yes
How would I know if they were inputting seconds, minutes, hours, days or weeks?
nice(
check the arg if it has a keyword like d w m h
at the end do py await client.process_commands(message)
do you have many on_message events
And if the user has inputted multiple formats i.e 2 days 6 hours
btw that filtering system could be better
use a kwarg and split the kwarg
how
🚶
On a CV splitter (not an estimator), this method accepts parameters (X, y, groups), where all may be optional, and returns an iterator over (train_idx, test_idx) pairs. Each of {train,test}_idx is a 1d integer array, with values from 0 from X.shape[0] - 1 of any length, such that no values appear in both some train_idx and its corresponding test_idx.
no
!d str.split
str.split(sep=None, maxsplit=- 1)```
Return a list of the words in the string, using *sep* as the delimiter string. If *maxsplit* is given, at most *maxsplit* splits are done (thus, the list will have at most `maxsplit+1` elements). If *maxsplit* is not specified or `-1`, then there is no limit on the number of splits (all possible splits are made).
If *sep* is given, consecutive delimiters are not grouped together and are deemed to delimit empty strings (for example, `'1,,2'.split(',')` returns `['1', '', '2']`). The *sep* argument may consist of multiple characters (for example, `'1<>2<>3'.split('<>')` returns `['1', '2', '3']`). Splitting an empty string with a specified separator returns `['']`.
For example:
that
how
Anyway I know how to use split
!d str.split
listen decorator is better
what's the difference between listen and event
listeners never worked for me
And if the user did 2days6h?
Listeners are inside cogs 
I like code that isn't buggy
if its a on_message event it wont overwrite itself
alr
how could the filter system be better
regex
Yes
he ment listeners by the plural version of listen
Regular expressions
ok can u give me like a repo on that or something
You will have to do research yourself
ok
There are tons of guides everywhere
i didn't make a repos for the filtering system itself, but i did make a bot that has a really good filtering system
Maybe I should just not make moderation commands
oh nice
should i give it to you?
but i want to try make my own lol thats the only reason i am asking help
gimme a sec
Don't
no spoonfeeding
there r tons of bots like censor bot and stuff but i want to make mine custom
Spoonfeeding 


Conversion is hard

I'm just not going to do moderation commands
can u atleast give me an article that makes sense
Not sure if its good
i mean he could do something like
for i in banned_words :
if i in message.content.lower().split():
await message.delete()
anyway, you can also mute the member after this, or adding ignored channels, users, much more shit
essentially, create a big set of swears, create a copy of the message by py test = message.contentand run it through filters, like any(i in test for in set_with_swears)
Regex is superior
yes
yes?
you have a whole module for regular expressions use it
i also ran mine through filters that changed words and characters incase users did smth like f*&k
me not knowing regex: 🏃
Requires wayyyyy too much hard coding
i did it
@slate swan my full code to github
i hate regex but it's useful
noice
I can also hard code a help command, whats your point?
you mean subclass it🧍♂️
No 🏃
get over here🏃
Interesting
this repository private
is it a private repo?
LMAO called it
@final iron have you subclassed the bot class
Not yet
Its too hard
you should
I am avoiding it
its pretty easy
I'm making trivia commands
isnt this beautiful?
import disnake
from disnake.ext import commands
from disnake import Intents
import os
import datetime
from riashidden import TOKEN
class Rias(commands.Bot):
def __init__(self) -> None:
super().__init__(
command_prefix=commands.when_mentioned,
intents=disnake.Intents.all(),
help_command=None,
status=disnake.Status.online,
activity=disnake.Game(name="!help")
)
def setup(self) -> None:
for filename in os.listdir("C:/Users/okimii/Downloads/rias/cogs")
if filename.endswith("py"):
self.load_extension(f"cogs.{filename[:-3]}")
def run(self) -> None:
self.setup()
super().run(TOKEN, reconnect=True)
async def on_ready(self) -> None:
print("Rias is online")
async def on_command_error(self, ctx, error):
embed = disnake.Embed(
title="Command Error",
description=f"``{error}``",
color=0xffffff,
timestamp=datetime.datetime.utcnow()
)
await ctx.send(emebd=embed)
No
I have that and I stole it from caeden
smh 
🏃
🏃
Can you like explain
sure
Can I literally just put the events in there without the decorator?
yes
How would I put a check
but no
For events?
be smort and use a cog smh🧠
So just shove all my events in to a cog?
sure
Yes sir!
your token

i can see it
@client.event
async def on_ready():
print(f"[SYSTEM] Start working {time.asctime()} |\n[SYSTEM] Bot online! |\n[SYSTEM] Name - {client.user} |\n[SYSTEM] ID - {client.user.id} |\n[SYSTEM] Bot working! |\n-------------------------------------------------")
while True:
await client.change_presence(status = discord.Status.dnd, activity = discord.Game('Elite Ranked'))
await asyncio.sleep(15)
await client.change_presence(status=discord.Status.dnd, activity=discord.Activity(name='за своим создателем Vinki', type=discord.ActivityType.watching))
await asyncio.sleep(15)
qiwicheck.start()
what is this🧍♂️
you want to get limited from discords api or something🧍♂️
on_ready
so all the commands work fine
except this one
it doesnt send the embed
it just clears the messages
thats what i does
It should be working
Remove the delete_after kwarg
Still haven't explained yet
!args-kwargs
*args and **kwargs
These special parameters allow functions to take arbitrary amounts of positional and keyword arguments. The names args and kwargs are purely convention, and could be named any other valid variable name. The special functionality comes from the single and double asterisks (*). If both are used in a function signature, *args must appear before **kwargs.
Single asterisk
*args will ingest an arbitrary amount of positional arguments, and store it in a tuple. If there are parameters after *args in the parameter list with no default value, they will become required keyword arguments by default.
Double asterisk
**kwargs will ingest an arbitrary amount of keyword arguments, and store it in a dictionary. There can be no additional parameters after **kwargs in the parameter list.
Use cases
• Decorators (see !tags decorators)
• Inheritance (overriding methods)
• Future proofing (in the case of the first two bullet points, if the parameters change, your code won't break)
• Flexibility (writing functions that behave like dict() or print())
See !tags positional-keyword for information about positional and keyword arguments
what do you need explaning on jeez
All of it
Just subclassing
🏃
🧍♂️
read now🚶
how is a global check done im not sure
why cant python be simple
@slate swan dont give answer
okie
We went over this before
!d discord.ext.commands.Bot.add_check
add_check(func, *, call_once=False)```
Adds a global check to the bot.
This is the non-decorator interface to [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.check "discord.ext.commands.Bot.check") and [`check_once()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.check_once "discord.ext.commands.Bot.check_once").
wdym
I was talking about the other guy not my question 🏃
then it would be self.bot
okie
message is a object. To get it's content use message.content
So do I do this in the init statement?
oh ok
Oh , you want a check for a single cog?
no?
just use the decorator
@bot.check()
tough cookies
Where would I add it
super().__init__()
in the init you add all the kwargs you would use in the constructor
make sense?
No
🚪 🚶
Wait so do I do the add_check in my main file?
inside the __init__ just self.add_check(your function)
add_check method takes an function as argument
subclassing is so lovely and easy
This is hard
your intentions is to add a check on all bot commands right?
Correct
Yea so the add_check thing will work
So in my cog's init statement add self.add_check(my_function())?
init isnt a statement
its a dunder/magic method
...
Why in the cog?
Because I don't know what I'm doing
good point
you'll be doing it inside the bot's class
Or , if you really want to do it inside the cog , I'm sure you would have passed bot to your cog's __init__ , just do bot.add_check from there
no
i think hes trying to subclass Bot
subclass this subclass that just let the dude learn on its own
Bruv, I'm just trying to add a check
ok sorry🚶
Because before, I just did the check in my bots init statement
🚪🚶
I was told nesting functions is bad practice or smth
Good choice
im entering your house lmfao
you will need to ask what da dog doin soon before he eats your ass
what dog?
i see no dog in your house
🧍♂️
Behind you 
theirs nothing their

Pep8 is a lifestyle
now solve the peps
lol
Its literally my command description
No
How does wait_for work?
Does it just wait until it finds a message satisfying the check?
hehe
!d discord.ext.commands.Bot.wait_for
wait_for(event, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits for a WebSocket event to be dispatched.
This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.
The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.
In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.
This function returns the **first event that meets the requirements**...
no
waits for a event
use the check kwarg
then wdym
im trying to make a banned words command and if i say one word but if i say something then the banned word or the banned word thens something it doesnt work
@client.event
async def on_message(message):
if message.content in banned_words:
embed = disnake.Embed(title="Inappropriate language", description=f"{message.author.name} said {message.content} in {message.channel.name}")
await message.author.send(embed=embed)
channel = client.get_channel(928380965787676804)
await channel.send(embed=embed)
await message.delete()
await client.process_commands(message)
And I want my bot to search through what people say for the correct answer
async def on_message(message):
if message.content in banned_words:
embed = disnake.Embed(title="Inappropriate language", description=f"{message.author.name} said **{message.content}** in ```{message.channel.name}```")
await message.author.send(embed=embed)
channel = client.get_channel(928380965787676804)
await channel.send(embed=embed)
await message.delete()
await client.process_commands(message)```
like this
welp im going to play some games later
🚶
@client.event
async def on_message(message):
if message.content in banned_words:
embed = disnake.Embed(title="Inappropriate language", description=f"{message.author.name} said **{message.content}** in {message.channel.name}")
await message.author.send(embed=embed)
channel = client.get_channel(928380965787676804)
await channel.send(embed=embed)
await message.delete()
await client.process_commands(message)
```
Damn
Everyone wants to do banned word stuff
Use regex
by adding a letter
🏃
ok
seems about right
Who would do such a thing?
not me ofc🏃
🏃
go learn regex
get in 🚙
go learn to subclass the Bot class🚶
🚙 💨
what makes you think I don't know already
everything
🚔
🧑🦯

Genshin impact


bye guys
goodbye
does anyone know how to make it so that the banned words will be triggered no matter if its upper case or lower case
!d str.lower()
No documentation found for the requested symbol.
str.lower()```
Return a copy of the string with all the cased characters [4](https://docs.python.org/3/library/stdtypes.html#id15) converted to lowercase.
The lowercasing algorithm used is described in section 3.13 of the Unicode Standard.
Finally
so where do i put in in my code
@client.event
async def on_message(message):
if any(word in banned_words for word in message.content.split()):
embed = disnake.Embed(title="Inappropriate language", description=f"{message.author.name} said {message.content} in {message.channel.name}")
await message.author.send(embed=embed)
channel = client.get_channel(928380965787676804)
await channel.send(embed=embed)
await message.delete()
await client.process_commands(message)
You would make the message.content lowercase
how
Have you learnt python yet?
a bit
mmm
Can someone help with something real quick
You would create a variable
please
thx
Ask your question
ok well am trying to make a discord bot dashboard for my server and am having trouble with it
cute dog lol
Not mine
Can i dm you?
oh
No
ok
whats the issue
send it here
I have a server as in ip address where it will take me to login to discord
but unfortnately after i login
this is what i recieve
Does that make sense?
well no they cant
pretty sure its a local thing
Not sure but I would assume role is None
!d disnake.Member.add_roles
await add_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Gives the member a number of [`Role`](https://docs.disnake.dev/en/latest/api.html#disnake.Role "disnake.Role")s.
You must have the [`manage_roles`](https://docs.disnake.dev/en/latest/api.html#disnake.Permissions.manage_roles "disnake.Permissions.manage_roles") permission to use this, and the added [`Role`](https://docs.disnake.dev/en/latest/api.html#disnake.Role "disnake.Role")s must appear lower in the list of roles than the highest role of the member.
ill try
How would i write this:
this:
i can print country
There you go 
i can try printing country1
Try
if not (message.author has higher role than 'staff'):
also i know i didnt need to use a f string for that
@final iron it prints None as you suggested
why is that, though?
i set the country value equal to something
if not (message.author has higher role than 'staff'):
!d discord.utils.get
discord.utils.get(iterable, **attrs)```
A helper that returns the first element in the iterable that meets all the traits passed in `attrs`. This is an alternative for [`find()`](https://discordpy.readthedocs.io/en/master/api.html#discord.utils.find "discord.utils.find").
When multiple attributes are specified, they are checked using logical AND, not logical OR. Meaning they have to meet every attribute passed in and not one of them.
To have a nested attribute search (i.e. search by `x.y`) then pass in `x__y` as the keyword argument.
If nothing is found that matches the attributes passed, then `None` is returned.
Examples
Basic usage...
It should work
thats odd, because using slash commands, only values that match the attributes can be passed
But I never use utils.get so idk
what do you use?
I have no situations like that
Where I need to fetch a role object by name
Only thing I could think of is that country isnt a role
Can you verify there are no spelling mistakes?
And iirc its case sensitive
yeah, its typed correctly
hmm
It should work
Maybe it has something to do with slash commands
I don't use them either
o
how can i delete my message? Like when i run !ping, how can i make it so the bot deletes that message?
You have 2 options
Use the delete_after kwarg in the send() function
no like, it deletes the message that has !ping in it
Oh
Then its ctx.message.delete()
kk
Spoonfeeding at its finest
Fetch the channel
!d discord.ext.commands.Bot.fetch_channel
await fetch_channel(channel_id, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Retrieves a [`abc.GuildChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.GuildChannel "discord.abc.GuildChannel"), [`abc.PrivateChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.PrivateChannel "discord.abc.PrivateChannel"), or [`Thread`](https://discordpy.readthedocs.io/en/master/api.html#discord.Thread "discord.Thread") with the specified ID.
Note
This method is an API call. For general usage, consider [`get_channel()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.get_channel "discord.ext.commands.Bot.get_channel") instead.
New in version 1.2.
now it doesn't work
Hey @final iron
can you help me
My bot is online but the bot is unresponsive
yesterday everything worked
if not (message.author has higher role than 'staff'):
Or would I have to list every single role's ID above Staff?
Probably a dumb answer but...
!d discord.Member.roles
property roles: List[Role]```
A [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role") that the member belongs to. Note that the first element of this list is always the default [‘@everyone](mailto:'%40everyone)’ role.
These roles are sorted by their position in the role hierarchy.
Note: These roles are sorted by their position in the role hierarchy.
!d discord.Guild.roles
property roles: List[discord.role.Role]```
Returns a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of the guild’s roles in hierarchy order.
The first element of this list will be the lowest role in the hierarchy.
Note: Returns a list of the guild’s roles in hierarchy order.
Maybe you can do something with that
But its probably a bad idea
umm
What
property top_role: Role```
Returns the member’s highest role.
This is useful for figuring where a member stands in the role hierarchy chain.
You then would compare the roles position to the staffs role position
!d discord.Role.position
The position of the role. This number is usually positive. The bottom role has a position of 0.
Warning
Multiple roles can have the same position number. As a consequence of this, comparing via role position is prone to subtle bugs if checking for role hierarchy. The recommended and correct way to compare for roles in the hierarchy is using the comparison operators on the role objects themselves.
I knew it was a bad idea
Hello!
if not message.author.bot:
if (('help' in message.content.lower() or 'assist' in message.content.lower() or 'aid' in message.content.lower() or 'assistance' in message.content.lower()) and (message.channel.id == 892880535918096405 or message.channel.id == 892880558751879208 or message.channel.id == 892877273311641622 or message.channel == 899846459405533235 or message.channel.id == discord.ChannelType.private)):
How do i check if the message.channel is in DMS with the bot?
async def verify(ctx):
await ctx.message.delete() # deletes the message the author sent
if str(ctx.guild.id) in verify_roles:
verify_role = ctx.guild.get_role(verify_roles.get(str(guild.id)))
# check if the role is not in the author's current roles
if verify_role not in ctx.author.roles:
await ctx.author.add_roles(verify_role)
await ctx.send("You have been verified!")
else:
await ctx.send(f"You already have {verify_role.name}")```
I found this code online for a verification code im and I want to add, where am I supposed to put the ID or name of the role?
Can someone help?
The role ID as integer, not string.
....get_role("585529568383860737") # Won't work
....get_role(585529568383860737) # Will work
@client.command()
@commands.has_permissions(kick_members=True)
async def verify(self, ctx, member: discord.Member, *, reason=None):
guild = ctx.guild
TrialStaff = discord.utils.get(guild.roles, name="Trial Staff")
if not TrialStaff:
mutedRole = await guild.create_role(name="Trial Staff")
await ctx.send("New role created!")
for channel in guild.channels:
await channel.set_permissions(mutedRole, speak=False, send_messages=False, add_reactions=False, view_channel=True)
else:
await member.add_roles(mutedRole, reason=reason)
await ctx.send(f"Verified {member.mention} for reason : {reason}. Welcome to the Staff team!")
await member.send(f"**Congratulations! You are now a Trial Staff member in {guild.name}.**")
@verify.error
async def verify_error(self, ctx, error):
if isinstance(error, commands.MissingRequiredArgument):
await ctx.send('mention someone.')
elif isinstance(error, commands.BadArgument):
await ctx.send('member not found')
elif isinstance(error, commands.MissingPermissions):
await ctx.send('You do not have the required permissions!')
else:
raise error
@slate swan whats this error
Nice bear
lmao
Remove self from verify_error
Remove self from verify too
It works now ty
np
its ctx.message.content.lower() and it will always say its wrong
You're checking if Captcha is in a lowered string. It will never be true.
^
Either remove .lower() or check with captcha.
and why the member var no need for it
and no need for return
since nothing else will happen i suppose
does dpy v2 have app commands?
@unique tendon set the nick kwarg to None and use on msg so you can store ids in a list or a db and if the id is in the list remove it
dont think it does
also, why does my bot.get_emoji(id) not embed an emoji? it just shows :checmark: instead
what is the code?
what is ctx.content?
wont work
ctx doesn't have an attribute of content
and?
what are you even trying to do?
how's that even going to work
your doing this
user: !verify
bot: Type Captcha to get verified!
and it would be done should wait for a msg
🧍♂️
i love getting ignored
!d discord.ext.commands.Bot.wait_for
wait_for(event, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits for a WebSocket event to be dispatched.
This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.
The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.
In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.
This function returns the **first event that meets the requirements**...
anyways, anyone?
dont really know why that order
your checking the content when the user probably doesnt know what to do?
first make the command give instructions and then wait for captcha

bumping this again
Is there a way for a non-onwer to use jsk
dont think so
Not a single way?
🚶
You should have a random letter combination as captha
that aswell
How to make a cooldown
I guess you could start a timer on_message and store the username in a file
I don't understand
is it a command?
why would u like to do that?
you can have multiple owners tho....
a cooldown for a command
!d discord.ext.commands.cooldown
@discord.ext.commands.cooldown(rate, per, type=discord.ext.commands.BucketType.default)```
A decorator that adds a cooldown to a [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command")
A cooldown allows a command to only be used a specific amount of times in a specific time frame. These cooldowns can be based either on a per-guild, per-channel, per-user, per-role or global basis. Denoted by the third argument of `type` which must be of enum type [`BucketType`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.BucketType "discord.ext.commands.BucketType").
If a cooldown is triggered, then [`CommandOnCooldown`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CommandOnCooldown "discord.ext.commands.CommandOnCooldown") is triggered in [`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") and the local error handler.
A command can only have a single cooldown.
where do I type @discord.ext.commands.cooldown(rate, per, type=discord.ext.commands.BucketType.default)
You decorate the command with it
not exactly
@bot.command()
@commands.cooldown(1, 15, commands.BucketType.user)
async def cmd(...)```
For example
should change the buckettype
what does the 1, 15 do
To what
Rate per
just add type since its all preference
not preference but you get what i mean
so 5 second cooldown?
I don't think it's necessary since it's not keyword-only argument
no 15sec
no like a example yk
so 1, 60 is 1 minute cooldown
In my example it means "one usage per 15 seconds"
60*
Kk it works in both cases anyways
i ment like this
@commands.cooldown(1, 15, commands.BucketType.buckettype)
lmao
yes
so do i place it under @client event
Ah so you meant for example
yeah
You decorate commands not the events
OMG
?
https://vcokltfre.dev/ see how to make a proper command @slate swan
A tutorial on how to use discord.py to create your own Discord bot in Python, written to fix the flaws of many other popular tutorials.
and why are you doing it like that
I did a guy's tutorial
was outdated
really outdated
Maybe because there's weird quickstart in docs
Do the tutorial I suggested, the one you watched is probably wrong one
probably a yt tutorial
I'm making a game bot
crazy how it doesnt have the pass_context kwarg 
not a song bot
ok?
It doesn't matter, just check that tutorial, it is for every bot
You make commands like
@bot.command()
async def cmd(ctx):
...```
(for cogs it's a bit different)
Not put the content check into on_message
yeah and mostly dont name your bot constructor client
mine is, client.
the "Bot" is never used in my code
;-;
Then you don't have commnads.
not me🚶
You sure about that
Client doesn't support commands



