#discord-bots
1 messages · Page 844 of 1
I mean, people get themselves roasted rofl
why are you fetching the member when you already have a member obj of them
servers.data[10]?
basic python errors indices cant be strings
I barely know Python ☠️
First of all, dont use servers as a variable name since its already a Command name and may cause errors, second of all, servers is a list
dud making a bot without knowing python is pretty bad
For my hosting service
Connected with the API
!e
my_list = ["hello", "world"]
try:
print(my_list[0])
print(my_list["hello"])
except TypeError as e:
print(e)
@slim ibex :white_check_mark: Your eval job has completed with return code 0.
001 | hello
002 | list indices must be integers or slices, not str
you see how when i try to access the element by its actual value, it doesn't work
not another one
Usually it's the other way around
.index exists
It searches for the servers/panels created
heh
!e
lst = ["Hunter", "uwu"]
print(lst[lst.index("uwu"])
Except that is support in-efficient compared to hash maps, as list.index(x) is O(n) whilst with dict's their getitem is O(1)
💀
Rip phone sucks
speaking of Big o, I been doing tons of practice Big o problems. very fun
!e
lst = ["Hunter", "uwu"]
print(lst[lst.index("uwu")])
#please make it work```
@slate swan :white_check_mark: Your eval job has completed with return code 0.
uwu
what are big o problems
Ye
finding the time complexity of some code
oh nice
👍
and how do you do that
Usually it's very easy to guess the time complexity
Sometimes it's a bit harder, such as len(sequence)
i found out today that you can actually remove all the constants and look at the biggest term to find the time complexity
len() on builtin sequences are almost always O(1)
because the constant gives you the EXACT time complexity, but we just want to see what it will usually be
But depends on the implementation of __len__
i think so onii
!f-strings exist
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.
how do you guys suggest I make it so users can choose where to place a number?
we can move to an Ot channel if you'd like to see
i have this one recursive one where I calculate the complexity of it
isnt get_friends_count a integer though
Woah its gonna be 9 pm already, thanks caeden
np
Select menu?
hmmmmm
you just need to loop through the guild bans, and see if the user's name and discriminator is equal to the member parameters name and discriminator
i don't like them ngl
?
I never made the effort to even look them up
Worst part about learning time complexity is, realising how shit ass in-efficient your previous codes were
as in:
banned_users = await ctx.guild.bans()
for banned_user in banned_users:
user = banned_user.user
# some conditional to check if the user name and discriminator is equal to the member name and discriminator
And there goes #discord-bots
🗿 true
i haven't even heard the term time complexity before
it's always u
I'm always the bad person
indeed
Oh Developer is here
Does @unkempt canyon have an invite link? If so where can I find it?
i also found it interesting how something in a logarithm that has something raised to an exponent, that exponent can become a coefficient to the logarithm
It doesnt
And its not the appropriate channel
Lol i changed my name the moment you say that
rn i'm trying to make a dropdown where you can select roles, it's all getting messy when you have like 10-20 roles, i'm quite confused atm ngl i'm just "gonna work to that next day"
Lol understandable, but what if the roles are more than 25.....
no biggie
brirl
Roflll
Math enjoyer I see
I respect it
then no dropdown ez, or maybe they'll be able to create a second one
@slim ibex wao you were binds all this time, and you sure you 14?
I see, good luck with the next day
yeah
my birthday picker works with two dropdowns in one view
and you'd vomit seeing my code
its a computer science term relating to the amount of time an algorithm takes to run based on its input (n)
yes and yes
You're so cool
hmm okay
eh thats easy
Damn, I thought you were 19 or 20
bro everyone thinks im older than i am
👀
thanks brirl
!ot i'm still a kid who OTs
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
Wth is a brirl
i can imagine
but well, at least it works
bro girl
Lmaooo
Wait what.....
next day can be tomorrow, or maybe after 2 days or maybe never 
Imagine that day be day
my server bot uses dpy 1.6.0
how
not even 1.7
I'd rewrite it in return of nitro oh cool
lmao
Lol no
mk
dud calm down lmao
what
me: 
calm down man
!ot
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
zamn, gonna take this in consideration
!ot
lol sure
biased ot command happy noises
the code is quite old, i mean i still sometimes modify things like add new banned words in the list but never actually started to rewrite it from 0
!ot
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
commands.BucketType.channel cooldown
No?
noob
F.U.N.N.Y.
!ot
cool.story
Stop spamming lol
stop talking lol
you're off-topic
I'm out
to an ot channel?
maybe
congrats 🏳️🌈
chill
No? 
is there a way for me to get a userinput arg and a member arg?
ill try that

might typehint member to Member
member being member: discord.Member
you want an argument to be the user input?
u good?
monster
yep
how
aka the input() function?
never seen someone to import member
nah not really !pb myinput member
i always import it
Simple is better than complex.
!zen 1
true
Explicit is better than implicit.
any idea how i could do that?
typehinting good practice 
mhmm
Unless you do it wrong
Thats so inhumane-
right
watch the oneliners write a 20m spaghetti be like "bro trust me this is better"
Rofffll that was hilarious
btw is there a way that can chnge the cooldown from 50 to 30
Yes just change it in the decorator
💀 i mean for premium features yk
finally on-topic
sharing your opinion about coding
unfortunately, your opinion is bad

!d discord.ext.commands.cooldown
@discord.ext.commands.cooldown(rate, per, type=discord.ext.commands.BucketType.default)```
A decorator that adds a cooldown to a [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command")
A cooldown allows a command to only be used a specific amount of times in a specific time frame. These cooldowns can be based either on a per-guild, per-channel, per-user, per-role or global basis. Denoted by the third argument of `type` which must be of enum type [`BucketType`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.BucketType "discord.ext.commands.BucketType").
If a cooldown is triggered, then [`CommandOnCooldown`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CommandOnCooldown "discord.ext.commands.CommandOnCooldown") is triggered in [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") and the local error handler.
A command can only have a single cooldown.
Well, I suck more than my opinions...
no brirl, you don't
even tho you're ot rn
oh goodness
ot this ot that what about just stop 
Is that possible?
ion think i can update the per param in the cooldown, i only found update_rate_limit
i believe that update_rate_limit updates the rate parm
huh?
talking abt cooldown
what are you saying
wym?
just look at this
ye it works fine for me
wut r u talking abt
you said i dont think i can update the per param in the cooldown, but you can
with update_rate_limit?
no
then how ?
what are you trying to do
should start off with that next time instead of just replying with Huh
……
they are tryna update the per parameter which u just said they can do so where’s the confusion?
im trying to change the cooldown like if ppl have premium feature the cooldown is going to be like 2 something like this
yk wut im trying to do right?
ohh i get what u mean
well update_rate_limit changes the rate param
in simple words, less cooldown for special people
i dont think you can do that afaik
but does it work for per ?
nah
@discord.ext.commands.dynamic_cooldown(cooldown, type=BucketType.default)```
A decorator that adds a dynamic cooldown to a [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command")
This differs from [`cooldown()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.cooldown "discord.ext.commands.cooldown") in that it takes a function that accepts a single parameter of type [`discord.Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") and must return a [`Cooldown`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Cooldown "discord.ext.commands.Cooldown") or `None`. If `None` is returned then that cooldown is effectively bypassed.
A cooldown allows a command to only be used a specific amount of times in a specific time frame. These cooldowns can be based either on a per-guild, per-channel, per-user, per-role or global basis. Denoted by the third argument of `type` which must be of enum type [`BucketType`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.BucketType "discord.ext.commands.BucketType").
If a cooldown is triggered, then [`CommandOnCooldown`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CommandOnCooldown "discord.ext.commands.CommandOnCooldown") is triggered in [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") and the local error handler.
A command can only have a single cooldown.
New in version 2.0.
here is my code
@client.command()
async def test(ctx):
message = await ctx.send('click here for roles')
await message.add_reaction('✅')
await ctx.send('giving role to'f'{ctx.author.name} ')
and when i used the command it says both of the outputs but i want it to only say to the person who clicked the reaction
Use the wait_for method
whats that
Also, you have some pretty f-strings
!d discord.ext.commands.Bot.wait_for
wait_for(event, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits for a WebSocket event to be dispatched.
This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.
The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.
In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.
This function returns the **first event that meets the requirements**...
It waits for the event to take place
whats the difference between that and the normal cooldown?
Idk for sure but as far as I remember, I saw someone using that for the same purpose
how do i use it in my code? i dont have a variable called events or anything like that
in 2.0
wait_for is a coro that waits for a certain event to trigger, so if i put on_message as the event, the bot will wait for a message to be sent by anyone and that will trigger it
which one do you hate more?
Myself
what about when they click the reaction
:l
then it would be reaction_add
Stop that at once, its annoying
reaction_add
No?
theres a whole list of events in the docs which you can look into
ye this, mb
should've told me earlier
Thank you so much
havent used it in a while since buttons are here 🤷♂️
you still need it sometimes
!pypi discord_components uses a wait_for for button clicks so uwu
for example: which year were you born in?
sad select menu noises
noone uses that lul
either everyone uses disnake or pycord or nextcord or d.py 2.0
wait_for(reaction.add)?
seems to tell you exactly what to do
lmao
wait_for("reaction_add")
thats it?
well yea thats a part of it
part?
the full thing is await bot.wait_for("reaction_add")
oh ok
ill try
this is my code now
@client.command()
async def test(ctx):
message = await ctx.send('click here for roles')
await message.add_reaction('✅')
await client.wait_for("reaction_add")
await ctx.send('giving role to'f'{ctx.author.name} ')
and i dont even click anything it just says that immediately
yea
uh wait
forgot, you have to add a check in order to check if the reaction was clicked
so add ```py
def check(reaction, user):
return user == ctx.author and str(reaction.emoji) == '✅'
and then edit the wait_for to this
```py
await client.wait_for("reaction_add",check=check)
what does that do
checks if the reaction is the reaction you want, if it is then the rest of the code will execute
don't use emojis to compare tho, use their unicode value etc
?
str(reaction.emoji) == "\U00002705"
and why not emojis?
messed up for some text editors ig
Do y’all recommend using pycord making a bot as a new bot developer?
disnake imo
i'll say disnake
now i get this
Exception has occurred: TypeError
Callback must be a coroutine.
File "C:\Users\a\OneDrive\Desktop\discord bot\my_bot.py", line 53, in <module>
@client.command()
error says it all, no?
show me your whole code now
^^
A lot of ppl say disnake but its harder to find tutorials..
Ig
2017 
just use docs
Docs just confusing sometimes but yea probably cuz im new to this whole python thing
and join their support server, they most of the times help you
Alright
so why would you even need youtube videos or something lol
and most of the fork videos like pycord works on disnake also

Idk this stuff confuses me but ill get it one day 😂
yeah, pycord delayed their official release by 1-2 months lmao even with more devs than disnake and still bad
i really wanted to switch to pycord but when i've seen their attitude and stuff 
So u use disnake?
ye not gud
yeah, better community, better development
Do bots not catch custom errors using on_command_error or except?
Ohh
custom error?
maybe custom error handler/ per command
if you don't have one, the error will be redirected to on_command_error and it will handle it, this if you have that exact error, else it will raise it in terminal
you can create custom exceptions, if that is what you mean
i tried to make custom checker for checking a command's excecutor permissions, it works but whenever someone initiate the error, the error doesn't even get caught
def is_admin():
async def predicate(context: commands.Context) -> bool:
with open("settings.json") as file:
config = json.load(file)
if context.author.id not in config["owner"]:
raise initiator.ExecutorNotEligible
return True
return commands.check(predicate)```
I thought i can catch ``initiator.ExcecutorNotEligible`` using exceptions or ifinstance
the command works when the executor have required permissions but when they don't it just shows the error in terminal
except initiator.ExecutorNotEligible as e:
print(e)
bot.send("You are not allowed to use this command.")``` does this not work?
making error handler per command would be easier but maybe this would be useful
the predicate function doesn’t have to be async btw
do i have to use commands.CheckFailure?
if context.author.id not in config["owner"]:
raise initiator.ExecutorNotEligible
return True```
could just be
```py
return context.author.id in config["owner"]```
you can handle the check returning False in other ways
instead of raising your custom exception, whatever it is, you could raise commands.NotOwner(). What is this ExecutorNotEligible exception?
i have a list of owners in settings.json
What is this
ExecutorNotEligibleexception?
class ExecutorNotEligible(Exception):
def __init__(self, message="Initiator lacks permission."):
self.message = message
super().__init__(self.message)
wouldn't this break the purpose of my @security.is_admin()?
I’m not sure how to raise custom check errors the right way
you want an error message for initiator.ExecutorNotEligible to be sent to discord?
i want it to execute a bot.send in the channel
Where is the rest of this function?
class tests(commands.Cog):
def __init__(self, bot):
self.bot = bot
try:
# test
@commands.command()
@security.is_admin()
async def test(self, ctx):
await ctx.reply("Function executed.")
print("function tested;")
except initiator.ExecutorNotEligible as e:
print(e)
bot.send("You are not allowed to use this command.")
def setup(bot):
bot.add_cog(tests(bot))```
ctx.send, not bot.send?
That isn't how this works. Can you please rephrase again what your goal is?
commands.Bot doesn’t have a send method
Also, Bot.send() doesn't exist, and any method like that has been deprecated and removed for a long while.
no no, it should at least print the error in the correct way. I don't want this massive error traceback whenever someone without permission executes the command
^
^ as I said
How to display errors for slash commands? If a person does not have rights
You can except commands.MissingPermissions or commands.MissingRole depending on your checks
my goal is to use a function to check if the command's excecutor has the custom permission, If the executor has the permission, it will continue the func, if not, it will raise and error
Do you have several commands that will share this permission checker? If so, are they all in the same Cog?
I have it but it doesn't respond to slash commands
i am planning to
it's still one
just tryna make my terminal clean
yeah all same cog
If they are all in the same Cog, you can implement a cog_check method to your Cog class that will act as a custom check for any commands under that Cog.
!d disnake.disnake.ext.commands.on_slash_command_error
disnake.ext.commands.on_slash_command_error(inter, error)```
An error handler that is called when an error is raised inside a slash command either through user input error, check failure, or an error in your own code.
A default one is provided ([`Bot.on_slash_command_error()`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.Bot.on_slash_command_error "disnake.ext.commands.Bot.on_slash_command_error")).
@rare saddle
thanks you so much
help?
!d discord.ext.commands.Cog.cog_check
cog_check(ctx)```
A special method that registers as a [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") for every command and subcommand in this cog.
This function **can** be a coroutine and must take a sole parameter, `ctx`, to represent the [`Context`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Context "discord.ext.commands.Context").
Here just replace with on_slash_command_error ? @slim ibex
@scarlet rune An example:
from discord.ext.commands import Cog, Context, command
class MyCog(Cog):
def cog_check(ctx: Context) -> bool:
...
@command(...)
async def foo(ctx, ...): ...
# This command will only execute if MyCog.cog_check() returns True.
so this will only check the cogs in that class or the whole cog?
!d discord.ext.commands.Cog.cog_command_error
await cog_command_error(ctx, error)```
A special method that is called whenever an error is dispatched inside this cog.
This is similar to [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") except only applying to the commands inside this cog.
This **must** be a coroutine.
basically
check the cogs in that class
?
mhmm
thanks
np
tbh everything works just fine until the error traceback in my terminal comes by
What about it is strange?
Override Bot.on_command_error then.
.command has more features than using on_message as a command
i just want to get rid of this error in my terminal
raise initiator.ExecutorNotEligible
initiator.ExecutorNotEligible: Initiator lacks permission.
Wait... It says on_message

lmao
dud lmao are you going to make commands which dont take any args?
Well you just have to implement an on_command_error listener somewhere (and have it registered ofc) and it should be fine
exactly
Are slash commands a pain in the ass to implement or not really?
with .command it will be way easier
i did T_T
if isinstance(error, initiator.ExecutorNotEligible):
return await ctx.reply("No perms.", mention_author=False)```
then don't raise the exception?
I apologize for not possessing the ability to read minds, please show your full code
How do i load cogs in different folders?
Lol
i mean, i want to raise that error then make the bot catch that error by printing just the error and bot.send
don't raise it with raise keyword if you don't want it to go to console
Depends on your library. It can get a bit confusing to debug some of the errors at first (No fork I've seen has done a great job of documenting the interactions API)
Using vsc and kinda wanna go ahead and get a jump start on them before that’s all bots can use
People mostly get in trouble by using interaction followups before the response
decent, the transition is quite easy
Go ahead, if that's your thing.
It's really not that bad.
It’s not tbh I hate the slash commands but they don’t look bad
Alright thanks
the pain it will start when you will use buttons, views, select menus and other stuff like this 
And also most of the people I've seen using interactions complain about how it says the interaction failed, when they just never deferred or responded to the interaction
😔
yeah yeah hmmmmmmmmmmm
Yeah I plan on being dead by that time
🤨

I already don’t really like using / commands in general and buttons are just even worse
@attr.s
class Infraction:
id: int = attr.ib(converter=int)
member_id: int = attr.ib(converter=int)
issuer_id: int = attr.ib(converter=int)
type: InfractionType = attr.ib(converter=InfractionType)
reason: Optional[str] = attr.ib(converter=str)
issue_date: datetime = attr.ib(converter=datetime)
expiry_date: Optional[datetime] = None
expired: Optional[bool] = False
attr > dataclass
buttons are nice from the user side to use
Right. This is because they never read the actual Discord API docs, and instead refer to just the documentation for the API wrapper. The official Discord Developer Docs actually put things into perspective a lot better and a lot quicker.
Yeah but my friend said buttons are a pain to actually implement
well, just to display a button is not hard, depends what stuff you want to attach to that button
on_command_error wont handle your exception if it happens inside an event so you'd need to handle it during on_error(event, *args, **kwargs) instead
Hope fully none of this transition will be super hard
Sometimes the official docs are actual shit though, they both got their ups & downs
@scarlet rune You can't raise your "own" error in a check like that, it propagates to Client.on_error. You exception class should inherit from commands.CommandError so that you're able to handle it in on_command_error or whatever it is.
# Wrong
class MyError: ...
def check(ctx):
# This won't work, it will be handled by Client.on_error() since it's seen as a non command related error
if not condition:
raise MyError(...)
from discord.ext.commands import CommandError
class MyError(CommandError): ...
def check(ctx):
# This error is treated as a command error and can be handled in a command error handler
if not condition:
raise MyError(...)
!d discord.ext.commands.CommandError
exception discord.ext.commands.CommandError(message=None, *args)```
The base exception type for all command related errors.
This inherits from [`discord.DiscordException`](https://discordpy.readthedocs.io/en/master/api.html#discord.DiscordException "discord.DiscordException").
This exception and exceptions inherited from it are handled in a special way as they are caught and passed into a special event from [`Bot`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot"), [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error").
their error did say it happened in on_message though
Which is what I was talking about. Client.on_error saw it as an error that occured in an on_message event.
oh nvm yeah it does display that for improper check errors
just couldnt tell that their error did come from a check tho since it was shortened
ah well, since it works like that, i guess i'll just ignore the errors but pass it with cog check. Can't resolve my issue with the errors so i'll just find a workaround
how to load cogs inside folders?
folder_name.cog_name
ty
!d discord.Member.is_on_mobile
is_on_mobile()```
[`bool`](https://docs.python.org/3/library/functions.html#bool "(in Python v3.9)"): A helper function that determines if a member is active on a mobile device.
basically just checking if "mobile" in member's statuses
what are all the permissions for commands?
i know there is for roles, role id, is owner
is there more?
It's not really possible to differentiate whether someone is using the desktop or the web browser, as the desktop client uses electron, which is basically still the web version, just on your desktop and in an application
I'm probably wrong though, since web_status and desktop_status exist
Why is discord.Member.is_on_mobile a method and not an attr?
What do you mean by optimisations
ask danny
🗿
it's a property
is_on_mobile()```
[`bool`](https://docs.python.org/3/library/functions.html#bool "(in Python v3.9)"): A helper function that determines if a member is active on a mobile device.
oh
Ah, so you mean that on mobiles users won't be able to see a photo that desktop can see?
Not sure
same reason maybe
@pulsar goblet sorry for not answering, I was eating. but for the print type client, is it just writing the code print(type(client)) ? if so it didn't print anything.
I don't understand why commands.BadInviteArgument is named as such instead of commands.InviteNotFound but just human nature coming into play I guess.
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
Usually there is a work-around, for an example. This issue I was referring to, could be fixed in on swoop via embedding an attachment into an embed, thus allowing both desktop and mobile users to see it. Perhaps it's worth it to optimise commands for mobile users
This is more so of a QOL thing, I'd only do it if it's not complex
Quality of life
Could just be a shortcut like ctx.send instead of ctx.channel.send
Ok so I made a 8ball command and I have it to where it goes Question: Answer: is there a way to make it go
Question:
Answer:
people still use ctx.channel.send🗿
InteractionResponse.send() doesn't exist I think.
!d disnake.ApplicationCommandInteraction.response
Returns an object responsible for handling responding to the interaction.
A response can only be done once. If secondary messages need to be sent, consider using followup instead.
🗿
InteractionResponse.send_message() does
!d disnake.InteractionResponse.pong 🗿
await pong()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Pongs the ping interaction.
This should rarely be used.
If the interaction hasn’t been responded to yet, this method will call response.send_message. Otherwise, it will call followup.send.
andy is here
InteractionResponse.send_message() will fail if the interaction has already been responded to. Interaction.send() checks for this and does a followup. That's the difference.
This mostly just used when handling interactions over the web
interaction.send() will call interaction.response.send_message() (respond to the interaction) if the interaction hasn't been responded yet. If it's responded, then it will callinteraction.followup.send() (webhook)
that's the main thing
interaction.response.send_message() by this method
that method responds to an interaction
That's one way.
no
and most often way
@client.command(aliases=['8ball'])
async def _8ball(ctx, *, question):
responses = ["It is decidedly so.",
"Without a doubt.",
"Yes - definitely.",
"You may rely on it.",
"As I see it, yes.",
"Most likely.",
"Outlook good.",
"Yes.",
"Signs point to yes.",
"Reply hazy, try again.",
"Ask again later.",
"Better not tell you now.",
"Cannot predict now.",
"Concentrate and ask again.",
"Don't count on it.",
"My reply is no.",
"My sources say no.",
"Outlook not so good.",
"Very doubtful."]
embed=discord.Embed(title="8ball", url="", description="", color=0xFF5733)
await ctx.send(embed=embed)
await ctx.send(f'Question: {question}Answer: {random.choice(responses)}')```
Is there a way to make the response go in the embed? Or is it impossible
cause it's responded already
Wdym? interaction.response.pong() is clearly the most used response method
You can't even respond with a ping, you can ack a PING interaction type via PONG
This is only sent when handling interactions over web anyways
Yes, put the choice in the embed description or a field, the title, etc
also pong should be rarely used - said the docs
With how discord.py is designed there shouldn't even be a chance for the need of pong to be used
sends a webhook and do stuff with it, which doesn't affect your bot's ratelimit
It's all over gateway
it's useful for big bots
I’m ass at this so dumb it down lol
Isn't PING only sent through web handling?
You guys have heard of satire, right?
Like the answer choices?
class discord.Embed(*, colour=Embed.Empty, color=Embed.Empty, title=Embed.Empty, type='rich', url=Embed.Empty, description=Embed.Empty, timestamp=None)```
Represents a Discord embed.
len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.
bool(b) Returns whether the embed has any data set.
New in version 2.0.
Certain properties return an `EmbedProxy`, a type that acts similar to a regular [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") except using dotted access, e.g. `embed.author.icon_url`. If the attribute is invalid or empty, then a special sentinel value is returned, [`Embed.Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty").
For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") for you.
https://cog-creators.github.io/discord-embed-sandbox/
This might be helpful if you want to fiddle around
It's missing some stuff, but should give you a general idea
discord could've done a wayyy better job at documenting embeds
Discord sucks at documenting stuff
Half of the things you need to manually check, like providers etc
It was a pain for me
Their entire API is pretty poorly documented for the scale that it operates at
I know how to use embeds I just don’t understand how to make it pick the random aswell as put the question and answer in the embed
oh shit
That query builder is gonna be a pain in the ass to build
bro the hype around graphql is like nonexistent now
wait which one? i did watch a firebase one recently^
I mean they're improving their users' experience on Discord by increasing the clutter that the interactions API introduces, of course.
I would actually be fine with a graphql API, would make large requests super minimal without needing useless shit
@pliant gulch
But, alas discord is hard at work figuring out what intent to gate next
Probably voice, since voice recv
I don't remember!
God I hope the group behind modelling the slash commands GUI gets fired for their crime against humanity
naw the people who did modals
did you see how it fucking works??
I'll send a raw payload rq holdon
Actually helped with the code more then I thought thank you!
👍 Of course
https://www.youtube.com/watch?v=vAoB4VbhRzM i watched this recently, but i do remember watching a video about graphql hype and shit @pliant gulch
Firebase is a suite of tools for building apps on top of Google Cloud Platform. It's most famous for its realtime database, but also includes services for user authentication, serverless computing, push messaging, file storage, and more. https://fireship.io/pro
#databases #tech #100SecondsOfCode
This video is NOT sponsored.
🔗 Resources
Fire...
Count on Discord to not have their own public embed visualizer
{'title': 'Test', 'custom_id': '78efd6ade79246f68a30979ebfe848d1', 'components': [{'type': 1, 'components': [{'type': 4, 'style': 2, 'label': 'input', 'custom_id': 'cbed10c7028046e98e7e5158fd4a87f0', 'min_length': 0, 'max_length': 4000, 'required': True}]}]}
``` 😔
nasty
Like wtf, components inside of components
What a bad API. Reminds me of when I just abused the shit of Dyno's API with requests
Do you know Dyno? Well turns out their entire service is a lopsided house of cards
Lmao, I actually hate all this interaction bullshit as a wrapper dev. I got really pissed with how slash commands worked, at one point I even was making my own schematic language to register commands
I can break shit so easily it's hilarious. It's even more pathetic for them when you realize that they operate at a pretty big scale
Sorta like prisma and edgedb
Lmao I had to read the docs for interactions repeatedly to actually understand it
I'm a pretty stupid individual but documentation should not be that confusing
I mean why is there so much nested stuff
Well, with how modals look right now, you can tell that they will be adding more than just TextInput
The nested stuff is a real pain in the ass though
All the models basically connect with each other and it's a pain in the ass
Working with JSON is already kind of a PITA in Python with all the dict.get() or catching KeyError shit but this just makes it worse
I made a base model to build procedural classes from raw dictionaries
Pretty big brain 🧠
Classes are still massive though
Human levels of English, please lmao
Since discord sucks at answering questions does anyone know if it will be fully / commands or if there will still be prefixes
https://github.com/an-dyy/Rin/blob/bcdfd943ee45a26ed9253288b06d0af81b4d2dbf/tests/models/test_base.py an example of them, but this is the old base model before rewrite, looks different now
If you have message content intents, you can still parse message content and handle commands that way
If your bot is under 75 guilds, don't worry about it
Ok bet ion think it will ever be big so ima just finish it and eventually one day slowly switch it to slash commands
How could I run a discord bot from my own computer?
host?
If thats the word
if you wanna keep it up 24/7, just keep the pc on with the bot running. but that isn't the best
host on a vps
I plan to keep it on 24/7 anyways lol
but hosting on your pc isn't a good idea
what is difference between bot and client
bot derives from client. bot also has commands while client doesn't
!d discord.ext.commands.Bot
class discord.ext.commands.Bot(command_prefix, help_command=<default-help-command>, description=None, **options)```
Represents a discord bot.
This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") you can do with this bot.
This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality to manage commands.
in conclusion, use Bot
Some thing's don't make sense to me though
Whys that?
Like why does commands.Bot have listen but Client doesn't
There should be no reason to not let client have listen
true
but you can extend implementation/functionality in derived classes
At that point you'd use commands.Bot anyways
?
no i just uninstalled
and uninstall discord_components
and don't use client
and stuff right
what do i use
wait
in variable
Pycord sucks ass
^
so is disnake better
But anyway, they kept the discord namespace
Yes
thats fucking bullshit
Ikr
So dumb
Probably just to help people transition from discord.py to their fork
But imo, it just made everything harder
legit
Irrelevant, just import trash_lib as discord and that's it
pycord devs sucks, they couldn't even change names properly 
yo how do i react to a message with a unicode emoji
Bad practice
😔
bad practice is to import *
I forgor misremembered
I still don't like it though
Like how do we know if someone is using discord/pycord or any other fork

I think 1 thing we can all agree up on was keeping the discord name space was dumb and annoying
Well yes
Imagine you have a car then all inside it's from another brand
Trash

So I made a purge command and I want it to send a message saying how many messages were deleted after but the amount isn’t working
await ctx.channel.send(‘purged (amount) messages’)
!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.
See your issue?
In ur example purge is just part of a regular string, plain text
!e
amount = "hi mom"
print("this is my cool phrase: (amount)")
print(f"this is my cool phrase: {amount}")
@final iron :white_check_mark: Your eval job has completed with return code 0.
001 | this is my cool phrase: (amount)
002 | this is my cool phrase: hi mom
ohhhhh ok i get it
I didn’t have anything indicating something needed to be done so it just read it as a message
how do i fix this?? did i install disnake incorrectly
I don’t use disnake but I would try uninstalling it and reinstalling it
Are you using a virtual environment
yea
Also the bot.run() line shouldn't be indented
Do you have the correct interpreter chosen?
new to this but im pretty sure
What virtual environment manager do you use
i have no idea what that is all ik is im using a virtual invironment
How did you create the virtual environment
tutorial.. hmm
in terminal
Install disnake again in that terminal not your cmd
i tried several times but not working
could it be because i previously had hikari installed?
🗿

how do I indent?
fr thought my discord was lagging and i was just sitting here waiting for it to speed up to normal
!indent
Indentation
Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.
Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.
Example
def foo():
bar = 'baz' # indented one level
if bar == 'baz':
print('ham') # indented two levels
return bar # indented one level
The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.
Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines
More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation
also why are you asking that here in a discord bot channel
because I was told to come here
why
idk
what did you ask them to make them tell you to come here
The question is
By who
also that
Keep watching
It will speed up 
after many attempts i finally fixed my issue🥲
what was your issue
Install it
the library
!pypi gl
so you want to eat a bread without actually having it in your bag? 
perhaps
Pip install it first?
Restart vsc if you're using it
So I've never used .env files on VS code. (So Im not quite sure how to use them lol), what I did was "Key": "<token>" but it doesnt work. Can someone help? ;-;
You don't need a .env on vsc
Wouldnt it show up on GitHub?
!pypi python-decouple
Ngl, I prefer this over dotenv
Alright, Ill try that, thank you
I just use os.getenv 👁️ 👁️
I'm on linux so, I just export blah="..."
idk if its truthful
Don't shoot the messenger
I use it and it's good
This isn't a problem that exists for me
I use 1 & 0 for booleans in env variables
Actually, I don't think that changes anything thinking about this, but I can just run int on it and use it inside of an if statement
Is there a way i could get a message to be sent when someone buys something from my website? I'm guessing Q2Auth but i cant find any good tutorials.. Also what would be a good test hosting for a simple html php website
Does the website has SOMe API?
Envs don't store bools, if you want to use it for True/False just use integers like andy said
Or enter "" for False
Is there a way i can separate scripts in visual studio code but have it still in the same file?... Might not make sense but.
Python allows you to import Functions, variables and classes from other files
@client.command(name='8ball', description='Let the 8 Ball Choose!\n')
async def _8ball(ctx, question):
responses = ["It is decidedly so.",
"Without a doubt.",
"Yes - definitely.",
"You may rely on it.",
"As I see it, yes.",
"Most likely.",
"Outlook good.",
"Yes.",
"Signs point to yes.",
"Reply hazy, try again.",
"Ask again later.",
"Better not tell you now.",
"Cannot predict now.",
"Concentrate and ask again.",
"Don't count on it.",
"My reply is no.",
"My sources say no.",
"Outlook not so good.",
"Very doubtful."]
response = random.choice(responses)
embed=discord.Embed(title="The Magic 8 Ball has Spoken!")
embed.add_field(name='Question: ', value=f'{question}', inline=True)
embed.add_field(name='Answer: ', value=f'{response}', inline=False)
await ctx.send(embed=embed)```
It’s all of a sudden only taking one word for question?
But I havnt touched anything and it was working perfectly fine earlier
Because you copied the code and forgot to add the * as a parameter in the function
(ctx, *, question):
I only copied the embed part cause I was struggling lol
It's completely from Lucas except for the embed, not even the responses are changed
Search for you may rely on it here in the search, and you'll know.
Im watching his tutorial lol
Tutorials are bad, but the way you're implementing the code, it seems like you're on a right path 👌
Yeah I’m not tryna completely copy just watch it use it and go off my resources from what I’ve done before
just some nitpicky stuff but make sure your reponse list indents are right, and put the first item on the 2nd line,
responses = [
"response1",
"response2",
...
]
and instead of value=f'{question}' you can do value=question, same with value=f'{response}'
And it won’t mess up the embed?
That has nothing to do with the embed
nah it's just some styling things
Awesome thank you
improving readability
Just saying, you don't need to create the response variable
@client.command()
def check(reaction, user):
return user == user.author and str(reaction.emoji) == ':white_check_mark:'
async def test(ctx):
message = await ctx.send('click here for roles')
await message.add_reaction(':white_check_mark:')
await client.wait_for("reaction_add")
await ctx.send('giving role to'f'{ctx.author.name} ')
sorry i was late
You can just do value=random.choice(responses)
Learn something new everyday thanks
what are you doing mate
making a reaction command
all i have to say it learn python before making a discord bot
yea
i learned the basics
and i get this error Callback must be a coroutine.
on @client.command()
he doesnt know how functions work, the not async funtion is supposed to be under the async funtion and indented.
im pretty sure he knows that commands are async functions, so idk why he put the check funtion there instead of just putting it under it
what’s happening?
use sqlalchemy
It's pretty neat and isn't hard to learn with a quick 10 minute reading
hard coding sql gives me war flashbacks
take that 10 minutes with a grain of kosher salt
Tortoise is a good async ORM
Better than JSON
json took me about 1/3 of the lines
still better
I prefer writing raw sql though
Same
Unless I have to use LEFT and other bullshit 😔

Professional programmer
I always forget the keywords
sql is very easy to remember for me atleast
SQL is almost English 👀
^
If you forget the keywords you have like a 80% of guessing them correctly
yep that's what I do
Although I've shifted more to firebase these days
Haven't touched sql in a while
what does fetch actually do in sql, is using it multiple times a waste of resources
EdgeDB is looking real nice
with org_structure as (
SELECT id
, manager_id
FROM staff_members
WHERE manager_id IS NULL
UNION ALL
SELECT sm.id
, sm.manager_id
FROM staff_members sm
INNER JOIN org_structure os
ON os.id = sm.manager_id
Amazing code

INNER JOIN 😔
hello
!d sqlite3.Cursor.fetchone
fetchone()```
Fetches the next row of a query result set, returning a single sequence, or [`None`](https://docs.python.org/3/library/constants.html#None "None") when no more data is available.
does anyone now how to make a rank card
Bruh is it even possible to have a latency command in a cog?
yea 👀
Ight I’m just stupid ima continue trying
which one should i use
I haven't used dpy in a bit but yes
where do i put where
does anyone now how to make a rank card
sheesh guess I forgot
You’ll have to use the time module
!d discord.ext.commands.Bot.latency
property latency: float```
Measures latency between a HEARTBEAT and a HEARTBEAT\_ACK in seconds.
This could be referred to as the Discord WebSocket protocol latency.
I really hate how people do sql shit procedurally 😢
Oh right right .ext
😳 procedural is my game bro
like bro
why do
db = await aiosqlite.connect(...)
cursor = await db.execute('SELECT * FROM some_table')
row = await cursor.fetchone()
rows = await cursor.fetchall()
await cursor.close()
await db.close()
when
async with aiosqlite.connect(...) as db:
await db.execute("INSERT INTO some_table ...")
await db.commit()
async with db.execute("SELECT * FROM some_table") as cursor:
async for row in cursor:
...
exists
first one looks so fucking ugly
I have it all set up like self is taken in first and everything but it’s saying
module http.client had no at tribute latency
Idk I can’t figure it out lol I’ll prolly just put it back in my main file
Send code
Good thing I use Postgres so I don’t need to commit
does it commit by itself?
lmao
Honestly, moyai 🗿 is the best standard emoji there is
^^^
async def ping(self, ctx):
await ctx.send(f'Pong! wow that took {round(client.latency * 1000)}ms')```
speaking of aiosqlite, i need to figure out how to reuse my connection
saw something with __aenter__ and __aexit__ but that didn't work (didn't even expect it to)
can someone explain the benefit of using async sq version over normal
Those are for context managers
concurrency
i've read about async a ton of times and still don't get it entirely
so transactions don't block eachother
to be very honest
it won't make that much of a difference though
Since only one client can be connected to the database at a given time in sqlite aio isn't that much of a boost
If I take out self and put it in the main file it works perfectly fine bruh I swear cogs hate me
show the whole cog

Discord.py is in an asynchronous environment and for good reason. Your bot when setting up starts a task which sends heartbeat payloads to the gateway, essentially keeping the bot alive. If you block your code, this could be by non async sql queries etc, for long enough your bot will just disconnect as you blocked the heartbeat task
noone?
from http.client import responses
from typing_extensions import Self
import discord
from discord.ext import commands
class Utility(commands.Cog):
def __innit__(self, client):
self.client = client
@commands.Cog.listener()
async def on_ready(self):
print('Utility is online')
@commands.command()
async def ping(self, ctx):
await ctx.send(f'Pong! wow that took {round(client.latency * 1000)}ms')
@commands.command()
async def purge(self,ctx,amount=1):
await ctx.channel.purge(limit=amount)
await ctx.channel.send(f"{amount} messages were deleted", delete_after=5)
def setup(client):
client.add_cog(Utility(client))```
I'm assuming that you have "self.client" somewhere in that Cog so you'd have to change it to self.client.latency
Doesnt the run method on the bot instance send the heartbeats or is there a different task for that too?
interesting okay
oh no no http.client has nothing to do with your discord bot's latency
get rid of all that and just use ^^
Short answer no, long answer technically speaking yes
def innit, nice naming conventions
no one
And your self.client should be an instance of commands.Bot and not discord.Client
and ur innit needs to be __ init __
I see xD
I cba to explain how the connection to the gateway works rn so
I didn’t even notice I put a extra n lol
XD, its alright
__init__
and use bot instead of client
I have no clue what was fucked but it’s fixed now thank yall!
I mean, we all have the same amount of eyes
pain 😔
I fount the solution I was a idiot lol
What is is http_exts, if you dont mind telling?
Gonna be honest I just ended up clicking hot fix until no more lines showed up lmfao
And it put me in more shit lol
I was commenting on how much you followed pep8
ah yes, he knows about *
didn't know about namedtuples tho
i want to make some basic discord bot ! commands, ik the basics but can seem toi figutre it out, any help would be very appreciated
only issue with namedtuple is the syntax for creating it and no types
i would use NamedTuple from typing
but here you prolly don't want a whole class definition so
and tuples are immutable
i've had basically zero experience with classes so far, i haven't found a reason i need them yet
surprising
classes are extremely useful
and you shouldn't be jumping into dpy without OOP knowledge
🤔 actually maybe it's time to use one
i've been passing player data from function to function this whole time
uh yeah classes exist
be careful with shared mutable state though
i know what all three of those words mean but shared mutable state in combination make zero sense to me
but it is 4am, i should probably sleep
its just when two objects can change the same data and they overlap
it can cause one object to stop working correctly
so be careful not to overwrite a players variables with another players?
oh or
i kinda see what you're saying
that's just polymorphism I believe
like when you define print and it breaks print
Can you give an example?
well if you have many classes that are related, polymorphism (overriding) allows there to be many forms of it
like an Animal base class can be the base class for a Snake
where the Animal class has a method that resembles the sound the animal makes, and Snake overrides that method to be specific to the snake
So can you?
1 sec
Ok ty
i think he means class instances that are asynchronous
?
class instances that arent in the same state or something like that

im not sure what youre referring to it seems like maybe youre getting confused with inheritance
Different instances are supposed to have different states
yeah
is there a quicker way to do this
oh shit dataclasses pls
I'm just trying to figure out what shared mutable state is
wdym when the state changes for all classes?
so classmethods?
This is what moai said ^ but I don't really understand
same
You can take variadic kwargs and use setattr and for loop ig?
dataclass the same but you just define attributes like this?
okay neat
like making sure a type is something at runtime
how is a dataclass more work
Not a really great way to do that but I'd just use a dictionary
And no, it's not more work
Dataclasses are better
It's more overhead, a dict will be more efficient
if i use a dict i will have to pass it back and forth between a lot of functions
idk im just gonna do this so i learn how classes work while im doing it, it can be a lil slower
dataclasses work exactly like a regular class
yeah idc im just settiling on using discord.py all these other ones are too weird
it worked 🥳
PascalCase for classes
User in your case
And don't use Sqlite for a discord bot
if it is small, it should be fine?
wait wont i have to pass player between functions anyway
asqlite (preferred, same guy who made discord.py), or aiosqlite
aiosqlite pog
Yea sure then
but just to keep it consistent, aiosqlite would be better
personally i don't like either since i hate writing sql but asqlite seems to be preferred by many
asqlite ,aiosqlite& Sqlite are all same in terms of syntax and queries, the methods and classes remain almost same too
😶🌫️ but yea it's true SQL fails to work conveniently in many cases
not really aiosqlite is way more maintained than asqlite
asqlite is not even added to PyPi
🙃
that's just what i'm hearing since it has better defaults
which i gotta agree with, row factory is much better than whatever it has normally
the weird tuple structure
its just the async bridge of it, you wouldnt see much change only some methods are coroutines but you would execute everything all the same and queries are the same
Yep
pretty easy to learn in my opinion.
I mean, just learn some raw SQL and you know it all
just learn sql and just play around with the lib
i need to know how to reuse my aiosqlite connection, but i'll do that tmmrw
wdym by reuse?
the aiosqlite.connect() object i assume
do you open a connection on each query?
i connect to the db in my subclassed bot class, but i don't want to have to open a connection every query
tie it to your bot var, preferably not in on ready
just keep the connection open permanently
i connect in an overridden start method
just have a connect method on a connection to the gateway and not on ready
so it would be on_connect
a start method? or
ye
the way i do it:
class Bot(...):
...
async def main():
myBot = Bot(...)
myBot.con = await aiosqlite.connect(...)
try:
await myBot.start(...)
finally:
await myBot.con.close()
asyncio.run(main())
if you want lol
can anyone help mw with some bot basics?
bot = Bot(...
@bot.event
async def on_ready():
asyncio.run(connect())
async def connect ():
await bot.wait_until_ready()
bot.db=# make connection```
is what I'd do
uhm
bad
I wouldn't do that
i had it in overridden connect before
Explain
oh, classes are actually really simple
asyncio.run() should really be only used as a starting place for your code, so on_ready() can get called multiple times and screw over the event loop
async def start(self, token, reconnect) -> None:
DB_PATH = "./bot/db/bot.db"
async with aiosqlite.connect(DB_PATH) as self.db:
BUILD_PATH = "./bot/db/build.sql"
if os.path.exists(BUILD_PATH):
with open(BUILD_PATH, "r") as f:
await self.db.executescript(f.read())
await self.db.commit()
await super().start(token, reconnect=reconnect)
i have this rn
On ready is a single time event
this should open and gracefully close a connection
on ready can trigger multiple times as it gets triggered on cache population i suggest you use on_connect which only gets triggered once and its when the bot connects to the gateway
unfortunately no
on ready can be fired multiple times.
Oh my bad
seems like on_ready also can get triggered multiple times
^^
that would work alright as well
my method?
given that you use asyncio.run(start(...)) on it
yah
as i said?
ah no, I don't
from bot import Bot
import logging
def main() -> None:
logging.basicConfig(level=logging.INFO)
bot = Bot()
bot.run()
if __name__ == "__main__":
main()
this is my entry point file
Won't self.db close the connection as soon as the context manager is out?
or you ment on connect?
sorry, meant to say on_connect
ah well im not sure on that tbh
unfortunate, don't know if we have a one-time only on_ready sort of thing built-in
would i, asyncio.run(start(...)) before bot.run()?
the former is a lower-level approach to bot.run() so only do one or the other
ok, so I can just keep it as is
useless class instance
are you using both?
no, i only have bot.run()
yeah that works but it's not as flexible imo

