#discord-bots
1 messages Β· Page 1081 of 1
u forgot fstring
no
why you need f-string
then what is :.2f
2 decimals
limitation for decimal places to 2
ya but that only works in fstrings π
@slate swan :white_check_mark: Your eval job has completed with return code 0.
90.01
Ryuga's really smort ngl
syntax for fstrings are {object_with_ __format__:<formatter>}
import datetime
hello = str(datetime.timedelta(seconds=float(f"{error.retry_after:.2f}")))
nah not int
float
@heady sluice
wait = str(datetime.timedelta(seconds=error.retry_after:.2f)
It says invalid syntax
GRRRR
?
read conversation
!e
class Foo:
def __format__(self, formatter):
if formatter == '#':
return 'u said #'
print(f'{Foo():#}')
@paper sluice :white_check_mark: Your eval job has completed with return code 0.
u said #
ryuga smart
if you don't put # nothing happens?
Ok
Not smart
Smartest
And a good helpful person
no it will raise an error in this case because __format__ will return None
its supposed to return str
always
;-;
cog command without self
Errors everywhere!
Why replit always say poetry add aiohttp everytime even i have downloaded it
Why my bot sending a weird thing
Why .76000 at back?
Is there anything to remove that?
i recommend experimenting with the datetime module, we gave you material needed, now its your job to make the tool
Ok sure but pls tell how to remove that .76000 it may confuse my bot users
those are the milliseconds, they are part of the formatter, check out the docs there are examples there which will help you format it properly
Kk ty
essentially only sending the preview of the image and hiding the link
Guys is there any event that if anyone use any command it gets triggered
Cause i don't want to add print in all commands
Is there any way if there pls tell!
Can anyone give me guidance on how to create discord bots using python?
start with the doc and do what it says, then ask here when you get to specific issues. https://discordpy.readthedocs.io/en/stable/
get it installed and follow the Quickstart
Ok tysm
class SayCommand(commands.Cog):
def __init__(self, bot: commands.Bot):
self.bot = bot
self.last_msg = None
@commands.listener()
async def on_message_delete(message):
self.last_msg = message
```snipe command is being stupid and not working for me, what is wrong with this on message delete event?
commands.Cog.listener, not commands.listener
but self.last_msg it still says is wrong
the message isnt in the cache of the bot then
huh?
and make sure the cog is loaded
it is loaded
you misss self
idk how you even got it to work without errors
oh wait nvm
Class instance
When calling a method from a class instance (ie. instance.method()), the instance itself will automatically be passed as the first argument implicitly. By convention, we call this self, but it could technically be called any valid variable name.
class Foo:
def bar(self):
print('bar')
def spam(self, eggs):
print(eggs)
foo = Foo()
If we call foo.bar(), it is equivalent to doing Foo.bar(foo). Our instance foo is passed for us to the bar function, so while we initially gave zero arguments, it is actually called with one.
Similarly if we call foo.spam('ham'), it is equivalent to
doing Foo.spam(foo, 'ham').
Why is this useful?
Methods do not inherently have access to attributes defined in the class. In order for any one method to be able to access other methods or variables defined in the class, it must have access to the instance.
Consider if outside the class, we tried to do this: spam(foo, 'ham'). This would give an error, because we don't have access to the spam method directly, we have to call it by doing foo.spam('ham'). This is also the case inside of the class. If we wanted to call the bar method inside the spam method, we'd have to do self.bar(), just doing bar() would give an error.
learn python classes πΆββοΈ
happens with me too, its okay (rarely)
thx tho
I dream of Kakashi 24/7, I don't like waking up in the case π
π thats a wamen of culture
consider using tools that help you see that.
define self
the python extension already has tools for that included
^
i'm not asking for help. i'm offering help. :)
im honestly confused now
Good afternoon, is it possible to know the locale (the language used by someone on discord) when someone uses a command ?
wait nvm
that's a Message object, use the content property on it to access the message's content
yeah i figured that out already but thx lol
!d disnake.Interaction.locale
I'm aware of it but I don't understand how to get it when someone uses a command π₯΄
Shall I get it from the message that triggered the command ? (Message got an interaction attribute I swear)
Regular commands and messages don't have interactions, if that's what you mean
How to do it? Correctly
Can we get the permission which the ctx command uses?
Ehm, I don't really understand how can I get the locale from an user when he uses a command then or if it's possible
Help
Can you elaborate on what you mean by "command"?
var = [
item1, item2
]
Regular, text-based command with a traditional prefix like !, or the newish slash commands, for which you type /?
I will try
Regular text-based command yup
In that case getting the locale from the interaction object is not possible, due to the fact that there is no interaction object
erf, I swear I'll stick to english commands forever then
Unless you migrate to slash commands
Or you have a database of users and their preferred languages
I already got a database so I think I'll do something so they can select their language
I have not checked what are these slash commands so far, I guess I should xD
You should, as discord recommends (read: forces) you to migrate to them
These are the commands that popup when u type /
That's good to know, I'll check it
Hunter's info is always the best (not sarcastic)
#discord-bots message POV me writing paragraphs
any way I can hide an image's url?
hide an image url? @dull stirrup
yes
copy and paste the image, not the link
or download the image and send it
I'm taking the urls from a database, then sending them seperated by a space
put the web address in
Only webhooks can send one message with multiple embeds.
Put it on an embed?
or that
It's currently not sending them in an embed
lemme see code
^^
sec
@client.command()
@is_registered
async def collection(ctx: commands.Context):
await economy.is_registered(ctx.message.author.id)
user_account = await economy.get_user(ctx.message.author.id)
await ctx.send(f"{ctx.message.author.name}'s Collection:\n{' '.join(user_account.items)}")
where embed at with image
wym
It's sending multiple links, embeds can only use 1 image
it's not embedded
if I embed it, it will break
async def command_name(ctx, argument1, argument2)
Help me with This thing
what do you want
@slate swan
I can't put 3 images in the same embed
It's not sending message to that channel
It means not working
try to pass it as a string
ids = ["id1", "id2"]
yes
that's for strings
Ok
what he put was correct for integers
yea
what u need help with
is there someway I could make my webhook send as many embeds as I have image urls (changes often)
send 1 image per embed?
then send however many embeds u need
for urls in wherever:
(send embed)
this would work right?
auschwitz
shh
I don't believe discord.type is a thing
I don't believe you can send more then 1 image per embed
the first argument
so ye
try attaching it as an attachment
that's why i said 1 image per embed
would that work?
yeah i don't see why not
@slate swan
what are the arguments that are being passed through?
idk anymore
you can set them to what oyu want
guys would this work
@bot.event
async def on_member_update(ctx, before, after):
if after.username == "SomeUser":
await after.ban()```
streaming, playing, listening, watching
Is this replit
Yea
Oh mo
Poor :(
Step 1 never use replit as a development tool
Is it 429 exception
For type I would map string literals to one of https://discordpy.readthedocs.io/en/stable/api.html#discord.ActivityType, like
types = {
"playing": discord.ActivityType.playing,
...
}
Others are very hard
its actually not terrible if you pay
Then why should I use
Visual Studio Code or PyCharm
I need pc
Or anything else you know
I don't have
Are you coding on mobile π³
Just tell me how to do it their
Yea
Oh god
π«
For projects or smth
Just use vsc for development
then deploy to a shitty vps from like linode or sum
Tell me how to fix it
not an excuse i made whole ass VPN with phone
I am a musician so I only use musescore
@vale wing
What
Then we can't help
Why full code
The code that is malfunctioning
It's privacy
Recently one guy tried to steal its source and was like "how to run it plz tell me"
Lmao
We can't help you with issue without knowing what the issue is
How should I put it like? The channel one
I don't even see send function anywhere
get the channel
Just declaring 2 variables isn't informative
If it's worng it doens't response if i just put 1 channel it works
those are two assignments of values to variables. afterwards, message_1 and channel_1 contain values.
And why are you storing ids as strings
so far, that's all we can tell.
Tell me how to put variables
That's it
the rest is just guessing without the code. and our guesses will be wrong.
Well you just declared them and assigned values to them
Hey all, anyone have some documentation on running discord bots at a higher scale? Finding that my bot is lagging on responses recently due to traffic. There are definitely areas I can optimize in the code, but I'm curious about scaling too.
How might i load balance across multiple instances of the bot? Is it just a matter of scaling vertically?
listen nobody will copy ur code here don't worry
One question β what's your python knowledge level
yo anyone?
How many guilds is your bot in and what do you use for hosting it
1/10
What?
thanks π
What's that
Ok well you are a regular code copypaster
:)
Sorry I don't help to such people
Just 1 guild right now, and I'm hosting on a home lab (didn't want to pay for a VPS). But you have me thinking about it now.
As an exercise though, what are the scaling options with discord bots?
Hmm looks like stack
Might sound discouraging but please learn some stuff of python
you paid for that?
i dont believe you, but if you did u got robbed real bad
Bruh
@slate swan are you trolling? There is a lot of free code available.
RIP
Ofc he is
No fr i am not trolling
i'm curious if you lost more than just money on this ... like if you don't know what the code is even doing, do you trust what it's doing?
Well I suspend you are using some methods that cause blocking because bot having issues with serving just one guild is bad. What library do you use for database interaction and API requests if you do such?
I bought it
Any proof?
Idk
I won't show the chat
Ask the guy u bought from
What will I do make you believe
a mix of redis and google firestore. but yeah, there are blocking tasks in the commands I'm noticing lag in
He offline from 2 hours
...
Ig i didn't watsed my bitcoin
Is it a good idea to use replit to make Discord bots? Since all the hostings are paid
From the sounds of it, I should focus more on code optimization first.
you need to learn how to spend money ....
Are you using common wrappers or async ones? Also do you use cogs
Anyone please help
and i dont mean it in a fun way
Can you help me how to fix it
what are you trying to do?>
Async, and I'm currently refactoring my code to use cogs. It's reached the point where its needed
Channel 1 is not working
use a library like discord.py
check the docs
Yeah bots that have everything in one file may be laggy. Also how do you listen to events? One event handler for one kind of event or you have listeners?
I am 1/10 in coding
there are many basic tutorials that will have you up and running in like 30 mins
Is it a good idea to use replit to make Discord bots? Since all the hostings are paid
@slate swan I can make you a bot for free I am bored lol
I can just think what is it doing by seeing 3 to 5 words
then you should learn that first before making a bot, its not for beginners
No
What should I do?
Dms maybe
Ok sure if it's not very hard to do I can help
I have a single on_message listener for certain phrases, but also many commands broken into individual listeners and now cog classes.
Is there a benefit to breaking many on_message events into separate event listeners?
Well I can't really recommend anything. Personally I have a bare metal server that I built from old computer parts and it works perfectly besides sometimes we get electricity cut off π
Dms @vale wing
Oh damn, ight ig
$ + $ = β¬
Anything free
Running the server isn't free as well but compared to the prices of servers with 4 gb ram it is miserably small price I pay for electricity it consumes
Omg @vale wing
Ok gl with it btw
Dms pls
That's big brain
Off-topic channel: #ot2-never-nesterβs-nightmare
Please read our off-topic etiquette before participating in conversations.
Well anyways, since I'm starting my career as a bot developer, i would like to know how do I make a simple mute command
Hi guys, I started to use slash commands instead of regular commands.. My / command isn't showing up while typed in my discord server (I'm admin, I checked applications.command in OAuth2) but I can't find two examples doing the same and most of them are using external librairies :
@app_commands.command(name="bet", description="Ajoute, crΓ©e ou valide un pari")
async def bet(self, interaction):
#doing things
await interaction.response.send_message(embed=embed, view=view)
It's inside a cog tho but as I said earlier I had no issue with it when using regular commands so..
How can i make it so it sends the image inside the embed?
Unbelievable
What peal can make
!d discord.Embed.thumbnail
'NoneType' object has no attribute 'send'
property thumbnail```
Returns an `EmbedProxy` denoting the thumbnail contents.
Possible attributes you can access are...
@commands.command()
async def permissions(self, ctx, channel):
em = discord.Embed(title=f'Testing', description=f"I am testing if i have permissions in this channel!")
channel = await fetch_channel(channel)
try:
await channel.send(embed=em)
except Exception as e:
await ctx.channel.send(f"{e}")```
@mossy jacinth
channel is returning None
use await self.bot.fetch_channel()
i provide the channel though
its a string, which must be integer
um ye
or typehinted it to discord.TextChannel would be even better, then you can directly channel.send
is there some Messageable interface thing as well
!d discord.abc.Messageable you mean this?
class discord.abc.Messageable```
An ABC that details the common operations on a model that can send messages.
The following classes implement this ABC...
Abc is an abstract class or smth
yes thats the one
abstract base class
!d discord.abc.Messageable.send
await send(content=None, *, tts=False, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=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/latest/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.10)") of [`File`](https://discordpy.readthedocs.io/en/latest/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/latest/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.10)") of [`Embed`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
its got send too ig
Yeah
Well it implements the Messageable
theres like 6 classes that have Channel in the name
For different types of channels
Ignoring exception in command permissions:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "/home/vscode/Everything bot's/cogs/commands.py", line 87, in permissions
channel = channel = await fetch_channel(channel)
NameError: name 'fetch_channel' is not defined
oh got it
I really can't type on mobile so...
Understandable
its a method of the Bot class
Sup everyone ππ
heyyyy
I'm fine wbu π
class SnipeCommand(commands.Cog):
def __init__(self, bot: commands.Bot):
self.bot = bot
self.last_msg = None
self.last_msg_author = None
self.last_emsg = None
self.last_emsg_author = None
@commands.Cog.listener()
async def on_message_delete(self, message):
if message.author.id != 981585342626955364:
self.last_msg = message.content
self.last_msg_author = message.author
@commands.Cog.listener()
async def on_message_edit(self, message):
if message.author.id != 981585342626955364:
self.last_emsg = message.content
self.last_emsg_author = message.author
im trying to make a snipe command for edited messages too, but the on_message_edit event isnt working, it says there are 3 args but it only takes 2, when there arent
hello who give me help please
Commande ban (Pour ban un membre ou quelqu'un)
@bot.command()
@commands.has_permissions(ban_members = True)
async def ban(ctx, user : discord.User, *, reason):
reason = " ".join(reason)
await ctx.guild.ban(user, reason = reason)
embed = discord.Embed(title = "Banissement", description = "Un modΓ©rateur a frappΓ© !", url = "https://discord.com/terms", color=0xFF0000)
embed.set_thumbnail(url = "https://th.bing.com/th/id/R.6295f456c34c3e88f7541cc8c1318be6?rik=1m1HBBcuephTtg&pid=ImgRaw&r=0")
embed.add_field(name="Membre banni", value = user.name, inline = True)
embed.add_field(name=f"Raison", value = reason, inline = True)
embed.add_field(name="ModΓ©rateur", value = ctx.author.name)
await ctx.send(embed = embed)
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.
Also describe the issue and any tracebacks you may be getting
sorry To ou bad english
this got pushed up by other long messages, i still need help for those who dont know
I started to use slash commands instead of regular commands.. My / command isn't showing up while typed in my discord server (I'm admin, I checked applications.command in OAuth2) but I can't find two examples doing the same and most of them are using external librairies :
@app_commands.command(name="bet", description="Ajoute, crΓ©e ou valide un pari")
async def bet(self, interaction):
#doing things
await interaction.response.send_message(embed=embed, view=view)
It's inside a cog tho but as I said earlier I had no issue with it when using regular commands so..
Any clue of what am I doing wrong ?
async def on_message_edit(self, before: discord.Message, after: discord.Message):
...
Ye
yeah, that
Did you sync?
# Commande ban (Pour ban un membre ou quelqu'un)
@bot.command()
@commands.has_permissions(ban_members = True)
async def ban(ctx, user : discord.User, *, reason):
reason = " ".join(reason)
await ctx.guild.ban(user, reason = reason)
embed = discord.Embed(title = "**Banissement**", description = "Un modΓ©rateur a frappΓ© !", url = "https://discord.com/terms", color=0xFF0000)
embed.set_thumbnail(url = "https://th.bing.com/th/id/R.6295f456c34c3e88f7541cc8c1318be6?rik=1m1HBBcuephTtg&pid=ImgRaw&r=0")
embed.add_field(name="Membre banni", value = user.name, inline = True)
embed.add_field(name=f"Raison", value = reason, inline = True)
embed.add_field(name="ModΓ©rateur", value = ctx.author.name)
await ctx.send(embed = embed)β
sorry
Also if I'm not mistake, you do need a CommandTree instance:
tree = discord.app_commands.CommandTree()
@tree.command(...)
...
Okay, what exactly is wrong here?
Ehm, no π₯΄
Well, there you have it
one second please
are there some doc about sync for slash commands? can't find anything related to it
do they get banned?
https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.CommandTree.sync the relating documentation
thanks a lot, gonna check it
yeah
but no message ?
@commands.command(name="esnipe")
async def esnipe(self, ctx: commands.Context):
embed=discord.Embed(description="** **", color=0x48c039)
if self.last_msg == None:
content = "No messages to snipe."
author = "N/A"
else:
content = self.last_emsg
content2 = self.last_emsg2
author = self.last_emsg_author
embed.add_field(name=f"Before: {content}", value="** **")
embed.add_field(name=f"After: {content2}", value=f"- by {author}")
await ctx.send(embed=embed)
content2 referenced before assignment?
Yeah content2 only exists if self.last_msg is NOT None
I would just do something like this:
if self.last_msg is None:
await ctx.send("No message to snipe") # embed also works too
else:
...
2 helpers in one channel
π
wow
lots of hewlp
is it unusual
yup
yup very
I need help To get the font to be Perfect but I dont know cos to fix it
Well, maybe we need more helpers then
π
kind of, only robin is usually here
well Robin grew up in this channel
okimii, cope
Yeah we don't get many staff around these parts
could use moar helpers
Probably
π
*more discord helpers
π
im still here
but sarthak is smarter
@slate swan send me inv to that cat emoji server π
oh another server with nice cat emojis
To go give help please
Discord doesn't support fonts
At least in the way that you get to pick which font your embeds are
isnt this a font bro
the c# cats are awesome imo
I wouldn't consider italics to be a seperate font
you sure?
But I'm guessing alpr is asking why the bold markdown in the embed title isn't bold
like thiz ?
The reason is because it's already bold
like me
π
hey guys
you just killed the chat
shhh
oh just saw the huge bubble
what do you guys think about this feature dont ask about the srcπ³ 
you can play gifs in your rich presence
is that a custom activity you wrote
idk how its done hunter never told me but he said something about setting a url maybe in his presence idk
@sick beacon
hunter
is the mention invalid i cant tell
appears as invalid user for me
desktop client?
cuz im on mobile client so i wasnt sure if hunter was in my clients cache
im on mobile phone
Didn't get a ping
That is, uhhh, infinity wars trailer running on my RPC
oh the Test / Test made me think it was some work in progress
Nah, just a random app id
it doesnt seem to work for me either
weird..
Never got the ping
Ye right I'd
Thanks for the 3 pings guys
Thanks for the 3 reactions guys
do u know how to access variables from variable names in string?
tell him to vouch for you to become a helper so you can have it as well
example?
xyz = {}#some dict
a = input()#'xyz'
print()# trying to print xyz from input
Ah I had a project like this where I had to take input in the form of a list
!e ```py
var1 = 1
string = "var1 is cool"
variables = (var for var in strings.split() if var in dir())
print(variables)
Had to use an eval since there was no other way
!e ```py
var1 = 1
string = "var1 is cool"
variables = (var for var in string.split() if var in dir())
print(variables)
!e
from fishhook import hook, orig
@hook(str)
def __repr__(self, *args, **kwargs):
string = orig(self)
for word in string.strip("'").split():
if word in globals():
string = string.replace(word, globals()[word])
return string
var1 = "hello World!"
foo = 'var1 :)'
print(repr(foo))
@paper sluice :white_check_mark: Your eval job has completed with return code 0.
'hello World! :)'
@slate swan :white_check_mark: Your eval job has completed with return code 0.
<generator object <genexpr> at 0x7f1e5b73fca0>
i checked on stack and they used globals() not the keyword*
yup its being used here by ryuga
thats neat
thank youπ
yup you can use dir(), globals() and locals() depending on the situation which dir() returns a list and the others return a dict
dir returns a list
i swear i remember it returns a dictπ
guess i got confusedπ
!e a=1; print(type(dir()))
@slate swan :white_check_mark: Your eval job has completed with return code 0.
<class 'list'>
it does when u do somethig like dir(object)
globals() and locals() return a dict
nop wait im tripping
wanna see something funny?
ik
π
hmm what do u think would be better i keep a json loaded in gloabals and then use dir() or globals() for command or open when its input in the command
@slate swan :white_check_mark: Your eval job has completed with return code 0.
a
!e
a = "hi"
inp = eval("a")
print(f"{inp}")
I was testing something
@maiden fable :white_check_mark: Your eval job has completed with return code 0.
hi
ye that's the way
π
U cannot do that, globals() returns a dict which would have a structure smth like: {"ctx": Context_object} and those objects ain't json parsable
i would use globals imo
wdym? i have a json like read = {} and if they do like read and some key i print read[key]
print(globals()[input("What var value should i show?\n"])
is a good example
how do i get command name
The name of the command.
oki thx π₯°
this thing
is ctx.name enough
thats the functions name which is probably the same
this chat keeps dying
ryuga revive it
he has spokenπ
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Context' object has no attribute 'stname'
now ask bot questions π« π±
async def streaming(self, ctx, *, stname):
await ctx.message.delete()
stream = discord.Streaming(
name=stname,
url="https://twitch.tv/elraenn"
)
await self.bot.change_presence(activity=stream)
await ctx.send(f"```toml\n[Activity Changed]: Type: {ctx.command.name} Status: {ctx.stname}```", delete_after = 5)
yes it worked 
help
It's Alive
what
the chat -_-
help me
ur doing ctx.stname, i think u just want stname
i should be more specific
!e
import io
from contextlib import redirect_stdout
with io.StringIO() as buf, redirect_stdout(buf):
import this
output = buf.getvalue().splitlines()[3]
print(output)
@paper sluice :white_check_mark: Your eval job has completed with return code 0.
Explicit is better than implicit.
!e import this
@slate swan :white_check_mark: Your eval job has completed with return code 0.
001 | The Zen of Python, by Tim Peters
002 |
003 | Beautiful is better than ugly.
004 | Explicit is better than implicit.
005 | Simple is better than complex.
006 | Complex is better than complicated.
007 | Flat is better than nested.
008 | Sparse is better than dense.
009 | Readability counts.
010 | Special cases aren't special enough to break the rules.
011 | Although practicality beats purity.
... (truncated - too many lines)
Full output: https://paste.pythondiscord.com/sarujekoha.txt?noredirect


is theres any way i can get loaded commands
like in every cog
all the commands registered?
yea
i guess
!d discord.ext.commands.Bot.commands
property commands```
A unique set of commands without aliases that are registered.
Cogs probably have it too
don't put me on
the docs please
{len(ctx.commands)}
!d discord.ext.commands.Cog.get_commands / walk_commands
get_commands()```
Returns the commands that are defined inside this cog.
This does *not* include [`discord.app_commands.Command`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.Command "discord.app_commands.Command") or [`discord.app_commands.Group`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.Group "discord.app_commands.Group") instances.

its a method of the Bot class not the Context class
what was the doc link for subclassing help command?
!custom-help
Custom help commands in discord.py
To learn more about how to create custom help commands in discord.py by subclassing the help command, please see this tutorial by Stella#2000

π there is teg for it
!d discord.ext.commands.HelpCommand
class discord.ext.commands.HelpCommand(*args, **kwargs)```
The base implementation for help command formatting.
Note
Internally instances of this class are deep copied every time the command itself is invoked to prevent a race condition mentioned in [GH-2123](https://github.com/Rapptz/discord.py/issues/2123).
This means that relying on the state of this class to be the same between command invocations would not work as expected.
thx
this is the first time im seeing this
sem, when was this added?
been there since at least more than half a year iirc
how do u look at all past commits on github?
was sent for the first time on 26/3/21
it's pretty detailed
why not just search for the embed's description in the discord search bar lol
smort
ya i can do that, but i want to know about that
anyways you can just click on the "last commit" on the code page it will list all the commits
ah got it, thanks
can I not hyperlink text in discord titles on embeds?
use the url kwarg
Embed(title="hyperlink", url="https://uwu.you")
!d discord.Embed
class discord.Embed(*, colour=None, color=None, title=None, type='rich', url=None, description=None, timestamp=None)```
Represents a Discord embed.
len(x) Returns the total size of the embed. Useful for checking if itβs within the 6000 character limit.
bool(b) Returns whether the embed has any data set.
New in version 2.0.
For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") for you.
Changed in version 2.0: `Embed.Empty` has been removed in favour of `None`.
me who was using embed.title.url for 2 hrs unable to figure out how to get an embed's title url
Its fine sarth, I know the feeling
π

int(
event_2.message.embeds[0]
.description.split("#:")[1]
.replace(".", "")
.replace("`", "")
),``` and then i did this, too proud.
why is yhat relatabt
ugh
π i forgot strip was a thing for a while
i mean its really the title's url so...
Its the embed's url
dw, i understand ash, you dont need to edit it million times
π i forgor
this reminds me that i need to impl bot vars to pykawaiis client
I dont know why there were a million typos in that
but i wont until its a commit thats worthy
wait how would that work?
phone moment?
you just set an unknown amount of kwargs in your client lol
U don't implement those yourself.......?
but you do 
and sleep, I have a good accuracy of 88% on phone
basically using setattr
yeah it seems like that
ig but you wouldnt need to use the dunder lol
And how would u possibly do that?
class A:
def __init__(self, **botvars) -> None:
...
i just set an unknown amount of kwargs
class Foo:
def __init__(self, **kwargs):
for key, value in kwargs.items():
setattr(self, key, value)
``` ig?
noooπ
!d object.setattr exists...
object.__setattr__(self, name, value)```
Called when an attribute assignment is attempted. This is called instead of the normal mechanism (i.e. store the value in the instance dictionary). *name* is the attribute name, *value* is the value to be assigned to it.
If [`__setattr__()`](https://docs.python.org/3/reference/datamodel.html#object.__setattr__ "object.__setattr__") wants to assign to an instance attribute, it should call the base class method with the same name, for example, `object.__setattr__(self, name, value)`.
For certain sensitive attribute assignments, raises an [auditing event](https://docs.python.org/3/library/sys.html#auditing) `object.__setattr__` with arguments `obj`, `name`, `value`.
!e
class A:
def __init__(self, **botvars) -> None:
pass
ok = A().botvar = 1
print(ok)
@slate swan :white_check_mark: Your eval job has completed with return code 0.
1
Yea
U don't need to accept the kwargs
!e ```py
class A:
def init(self) -> None:
pass
ok = A().botvar = 1
print(ok)```
@slate swan :white_check_mark: Your eval job has completed with return code 0.
1
just init(self)
guess i dont need to make a commitπ
actually you dont need the init too kek
yeah lmao
its an example
π¦
how do i make a command like that if the command user deletes his command message then the bot too delets it's response on that command huh?
use bot.wait_for('message_delete') with proper checks to check if the user deletes his message
then what should i add?

blue eyes
looks like someone dropped ink on em
client.wait_for('message_delete',check = lambda message: message.author == ctx.author)
await gg.delete()```
it is deleting message on its own help pls
i didnt even dellete my msg
how many global emojis were there?
sarthak showed me them
check the message id too, message.id == context.message.id
you cant really know its just some servers have them
how do you even use them...
so if u join those servers you get access to global emojis
i can send you the links of the servers if you guys want? just ping me in and ot channel and ill send the links
just like normal emojis, join the server, used them as if you have nitro but limited
ohh
12 am, cope
client.wait_for('message_delete',check = lambda message: message.id == ctx.message.id)
await gg.delete()```
this?
yes that would work
not working it is deleting the msg soon it responds
12 am there?
yes
yeah
you got the answer.. π
how would i make my bot wait a few seconds between doing things in an event
show full code
asyncio.sleep(seconds), its a coroutine
ok now it's working lmao it just needed an await
welp i gtg cya gn have a nice day ahead
how're you so smart
night night, have a good sleep
cause hes from in...
ask oki, he more
no im not indianπ
how does that matter
cause yall smart 
hunter is indian and look at him
Indians are comparatively smarter
yes
π§’ why do ppl think this L;
maybe im indian
sarthak adopt me
me too

i'll prefer being hunter for a while
!ot
Off-topic channel: #ot2-never-nesterβs-nightmare
Please read our off-topic etiquette before participating in conversations.
π
no your leaving like my dad damnπ
I was gonna say that l, nooooiiii
the embed on phone....it just effing floats upwards
on reacting continuously
yeah
it buggs out
the embed is slowly segfaulting
Can I just take a moment and say thank you to the regulars here? Haven't had any issues coming from pride month
So ya, y'all rock
i have an idea brad
make us helpers
lol
π
Helpers get nominated, and then voted on
nomitate use and vouch for us
Might be worth asking for a reaction role permission instead?
Mods have told numerous times before, the reason why there are no reaction perms tbh
increase the slowmode instead
ash shhhh
if embed.color == 16777215:
return 1
elif embed.color == 8060813:
return 2
elif embed.color == 5808355:
return 3
elif embed.color == 11360483:
return 4
elif embed.color == 16314629:
return 5
elif embed.color == 15344162:
return 6```
this function took me 2 hrs to make
!sm s #discord-bots 120s
β The slowmode delay for #discord-bots is now 2 minutes.
lol
yey 
I changed it back
no 
But back to the helper thing, it really is through nominations and voting, as far as I know no one has made it through with a shortcut, even if they are nominated by an owner
democracy, you love to see it
at least brad's humourous
brad vouch for us
we cool right
no
Yeah we are all cool
ashπ
brad: your pfp is creepy adorable π
what can I say except you're welcome
Thanks, Jeb is from Kerbal Space Program and is a pretty awesome Kerbal
π
I've been to the Mun, Minmus, Eve, Duna and Laythe (I guess orbiting Jul counts?)
hello and what is going on here π
π
I think ot channels exist, brad
why not something in our solar system, we need a new place to stay 
:incoming_envelope: :ok_hand: applied warning to @velvet compass.
I started it from here: #discord-bots message
he was saying how cool we are
well thank you π
not you robin
do that with Lemon
watch me get banned

would be fun
wow its like thatπ
πΏ
I still remember Eivee (don't mind the spellings) invoking the ot commands cz lemon was taking about ot stuff
So... discord bots?
weird name, but srsly, lemon
lets go to #ot0-psvmβs-eternal-disapproval guys!
the owner
no comments
Nah, its just in the right place 
#ot0-psvmβs-eternal-disapproval
Better not go there unless u wanna see some..... nvm

https://paste.pythondiscord.com/xohunayide
this is over doing it?
what u doing
idk, i figured i could use asynccontextmanagers to handle exceptions instead of two try-excpts
How can i make so the error message also deletes the embed of another command?
!d discord.ext.commands.Context.send
await send(content=None, *, tts=False, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=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.
This works similarly to [`send()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") for non-interaction contexts.
For interaction based contexts this does one of the following...
^ it has a delete_after keyword arg
File "C:\Users\sethh\Desktop\Projects\self\main.py", line 1, in <module>
import discord, rich, colorama, os, colored, requests, json, asyncio, urwid
ModuleNotFoundError: No module named 'discord'
why not work the module is installed
What code editor do you use
vsc
Do you use venv
whatsup bertie, hru?
pretty good, i'm afraid we gonna have to stay ontopic so we dont get warned
yep
@slate swan
@bot.command()
async def chat(ctx):
await ctx.send('I\'m good, hbu?'``` very weird syntax error :D
Missing closing bracket nothing really weird
U must've missed the joke :)
Thought it was kind of joke
I was 'chatting' with okimii while staying on topic
dont know its an advanced errorπ
Compare their top_role
and im good
!d discord.Member.top_role
property top_role```
Returns the memberβs highest role.
This is useful for figuring where a member stands in the role hierarchy chain.
ikr 
π
Docs are cool
yes
But not docs for java libs
src 
I didn't read any java docs
Hope you never will
I got my brain destroyed after trying to figure out what method should I even use
but learning java (oop language) before dpy was like skyrocketing difficulties downwards
java can be cool af
but c# still is a betterjava
Well in what context are you trying to implement that stuff? Like mute command? Then like this
@bot.command()
async def mute(ctx, target: discord.Member):
if ctx.author.top_role <= target.top_role:
await ctx.send("Too low role")```
Yeah
It's hard to do anything with java especially with gradle dependencies without IDE
then a viking just spawns and creates minecraft
god I make so many grammar mistakes now
btw we won't go to ot
How do you even get who deleted the channel?
audit logs
Nah you should use venv
jsons better
How is json related to venv dude
what is venv
kind of ew but I appreciate the effort
Here's the guide on how to configure venv https://github.com/Exenifix/discord-bots-tutorial/blob/master/guide/01-installation.md#visual-studio-code
!venv
Virtual Environments
Virtual environments are isolated Python environments, which make it easier to keep your system clean and manage dependencies. By default, when activated, only libraries and scripts installed in the virtual environment are accessible, preventing cross-project dependency conflicts, and allowing easy isolation of requirements.
To create a new virtual environment, you can use the standard library venv module: python3 -m venv .venv (replace python3 with python or py on Windows)
Then, to activate the new virtual environment:
Windows (PowerShell): .venv\Scripts\Activate.ps1
or (Command Prompt): .venv\Scripts\activate.bat
MacOS / Linux (Bash): source .venv/bin/activate
Packages can then be installed to the virtual environment using pip, as normal.
For more information, take a read of the documentation. If you run code through your editor, check its documentation on how to make it use your virtual environment. For example, see the VSCode or PyCharm docs.
Tools such as poetry and pipenv can manage the creation of virtual environments as well as project dependencies, making packaging and installing your project easier.
Note: When using Windows PowerShell, you may need to change the execution policy first. This is only required once:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
a virtual environment for isolating project packages
there's None
i think they confused it with a .env file for saving configs..
how is this gonna fix me
Your packages won't be messed up
the code could be better of course but there's no other way to check who deleted a channel other than audit logs
Hello there
I hate discord limitations
by not using useless variables for example
Well that's on channel create, not delete lol
whats wrong in that?
Press CTRL + SHIFT + P and pick "Select Python Interpreter", then select one with "venv" i don't haveselec python
Screenshot
I personally think on_guild_channel_delete should pass you a member argument on who deleted the channel
wtf is that
Try "select interpreter"
And yeah seems like you already do have a venv
And it is not configured as project interpreter
Anyway let's create a new one
hmm that might be a good qol, but then people will be able to view unauthorized things. Im pretty sure only people with admin can view such things so if a bot can give u the names without having admin itself, then its kinda messed up
there's a permission to view audit logs
you don't need admin for it
and good point
but can't discord check for the perms to see the things it should pass to you? would that make things much slower?
ah right forgot about that
idk how discord checks stuff, but one check shouldn't be that expensive
also you're making a lot of API calls by checkin audit logs
so how is that any better
Perms check is something about byte shifting or smth
huh?
Integrate your service with Discord β whether it's a bot or a game or whatever your wildest imagination can come up with.
Sorry man
I forgot the problem
well
So basically you must have Member object (I dunno how'd you get it) and a Role object which you may get with Guild.get_role then just compare your role with member's top_role @pulsar bay
Yeah
Somehow they done perms calculation in just several math operations but although I know about bytes shifting and bitwise operators I dunno how they are typically used
its giving me same error ,dms
Ok
if not member.top_role >= guild.me.top_role:
#don't ignore, you're better
it called "bit shifting" and they are mainly used to do quick and easy calculations
like checking perms
It's actually detailed pretty well in the docs
Ok sorry didn't know how it's named in english
you learn this shit in your language
you don't need to get a role
you get member well... your way
russian
studied Exenifix
if i is a member object, yes
it doesn't look like it
seems like an AuditLogEntry to me
put the user
how can my bot check if the user provided a real-/full- website link? Because it still wants to check if https:// is a real website same with anything else...
if statement
could you give me an example please?
if(args1.includes something something) {
}
make requests to the url and check the status code
thats javascript-
this is a way too
am I seeing things or were there messages that were deleted...
Same, I think the person who asked either deleted the message or I am hallucinating questions now from randoms
How to add multiple languages to a bot?
I just haven't tried anything, it doesn't work for me and nothing works
how can you not try anything and have it not work?
multiple languages?
I tried to deal with gettext, then just using json files and much more, but I did not find a normal working example
Well, yes, there is English, Ukrainian, and so on.
dont just the local settings translate to the required language
Idk about u, I am already insane since months lmao
is there any git repo which has a nice embedded dpy help command?
!custom-help
Custom help commands in discord.py
To learn more about how to create custom help commands in discord.py by subclassing the help command, please see this tutorial by Stella#2000
!d discord.Interaction.locale might help you with this
The locale of the user invoking the interaction.
@rare saddle ^^^
How to work with it?
And if it already works, then how to translate the description of the slash command and its parameters?
i know that tutorial, i am asking for a copypasta repo
or one which i can import directly from pypi
A list of embeds the message has.
it returns a list which would be empty if it has no embeds
cuz u need message intent
!d discord.Intents.message_content
Whether message content, attachments, embeds and components will be available in messages which do not meet the following criteria:
β’ The message was sent by the client
β’ The message was sent in direct messages
β’ The message mentions the client
This applies to the following events...
@sick birch I have my database created on google cloud and I need help configuring the connectivity. since im getting this error
disnake.ext.commands.errors.ExtensionFailed: Extension 'cogs.events' raised an error: OperationalError: connection to server at "34.68.242.84", port 5432 failed: Connection timed out (0x0000274C/10060)
Is the server running on that host and accepting TCP/IP connections?
The folks at #databases would be able to help you better with that, I've no experience w/ google cloud
K thx
im sure someone has already made this so ill just ask here, how do you get the exact time of something happening from its discord id?
Do you want it to do it manually or have discord.py do it for you?
oh discord.py has a feature for that?
!d discord.utils.snowflake_time
discord.utils.snowflake_time(id)```
makes sense since this id system has been around for a while
it was originally used by twitter
If you're going the manual route, you can do a little bit-shifting and get it to work
ik
i could easy do it myself but if people had already done it asking is even easier
what does this return
Good point, no need to re-invent the wheel here
yea
datetime.datetime

