#discord-bots
1 messages · Page 826 of 1
Do i need to edit or make entire new code..
if you use hikari, yes
Anything for best!!!
xd
F
;-;
Is hikari a different lauguage??
hah, use disnake, has slash commands and interactions too so
if i include the if statement it isnt working
api wrapper for discord api
Ok.
yes.
Better than js??
huh?
I want the best cuz i dont want to change in future
Cuz hikari dont has same
As ash said
use disnake
.-.
PLEASE use #bot-commands for bot commands, thanku dear
ok the command doesn't work this was the code ```py
deletion_list = []
@bot.command()
async def deleteadd(ctx, user: disnake.User):
await deletion_list.append(user.id)
await ctx.send("Done.")
@bot.event
async def on_message(msg):
if msg.author in deletion_list:
await msg.delete()```
the on_message event is eating your commands, use @bot.listener() instead
See
Why ppl avoid pycord
my thing works but everytime some one reacts again its sends it again
umm
Both works fine
listen works
For me
No, he has to check if the number of reactions is greater than 1, or 2 if the bot adds the reaction
Huh?
well the command isn't getting registered
I need test guilds i guess
yes
wait why?
it isn't a slash command
pycord dev team bad
no so basically when the quote emoji is added the message shud be sent in that channelbut i dont want it to repeat everytime when another user added that same emoji
is there an event to detect when the bot joins a guild?
@gaunt ice
on_guild_join
nice
!d discord.on_guild_join
discord.on_guild_join(guild)```
Called when a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild") is either created by the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") or when the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") joins a guild.
This requires [`Intents.guilds`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.guilds "discord.Intents.guilds") to be enabled.
OHH TYSMM
that will don't work if the user will delete the reaction, make sure to check if an user has already addedd a reaction too
okk
whats your IDE
also whats the context where its not getting "updated"
is it,
a: your internet
b: your IDE
c: didnt save code
d: none of the above
d
ok
vs code
start?
I added a new command
in a cog or the main file
default help command?
yes
@timber crag
you need to process your commands with on_message
either use @bot.listen() or process the commands
processing is await ctx.process_commands(message) or am i wrong
!d discord.ext.commands.Bot.process_commands
await process_commands(message)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
This function processes the commands that have been registered to the bot and other groups. Without this coroutine, none of the commands will be triggered.
By default, this coroutine is called inside the [`on_message()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_message "discord.on_message") event. If you choose to override the [`on_message()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_message "discord.on_message") event, then you should invoke this coroutine as well.
This is built using other low level tools, and is equivalent to a call to [`get_context()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.get_context "discord.ext.commands.Bot.get_context") followed by a call to [`invoke()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.invoke "discord.ext.commands.Bot.invoke").
This also checks if the message’s author is a bot and doesn’t call [`get_context()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.get_context "discord.ext.commands.Bot.get_context") or [`invoke()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.invoke "discord.ext.commands.Bot.invoke") if so.
no ctx
got that confused lmao
I'll use @bot.listen()
happens
processing is easier
just put it at the bottom of the on_message
oh
processing is easier but listen is recommended with some exceptions
@bot.event
async def on_message(message):
do stuff here
await bot.process_commands(message)
tbh bot.listen is easy aswell
just change .event to .listen()
!d discord.ext.commands.Bot.listen
@listen(name=None)```
A decorator that registers another function as an external event listener. Basically this allows you to listen to multiple events from different places e.g. such as [`on_ready()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_ready "discord.on_ready")
The functions being listened to must be a [coroutine](https://docs.python.org/3/library/asyncio-task.html#coroutine "(in Python v3.9)").
Example...
.event is easier to manage
how so
ctrl + f
u can have multiple .listen()'s aswell
and you can also use it for errors
idk if listen can be used for error handling
i dont use it
yeah just use on_command_error for that
bot.event is useful in some cases for on_message, as I said
error now
TypeError: object NoneType can't be used in 'await' expression```
in this line py await deletion_list.append(user.id)
remove the await
did
let me wait for output
is there a on_guild_leave event?
on_guild_remove
!d disnake.on_guild_remove
disnake.on_guild_remove(guild)```
Called when a [`Guild`](https://docs.disnake.dev/en/latest/api.html#disnake.Guild "disnake.Guild") is removed from the [`Client`](https://docs.disnake.dev/en/latest/api.html#disnake.Client "disnake.Client").
This happens through, but not limited to, these circumstances...
same as with members with
on_member_join
and
on_member_remove
Give disnake docs
now the bot is not deleting the messages
if msg.author.id
you get the user id, and you are looking for the name
oh
now, you are looking for the matching id
Im using cogs can it be used in disnake
ofc
Okk
disnake is a fork
How can i make it so it @s them so its blue?
when i did message.mentios it didnt like make it look like this @balmy ivy
thx
thats just how vsc looks
!d disnake.Member.mention
property mention: str```
Returns a string that allows you to mention the member.
Buffalo bills
bro..?
@balmy ivy
what are you trying to do
they wanna ping the user
member.mention
i have no idea why he said "so its blue" it threw me off track
yes I already told them that
message.mentions[0].mention
Disnake is same as discord.py
ty
np
?
also for this what would i do for it to @ the bills team?
you can follow syntax like <@id>
or just obj.mention
is it a role?
yea
property mention: str```
Returns a string that allows you to mention a role.
yea so get the role and mention it
if u have the role object, just .mention it
but then ofc, you can f'You have joined the <@&id> team'
but yes .mention is better
not ideal
before i knew message.jump_url existed - f'https://discord.com/channels/{message.guild.id}/{message.channel.id}/{message.id}'
lol
wait so it would be + mention],
100% copied docs of discord. Py
what’s the member variable without the discriminator?
like
“ernesto” not “ernesto#1234”
.name
ty
Lol
property name```
Equivalent to [`User.name`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.name "discord.User.name")
of course lmao, its a fork what else do u expect. Everything is same + additions
Just rename all discord to disnake
property name```
Equivalent to [`User.name`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.name "discord.User.name")
property display_name: str```
Returns the user’s display name.
For regular users this is just their username, but if they have a guild specific nickname then that is returned instead.
message.author.mention
property me: discord.member.Member```
Similar to [`Client.user`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client.user "discord.Client.user") except an instance of [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member"). This is essentially used to get the member version of yourself.
i did this and it worked
ohh the role
yeah its a role
alr
nick name in the guild, if its none then returns the user name
Hmm
just use member.name tbh
was telling the difference since they asked
Infernum where do i add disnake class in or outside cogs class
what?
Class cogs(stuff)
Class disnake
Disnake is not a class, it's a library
how to count the no.of reactions of one emoji
reaction = get(message.reactions, emoji=emoji.name)
if reaction and reaction.count > numberhere:
???
sr for caps
!d discord.Reaction.users
async for ... in users(*, limit=None, after=None)```
Returns an [`AsyncIterator`](https://discordpy.readthedocs.io/en/master/api.html#discord.AsyncIterator "discord.AsyncIterator") representing the users that have reacted to the message.
The `after` parameter must represent a member and meet the [`abc.Snowflake`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Snowflake "discord.abc.Snowflake") abc.
Examples
Usage
```py
# I do not actually recommend doing this.
async for user in reaction.users():
await channel.send(f'{user} has reacted with {reaction.emoji}!')
```...
And use len on it
so like
ahhh how do i explain
the same emoji
but the count of it
Paint
yes, discord.Reaction.users will return the users who reacted with an emoji (yes, same emoji)
How to create a cooldown for specific user? @cooldown will work?
not the users i want the count
Yea but use the user buckettype
@commands.cooldown(1,6,commands.BucketType.user)
if you know the users who reacted on the reaction, you can count the users and that would be the number of count?
ohh okk then how
how to pass it in the parameters?
@cooldown(use,per,BucketType.user)
when i do this it says undefined name 'member'
Show code
alr
I was wondering how does dank memer actually make progress bars with the emojis?
users = await reaction.users().flatten()
This will give the list of users
Use len on it
ohh okk
What does flatten() do?
Yesdank meme has great ui
no like quite astonished how they have coded the emoji progress bar
As the name suggests, serialise the list in the same order
Ok
like I was thinking how they have coded the fill code
what do they multiply with and how do they change the emoji
to fit the percentage
@slate swan
hmhm okk
Lightbulb
Do you even know what it is?
No
ooo
oh u have used it before?
Use disnake 

!d discord.RawReactionActionEvent
class discord.RawReactionActionEvent```
Represents the payload for a [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") or [`on_raw_reaction_remove()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_remove "discord.on_raw_reaction_remove") event.
Yeah
hikari&rin lover
@slate swan
whats ur opinion on it
Epi
I don't have one
!python
ah
python = snake and python = discord server and discord server = snake
so disnake 0-0
Python = snake so bot = snake+discord = disnake
dude
¯\_(ツ)_/¯
Me👋
@slate swan hbday ^_^
I'm doing that from even before dpy was closed :p
I understand ur status
welp
!ot they didnt wish me too, im fine
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
There are bots that have cooldowns.
How are they actually doing those?
I'm trying to find another way than "simply" using asyncio.sleep(), since it also has to work after a restart.
print("my bday was 10 days ago ")
Toatally not ot
Maybw they store data in a DB
From where do u even conclude these types of things lmao
Oh hi there NIR
Than, everytime a certain command is invoked it does the checking it needs
Hi Hunter!
👋
You are aware that’s a built in feature of discordpy? You need to use the cooldown decorator
isinstance(Python, Snake) 👍🏿
Pretty aure he wants for it to work even if the bot gets restarted
Oh I see
oh why-
Yeah you’ll want to store it in a database
Robinhood
and change the database cooldowns every minute?
isnt that too much of a load?
👀 changing cooldowns?
But I don't want the cooldown to be on the command.
Yes
Hmm, preferred would be to use threading and run it in a different thread tbh
But you wouldn't have to, if you don't want to send out a notification
Maybe use hours
how to get bot to check for "hi" in a specific channel by channel name?
you can do it by id
how
on_message
?
if the message has a word in it the bot will respond
in a specific channel.
if message.channel = channel id here:
THANK YO
@stone moon or you can search the channel for the word using await channel.history(limit=1000).flatten()
then
but i wanna get it by channel name using like discord.utils.get so its versatile but i forgot syntax
channel = bot.get_channel(channelID)
messages = await channel.history(limit=123).flatten()
if "word" in messages:
do stuff
How do I hid or customize this help message
bot = commands.Bot(command_prefix="!", help_command=None)
then you can make your own
!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...
bot.get_channel(ID)
Is there a way to customize this one into an embed ?
i have an automated help command on my github if you're interested, but you can just use a command with an embed for it.
just make a command with the name help as usual
Okay
Its the same duh
I know
its been deprecated since anything after 1.8.x
Wha...
I just want to thank you i learnd alot from your code
after 1.8
No?
with discord.py (not forks)
Who tf says that
Wait, what?
Lmao Ash God 🙏
Who even comments their code nowadays lol
no idea
I never did that, except for a school project but anyways
i need serious help
Me, for school projects only
Same but for school only
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
Since my projects are closed source idc
As if u gonna come there 🤣
i always code open source, pull requests just make it feel more collaborative
Hmm cool
I'll come if you would
You didn't close the bracket } in your ab me
Sure, I don't have a problem
Ask discord to do that
Oki
i hate the limit for about mes
There
can you guys answer something for me
@quaint epoch is there a way i can make a url my embed title?
what do you mean?
you mean like, put a url embed IN the embed?
a hyper link in a title?
like the title redirects to a url
yes
exactly
nah idk if you can
do i do title = "title", url="url"?
only in descriptions iirc
discord.Embed(title=f'{url}') no try
nah
like a hyperlink
you know those markdown links
ok you mean something like this
here
and here is a link
yes
like that, if you can picture it
its for a reminder command. with the message.jump_url
i also have one more problem
but its kind of weird
ill try this
i got it
@commands.command(brief="🕒 | Set a reminder up to a month! (1d, 1h, 1m, 1s) 'm!reminder 10m do the dishes'")
async def reminder(self, ctx, time, *, reminder):
embed = discord.Embed(
description = f":MechaAccepted: | Set a reminder for {reminder} in {time}!",
color = discord.Color.green()
)
msg = await ctx.send(embed=embed)
ctime = {"s":1, "m":60, "h":3600,"d":86400}
mtime = int(time[0]) * ctime[time[-1]]
await asyncio.sleep(mtime)
embed = discord.Embed(
title = "Reminded!",
url=msg.jump_url,
description = f"{time} ago you asked me to remind you of {reminder}. To see the message, please click the title of this embed!",
color = discord.Color.green()
)
try:
await ctx.author.send(embed=embed)
except:
await ctx.send(content=ctx.author.mention, embed=embed)
``` @slate swan
there is another problem
if i try to make it ten minutes it only does it for one minute
and it gives no error
but i cant find it
Hello, can I apply here for help related to programming?
ctime = {"s":1, "m":60, "h":3600,"d":86400}
mtime = int(time[0]) * ctime[time[-1]]
await asyncio.sleep(mtime)
``` is mainly the thing
just go around helping people
- type hint time as an int so you dont need to make it an int
- use a database and not .sleep so multiple users can use it
wdym the role?
or just helping users
then i cant multiply it for some reason
and also it gives errors when i add the "d" or "m" for minutes
I understood this, I just went in, the problem is different, if I need help, will they help me?
yes
okay
@slate swan do you have any idea why it isnt working because im lost lmao
ctime = {"s":1, "m":60, "h":3600,"d":86400}
mtime = int(time[0]) * ctime[time[-1]]
await asyncio.sleep(mtime)
i mean why index it if its an int and not a list?
because of the "m", "d", "h", and "s" variables for time
well you cant make letters in to strings?
thats the thing i have an idea but i will need to mess up my formatting
just call the arguments like this d:1 and you split the arguments in to 2 with the str split method and you just index the first element since it returns a list
im gonna try the type of time as a different arg
that works as well
?
!f-strings
Creating a Python string with your variables using the + operator can be difficult to write and read. F-strings (format-strings) make it easy to insert values into a string. If you put an f in front of the first quote, you can then put Python expressions between curly braces in the string.
>>> snake = "pythons"
>>> number = 21
>>> f"There are {number * 2} {snake} on the plane."
"There are 42 pythons on the plane."
Note that even when you include an expression that isn't a string, like number * 2, Python will convert it to a string for you.
idk how i can make them together but read as 2 different args
asyncio.sleep() can't reliably sleep more than about 48 days
http://bugs.python.org/issue20493
youre not its just 1 argument and you split the string with split method on a colon and since .split returns a list just index the first element
i only said it can go up to 30, if it gets bad ill just make a limit
a better solution would be to store it somewhere and use some polling mechanic
a db
you store the time and you check it maybe every 30mins so many users can use it with their snowflake id binded and just place holders if using sql to avoid sql injection
I have a very strange request for help, now I will try to describe
It's just that my teacher sent me a file (4.63mb; exe, apparently just a deliberately broken file). No code, no information. The only thing to do is open it. The word (musical instrument) should appear in the console.
I've tried ALL methods, but nothing comes up. I started to think he was just playing a trick on me. Does anyone have any ideas? I will be very grateful.
@slate swan im going to test this now
@commands.command(brief="🕒 | Set a reminder up to a month! (1d, 1h, 1m, 1s) 'm!reminder 10 min do the dishes'")
async def reminder(self, ctx, time: int, timetype="s", *, reminder):
embed = discord.Embed(
description = f":MechaAccepted: | Set a reminder for {reminder} in {time}{timetype}!",
color = discord.Color.green()
)
msg = await ctx.send(embed=embed)
if timetype == "m":
mtime = time * 60
elif timetype == "h":
mtime = time * 3600
elif timetype == "d":
mtime = time * 86400
await asyncio.sleep(mtime)
embed = discord.Embed(
title = "Reminded!",
url=msg.jump_url,
description = f"{time}{timetype} ago you asked me to remind you of {reminder}. To see the message, please click the title of this embed!",
color = discord.Color.green()
)
try:
await ctx.author.send(embed=embed)
except:
await ctx.send(content=ctx.author.mention, embed=embed)
this isnt related to this channels topic so pls check for another channel
you always need them
Of course, I'm sorry, what do you think, which one is more suitable for this topic?
string concatenation 
f string 
!ot
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
maybe ot channels
fixed
mtime = 0
if timetype.lower() in ["s", "sec", "seconds"]:
mtime = time
elif timetype.lower() in ["m", "min", "minutes"]:
mtime = time * 60
elif timetype.lower() in ["h", "hrs", "hs", "hours", "hour", "hr"]:
mtime = time * 3600
elif timetype.lower() in ["d", "day", "da"]:
mtime = time * 86400
i had == instead of in
you can use or
bro f strings are a thing
do this.
embed = discord.Embed(
title = "aaa",
description = "ok",
color = 0xfffff
)
await message.channel.send(embed=embed)
!e
print(str)
@slate swan :white_check_mark: Your eval job has completed with return code 0.
<class 'str'>
that wont work for this type of code
yes it would
bro do you want me to show you?
embed is just an instance of the class it doesnt matter
i already tried but i will show you
its basic oop
Oops
lol
@slate swan 👋
hi
Saw you after a million years
ikr hyd
I am always great 😃👍
nice
so with that type of embed how will i mention the role and the mention the user?
!f-strings
Creating a Python string with your variables using the + operator can be difficult to write and read. F-strings (format-strings) make it easy to insert values into a string. If you put an f in front of the first quote, you can then put Python expressions between curly braces in the string.
>>> snake = "pythons"
>>> number = 21
>>> f"There are {number * 2} {snake} on the plane."
"There are 42 pythons on the plane."
Note that even when you include an expression that isn't a string, like number * 2, Python will convert it to a string for you.
and thats not a type of embed
this*
thats just a instance of a class
how would i mention a role and a user with this?
role.mention
no ik that but how would i set that up
Damn you need to read some docs 
same as you would with anything
i already had that done
!e
a = 1234567890
print(f"crazy numbers are:\n{a}\nnew stuff")
@slate swan :white_check_mark: Your eval job has completed with return code 0.
001 | crazy numbers are:
002 | 1234567890
003 | new stuff
use
embed = discord.Embed(
title = f"{message.author.mention}"
)
await message.channel.send(embed=embed)
@balmy ivy
no
😬
no need for the f string
Oh 😂
!e
a = "lol"
print(a)
print(f"lmao{a}")
@slate swan :white_check_mark: Your eval job has completed with return code 0.
001 | lol
002 | lmaolol
embed = discord.Embed(
title = f"What a great day, {message.author.mention}! Dont you agree?"
)
await message.channel.send(embed=embed)
that makes more use of the f string
yes
@balmy ivy
!e
a = "this is great!"
print(f"you know what..\n{a} we shouldve done this sooner!")
@timber crag :white_check_mark: Your eval job has completed with return code 0.
001 | you know what..
002 | this is great! we shouldve done this sooner!
What is wrong with this?
import discord
import os
from discord.ext import commands
from dotenv import load_dotenv
bot = commands.Bot(command_prefix = '.')
token = os.getenv['TOKEN']
@bot.event
async def on_ready():
msg = f'{bot.user[:-5]} is ready for action'
print(msg, '\n', '-'*len(msg))
bot.run(token)
Error:
Traceback (most recent call last):
File "/data/data/com.termux/files/home/Codes/Bots/Hashirama/main.py", line 1, in <module>
import discord
ModuleNotFoundError: No module named 'discord'
Modules installed:
ffmpeg-python==0.2.0
future==0.18.2
imageio-ffmpeg==0.4.5
numpy==1.22.2
pycord==0.1.1
python-dotenv==0.19.2
Using latest pycord
Used all instruction given in the docs
Have you installed pycord?
yes
Are you using a venv?
yes
Have you selected the correct interpreter?
wdym
You need to select the python executable in the venv iirc
Helpp
seems like self.config[...] is returning None
print(self.configs["channel_level_update"])
unless the error is different to where you sent
search for get_channel()
how do I make it where if youre not bot owner it'll respond saying "this command is restricted to the bot owner"
@CLIENT.slash_command(name = "shutdown", description = "Allows vondy to shutdown the bot.")
@commands.is_owner()
async def shutdown(ctx):
em = discord.Embed(title = f"The bot is shutting down.", color = discord.Color.red())
await ctx.respond(embed = em)
exit()```
!d disnake.ext.commands.NotOwner
exception disnake.ext.commands.NotOwner(message=None, *args)```
Exception raised when the message author is not the owner of the bot.
This inherits from [`CheckFailure`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.CheckFailure "disnake.ext.commands.CheckFailure")
is there a video to understand the docs cause I have no idea how to read docs
Even if I replace the self.configs... with actual pure id, it's still giving the same error: TypeError: get_channel() missing 1 required positional argument: 'id'
it has a search bar
how do i make a command
0|spooky | Ignoring exception in on_guild_remove
0|spooky | Traceback (most recent call last):
0|spooky | File "/usr/local/lib/python3.8/dist-packages/discord/client.py", line 351, in _run_event
0|spooky | await coro(*args, **kwargs)
0|spooky | File "/root/SPOOKY/Bot/bot_auto_events/on_guild_remove.py", line 34, in on_guild_remove
0|spooky | embed = discord.Embed(title=f"__REMOVED__\n{guild.name}", description=f"`Owner :` {guild.owner}\n`Humans :` {len(list(filter(lambda m: not m.bot, guild.members)))}", color=discord.Color.red)
0|spooky | File "/usr/local/lib/python3.8/dist-packages/discord/embeds.py", line 189, in __init__
0|spooky | self.colour = colour if colour is not EmptyEmbed else color
0|spooky | File "/usr/local/lib/python3.8/dist-packages/discord/embeds.py", line 318, in colour
0|spooky | raise TypeError(f'Expected discord.Colour, int, or Embed.Empty but received {value.__class__.__name__} instead.')
0|spooky | TypeError: Expected discord.Colour, int, or Embed.Empty but received method instead.
huh
you passed wrong type for the colour=
embed = discord.Embed(title=f"__REMOVED__\n{guild.name}", description=f"`Owner :` {guild.owner}\n`Humans :` {len(list(filter(lambda m: not m.bot, guild.members)))}", color=discord.Color.red)
embed.set_footer(text=f"Total: Servers: {Servers}, Members: {Members}")
discord.Color.red()
its a classmethod
oh yea
tbf they should've made it a property.
meh
discord.Color returns hex
red is a classmethod
not a sin tbh
Anyone use replit? If so, do you have the hacker plan?
no.
It makes more sense to make it a class method, also saves preformance
As what if I only wanted blue? Then I would be forced to have an instance that has all the other colours as well
self promo isnt allowed
We don't allow recruiting here.
ok
So..? If you could remove the message please.
@client.command(name='VVD')
async def on_message(ctx: commands.context):
await ctx.send("is the best defenda")
this doesent work for some reason i think its because on_message is sorta dimmed why is that
a) unless you want your command to be called on_message, you should name it something else (like the name of the command)
b) ctx is an instance of commands.Context not commands.context
c) are your indents correct?
a) ok
b) ?
c) yes
Is this multiple choice?
oh
im joking
k
are you calling it like <prefix>VVD?
yea
its ctx: commands.Context not ctx: commands.context
but that shouldnt break it
Hello I want to make it so after a webhook sends 10 messages it stops
why?
?
ok
Yes
@naive spoke caps are really important it can cause your whole code to fail
alright
when i ran ?help i got this TypeError: on_message() takes 0 positional arguments but 1 was given
can we see your code please? i have a theory
code ```py
@commands.command(aliases =['Mute'])
async def mute(self, ctx, members: commands.Greedy[discord.Member],
mute_minutes: typing.Optional[int] = 0,
*, reason: str= "None"):
if not members:
await ctx.send("You need to name someone to mute")
return
if member == ctx.author:
return await ctx.send("You can not mute yourself")
muted_role = discord.utils.find(ctx.guild.roles, name="Muted")
for member in members:
if self.bot.user == member:
embed = discord.Embed(title = "You can't mute me, I'm an almighty bot")
await ctx.send(embed = embed)
continue
await member.add_roles(muted_role, reason = reason)
await ctx.send("{0.mention} has been muted by {1.mention} for *{2}*".format(member, ctx.author, reason))
if mute_minutes > 0:
await asyncio.sleep(mute_minutes * 60)
for member in members:
await member.remove_roles(muted_role, reason = "time's up ")
error:
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: UnboundLocalError: local variable 'member' referenced before assignment
Ignoring exception in command None:
if member == ctx.author...
How would you get the number of cogs the bot has as a string and append to a list?
do you mean if ctx.author in members?
My more advanced help command than yesterday
Why not use buttons?
cogs = str(len(self.client.cogs))
shhh, he's extremely new
lol
This could be a lot cleaner by subclassing HelpCommand and using that as a skeleton class
As there are some good tear down methods, etc
he doesnt know what a class is, let alone what subclassing is
So this works?
What does TypeError: 'InvokableSlashCommand' object is not subscriptable mean
and no other command is working
yeah
!e
var = 12345
print(var[2:])
@final iron :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 2, in <module>
003 | TypeError: 'int' object is not subscriptable
How would you make it.. errm less descriptive
thanks
What attributes does self.client.cogs have?
new error: from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: find() got an unexpected keyword argument 'name'
Docs are your friends
get not find
Clearly yes
!d discord.ext.commands.cog.Cog
class discord.ext.commands.Cog(*args, **kwargs)```
The base class that all cogs must inherit from.
A cog is a collection of commands, listeners, and optional state to help group commands together. More information on them can be found on the [Cogs](https://discordpy.readthedocs.io/en/master/ext/commands/cogs.html#ext-commands-cogs) page.
When inheriting from this class, the options shown in [`CogMeta`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CogMeta "discord.ext.commands.CogMeta") are equally valid here.
What you said returns a list of the objects I showed above
!d discord.ext.commands.core.Command
class discord.ext.commands.Command(*args, **kwargs)```
A class that implements the protocol for a bot text command.
These are not created manually, instead they are created via the decorator or functional interface.
What I just sent
You can look though the attributes
But, yes, it is qualified_name
Yes
why tf you're putting [] around it i will never know
So I have the variable pages but when I / 4 if len(contents) is less than the next multiple of 4 then it prints a decimal number of pages. How to round that up to next whole number
List

Sooooooooooo? What
so wuts the problem
if you cant see the problem here, im not sure if you should be doing discord.py
.
but like i just wanted to know what the problem ment
there are multiple problems
out of curiosity, does anyone know if discord bots connect to discord's servers via a secure protocol, or is it plaintext data transfer?
how come this doesnt work?
if ctx.message.author.guild_permissions.administrator:
await member.kick(reason=reason)
await ctx.send(f'User {member} has kicked.')
elif:
await ctx.send("You don't have permission to kick members.")```
look at contents
do you mean else?
Well, surely the API is via a secure protocol as it uses HTTPS instead of HTTP, and for other things that bot's can offer via services would most likely use Oauth2 as the authorisation framework
when i do else still says invalid syntax
ok thanks! that makes sense 🤔
it looks to me like you havent indented await ctx.send(f'User {member} haas been kicked.')
nvm i found it
no that isnt the problem though...
i want to fix the else
do i have to make another prefix for the command?
@manic wing example as in a simpler version that I could possibly understand instead of yours which is what 200+ lines long?
e
idk, ask @velvet tinsel - he's beginnerish so his code should be understandable

I deleted the help command and I'm restaring I think I have a general idea of how I want it to work
good luck
i will sus you
🥺
you've got member intents?
try debugging it (adding prints in various places to see where it triggers/doesnt trigger)
Okay
command has an attribute named value?
no?
What about description?
@discord.ext.commands.command(name=..., cls=..., **attrs)```
A decorator that transforms a function into a [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") or if called with [`group()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.group "discord.ext.commands.group"), [`Group`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Group "discord.ext.commands.Group").
By default the `help` attribute is received automatically from the docstring of the function and is cleaned up with the use of `inspect.cleandoc`. If the docstring is `bytes`, then it is decoded into [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") using utf-8 encoding.
All checks added using the [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") & co. decorators are added into the function. There is no way to supply your own checks through this decorator.
this will show it all
Anything I could improve on or does it all look good so far?
what's the best tool to obfuscate code?
Not relevant to this channel
what's the best tool to obfuscate PYTHON
Again, not relevant to this channel
it's python
i want to obfuscate my discord.py code
How many times do I have to say it's not relevant to this channel
it means that you didnt listen to me the last time i told you what it meant 
Are you adding name in to your embed fields
ye
i have bad memory
do you mind repeating please?
curseWord = ['word1', 'word2']
if any(word in message.content.lower() for word in curseWord):
await message.delete()
When I run this, the message just flickers a bit and stays, does anyone know why this doesn't work?
The bot has manage messages perms too
As you would do normally?
!d discord.Message.add_reaction
await add_reaction(emoji)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Add a reaction to the message.
The emoji may be a unicode emoji or a custom guild [`Emoji`](https://discordpy.readthedocs.io/en/master/api.html#discord.Emoji "discord.Emoji").
You must have the [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission to use this. If nobody else has reacted to the message using this emoji, the [`add_reactions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.add_reactions "discord.Permissions.add_reactions") permission is required.
Just to note, coming here shouldn't be your first resource
read the docs bruv
The order should be docs -> Google -> here
Depending on your search engine you can use ctrl + f to search for keywords in the docs
You can even search right here. Searching for add reaction brings up the result you needed
Can someone help I got a command that I wanna repeat
And it stops when you do !stop
Dw it’s not spamming api
Don't ask to ask
Just ask
What
Can't fix this
I just lost 60 brain cells
Ok
The layout of webhook is wrong
from discord_webhook import DiscordWebhook, DiscordEmbed
webhook = DiscordWebhook(url='your webhook url', username="New Webhook Username")
embed = DiscordEmbed(title='Embed Title', description='Your Embed Description', color='03b2f8')
embed.set_author(name='Author Name', url='https://github.com/lovvskillz', icon_url='https://avatars0.githubusercontent.com/u/14542790')
embed.set_footer(text='Embed Footer Text')
embed.set_timestamp()
embed.add_embed_field(name='Field 1', value='Lorem ipsum')
embed.add_embed_field(name='Field 2', value='dolor sit')
embed.add_embed_field(name='Field 3', value='amet consetetur')
embed.add_embed_field(name='Field 4', value='sadipscing elitr')
webhook.add_embed(embed)
response = webhook.execute()
@pine crypt this is the layout you should use
What
I just copied from docs
What are you talking about
I'm doing it in a loop
@final iron it’s all embed webhook related stuff setup
Then remove excute
Discord has built in webhooks?
Sorry I have no clue what you are talking about
Yes
I am a beginner
Response = webhook.excute() just remove that to repeat
I just gave example
Because I personally use the library
What are webhoooks?????
😭
I feel so stupid rn
I’ve been explaining webhooks for nothin
💀
Ignore what they said
Can I have an answer that fits along the lines of my original code
They had no idea what they were talking about
Share the full traceback
I interpreted your code wrong I mistakenly thought it was webhook
Even if it was a webhook it made no sense
Sorry it’s just the way I do it
well it says it
Yes, and how to fix what it says
it tried to do a request with missing fields and returned a 400 http code
theres only 3 fields iirc and why are you making a field for each command
thats why its reponse status is a 400
any idea how I can remove the send message permission for a channel for a certain user?
@haughty quartz make mute role
it should only be for one specific channel tho
Still works
not for the whole server
So it goes
Command Name
Command Description
Command Name
Command Description
In the embed
Yes you can make it one channel
With mute command
Roles
i think theres a method for that in the channel class or member im not sure which
have you seen the limits in embeds?
I don’t know much about permissions to be honest
wdym
Yes
cough
okay
do u know what method it is
Use discord py docs
He’s not 100%
yeah okay I'm gonna do some research ig
nope check docs
I removed it from the other for loop and now it shows the same error, but only once
dpy docs are easy
how can i do a if isinstance(error, MissingPermissions): as if the bot responds to this: ERROR I do not have the permission {permission} to execute this command?
^ and really useful even for beginners to advanced
thanks u two
Does bot have permissions required
if isinstance(error, MissingPermissions):
print(error)
error is that exception and missing perms is the type
How do I loop a command
And then stop loop on command
I’m not good w loops
I only have like 2 pages so why would the error be aout 26 fields in embed?
what are you trying to do exactly?
bro
Embed limits
Embed descriptions are limited to 4096 characters. There can be up to 25 fields. A field's name is limited to 256 characters and its value to 1024 characters.
dang google is helpful
This uses buttons?
how does all this workkkkkkk?
btw each field should have a value so thats why the error is raising
yes! this show "You are missing Ban Members permission(s)" but i want to show only 'ban members'
there is any way to?
wdym a list of all banned members?
nono
im not sure what youre refering to
i just want to show You are missing Ban Members permission(s)
this ban members
which, in this case, is the name of the missing permission
!d discord.ext.commands.MissingPermissions
exception discord.ext.commands.MissingPermissions(missing_permissions, *args)```
Exception raised when the command invoker lacks permissions to run a command.
This inherits from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure")
!d discord.ext.commands.MissingPermissions.missing_perms <- a list of all the missing permissions
No documentation found for the requested symbol.
well that isnt a thing
huh
wdym
I’ve got something that when it finds a available it sends to channel of command otherwise failed ones just print
?!?! Ok, I guess the docs are broken, https://discordpy.readthedocs.io/en/stable/ext/commands/api.html?highlight=missingpermissions#discord.ext.commands.MissingPermissions.missing_perms
But it only checks 1 instead of keep going
you can make a task and check the channels ig
every 30 secs or so
@bot.command()
async def checker(ctx):
r = requests.get(f'https://tiktok.com/@{users}')
if r.status_code == 200:
print(Fore.WHITE+"🚫"+Fore.RED + "Taken"+ Fore.RED+ f' {users}')
else:
print(Fore.WHITE + "✅" + Fore.YELLOW + "Available" + Fore.YELLOW + f' {users}')
ctx.send(f'{users}')
I don't use python3.6
like this
!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").
Then just change it to your version
!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.
Thanks
I forgot whoops
without the 'You are missing'
i mean is that what you want?
yes...
then?
i dont know explain very well, but, if i type
await ctx.reply(f'**ERROR** | You need to have the permission of {error}', mention_author=False)
the bot returns ERROR | You need to have the permission of You are missing Ban Members permission(s) to run this command.
and i want to show only ERROR | You need to have the permission of Ban Members to run this command.
or use this exception
thats not what i wanted, but thanks anyway for the help
Then just modify your text and let just error
im not sure if you can maybe check all the attrs and stuff
error returns a sentence
That's what I'm talking about
Why add you miss... when the error already says this
Let it be just that
he only wants it to return the type of perms he wants and error returns
You are missing Ban Members permission(s)
i suppose
How would I make it so 4 commands are displayed per page?
And if there are no pages, add a page to continue
@slate swan yes I have made the most dumbest way of doing it
@tasks.loop(seconds = 10) # repeat after every 10 seconds
async def myLoop():
async def checker(ctx):
r = requests.get(f'https://tiktok.com/@{users}')
if r.status_code == 200:
print(Fore.WHITE+"🚫"+Fore.RED + "Taken"+ Fore.RED+ f' {users}')
else:
print(Fore.WHITE + "✅" + Fore.YELLOW + "Available" + Fore.YELLOW + f' {users}')
ctx.send(f'{users}')
@tasks.loop(seconds=5.0) ```
God tier
How would I make it so four commands appear per page?
And if there are no pages, add a page to continue?
Just because you get stuck every time don’t resort to here try google then discord.py docs and we should be last resort
Google have very general help, not specific to most of the things I want to do
its not a command no need for the command deco and why nested classes and request isnt async use aiohttp and .send is a coro
Ok
!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").
Since when do tasks take in ctx
I’m dumb sorry
This will throw an IndentationError
@final iron my head is broken rn 😭 :
async def checker(ctx):
r = requests.get(f'https://tiktok.com/@{users}')
if r.status_code == 200:
print(Fore.WHITE+"🚫"+Fore.RED + "Taken"+ Fore.RED+ f' {users}')
else:
print(Fore.WHITE + "✅" + Fore.YELLOW + "Available" + Fore.YELLOW + f' {users}')
ctx.send(f'{users}')```
@tasks.loop(seconds=5.0, count=5)
async def slow_count():
print(slow_count.current_loop)
This is like the only part of loop that I understand
Have you tried learning python?
yes its the full error
you could just do ERROR | {error}
I have but my head tired
Can u buy me new head
halp
how do you instantiate your bot
i used .replace to remove the rest
but thank you anyway
Traceback (most recent call last): File "main.py", line 106, in <module> @Bot.command(aliases=["mirai"]) AttributeError: type object 'Bot' has no attribute 'command'
How do you instantiate the bot
what does that mean
error looks like you both used a class different from commands.Bot and forgot to call the class
Ik problem
@steep wind bot = commands.Bot(command_prefix= "!")
global bot
bot = commands.Bot(command_prefix=".", self_bot=True)```
huh?
If you have a bot class it should subclass commands.Bot
That should work
and then you define a custom constructor and methods
bot = commands.Bot(command_prefix= "!")
it doesn’t inherit object
Personally I use this
@steep wind
yes
Subclassing better 🗿
Use that
im trying
Opinions
same error
@steep wind have you imported discord.py
if you want to have a bot class, it should inherit commands.Bot
How would I use my page and pages variable to make 4 commands per page?
And you define the constructor with __init__
you don’t use global variables or inherit from object
@slim ibex kinda looks like he forgot to import discord?
just discord
pain
ikr
no. He would have gotten an import error or module not found or something if he didn’t import
True
How would I make 4 commands per page???
do you mean having four commands per field in your embed?
per page then multiple pages
does anyone know how to fix or na
If you want to subclass it would be like this
class Bot(commands.Bot):
def __init__(self):
super().__init__(…)
# other methods
If you aren’t subclassing you just do
bot = commands.Bot(…) in global scope
read the erropr
i belive you have eyes
na
lowercase B smh
wdym pages, like different embeds that you're planning to add buttons afterwards to switch between them?
ye
Glowstik 👀
||nothing to see here||
it’s aliases
ah then i just forgor
💀
!d discord.ext.commands.Command
class discord.ext.commands.Command(*args, **kwargs)```
A class that implements the protocol for a bot text command.
These are not created manually, instead they are created via the decorator or functional interface.
you should group the list of commands into sets of 4 first, then create an embed for each group
You sure?
🗿
how would i group them
plenty of ways to do that but they all pretty much involve common python stuff
e.g. using slicing py groups = [] group_size = 4 for i in range(0, len(client.commands), group_size): groups.append(client.commands[i:i+group_size])
oh, forgot it returned a set
why did you add the code inside your other for-loop though?
is it meant to be outside?
that outer for loop kinda isn't needed
convert it into a list()
what do i convert?
the client commands...
could also be a nice opportunity to sort the list afterwards
otherwise your commands will be in some arbitrary order
for i in range(0, len(list(self.client.commands)), group_size):
groups.append(self.client.commands[i: i+group_size])



