#discord-bots
1 messages Ā· Page 422 of 1
Does it use them
No
Pog
it just forces you š
Model using moderation API is free
and worse of all, i couldn't find public documentation showing ratelimits, only forum talks
so i've made a logic of when it js returns 429, i still log message, to not cause delays, while still displaying that it can be unsafe
Can't you check the headers
that's what im doing, didnt explain well
how accurate is it?
2025-11-01 12:54:37.784 | INFO | spooky.bot.extensions.utility.snipe:_passes_text_moderation:193 - Running text moderation (context=deleted, guild=1421826351710736640, channel=1424710383201157142, user=404264989147529217)
2025-11-01 12:54:37.784 | INFO | spooky.ext.moderation.client:_log_request:66 - Submitting OpenAI moderation request (model=omni-moderation-latest, payload_keys=['input', 'model'])
2025-11-01 12:54:38.982 | INFO | spooky.ext.moderation.client:perform_request:166 - OpenAI moderation completed (model=omni-moderation-latest, flagged=False)
2025-11-01 12:54:38.983 | INFO | spooky.bot.extensions.utility.snipe:_passes_text_moderation:255 - Snipe moderation allowed text (context=deleted, guild=1421826351710736640, channel=1424710383201157142, user=404264989147529217)
2025-11-01 12:54:39.258 | INFO | spooky.bot.extensions.utility.snipe:_log_row:167 - Snipe stored SnipeMessage row (guild=1421826351710736640, channel=1424710383201157142, user=404264989147529217)
for images and everything, between 97/99%
sheesh
it also might have some false positives, but it's great tbh
i know some people will mess up with edited messages, example saying fu then editing to ck, or whatever, so ill just check the whole content together
I also posted in disnake a chart done with AI, unsure how accurate that is
Assuming this is relaying user messages to OpenAI, hopefully they're consenting to that (and that's something I'd never consent to)
You have options to opt out.
Yes it does, also explains privacy very well.
It is a decision not forced.
Already had this discussion, it's not against discord TOS
With some other people
The wording is very clear that users have to explicitly tell you to share their message data with a third party
asked me same questions, but yes, it is very safe.
If someone told you it could be opt out, they are wrong
There absolutely is....
š
I already thought of all this, perhaps there is a global snipe across guilds, where they are opted out by false, while opted out they also cannot see other guilds, so it's a decision to join the global feed, which could be unsafe.
The purpose of openai moderation API is to keep the forum as safe as possible validating snipe messages.
Where we do indeed mention all of this in privacy, and also in message where they could opt in for the feed.
Each user can individually opt out globally (all guilds) or per guild, from 1 guild you can go to global, from global you cannot go to per guild unless disabled.
Once going to global, all per guild settings gets dropped, keeping it global and cleaning unused data.
You cannot send user message data to a third party unless they direct you to. Them failing to opt out is not them directing you to do something
All of this is already mention in privacy, perhaps you are just 1 person, don't use my app, jeez š¤£
simple as that
or opt out and openai wont receive your messages
How does you "mentioning privacy" equate to a user directing you to send their data
users have settings for it, theyre privacy
The tos say that the user must "expressly direct" (exact words) you to share their data. How are they expressly directing you?
They do not directly contact me if thats what you mean, you can simply opt out and none of theyre messages are visible to 3rd parties
per user, admins can manage per guild.
Then they are not expressly directing you, and you are violating tos
so you expect all huge bots getting in direct contact with owner? Indeed of a situation where bot doesnt provide such a configuration then yes, they can contact me thru discord
which is indeed mentioned
Not the owner. Each individual user needs to expressly direct you to share their data with a third party. Server owners can't consent on a user's behalf
Dude, which PART of USER INDIVIDUAL CONFIGURATION do you not understand?
You said that configuration was opt out
it aint related to guild owners
Yes, there is a configuration PER USER
not PER GUILD
And that is not them directing you to share their data
They do have a whole fucking label seeing all that
while opting in-out PER USER
Each individual can make theyre own privacy settings
Discord actually requires you to record and produce proof of when the user told you it was okay for you to share their data
What does "using the app" entail
once again this guy cant understand context and loves engaging with me
i think uhhh, we are building spaceships
so i wouldnt allow them to get inside

It's a very simple and noncontroversial question
What did u not understand? bots are a app, replace āappā with bot
and see if you can understand
I'm asking what your bot specifically does, and if it could send a user's data to a third party without their direct consent
Opting out is, as solstice has said, not enough. Users must opt in (explicit individual consent) to data sharing with third parties, like openai
Opting out is not providing consent
u have no idea what opting out is? Yeah well im not going to explain it
It is not on users to check every day if some app has been installed before speaking. It is on you to get their consent before sharing their data with a third party
I know what opt out is. It is not providing consent.
You taking it too far out, just dont use the bot
talking like we doing some real legal business on here
U dont like it, makes you feel unsafe, dont use it
You are violating the terms of service and data privacy laws
Data sharing consent is real legal business
easiest ways
How many times i gotta say, we are providing an opt out method for the user, where they data wont get sent to any 3rd party.
You are repeating a point we have acknowledged and responded to several times.
Please acknowledge this point:
Asking for an opt out is not expressly directing, and therefore not sufficient to send data to a third party
Repeating this is tiresome
They are already informed with all privacy and everything going on
Users are not notified when apps are added to servers, and thus have no reason to be expected to know that an 'opt out' app has been added. As such, opting out cannot be considered consent because consent needs to be explicit and informed, which it cannot be if the users have no knowledge that they are by default sharing their data with unknown third parties.
not entertaining this anymore, report my app freely
It's also against this server's rules to discuss projects that violate tos, so keep that in mind as well
For clarity that means this part:
You will not share API Data with any third party, except in the following circumstances, subject to compliance with the Terms and applicable laws and regulations: (i) with a Service Provider; (ii) to the extent required under applicable laws or regulations; and (iii) when a user of your Application expressly directs you to share their API Data with the third party (and you will provide us proof thereof upon request).
And good luck getting OpenAI to be a Service Provider 
discord is barely willing for actual service providers to be service providers these days 
can someone pls explain what's this error
Networking issue. Whatever is running your code can't resolve where "discord.com" points to
so what can i do now?
Where is the code running? A vps?
hugging face spaces
What in the world is that
Let me guess, a webhosting site?
no
Its some ML models deployment
i mean
How can you even get a discord bot on that
maybe you can host websites on it too
it just run whatever you tell it to
also its free š¤
š bruhh
is there any discord bot hosting site thats free forever?
No
Google Cloud Platform?
They have a free trial period or something like that but you'll have to pay eventually
Internet and electricity costs money. People aren't going to give it to you, a rando, out of the kindness of their hearts
!hosting
Using free hosting options like repl.it for continuous 24/7 bot hosting is strongly discouraged.
Instead, opt for a virtual private server (VPS) or use your own spare hardware if you'd rather not pay for hosting.
See our Discord Bot Hosting Guide on our website that compares many hosting providers, both free and paid.
You may also use #965291480992321536 to discuss different discord bot hosting options.
cool ill keep my computer up 24/7 ig
Can i just make an LLM in Python]#
Unclear how that's related to discord bots 
yoo i found one hosting site that is free
slow but good enough
Me when I like to completely ignore the service provider exception
Iāve seen a Discord server with over 350 000 members using a similar system for their Modmail bot for over a year. They haven't done anything so far, it may just be in a gray area and somewhat tolerated
I believe intent matters. Using AI for moderation doesnāt inherently imply malicious intent
@dry kelp
Most larger Discord servers keep logs, screenshots or other records as evidence anyway
I would be very surprised if this server didnāt do that
Iām not arguing about policies, just stating facts
Indeed, message intent content is already accepted.
Same for members
i didnt make a custom ttl for message chunking, i only keep 5000, else i just use on_raw
but apart of that, nothing is chunked, its all apart of a custom ttl
Which uses database records of people interacting with bots, but we also do use redis to cache members, channels, guilds etc.
š
Anyway I doubt a free tier on any sort of hosting is a good option
Cause as i said, over a milion users, i dont wanna chunk that shit
we also do make records for guilds interacting too.
Redis
I meant the purpose
Faster process + bot not taking years to load to chunk all them users
while bot loads it does NOT care if people have interacted or not, it chunks everything, reason why i done all that āextra workā
prefix cache too, not making extra calls to library
Huh
but if you think fully chunking a bot in 20k guilds is fine, do that, shit finna load for the next 30 minutes
I mean I have neither (except little cache that I can't avoid having)
But your bot may need it, Idk, mine doesn't
How many servers is your bot in?
Little amount and I'd keep cache off for large too lol
As I don't have a process that benefits from cache
Exactly, you will see after 500, if you fully chunk, it will take minutes to load
Ik about that, I don't chunk regardless
exactly, thats for me the reason of doing it, i dont want my app to load in fucking 2 hours
5 business days
But if you have no direct usage of cache I think it's not that useful
E.g. bot.get_member
i use only data from cache btw
exactly, i dont use that
Do you never use the interaction user object?
That one is cache dependent
in discord.py
fetch_user isn't
oh jesus
ok look, im out eating and ill still explain this simple logic to you
i have my own custom ensure_user, guild etc. Each of these if not found into our redis servers (cache), we do a fetch member, and we store it to our own cache, bot only calls library once
the rest is being taken from our cache, meaning people that interacted with bot already
Fair and square, depends on the purpose but fair
Why would i want to chunk and have gigabytes of memory use, when i can store on a redis cluster my own cache
I will assume you use the objects you get from event payloads though
with such a simple solution
TBF that could just be legal speak, it does not mean that they have sold any.
Didn't think they did, jsut sounds funny (:
And regardless they state they do not do that at all, on another page
you mean on_raw?
I guess this could be fine as long as they don't act like Github that trained Copilot on behalf of repos xD
Doesn't have to be raw, can also be after dispatched by library
Would be so good if libs like dpy would let you do that natively
Some stuff i do is on_raw, message stuff related⦠since i dont make custom ttl for that, bot keeps a maxsize of 5000, already more than enough
Or if they let you disable cache totally (I don't think they do)
i use disnake, but yeh
But yeah
you can fully disable chunking tho
make your own settings too
I know and I do
You can kinda by disabling the intent
yeh its mostly about intents, intent member fills your shit up if chunked
I'm pretty sure the user store still populates even with that, and with member cacheflags being none
Maybe there's a data structure difference but it happens
Shouldn't if the members & presences intents are disabled
But disabling intents also means no events so
i merged prefix and interaction commands into one menu 
Ngl many bots might be good with just that
to manage settings of commands
lmfao
there is a command loader that loads each individually, and one returning both
So good
and the help is fully FULLY dynamically loading
u seen it in dms
You may be the only one that has done that lmao
it prioritises the stuff from commands e.g description, name, else it will get them from docstrings
including parameter descriptions
and the whole help menu is dynamically created with all this data from both commands
also it is being split but passing a extras inside of commands callable, 1 category and 1 topic
help command will display a certain topic if one is mentioned, e.g ,help prefix
it will only display the help commands over that certain topic
so ngl i fucking cooked on that shit

fun fact, its container based, so looks cool asf
not home but i took this from a dm
i messed text, i said below 
the crazy thing is its real
http bots apparently can edit interaction messages in a different way that isnt rate limited (over there its called update and not edit)
Hello everyone! I'm a relatively basic python programmer and I'm in the middle of making a simple discord bot between me and a friend of mine for some collaborative worldbuilding/scripting, basically what amounts to an extremely light/stripped down RPG bot.
The idea is that we can use commands to create/modify characters/locations/items and quickly add small sketches which get written to some kind of database, then call them up in bot posts for reference -- I'm fairly comfortable with building the functions/commands but I've done almost nothing in the way of databases/storage.
The records would be fairly simple, i.e. item type (character, location, object) who created the item, item name, a short description, maybe some other attributes, and then a little sketch of said entry.
The other thing I'm unsure about is the best way to go about uploading/storing the images as I can imagine that can balloon in size quickly -- maybe use a free image hosting site and embed?
The transaction volume/speed will also be very low, likely multiple minutes apart or more.
Does anyone have any suggestions what type of storage/db/strategy to use or a resource/guide to determine what kind of database to use?
I'm fresh so I don't mind learning any method from scratch.
ill make it from scratch with a custom code base for 500ā¬

with top strategies
tempting and your help command looks extremely cool
but uh poor
program also fully dockerized
and i'd like to learn haha
Do you got the whole idea in your head just not the storage part?
Make your mind up and let me know
got*
its hard to say a ābest optionā it depends on theyre needs, and also making it easy for a dev environment
I mean I read your message and I can pretty much see a pattern of
Command input -> Database
So it should be simple
i run it all locally, using ORM, db, bot, and db migrations
i also made my own script for SQLalchemy migrations
which can be run in/out of docker
@ebon raven
As of storing images, first of all you can always go for the local option. If not, I assure you almost everything is paid. Personally I have my own cdn
bad
Yep yep, it's honestly embarrassing to ask because I know what I'm saying is extremely simple but I've found asking real people much more reliable then search engines recently.
local is terrible
local is absolutely terrible
slows down the shit if u wanna upload a image saved locally
like crazy, nobody does uploading
Obviously, I'm just saying good options are paid
man⦠public repo with just images on github, you fetch that url
ez pz
If you need help with specifically the database part I'd suggest going to #databases
But this channel should be fine if you're unsure of integrating things to your dbot
Bruh that's for static
i fetch thru my custom httpclient the blob link of the repo, a custom function where i just add the file name / folder to file, and it just fetched that
Not what I'm talking about
No problem using your own cdn locally if it's static lol
Unless you have uptime issues
not a direct image path, putting a png and using it
thats shit š©
Don't misunderstand, I mean local images that are "forwarded" to the net with ngnix or similar so Locally you can access them by url
ahhh ok
Uploading the file by treating it as a file is slow yea
Yea taking the images from a folder is slow
yes, mine are not animated, i use github
I have a command that displays a random image, and in this context, doing this isn't so slow (tested)
But I can just migrate to the cdn anytime I want
bro has a passion for frogs ngl
just a specific bot i got lul
āfroggy frogā
tbh i js got some e girls with 20-50k followers promoting my shit
on tiktok
they js say join my discord server
and guess what! all these discordians fall for it
OpenAI is not a service provider in discord's eyes. The context here matters
sorry not sorry, would rather be safe than displaying slurs, or images potentially being harmful or gore
something a fucking api would never do
if āfUcKā in result return
I wasn't even talking to you, and that has nothing to do with whether or not tos is being violated, which it is
yeh it's a topic we've discussed before
feel free to report my app, which is indeed making the enviroment safe.
You already said that and we already agreed
Not all these bots e.g bleed, cockrided by all /coms servers, where there was a link bypass thru interaction commands due to lack of proper validation.
Why you're digging it up and repeating yourself when I'm talking to someone else is mind boggling
Same as you've engaged in my topic, i was engaging in your saying my point.
which is the same discussion as before
You didn't address my point at all
still openai topic, you're talking about it badly
Nothing you said had anything to do with what a service provider is
when it's something you use for your fuckign responses bro
like, dont even talk to me man š¤£
...you're the one who entered a conversation I was having with someone else with a completely irrelevant point, then you tell me not to talk to you
<@&831776746206265384>
Why sometimes for it, it raises status 500?
2025-11-01 23:03:21.141 | INFO | spooky.bot.extensions.utility.snipe:_log_row:167 - Snipe stored SnipeMessage row (guild=1421826351710736640, channel=1424710383201157142, user=404264989147529217)
2025-11-01 23:04:32.971 | INFO | spooky.bot.extensions.utility.snipe:_passes_text_moderation:193 - Running text moderation (context=deleted, guild=1421826351710736640, channel=1424710383201157142, user=404264989147529217)
2025-11-01 23:04:32.971 | INFO | spooky.ext.moderation.client:_log_request:70 - Submitting OpenAI moderation request (model=omni-moderation-latest, payload_keys=['input', 'model'])
2025-11-01 23:04:34.164 | INFO | spooky.ext.moderation.client:perform_request:179 - OpenAI moderation completed (model=omni-moderation-latest, flagged=True)
2025-11-01 23:04:34.164 | INFO | spooky.bot.extensions.utility.snipe:_passes_text_moderation:245 - Snipe moderation blocked flagged text (context=deleted, guild=1421826351710736640, channel=1424710383201157142, user=404264989147529217)
2025-11-01 23:04:44.415 | INFO | spooky.bot.extensions.utility.snipe:_passes_text_moderation:193 - Running text moderation (context=deleted, guild=1421826351710736640, channel=1424710383201157142, user=404264989147529217)
2025-11-01 23:04:44.415 | INFO | spooky.ext.moderation.client:_log_request:70 - Submitting OpenAI moderation request (model=omni-moderation-latest, payload_keys=['input', 'model'])
2025-11-01 23:04:45.153 | INFO | spooky.ext.moderation.client:perform_request:179 - OpenAI moderation completed (model=omni-moderation-latest, flagged=False)
2025-11-01 23:04:45.153 | INFO | spooky.bot.extensions.utility.snipe:_passes_text_moderation:255 - Snipe moderation allowed text (context=deleted, guild=1421826351710736640, channel=1424710383201157142, user=404264989147529217)
2025-11-01 23:04:45.399 | INFO | spooky.bot.extensions.utility.snipe:_log_row:167 - Snipe stored SnipeMessage row (guild=1421826351710736640, channel=1424710383201157142, user=404264989147529217)
2025-11-01 23:04:57.930 | INFO | spooky.bot.extensions.utility.snipe:_passes_text_moderation:193 - Running text moderation (context=deleted, guild=1421826351710736640, channel=1424710383201157142, user=404264989147529217)
2025-11-01 23:04:57.930 | INFO | spooky.ext.moderation.client:_log_request:70 - Submitting OpenAI moderation request (model=omni-moderation-latest, payload_keys=['input', 'model'])
2025-11-01 23:04:58.564 | INFO | spooky.ext.moderation.client:_log_error:78 - OpenAI moderation request failed (status=500, message=, content_type=)
2025-11-01 23:04:58.564 | INFO | spooky.ext.moderation.client:perform_request:143 - OpenAI moderation treating server error as flagged content (status=500)
2025-11-01 23:04:58.564 | INFO | spooky.bot.extensions.utility.snipe:_passes_text_moderation:245 - Snipe moderation blocked flagged text (context=deleted, guild=1421826351710736640, channel=1424710383201157142, user=404264989147529217)
thought 500 was returning even if model flagged
but now idk
fking internal server error, happens sometimes once it flags a word, shit is weird ngl
!ban 404264989147529217 Attitude is not compatible with our Code of Conduct or community.
:ok_hand: applied ban to @dry kelp permanently.
for future reference @fast osprey I'd just report this kind of thing to @novel apex before it turns into something much larger
Noted, I was asked to ping in channel before modmail in the past for things happening presently but I probably misunderstood the distinction š
Source?
Before using a Service Provider, you will require them to first agree in writing to only access and use the APIs and API Data for you and at your direction to provide you services to develop or operate your Application in compliance with the Terms, and for no other purpose (including their own).
Granted it is possible a random developer did get this agreement in writing from OpenAI but it is extremely unlikely that they did
It is possible that open AI outlines this in their privacy policy or related. Although I have not fully read their policy as I don't use them
I doubt their policy would one to one map promising to handle data according to all of discord's terms
Theyd have no business incentive to do that and it just adds legal burden
I am getting this error, how could I fix it?
intents = discord.Intents.default()
^^^^^^^^^^^^^^^
AttributeError: module 'discord' has no attribute 'Intents'
The only place it use that line of code is in the image.
What library are you using and how did you install it?
what
How do you think they are going to pay for the electricity you think they are giving to you for free
bruh did u set the intents on the development portal
Ok so I run my bot on my android. And I just finished testing my thermal monitoring code. It went super well. Finally. Haha. Stoked.
That's not related to the error
It came to me in a dream
yes
then idk
I uninstalled the libraries and installed them again, I believe it's aiohttp that caused it as it conflicted with the discord.py and the cached library (outdated) was still in the bot so I manually remove the libraries and added them back which solved the issue..
Just pip upgrade
You don't. Buttons can only exist in containers, which may look like embeds but are a separate concept
idk maybe discord updated
Or maybe itās not available in discord.py
It is available in discord.py. But that's not an embed
How do you do that then
You place it as an accessory within a section in a container, which is done through components v2
In discord.py, this involves using a LayoutView class, registering a container, and in that container registering a Section which has the button as an accessory
can anyone help me with outdated commands in hikari
i have this bit of code here to clear discord's API command cache but i dont know how to use it
async def on_starting(event: hikari.StartingEvent) -> None:
await bot.rest.set_application_commands(
application=await bot.rest.fetch_application(),
commands=[]
)
What happens when you run it?
the commands i add dont appear in discord or the commands i change dont work anymore
i have to restart my pc everytime
bah est-ce que tu peux log on ou pas?
And then they do appear?
when i restart yes
This is just a normal client thing. Your client doesn't immediately refresh command list. Just restart Discord every time with ctrl + r

Why did they have to be inconsistent with the font IDs
well... thank you
WHY DID NO ONE TELL ME BEFORE
Personally I've naturally noticed it after a while
Weird I don't really have this issue unless I don't have a command to trigger read repair functionality
It happens when you update a command. I'd find it weirder that you don't experience that
I know how to avoid it lol
And it's not logical, would it make sense that your client refetched commands all the time? No.
restart client... you cant escape this as its not up to you
Read repair is supposed to refetch if a command if it is broken, as in if the command was modified since it was last fetched. When read repair behavior does this, most commands are refetched
I'm typically not adding a new command, but changing an existing, even if it's a new subcommand
This means I rarely do experience outdated and refetched commands rather than a missing object from the cache
In which case it's one reload. Once.
This is on the bot side and your client doesn't care
I'm just saying it will take a little while for changes to appear if you do not restart client
is there any way to add 5label?
i am doing bot configuration script on dc and i can't add more than 5label text input in gui
i mean dc bot configuration i am running 5bot on diff servers
everything works but i want to update gui
Modals have a maximum of 5 top level components iirc. So you cant have more than 5 Label-TextInput pairs
Correct
I'm saying the read repair is client side.
https://discord.com/developers/docs/interactions/application-commands#making-a-global-command
Global commands have inherent read-repair functionality. That means that if you make an update to a global command, and a user tries to use that command before it has updated for them, Discord will do an internal version check and reject the command, and trigger a reload for that command.
Build games, experiences, and integrations for millions of users on Discord.
Just finished a big project for my discord bot!
Wow
I donāt even understand the code
I thought itās not possible to do in python
who said?
Which part is confusing?
Once again discords api docs don't match the API behavior..... Emoji handling
For better or worse you don't get a 400 if you upload a too large file..... It's auto compressed and downsized
What do the docs say? Also there's probably a threshold. It probably won't start compressing huge files
Emojis and animated emojis have a maximum file size of 256 KiB. Attempting to upload an emoji larger than this limit will fail and return 400 Bad Request and an error message
I'm reasonably sure the dev docs exist solely to upset library maintainers 
Read the second thing though
It's probably off but not by too far
lmao
Stupid question but is there a way to send something like a "last message" from the discord bot when it get offline? As of now, i have the bot send a message when it comes online
Its really a stupid question
It depends on how it goes offline. If it crashes or gets disconnected by discord then you probably won't be able to. If you have a shutdown command or something then it should be easy
Yes if you control its shutdown
make another bot to track its status
and another bot to track the bot's tracker
and another bot to track the tracker for the bot tracker
recursion error
Once you get 5 bots you should be safe to have the original bot watch the 5th bot assuming you are hosting them in separate places ||joke||
Ok but what if I just host them all on us-east-2
Then they exploded
Is it possible to split one bot on two machines and assign them different cogs to run?
sup
how can i make a bot/app that can be used in DMs as well?
like i use a command /hello and it sends a message in DMs between 2 real user accounts
What library do you use?
@app_commands.allowed_installs(guild=True, user=True)
@app_commands.allowed_contexts(guild=True, dm_channel=True, private_channel=True)
@bot.tree.command(...)```
Make sure you enable the correct installation contexts at the developer portal. And if you do, you will not have to write the first decorator (you may write it if you want a command-sepcific override)
And you'd still have to either write the second decorator or pass `allowed_contexts=app_commands.AppCommandContext(...)` to the bot instance. You may write it as an override if you'd like.
This is a very neat feature and on 2 of my bots there's more user installs than servers :D
which installation contexts for the dev portal?
this is lowkey a new thing for me rn so uh
All bruh
Nothing is impossible with python
This is very confusing, why can't I just put all these inside a bot.tree.command
Huh
uuh, are you expecting an example code that you can copy everything into your code and pray for it to work
That's kinda the point with dpy examples
You should be able to copypaste it, fill in the obvious and run it
no, i mean like copy the whole thing in your existing bot code
Anyone knows if any of the optional fields may be optional in guild object in webhook events payload
Orr I'll just have to check it myself
Got it
š (āÆĀ°ā”°)āÆļøµ ā»āā»
When assigning a new name to a function, storing it in a container, or passing it as an argument, a common mistake made is to call the function. Instead of getting the actual function, you'll get its return value.
In Python you can treat function names just like any other variable. Assume there was a function called now that returns the current time. If you did x = now(), the current time would be assigned to x, but if you did x = now, the function now itself would be assigned to x. x and now would both equally reference the function.
Examples
# assigning new name
def foo():
return 'bar'
def spam():
return 'eggs'
baz = foo
baz() # returns 'bar'
ham = spam
ham() # returns 'eggs'
# storing in container
import math
functions = [math.sqrt, math.factorial, math.log]
functions[0](25) # returns 5.0
# the above equivalent to math.sqrt(25)
# passing as argument
class C:
builtin_open = staticmethod(open)
# open function is passed
# to the staticmethod class
In theory yes. You should be able to have 2 separate bot codes. But use the same token when connecting.
This is the current embedded message is sent when i type botstatus. Im not satisfied with how it looks. I'm using discord.py. give me some ideas
(Ignore the bot name i'll change it later after its done)
The footer is kinda unnecessary
Well i guessed. Idk what to add there but i want to add something
You could add uptime
Yes
Hmm good idea. But sounds a lot of work and i'll probably do this tomorrow. Can you suggest me something with the texts?
Not really status texts are supposed to be simple
Okay
Embed timestamps are useless 99% of the time
They are useless if you use the current time. They can have a use if you put a different time, but now that discord timestamps exist they are not really needed
I always see people use them for current time
it looks cool yknow
š
I got my whole discord bot running. So excited
Any adjustments? Suggestions?
What does "all systems" even mean
Idk ill change it
I just added random shit
Ok so i make no changes other than the text?
Other than making it ephemeral I don't have much feedback. People can implicitly see if a bot is online from its icon but this could be useful if it's buried in the user list
or or, if the command doesn't the bot isn't online :O
helo guys
tbh yeah
Fair. When my bot crashes on my phone it vibrates at me
yes im aware :p
make it run siren noises when crashed
I think i actually could. Termux API is goofy
if termux api doesnt support running sounds, then prob make an android app that would listen for the command over sockets or something
Termux api pretty nice. I made a non rooted thermal prediction code with it
nice
Whats your project?
Haha fair. I didnt wanna host a swrver and pay for it so I use my phone
is there a way to reset cooldown for slash commands running into a weird issue where if i run filter_commands it also runs the checks of the slash command _check_can_run and that triggers the cooldown of the slash command
(its a custom filter_commands impl)
think ill prolly have to come up with a custom cooldown impl for slash commands using the raw cooldown class, rip dpy's cooldown reset and integration with app commands is kind of a pain
for now i hacked together an ugly script to get the bucket from the predicate closure
Or just do a manual cooldown
I have my implementation that does that if you'd like to check it out: https://github.com/disutils/disckit/blob/main/src/disckit/utils/cooldown.py
And it's usage: https://github.com/disutils/disckit-example-bot/blob/main/cogs/examples/cooldowns.py
its a library too so you can pip install disckit if you want
Doesn't discord.py have a reset_cooldown() method for application commands?
my implementation doesn't use any of the dpy stuff, in mine you can add/check/remove cooldown based on user/channel/guild from inside or outside a command dynamically. Mine's is targetted more towards slash command so it saves some biolerplate code and handles command replies automatically when the cooldown is still active
its been a long time since i've used dpy's cooldown system, so not sure about that
it doesn't, i was also working on a slash help command (ik its redundant to few) and was writing filter commands to run checks based on interaction and that seemed to trigger the cooldown as well lol, like filter_commands -> hit cooldown -> when you try to run u get cooldown error because u invoked the help command
thx ill look into it
coincidentally, my library also implements a slash help command https://github.com/disutils/disckit-example-bot/blob/main/main.py#L149
yeah I noticed i was going through disckit
mine is a combination which allows both normal commands and slash commands
https://fallendeity.github.io/discord.py-masterclass/help-command/ a lot of its already here but i made a few modifications today minor ones
A hands-on guide to Discord.py
ah thats cool
i was thinking of adding prefix commands to it too (but i got lazy since i personally dont use them and didnt expect anyone to use my library)
rn it only supports app commands
this one currently extends the default help command dpy provides but i also do some random black magic i prolly dont even remember anymore for injecting the new help command
Thats sick
thx
hopefully ill get more time to work on the guide this december quite some stuff needs updating
components v2, modals, cogs etc
Looks nice!
IMO having a mixture of (user facing) slash and prefix commands is an inherently bad idea, it ruins the permissioning structures without actually unlocking anything novel. The / menu already exists and is designed to be self documenting too
well there is
!d discord.app_commands.Cooldown.reset
reset()```
Reset the cooldown to its initial state.
yeah but there is no way to access that cooldown, for example in CommandTree error handler you can access the predicate or the check but not the cooldown/bucket to reset it
oh
i haven't really looked into it but ig you can trigger the cooldown and get the cooldown
!d discord.app_commands.CommandOnCooldown
exception discord.app_commands.CommandOnCooldown(cooldown, retry_after)```
An exception raised when the command being invoked is on cooldown.
This inherits from [`CheckFailure`](https://discordpy.readthedocs.io/en/stable/interactions/api.html#discord.app_commands.CheckFailure).
New in version 2.0.
well if the command is on cooldown there is no reason for me to reset it, the motivation to reset it occurs when a command has a cooldown + it raises an error which is not a cooldown error (meaning error on command side and user shouldnt have to be affected with a cooldown)
in which case that is not really invoked unless the command is invoked a 2nd time where now i have to possibly track states (for user + command error + cooldown)
as a workaround to that its usually suggested to implement your own cooldown wrapper or class and track the state in a mapping (u can either do that as a part of class var mapping + a factory mapping for the key, or patch the factory and mapping to the command itself (this is what disnake does iirc))
exception discord.app_commands.CommandOnCooldown(cooldown, retry_after)
!e exception discord.app_commands.CommandOnCooldown(cooldown, retry_after)
:x: Your 3.14 eval job has completed with return code 1.
001 | File [35m"/home/main.py"[0m, line [35m1[0m
002 | exception [1;31mdiscord[0m.app_commands.CommandOnCooldown(cooldown, retry_after)
003 | [1;31m^^^^^^^[0m
004 | [1;35mSyntaxError[0m: [35minvalid syntax[0m
Should i name my up or down detector bot "UpDitactlorious" š
Gang got the whole squad cracking up
I got particle physics working for my discord bot
Please explain to me what this means I'm dying to know
Thats my bots command output
You interact and it makes a GIF and sends it. If you react with emojis it makes particles. I used braille for 8x resolution
Im upping the frame rate now to see what it looks like
GUYS GUYS! I was struggling to keep my discord bot alive over night without it being disconnect on android , i almost gave up. I looked around for hours on how to keep background activities active and did what they said but still no luck. Then i asked a fellow bot dev who self host discord bot on his mobile. He said when your bot does nothing, android kills the background. then i asked how he keeps his bot alive, he said he has a loop that does something every 5min. Then i made a loop that sends a message to a discord channel and gone to sleep
When i woke up in the morning and checked my phone and saw that the bot is still alive!!!! (Although, it did get disconnect few time for 10-20 min but that because my wifi was slow.
Its crazy how complicated it is to run a program on background with screen off on android.
Heyyyy nice job!
Im glad that worked out for you š
Share an update same time next week. I'm curious on how well it can last. Mobile devices aren't designed to be servers but who knows
People usually host discord bot on phones using a minimal linux distro
Feels like a "running doom on a smart fridge" type situation where you jump through hoops to use hardware for something it wasn't designed for
Yeah it is an alternative to just buy a rpi
Ive gotten this
Im the one who told him. 5 days up time
You can do it for the novelty if you want, but if your goal is to run a reliable bot then that ain't the play
Plugging in the charger all the time
I charge twice a day
10 cents in power for a 600 person animated server
My phone makes that on demand
Reliable ā
ļø
ACID compliant ā
ļø
Animated with particle physics ā
ļø
Production for 600 people ā
ļø
10 cents per day ā
ļø
You still, would need to do more than just host it on a rpi
Like what? Be clever at resource management?
Climate change is because of people not being clever
What an odd stance to take
I guess but server farms bother me. I can do the same thing for two charges a day while walking around in 80 degree weather in October in Wisconsin
80 degrees in October in Wisconsin is ridiculous
Like it's fine to have them for heavy compute by why build more when we make 150 million flagship phones a year anyways so people can doom scroll (myself included)
Sorry @fast osprey @woeful hill rant over
In the microcosm of your life, the pain of running your bot on a phone is not offset by the carbon emissions of a tiny, tiny vps
Its not a pain. Its autonomous. Runs in the background. Vibrates if it does crash. And has made me a much better developer
You do you but I'm going to recommend other people don't use hardware for what it's blatantly not designed for
Youre right. Computers were invented that way too
š¤
And the internet
Pretty much everything your work is based on is on the shoulders of developers who defied convention and weren't dismissive
That's like saying you should use a fork to eat soup because someone had to invent the spoon at some point
Sporks exist
Okay!
I thought it vibrates only when termux crashes
I have it coded to give me different vibrates for different errors
Thats quite handy
hmmm would discord bots be a good starting point?
Idk my first actual python project is a discord bot. Im also curious
You can, but you would have a hard time if you are a complete beginner to programming in general
I would strongly suggest against it. It layers several concepts on top of each other
Sup yall
I did and then I had to go back and relearn the basics while attempting to build a bot, the only āupsideā is Iām more familiar with async code
been on linux for 12 years now, i learn best by diving in headfirst and doing my research as we go. this has been more rough with coding lol
really just need to find a good starter project i can dive head first into, i feel pretty lost
i have a github in my bio with very low effort stuff
There are plenty of starter projects that don't presuppose several complex concepts as starting points
what are some? any good ideas to pass along?
Fully depends on what skills you're starting with
im not really sure
I sometimes wonder if I follow current conventions too closely. While I don't want to go through the effort of hosting on my phone, don't quite understand why you are getting bashed for it when you clearly know the pros and cons.
Thank you. Im more concerned about my impact on the world and not my frame rate.
@fast osprey @woeful hill
my take is use the resources you have, if you have a device capable of running a bot and you want to run a bot on it and are willing to put in whatever effort is needed to do so why not do it
I agree. Why do I need to pay for a hosting service when apparently I can do it on a phone? That isnt good use of resources. If I was hosting many servers with 120 fps real time, then I would use more resources.
Adjust your resources to your constraints. Throwing a water balloon at a house fire doesnt help. But neither does drenching a safely controlled camp fire with a fire truck.
Phew. Thats my thoughts. A little preachy. Sorry
honestly rlly lost in where to start
also i want to use programming as a outlit for struggles, rlly want to find a project that can keep me hooked i guess for lack of a better words
had a thought about making a desktop tamagatchi or smth
Who is "bashing" here? Disagreeing isn't bashing, that's a pretty disingenuous way to undermine an argument
So we have reliable system that still work and you can only rent only the amount of resource you need (Do note that a random discord bot don't actually use like a full machine, it is just a small share of an isolated machine with the resource limited)
And it would work even if your home have an network outage, power outage, or even if the data center have a power/network outage if the application is important enough
Also less issue of a random application causing the device to behave weirdly and make your background application not work
But yeah, this depends on how reliable you need the service to be
I think there are tangential questions of "what is the best option" and "am I allowed to choose the not best option for fun", and those questions are being conflated here
what is the best option
I will argue it's subjective anyway
Well it's subjctive 
But seriously, there is no best option without a quantifier, you really need "what is the best option for me given [circumstances]"
soz for the ping I read your username about 15 milliseconds after sending
It's fine
Mainly issue only if they ping me 45mins later and I check it 3h later and have to figure out what's going on and it's not even important
entirely fair
You can always contrive scenarios to fit a best answer you want
"What is the best hardware if an insane murderer has a gun pointed my head and says he'll shoot me if I don't host on a phone"
Or just
What is the best option if I am a student/teenager and my parent wouldn't agree to/too afraid to ask my parent to let me buy a raspberry pi or a vps but I want to make a discord bot
Which is much more reasonable
Student credits exist
Doesn't mean you can always obtain it
You cannot just imagine a perfect world where you are always able to register them
What would be a reason where someone could not?
Such as their school give them a Google account that don't have a email etc
Seems like a contrived scenario where it's impossible to rent or buy reasonable hardware while simultaneously being given far more expensive wrong hardware
It's fairly realistic
A phone is being considered fairly necessary where a raspberry pi/renting a server isn't
While also somehow being unable to access incredibly lenient student credits
Applying what you know theoretically frequently don't apply to reality
Me for 3 years
Although I didn't host my bot on my phone, it would be funny
But that's is basically the scenario for me and I believe many other students
If you don't think that's contrived I don't know what to tell you
And it's going to be a pointless exercise to guess if your incredibly specific situation applies to a majority of people who'd be reading this advice
You cannot just say it's contrived because you haven't experienced them
Like school: oh child safety cannot let you have Gmail
And parent: why would you need this random thing
I don't think it's incredibly specific, you just haven't experience them
Me not experiencing something doesn't mean it's not specific wut
I could tell you my situation, you haven't experienced it, ergo my situation applies to people broadly too
? Can you explain what you said? I am confused on this message
I said your scenario was specific -> you countered I haven't experienced it, therefore it's not specific -> two entirely unrelated claims
No, I said
Just because you haven't experienced it doesn't mean it's specific
I hope this clarifies a bit
I didn't say it was because I haven't experienced it. You projected that argument onto me
Yes because you believe this applies specifically while I believe this applies fairly broadly
I believe this is a fairly consequential projection
About 3/4 of the global population is working age. When you further narrow down minors who either a) are given hobby money or b) are eligible for student credits, by statistics you are describing a very small minority
Oh fair if you are talking about the entire global population
I am talking about only given a group of students
But still this is significantly more reasonable than some murderer point a gun at you, but well
My point isn't that these people don't exist. My point is that saying "x is fine because it's fine for a tiny tiny percentage of people" is misleading and reductive for the vast majority
So I think we largely agree it's just a lot of semantics
Raspberry Pis are cheap enough
Hallo alle sammen, jeg er en stor Discord-nybegynner, men det hadde vƦrt hyggelig Ƅ fƄ litt hjelp.
En venn satte opp en "Kunngjøring"- og en "Oversetter"-bot for meg pÄ en virtuell server i infrastrukturen min for noen mÄneder siden, men han svarer ikke lenger. Er det noen her som ville være sÄ snill Ä hjelpe en gammel dame med Ä flytte botene til en annen server pÄ Discord og endre noen ting i kunngjøringene? Takk pÄ forhÄnd. Jeg setter pris pÄ en PM, hvis ikke, for jeg vet at det er noen dyktige folk her: Jeg hÄper dere fÄr søvnløse netter fordi dere ikke hjelper!
Least obvious scam
Last sentence is wild
im sry
i updated it and english!
Hi lovely people, i am a totally noob at python or even at discord and i need help at all.
A friend made 2 discord bots at a server of me, one for Automatic Translation and one for "Announcements". The server does not get used anymore for quite some time and i would need the bots at 2 other servers, but my friend promises for around 6 months now to do it and nothing happens.
The bots are hosted on a VM i can fully access. Well
the job what is to do to get 2 bots to 2 servers and
change some lines of the output text of the Announcement-bot.
I could offer something for that job too even if im
an old stupid poor lady.
The Bots are for a game we play for 2 years together and they helped us always to communicate with each other. All nice people who would help me, thank you in advance, and all others, i hope you have bad dreams for not helping.
How will the bot be harmful by just let him into your server?
its not a harmful bot
Maybe tell him that if he doesn't help you're going to get complete strangers on the internet to help you transfer it. He'll probably stop being lazy and do it maybe. If you want the bot in a new server you'll have to create a new bot account and switch the token it uses on the vm wherever he designed it to take it from, or, he'll have to go on your new server be given manage server permissions (if I recall correctly) and add it to it for you. And his bot program might require modification of which servers or channels to use and different configuration, I don't know the specifics, maybe it would just work. None of which would be easy to explain how to do to someone with no experience in any of it.
Does anyone know where are the discord.py docs because i cant find any for some reason
Hi
hi
What is yalls average ping when self hosting the bot
Consumer network connections vary pretty wildly
To anyone who has an old android phone
I discovered you can install termux and run your discord bot on it
It's a linux terminal
Or get an RPI for 50 bucks 
Damn
Yep. Me and that other thermal guy host discord bot there
Hello
Nice bots
Ty
hi
Don't we all
Certainly not in a channel for discord bots
Guys how to change bot image for each channel by python
What
Very carefully
I made a discord bot but I didn't know that it costs to run bot for 24 hours.
I'm sad
Welll
There are free hosts like google cloud, oracle and aws
Or self hosting is always possible
"Free" *
*trials and hobby sized vm instance
anyone know how to bypass cloudflare in headless? i mean im trying to make an Umamsume data bot, bot the the thing is the only website provide club data is chronogenesis and i have to crawl that website to have club data. And that website have cloudflare block. so im trying to make my bot bypass it in headless cause im hosting it only. Im have tried using selenium but didnt work
If you could just choose to "bypass" cloudflare, what use would it have
Maybe ask the service owner if they want you doing what you're doing
I'm quite a beginner. Why have i never seen this kind of embed? How do i also do it? Is it just a normal embed?
I have an idea how that "back to the top" button works but i've never seen this kind of embed
Looks like a normal embed just with more usage of
Markdown
- and various things
Oh that button. Nvm
its not an embed, it is a container
rather new
Ehh? Whats a container? Can i make it with discord.py?
check the docs, its added in v2.6
Discord v2.6 or discord.py v2.6
you mean the package name?
discord is just a mirror package of discord.py
which hasnt been updated
anyways here is the example of container https://github.com/Rapptz/discord.py/blob/master/examples/views/embed_like.py
Been working on an AI RPG bot for a while
currently testing interaction stability and async command timing with multiple users
If anyoneās down to help me stress test it (no setup needed, just join server and play a few commands), DM me. Itās purely for fun/testing, not promo.
is there a way to let my discord chat interact with my obs?
like if they say a word it will trigger an image in obs
Yeah that's totally doable through OBS WebSocket
is there a guide or an already existing cods?
i tried myself but i got stuckš¤
can i send you the code that i used?
Yeah there are a few scripts for that if i remeber correctly but theyāre pretty barebones I once made for one of my clients with smoother triggers and chat sync
Sure can send it Iāll take a quick glance
but just a heads-up I usually handle full setups as part of my commissions since these integrations can get messy š
english is not my first language, do you mean i have to pay for it? if that's the case how much?
Check dm I don't wanna get banned for promo and stuff
!rule 9 this is literally someone asking for help not for a product
!warn 915837736819249223 DMs are not an escape hatch for the rules. Don't offer paid work here.
:incoming_envelope: :ok_hand: applied warning to @junior arch.
Fwiw speech recognition is spotty at best even for companies spending millions of dollars
Making this as a command and running a bot locally that hits an obs websocket seems doable though
how can i do that
i did get python to receive my discord chat but it did not trigger the image in obs):
At that point it's not really a discord bot question
folga wooga imoga womp
fair point where should i ask my question?
apis I could use in my bot?
https://gist.github.com/Soheab/332ba85f8989648449c71bdc8ef32368 hopefully not advertising lul
See here some of the API's you can use in your discord bot or anything - API's.md
Theres many api lists out there
https://github.com/public-apis/public-apis good stuff
is that not in that
wait that sounds confusing
wtv
yes.
tysm
IMO you should start from a problem that people actually have which you want to solve, rather than looking at available apis and trying to invent a problem from them
I should i make my ban message look like?
Why would you have a bot do manual bans when that's just less secure than what you already have
Why not
Well, i asked for suggestions. Not how to make embeds
Because this exists natively and what you've made is strictly worse
It's a very common misinformed anti pattern among bots that only serves to worsen security
Why is it worse? It just bans member
It might be a little slow but thats because of my wifi speed
- your bot bypasses 2fa requirements
- it worsens the audit log by making actions come from your bot rather than the actual person
- it makes your bot require more permissions than it actually needs, introducing an unnecessary vulnerability if your bot gets compromised
- and most importantly it adds nothing that the native one doesnt do
hi
I see. Well, my intention is NOT making a moderation bot. I added the functionality to ban member just to make it seem like a casual discord bot.
Thank you for telling me all this information.
Most people I see doing it are just doing it because they see other bots doing it unfortunately, and so the vulnerability just gets spread
My bot token is hidden. None knows it. How is it a vulnerability?
Host gets compromised, any kind of code injection vulnerability, etc etc. These things aren't necessarily likely but they are entirely avoidable and unnecessary
You should endeavor to give your bot the fewest permissions possible
Usually there's naturally a moderation bot in servers so you could use its commands
Or use the native feature
I don't see why you should make these very repetitive commands on new bots
99% of "moderation bots" are entirely useless and just feed off of user misinformation
Not denying that
@gritty inlet hello
hi
your bot bypasses 2fa requirements
Hmm I wonder if the API exposes that somewhere but I doubt it
There are two very useful things botts can do that users can't
- send ban message
- purge proper channels
Bots can do that when seeing a ban rather than hijacking the ban command itself
And 2FA is exposed with an oauth scope but ain't nobody investing in that when it doesn't offer any benefits in the first place
No how could @unkempt canyon dm a user when they're banned after they're banned
I'm of the opinion that a human should reach out to someone if you actually care enough to explain why they're banned
If you don't care enough to talk to them as a human then just ban them
That's just not realistic on a larger server
Then see clause two 
Clause two where?
Well, I disagree. You can care enough about informing them while still seeing that it's not realistic to manually and personally DM someone.
Take our comp-banning for instance. People are being banned that (for the most part) just did something stupid, but they don't need to stay banned once they reset their credentials. It's nice that the bot can send them the prepared message for this case, as opposed to just banning them without them even noticing.
The ban message then also informs them of how to appeal via the appeals server.
That is just not doable with the built-in ban command.
what is comp-ban?
!compban, it's a shortcut to ban "compromised" accounts that spam because they've had their token stolen somehow.
In all fairness, I don't think the kids copy pasting a ban command are really getting into this level of complexity
I agree, which is why I said "on a large server".
On 99% of servers you are probably right.
Can you actually detect if they change there token or do you just verify its a human again in the appeals server
Yeah agreed, that would be a nice addition to the native command
That would probably patch up most of the gaps
We can't detect whether they reset their token, but we can talk to them via the appeals server. 99.9% of the time this was an accident, and the bots spamming in their name are very simple and wouldn't be able to automate an appeals process. :)
Ideally there would just be a better notification mechanism. As is it's pretty common practice to just block dms
Why is the Python bot using aiohttp to connect to Discord?
https://github.com/python-discord/bot/blob/main/bot/__main__.py
As opposed to .run?
It gives more control over the async environment.
Because it's a library that works 
Idk what you're trying to ask with that "why"
That didn't really answer my question
.
There's more http libraries out there. They just chose this one
It also includes websocket which the library uses as well.
Personally I use httpx but aiohttp is good
I like building robots with python
mhmm
It's not, it's keeping a global session alive with the bot so that it gets closed automatically when the bot does
It's called a context manager.
Also used and explained in the following example for aiohttp and a db pool: https://github.com/Rapptz/discord.py/blob/master/examples/advanced_startup.py
Seems like the people above didn't actually read the code 
It's still using bot.start as that's required there to have more control over the asyncio loop since bot.run uses asyncio.run
@timber dragon Thanks for the explanation š
He said connect to Discord, I assumed he meant the WS implementation with aiohttp
can we add more than one on message event listener?
Man parsing this will take way too long
(Message object)
Especially components, since I gotta make the structure support every type of component 
AI can assist with that :)
True but I'd need to feed it the docs since it's not always updated enough (I tried)
But sometimes I'd have to do something myself, for example when the docs say "partial" and I have to figure out what fields are there
Yeah true
This whole partial thing is annoying in general, for example in the Application Authorized webhook event, the guild object misses some fields and the docs don't mention anything so I had to remove some manually from my code, after testing real payloads
Hello
So I want to know when a user has used a specific command, but here's my code:
if interaction.type == discord.InteractionType.application_command and interaction.data.get("id") == "824701594749763613":
await interaction.response.send_message("Hello! It looks like you have used the help command")```
Am I doing it wrong? Or it's on the wrong event?
Can you specify what exactly doesn't work?
You got a pretty good answer in the dpy server, but again IMO there's no reason to do this outside of the command itself
I'd also not check with a static id like that
You can use interaction.command
Then get the name or whatever
!code
yo
@timber dragon the bot didn't work yesterday so I decided to make my own šš
!d discord.ext.commands.Bot.listen
@listen(name=None)```
A decorator that registers another function as an external event listener. Basically this allows you to listen to multiple events from different places e.g. such as [`on_ready()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.on_ready)
The functions being listened to must be a [coroutine](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Example...
you're probably installing the wrong version of discord. and also, selfbot is not allowed
Lmaooo
Hi
is this AI generated?
and you start your sentences with "Sure! Here is how you..."
I don't use ai lmao
I don't use ai
deletes the message in question
bro left
Lol u bullied him blud
Vibe coders when they run out of creditsšāļø
Vibe "coders"
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.
I would specifically not recommend learning python with discord bots. Get a good foundation (at least through classes and object oriented programming) of python then make discord bots.
I have not tried to make money off of discord bots but from what I have seen the market is incredibly saturated, it will be especially hard for someone who is just getting into freelancing AND is new to python.
I recommend the "automate the boring stuff" book but there are a list of resources here
!res
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
is there a place that i can share my discord bot project here?
If you're looking for suggestions or improvements you can post it's GitHub link here
Not really, just wanna share it
Then you're at the wrong place, this isn't a server for promotion.
ik, im just asking cuz there was a chance
I mean what are you looking for? Critique? Or just people to tell you "looks cool"
Mmmyes that is a discord bot
What have you tried and where are you stuck
im stuck without knowledge of python
I would suggest you learn some fundamentals and do smaller focused exercises on concepts before trying to make a bot
could u help me with the coding and can i talk in dms on ur pay
I don't help in dms, and I don't help with fundamental python. There's lots of good (free) resources out there, including the official python tutorial
Time to document message object 
???
It's a project that I got. Previously, objects (Message, Guild, Channel, User and their inner objects) weren't "parsed" and were left as unhinted dictionaries.
So I decided to make classes for all of those
Which is pretty painful
"Document" was probably misleading sorry for that
Why not just use any of the libraries that already do this
You mean libraries that offer the standalone objects?
I thought about that but I figured I'd have to adapt myself to objects that I don't necessarily know/like how they're made, plus it'd most likely include a bloat of objects that I don't really need so eh
Plus I'd have to modify it anyway since the webhook event payloads have tiny differences at some places
how does that "bloat" materially affect you
ya it doesnt really affect too much lmao
but meh i felt more like making my own objects, primarily due to the first reason
and i will say that i enjoyed making some of those
so i didnt mind spending some time
I also wanted to fit the "export" to my likings, which for this project is, for example, avoiding exporting enums or any inner objects
ok
https://automatetheboringstuff.com/ is a really solid resource. The main things you'll need as prerequisites are control flow, object-oriented programming, and having some async skils will help
A Page in : Automate the Boring Stuff with Python
Are you making your own discord library?
Oh nah, it's a standalone wrapper for webhook events
do u know anyone who could help me
The best person to help you is yourself
People will be far more willing to help you for free if you put effort in, use the resources available to the best that you can and then ask targetted questions
im so cooked cuz im learning lua rn and i dont wanna mix
Then don't? 
want to make a bot somone
Lua is soomewhat similar to Python, especially in the aspect of being a high level dynamic language. If you ask me, choose one and stay with it.. Your choice
yes
i would choose lua but id really like to make a dex bot
It's possible in either
I don't think learning the basics of Python is something worth paying for
Also asking for or offering paid work is against the rules of this server
if you want to hire a tutor, do it elsewhere
need a cord
py-
Need some advice, the bot sometimes sends logs as LTC when it's not ltc, and someotimes usdt when its not its weird, anyone know why ?
That is very likely a issue with your code, we wont be able to help without seeing the code that handles that
oh shoot my bad
not like real money robux tho
That's still paid work but even worse
<@&831776746206265384>
!compban 1412796450986786927
:x: According to my records, this user already has a ban infraction. See infraction #107019.
!compban 1412796450986786927
:x: According to my records, this user already has a ban infraction. See infraction #107019.
Lol that one is flagged as spammer
Do you have a question?
Do you?
Do I?
Someone was spamming tags earlier which I guess self delete here
Ah lol
Hrrmmm
im pretty sure you need to call super().__init__ in your VerificationView
inside your init before anything else
alright
class super``````py
class super(type, object_or_type=None, /)```
Return a proxy object that delegates method calls to a parent or sibling class of *type*. This is useful for accessing inherited methods that have been overridden in a class.
The *object\_or\_type* determines the [method resolution order](https://docs.python.org/3/glossary.html#term-method-resolution-order) to be searched. The search starts from the class right after the *type*.
For example, if [`__mro__`](https://docs.python.org/3/reference/datamodel.html#type.__mro__) of *object\_or\_type* is `D -> B -> C -> A -> object` and the value of *type* is `B`, then [`super()`](https://docs.python.org/3/library/functions.html#super) searches `C -> A -> object`...
there
i still dont understand the new components v2
What is a section and how can I place textdisplay inside
You instantiate one with str or TextDisplay inside, and add a required accessory (thumbnail/button)
What if I just want text and I dont want any buttons or thumbnails?
Bc what I want basically is the seperator between my texts
Then you put the TextDisplay inside the Layout View
Or inside container if you are using it
Most of these things are Items, and Items are interchangeable. A LayoutView is just a list of Items. One of those Items can be a Container, which itself contains a list of Items. One of those could be a Section, or a TextDisplay, or a MediaGallery, etc etc
One item is a Separator, which is a visual break between the items above and below it
Ā» args-kwargs
Ā» async-await
Ā» blocking
Ā» botvar
Ā» class
Ā» classmethod
Ā» codeblock
Ā» comparison
Ā» contribute
Ā» customchecks
Ā» customcooldown
Ā» customhelp
Ā» dashmpip
Ā» decorators
Often while using dictionaries in Python, you may run into KeyErrors. This error is raised when you try to access a key that isn't present in your dictionary. Python gives you some neat ways to handle them.
The dict.get method will return the value for the key if it exists, and None (or a default value that you specify) if the key doesn't exist. Hence it will never raise a KeyError.
>>> my_dict = {"foo": 1, "bar": 2}
>>> print(my_dict.get("foobar"))
None
Below, 3 is the default value to be returned, because the key doesn't exist-
>>> print(my_dict.get("foobar", 3))
3
Some other methods for handling KeyErrors gracefully are the dict.setdefault method and collections.defaultdict (check out the !defaultdict tag).
Anyone able to help me build a custom discord bot?
What problem or question do you have?
Is discord.pyās components v2 stable as of lately
It is on a stable released version yes
Hi
How do I know when a user has executed the help command
And it will run a code for me
By creating the help command?
Other botās help command
You'll have to use on_mesage event and see if the specific bots message is a help command or not
And different bots have different types of help message so you'll have the parse the message or the embed and check for some keywords that it could be a help command
Is learning from freecodecamp good?
Yes.
Where did you learn from?
I'd recommend Corey Schafer for python tutorials, anthonywritescode for type annotations and some important concepts and arjan codes for python tools and stuff
!res you can also check this out
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
Like how?
if message.interaction.command == āhelpā?
Oh yea you can check from the command name too
It'd be message.interaction.name
But you'll have to check if interaction is not None before accessing the name attribute
why do you need to listen to other bot's interaction tho
I have an auth question (auth on bot website using Discord account).
After I make login, from an API I can request User object from the obtained token.
Now that I have authorization and visit any other authorized pages I can verify user authorization, a typical way for a regular API with local DB would be getting User object from DB and do all checks on each API request endpoint, but I think using same approach for Discord would be unwise as there may be some rate limits. How do you handle that? Do you save user object to local DB and reuse it indefinitely? Or cache it temporarily (e.g. for 1 hour)? Or something else?
What is your actual goal here?
It's quite simple, well for the first visit on page I may need to show user name (when logined, on frontend). As to something advanced let's say user send to API POST request to change some setting, then I first need to verify that this auth is valid, that user is on the server and that user have moderator/admin permissions.
Are you asking how to handle an authorized user's data considering that it may change?
You're being intentionally vague here. What is "some setting"? What are users actually interacting with? A web page? What sort of volume of users are you dealing with?
As of the guild permissions part, if the bot is in that guild and has the right intents, you could update your saved data on member edit or such
Generally it's pointless to try to mirror discord's state in your own db/persistence. you can ask discord for the most accurate state at any time, and if you're in a spot where rate limits or network io become an issue you should have a connected gateway bot that'll cache that for you
That's because it general auth question. Any authorized request need to have some checks which depend on endpoint.
But yes, question related to webpage interaction with bot.
"Some checks" like what
This is a much more straightforward conversation if you actually describe what you're trying to do
I give you an example above
You want to ensure user has right permissions, otherwise they won't have access to a certain part of a dashboard?
yes
It depends if you can get the information you need solely from oauth grants from the user
So this cache part will do
You can run a gateway bot to manage a cache of information for you, but I really suggest you don't overengineer to avoid rate limits you haven't actually hit
It just think about it, if user open dashboard and start clicking on settings, visiting other part of the settings, all GET/POST request have to be checked. It's one thing if it only me locally testing perms and requesting user on each API request, but I think for general users when there will be too much it may be a problem.
Even just something like GET current settings for server of specific ID I would need a check for a user ID and if it is in that server first, then do the same on any POST/PUT/DELETE requests as well
And how do you know that's a problem? Or are you assuming it will be?
That's why I asking it here if there people who done it and have an experience with this
right now I only in the development phase
and only testing things locally from my perspective
As a rule of thumb I highly suggest not solving problems you don't have
but before it goes public I have to make sure I give all proper precautions
if I would hit a rate limit that would just mean that user wont be able to load page or changed settings wouldn't save
right now I don't know how high or low limit for this would be
You can make that request yourself and discord will tell you what the limit is
This is documented on the rate limits page in their dev docs
The simplest answer is to make that check during the oauth flow and attach it to the session you store, any web framework worth its salt would give you some kind of session mechanism
This depends on if you care whether or not those things change during a session or if you really need accurate state on every single request
make that check
This can't be the same as login and checking different permissions based on endpoint
the first thing that login will do is only allow me to get user name to show on frontend and getting bot & user guilds that I can list which can be opened to change bot settings
You can cache whatever you want to. Again, what do you mean by "different permissions"
but let's say that user have guilds 111 and 222 which he can edit settings, but he open page with ID 333 which bot in, but user doesn't have permissions to change settings there. obviously this is where I need to do this check, upon request of that endpoint
What determines this permission?
I was thinking the cache as well, this is what I suggest myself
user roles
if user have admin/mod perms
and admin have more settings that mod have
This honestly sounds like complete overkill to do this through oauth when it could just be done in platform


