#discord-bots
1 messages · Page 408 of 1
People who are smart enough to do that are almost always smart enough to find those things themselves
Ok so 10
Can we fit all of them in 1024 character
(for why 10, I also considered interactions section one)
A pinned message would work as well. But if you limit what info is needed for each library then it helps.
I am planning on writing up a few examples and posting in #community-meta when I have time
I've updated my guides message to include the libraries too, may help 
Not sure why that message is not pinned.
Well, there are no new pin message for 2y
This probably doubly applies to pinned messages lol
I don’t need no pinned messages
What library? Or are you using the raw API? I assume you want an example of how to send a message containing an action row?
!d discord.ActionRow
class discord.ActionRow```
Represents a Discord Bot UI Kit Action Row.
This is a component that holds up to 5 children components in a row.
This inherits from [`Component`](https://discordpy.readthedocs.io/en/stable/interactions/api.html#discord.Component)...
I dont know discord.py but action rows are pre components v2
you can do this on a view, not on a modal yet
oh thats easy enough
!d discord.ui.View
class discord.ui.View(*, timeout=180.0)```
Represents a UI view.
This object must be inherited to create a UI within Discord.
New in version 2.0.
They are asking about a message in response to a modal submit
Oh then the modal is irrelevant, sending a message works the same in this regard no matter how you're sending it.
You generally don't interact with rows yourself, just use the row kwarg when making components
is there a way to persist data for buttons (i.e. self.user) upon bot restart using .add_view on bot startup?
A database
discord.py at least supports dynamic items if you can embed the info you want into the custom_id
dynamic item is so helpful
I have a button that embed:
prefix(identifier for the kind of dynamic item related)
current page
interaction page(the page to be changed on interaction)
key(identifier of what to trigger in the prefix category)
author id
https://gist.github.com/i-am-unknown-81514525/8d84ed916f3943119759354a76bf1677
An example implementation of such
d.py DynamicItem Base Class implementation. GitHub Gist: instantly share code, notes, and snippets.
So good
hi could you learn how to make a discord bot? with python or node.js jajsjsj
Given this is the official python server, you're not going to get help with the latter
Bro we’ll help you with COBOL before we help you with any JavaScript
OK, why?
Profitable - (?)
It should be faster if you idex by the column frequently
Last time I checked you don't get money for indexing the database (?
Database indexes do typically speed up reads on average, at the cost of slower inserts
You do need to make sure to use the right index on the right column, but it depends on many factors
Yeah this isn't a binary "is it indexed or not". You don't index the whole database, you add specific indices which will improve queries of a specific type
How does being Polish change the fact that you can use Google to translate?
Say what word you'd use in Polish here, I'll translate
So just say the word. I told you I'll translate it
The meaning was "is worth it?", not "is it profitable?"
Case closed
I mean I was just joking
Sorry for making it sound way too serious
whats the status of discord.py compatability with slash commands and um what are they called
interactions
Maybe harder to use than other library but should support everything except HTTP webhook based interaction(Doubt for any plan of support) and Component V2(Currently PR)
When cog starts, all tags would be read from the database and saved in memory.
this might not scale well
are you trying to use the autocomplete thing for tags
you could load just the names then, i think that should be fine up to a very large number of tags
In order to collect, aggregate, copy, duplicate, display or make derivative use of the Service or any Content made available via the Service for other purposes (including commercial purposes) not stated herein, you must first obtain a license from OLX INDIA.
Could've just said no
Would be helpful to kindly remind them to read the ToS and don't need us to read it for them
So that's why
It seems this service also has an API in which case it is likely not difficult to obtain a license. Or have allowed routes of accessing the data.
@silent pier FYI JSON stuff still works.
Dont share your token you muppet
fkk 🤦♂️
go reset them both right now
mistake'
Dont even speak. Go reset.
There are users in here who most definitely have those tokens saved already
But briefly, it looked like some online bot hosting server stuff. I'm sure they have the utility to handle environment variables in the dashboard and that's way easier to manage @silent pier
yeah donee
ig im gonna stick with env variables then, with shorter names ( but why the json breaks... im curious )
Your JSON shouldnt be breaking.
Also, you don't need longer names, just names with enough in them that you know what it is.
Also JSON is an incredibly crappy config format all things considered
"Fine" is such a meaningless term
JSON was designed to be a data interchange format between separate systems. Not configuration within an individual system. There are formats far better suited
Ahuh, sure. like what? XML?
Unencrypted config files are still not great for secrets (ex your discord token). But the format you pick is largely irrelevant if you do besides readability and size (which I'd rank JSON lower than literally every other option including .env)
TBH you have more issues to worry about than an unencrypted config file if people can get that data
Okay...?
I'm not sure how the existence of bigger problems mean you shouldn't solve smaller ones
What I'm trying to say is, if you can stop someone from getting access to the file or the data inside of it, you don't need to worry about whether the file is secure or encrypted or not.
But if someone can access the file or the contents they've already owned you.
You don't need direct access to a file to get its contents
I know, I didn't say that was the only way.
If the claim is that secret management utilities don't give any incremental security, I'm not sure why every industry shop worth their salt would use them
All I am trying to say is, if someone can already access the file or the contents, regardless of the file type or the content encryption level, then you've already lost everything.
That is just blatantly not true
How so?
Let's say you have a code vulnerability that exposes read access to the file system. It matters if you're putting your secrets in that file or in a secret manager
You haven't "lost everything". Go ahead, read my config
But you've also lost all those other files.
I dont need your tokens, I already have access to everything
What do you mean "lost". I think you're misunderstanding what a secret manager is
but again, if you move the things that are sensitive to a secret manager it doesn't matter
Honestly, I am not sure having a secret manager and trusting them not have vulnerability, with the complexity of deploying code in the background(i.e. automatic code deployment) that needs secrets to operate would be worth it
It's just the tradeoff between the security/trust of the third party and the complexity of using the third party
But if using a plaintext format, hopefully you are not using json/XML for most of them (situational dependent)
All things equal it's better to not put secrets in a flat plaintext file, but my argument wasn't that it was easier to use a secret manager (or even necessarily worth the tradeoff).
But even among plaintext config formats, some just don't make sense when used for that purpose
Yep, for the security/trust side, you shouldn't put secret in plaintext file because you shouldn't trust the read access of the filesystem not being access by thing it not suppose to
Is hard to make an discord bot? using python
Hard is hard to define, it depend on your skill level
if you are new to python, yes, it is very hard, similar to most application you make that many people would use
or if you make a user facing application with more than just a few user use, it woulld probably easy to make one by translating the skill you learnt
"it woulld probably easy to make one by translating the skill you learnt"
Sorry, can you elaborate on this? What does translating the skill mean?
like, if you make a website with server before, it would be easy to translate it to designing discord Embed because you know how to structure thing to look nice
Ah, that makes sense, thanks
you make a webserver before using fastapi so you understand the priciple for async networking which is required for making discord bot
na
Just yolo
???
Just start making one. Google some stuff and eventually you'll have a terribly made bot. Eventually you'll want features so you figure out how to make them.
Then and only then will you have a somewhat functioning bot. You'll create a community for it. YAY! \o/
You made an assumption that you can making a functional bot with it, without knowing any concept and just work through it
And you also made an assumption that they won't give up, and will have the dedication to spend a long time just trial and error, bruteforcing, with minimal feedback(or just don't understand them)
It's possible, but not easy, and you are making a very bold assumption
I mean, the only thing stopping anybody here from making a bot is their own time and dedication.
You dont need to know and understand everything going on to make a bot
Source: Me
You don't, but you just going through a even harder path
I started learning python just to make a discord bot. I knew frick all. still know frick all.
I am not saying it's not possible
I am just saying it is not easy as you claimed
¯_(ツ)_/¯
It also depends on what type of bot he wants to make.
How big he wants it. What database he wants, if any.
If he needs to use any apis for data.
If he wants to use webhooks and websockets.
If you just copy and paste from GitHub, it is not making a bot
Anything further from just copy and paste require usage of concepts that are easily confusing
If you didn't know the concept
Learn as you go I guess
Like
Why await don't work here
Wdym event loop
Well the issue is you claim it is easy
It's not
You don't need to completely understand something to be able to use it.
No, but it is the easier path
Too long. Want bot now.
Well, did OP said that?
¯_(ツ)_/¯
You just picking the very difficult path
And claim that it's very easy and making a wrong illusion
Wrap it up bro it’s time to use the best practices for once
Lol
bruh i literally gave all the proofs wdym "your json shouldnt be breaking.", IT IS BREAKING
Have you since deleted your messages? I dont see where you show the json/code that is broken
presumably yes
alr lemme reshare, deleted from here cuz i accidentally posted the tokens
You’re a genius bro
bro i know i am... dw, re-generated THEN reposted OLD tokens...
Btw the reason is the actual entry point of the script is /home/container/main.py
Therefore it couldn't find the file
There still contain information that you might not want other people to know from there
Such as your discord application id
oh wait... THANKS GAWDDD
it should have thrown a file not found error
but idk why i made an empty config.json in home/container
this is WHY
lol
Nice
I mean, the only slow part here is the network and you cannot fix it
It's not really necessary to optimise such
But the best way is don't inline it
One thing to start is having self.DATA in lowercase form
So you don't do power every time
i think you should get all the contains with first, then only run through that loop for ones where it starts with current. it would be slightly faster
if you wanted to all out you could probably use your database's full text search feature (if it has one)
Chances are you're at the data volume where you're talking about the difference between ms
preemptively optimizing things before you've done any profiling to actually find the bottleneck can be a massive waste of time
the network round trip delay with discord autocomplete is going to dominate. not many optimizations you make right now are going to help
if you're at the point where it takes on the order of seconds to search, then it could be time to look into optimizations
You can do both thing in the loop
Since they are mutually exclusive, you check the first, if not, then second
Micro optimization but if your suggestion list is huge, use generators and itertools, it's a lot faster
Hey guys I just created a drop the handkerchief bot
The permissions and desc is not updated
But yeah it does work fine
Where's the nuke command?
Then post the code
:incoming_envelope: :ok_hand: applied timeout to @flint crater until <t:1748610621:f> (10 minutes) (reason: attachments spam - sent 8 attachments).
The <@&831776746206265384> have been alerted for review.
Also <@&831776746206265384> kind of sketch someone unsolicited posting a bot invite link asking for admin
@dark perch your message was removed. Don't share bot invite links unsolicited like this. If you want feedback share the source code
uhh
i haev src code in my github
check there its totally safe
Well, you have to send the GitHub link
, we couldn't magic that out
Just don't send bot/server invite
There's also no guarantee that a random code link you send is what's running behind the random bot you're asking people to add with administrator
Yep
uhh ya i forgor
totally harmless bot
Requests message content despite seemingly never using it
After skimming the code the 2 big things I noticed
- Don't sync commands in on_ready. You should only be syncing when you have changes in your commands.
- Don't use json as a database. You can use sqlite with minimal setup that would be a better option if you don't want to use another DB
i need to update the perms
if u want to test it pls let me know
Intents are not perms
yeah that too i'll update intents i know
i have a server where u can test withotu adding it
While I don't agree with how it is used, it is still used
resp_msg = await bot.wait_for('message', check=check_msg, timeout=RESPONSE_TIMEOUT)
return int(resp_msg.content)
Oh interesting
Personally I'm only interested in targeted questions on the code. It's time consuming to test someone's stuff for free with no attachment to the project when you could just do that yourself and distill out any questions
k
Dude when are you ever going to need Admin perms for that
Benefit of the doubt, new developers just throw admin permission to make problems go away without thinking of the implications
measure it
profiling should absolutely be your first option
Profiling should be the first thing before attempting to optimizing it
Can't you just use difflib
Also iirc a list compherison is faster than a loop
from difflib import get_close_matches
matches = get_close_matches(current, self.DATA, n=25)
return [
Choice(...)
for ... in matches
]
Damn regex
maybe with components v2, I dunno, but not with v1
You could send 2 messages but that is prone to failures. Components V2 would be the way to go. A container followed by a TextDisplay
I don't think there is :/
Yuh
i uploaded a file on discord and its showing this text as well, how do i hide the text
im trying to prank my friend
can i turn it off? for everyone
If a) your notion of "pranking someone" is trying to mislead them to download a file to run on their computer and b) they fall for it, y'all got issues.
This also has nothing to do with bots, just you lying to people
he is my real life friend
Yeah that doesn't matter to anything I said
he is quite dumb on things like this
thought it would be fun
i wont do it to just anyone lol
also the links are quite safe
just a discord server invite and rickroll youtube link
Still has nothing to do with bots, python, or development
yeah can somebody remove that
it is a bat file which has commands maybe
I think for windows users
I wouldnt trust if he she it says a discord invite link and a rick roll
grrr makes me angry
its an image of a file preview
Honestly should have just do !rule 5 6 lol
Do you know if there is a way to use selector first to choose an option and then prompt file upload? I can only see that file can be send from slash command itself, but without additional prompting there is no way to know which option would need file (+ it can be cancelled if option is not found)
You can have a choice as another parameter but that's about it
Is there a way then for autocomplete to fill data from other options?
So that I could put variables that need to be filled first to be able to find that option
In my case I have DB with 3 columns that specify category and it's subcategories and only by filtering by subcategories I could get a value that I need for upload
Yes, you can reference other options with autocomplete.
So if your first option has a list of choices you can then access that in the autocomplete option to provide recommendations based on that selection
Do you know how to do that with discord.py? It come with interaction: discord.Interaction and current: str parameters for autocomplete.
interaction.namespace will have the other current param values iirc
Yes, that seems to work, thanks.
@stark ingot This interested me way too much so I also wrote the schema for it
https://gist.github.com/i-am-unknown-81514525/9fd2269897ec58428165f9071105131f
I haven't tested it tho
👍
Hey, does anyone know a Docstring generator for Classes and Functions, just curious on if there is a pypi package or something that can do it. Kinda like ruff and isort and basedpyright those do writes (not basedpyright) but you get what im saying.
something like cli_command numpy path_to_file.py or something
and it works on Python 3.12.xx ^
Wanna use ai? lol
https://github.com/airtai/docstring-gen
or https://github.com/FelixTheC/docstring_generator
there is also trelent extension
how can i use Components v2 on discord.py?
or i need to switch to discord.js?
it's not supported yet
There’s a PR
You could use the pr but not recommended
https://github.com/Rapptz/discord.py/pull/10166
You should only use it if you know and are super sure what you doing , because, at least on the dpy server, you will not receive any help about it until it gets merged
looks pretty nice but it should have an option to run without user input on production
It also really depends on the target audience for this. IMO there's a very slim middle ground between people who would prefer to just set a config file and people who would prefer to do it within the bot itself or with a dashboard
why not?
I think it is pretty cool for your use case
No idea what it says but looks cool
Idk if you are doing it but more fun if the set config is also saved so it retain for further usage
Nice
Legend says "1".lower == "i"
Doesn’t the template feature basically do this
Well, to differentiated from the template, you can have it also backup what role the user have and restore that
And for every user that is not currently in the server, it would save the record and restore it when they join, then remove the record(for indefinite or limited duration of time)
But the main differentiator is that the server templates are stored by discord, a multimillion dollar company with expansive server architecture, not one rando 
being able to store your own stuff locally is also nice, alternatively
I guess setup_hook?
I just load my cogs in setup_hook if that's what you mean
when people say not to use on_ready they generally say to use setup_hook instead
I have it like this in my bot:
async def load_cogs(client: commands.Bot) -> None:
for filename in os.listdir("cogs"):
if filename[-1] == "y":
try:
await client.load_extension(f"cogs.{filename[:-3]}")
logger.display_notice(f"Cog {filename} successfully loaded")
except Exception:
logger.display_error(f"Cog {filename} failed to load")
@client.event
async def setup_hook() -> None:
logger.display_notice("Starting cog loader")
await load_cogs(client)
logger.display_notice("Attempted to load all cogs")
cprint(STARTUP_ART, BLUE)
logger.display_notice("The bot is now running successfully")
but also I have a custom logger so like
and a custom printing function
I can remove the custom stuff probably
make it easier to read
i'll do that rq
oh okay cool
Well lol
Oh btw I do think your bio may not be functioning as intended
Whatever don't important
Okay
I don't know the specifics of how that works
It will load all the cogs
then run the bot
I think
setup_hook is called exactly once between login and connect. The library calls it for you
It's also notably not an event
is it not? let me check, I haven't touch setup_hook for a while
What is the difference between those?
@app_commands.command()
@app_commands.guild_only()
@app_commands.guild_install()
@app_commands.allowed_contexts(guilds=True, dms=False, private_channels=True)
async def create(itx: Interaction) -> None:
"""
"""
@app_commands.command()
@app_commands.guild_only()
async def create(itx: Interaction) -> None:
"""
"""
It's not. Discord emits events to your bot, and setup_hook is entirely local
ah, ye 100% not discord event
because I remember you do the event decorator vaguely
It works with the decorator due to an implementation detail of how the decorator works, but it's not something that I'd recommend
so I gone to check code
well, it is the best way to do it if you don't subclass the client
well, the bot is too late to change now
I don't use that library, but assuming it follows the API guild_only is a deprecated feature where installation locations and contexts are the replacement
What da frick

guild_only sets guilds contexts to true for you. The api field is deprecated as said above so it doesn't use that.
There is also one for dm_only
Uh Guys what to do if the command says
discord.ext.commands.errors.CommandNotFound: Command "invite" is not found
Even though Its working and no error
Means someone did <your prefix>invite but invite isn't an actual prefix command for your bot
You can ignore the specific error in on_command_error or set the command_prefix to () if you don't use prefix command
why it not show the cmd like /paymentinfo i already start it in terminal
Did you sync the command?
guild_only does work on groups
Hello! This post is all about User Installable Applications and how to set them up.
Oh nvm it doesn't show groups
Want to mark an app commands group as user installable / usable (contexts)? There are two ways depending on how you defined it.
Documentation
- Subclass (recommended) or using commands.GroupCog
You can use the decorator(s) directly on the class.
@app_commands.allowed_installs(...)
@app_commanda.allowed_contexts(...)
class MyGroup(app_commands.Group):
# class MyGroup(commands.GroupCog):
...
- Manual initialised
Use theallowed_contexts=andallowed_installs=kwargs.
# same thing if inside a (Group)Cog
my_group = app_commands.Group(
name=...,
description=...,
allowed_contexts=app_commands.AppCommandContext(
guild=bool,
dm_channel=bool,
private_channel=bool,
),
allowed_installs=app_commands.AppInstallationType(
guild=bool,
user=bool
)
)
Note: sub command/groups cannot have their own contexts/install values.
Might aswell send it all here too
Set dm_channel and private_channel to false
whenever i put the code it says module discord not found and im using ios python code editor, how to fix???
You cannot installs packages like discord.py on a mobile app lol
laugh on termux
You can with pydroid
By the way sup
Bro just code on your computer
!d discord.Guild.create_voice_channel
await create_voice_channel(name, *, reason=None, category=None, position=..., bitrate=..., user_limit=..., rtc_region=..., video_quality_mode=..., overwrites=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
This is similar to [`create_text_channel()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Guild.create_text_channel) except makes a [`VoiceChannel`](https://discordpy.readthedocs.io/en/stable/api.html#discord.VoiceChannel) instead.
Changed in version 2.0: This function will now raise [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError) instead of `InvalidArgument`.
What does a nsfw voice channel mean lol
Only text channels can be marked as nsfw

Oh it is supported https://discord.com/developers/docs/resources/guild#create-guild-channel
Time to pr™️
Now that's not a thing
Voice channels got no topic
can't set it
It is only available for
Text, Announcement, Forum, Media
But discord did not make it optional so they have to return it
Probably returns it for easy migration lol
you can set stage topic with your client, but idk if you can with bots
and yeah since you can use text chat in voice channel from years ago they added that
Yeah
That's status
A forgotten feature that they never documented or announced
i mean they keep changing it
Fr?
I think i implemented it in py-cord cant remember
Discord is a mess

Yes and guess who implemented it 
https://github.com/Pycord-Development/pycord/pull/2368
Tag match?
That is relatively new, not sure if it is in the API
First time seeing it
Oh it's already in the clients
Good QoL feature
I don't see a pr for it on the docs repo so I guess not many know about it yet
i think so, could be me just got the perm revoked at some point since it first time appear
Returned by the API but not documented anywhere (by discord)
"default_tag_setting": "match_all",
Also there is a template field 👀 wonder if that will ever be used.
And default sort order returns null despite not being listed as nullable in the docs :/
It is?
default_sort_order? ?integer the default sort order type used to order posts in GUILD_FORUM and GUILD_MEDIA channels. Defaults to null, which indicates a preferred sort order hasn't been set by a channel admin
shoot looking at the create docs not the object
Ah
Is that also an empty string for you?
yes
My guess is it would be used as default text so when you hit new post it fills in the text box with whatever is in that string
Like what github issues do
I was thinking it could create like default posts but that doesn't really make sense now that I think about it lol
Uh i made it right still the same error
Should i just send the command? its very tiny
@bot.command(name="invite")
async def invite(ctx):
embed = discord.Embed(
title="Server namae",
description="Linkie :)",
color=discord.Color.blue()
)
await ctx.send(embed=embed)
@timber dragon there's nothing wrong
i mean i check the python masterclass
So the command does exist
Yes
You sure your bot isn't running more than once?
wdym?
Maybe you're running two instances, one with the command and the other without
Can you send the full traceback
Alr brb
WARNING:discord.client:PyNaCl is not installed, voice will NOT be supported
Bot has logged in as Mizuki#4840
ERROR:discord.ext.commands.bot:Ignoring exception in command None
discord.ext.commands.errors.CommandNotFound: Command "invite" is not found
@timber dragon
here
Is the invite command an slash command or prefix command?
prefix i dont use slash or hybrids
That's not the full traceback
uh
So the command did work there right?
Pretty sure the traceback gets thrown out by defualt because it is ignored
-# Or i might just be silly
It shouldn't in dpy
Uh i dont get it
It looks like you are defining your commands after you start the bot. This might be the problem
Can you show your whole code after you remove the token
oke
They said the command does run 
#discord-bots message
@stark ingot
why?
Define the command first then just bot.run("token") at very end
Oh i must put it in the end?
Running the bot blocks the "event loop" which means any code after it won't run until the bot is stopped
Basically think like starting a bot is almost equivalent in running
while True:
...
guys why does my bot join my channel then leave then join again then leave
because you wrote code that does that
What channel
but i didn’t
voice channel sorry
and how have you come to that conclusion
umm
seeing the code would be helpful I think
Please react with ✅ to upload your file(s) to our paste bin, which is more accessible for some users.
it's against discord tos to play music you don't have the rights to, and against youtube tos to redistribute their content
what does that matter
dont ban me i didjnt know 
lol I'm not a mod or anything
but you may want to read the tos and also the rules of this server
ok
Are you asking for help or just promoting your bot at this point
Doesnt answer my question
Given that plenty of other bots do this, even though they don't need to, it's not really groundbreaking or innovative. Comes off as bragging at best and self promo at worse
I don't see you make any more features than server templates
Also 2 channel can have same name and your backup is screwed
It's not keyed by name. But we already had this discussion before, they were told that server templates does this and more reliably, and they decided they wanted to make it anyways for Some Reason
Maybe because it is their code and their time that they can do what they want 
People are allowed to do what they want with their time. It's a different matter when they feel compelled to go into a public help server, post that thing multiple times unsolicited, and ignore constructive criticism on it
But they store the system channel and those as the channel name
Surly it somehow know which channel it should use
Looks that the "System" entry is just a category they decided to name that
Just seeing the image alone is already good enough for me to create the same type of stuff
Also how do i make my bot reply to a certain argument?
Where do you guys host Bots?
Any Free thing? 🥸
!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.
PEAK
https://hetzner.com is p good
Cheap hosting solutions, dedicated servers and cloud services at Hetzner ✓ GDPR-compliant ✓ affordable prices ✓ 100% green energy
Tbf I am wondering how much power my raspberry pi draw per month
Curious not never got a chance to find out
If it takes maximum power at all time(27W)
Assuming 1 month is 30 day
It would draw 19.44kWh
If it's just running a Discord bot, it probably isn't drawing more than a few watts since it's just waiting for the network response most of the time
And Pis are pretty efficient from what I've heard
But there are probably ways to check how much power it draws and track its power usage overtime, maybe ask in #microcontrollers if you're curious
Not "just"
It running many many container
And also build stuff for me
I have searched before but couldn't figure it out so just gave up lol
How to make the bot use reply to the author?
ctx.reply
There is this old tag from the dpy server:
⚠️ Original tag by Vex#3110 called "raspberry pi" was edited and removed this information for some reason.
A raspberry pi is less economic, and less preformant than a cheap VPS? Why?
Cost:
pi b3: 35$
50 gig SD: 10-20$
Power supply: 10$
Other shit: 10$
Total: 55-70$
Scaleway VPS: 3.50USD/month
OVH VPS: 3.35USD/month
This means that it takes about a year for a PI to have a cheaper base cost.
Preformance:
https://i.imgur.com/KEBB9Jo.png
Of importance here is that a raspberry pi has half the ram, and your home internet connection, which, depending on where you are, can range from awful to good. In the end, you're still limited by the fact it has a usb ethernet connection instead of a proper connection. Furthermore, SD cards are slow. That's just the way it is, there isn't a way around it.
Bruh Thats all? Thank you 😭😭🙏🙏
dude $3.50 a month for 2 cores, 2 GB RAM, 50 GB storage and 200mbps (2x my internet speed) is insane
that's all
!d discord.ext.commands.Context.send
await send(content=None, *, tts=False, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, ...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message to the destination with the content given.
This works similarly to [`send()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.abc.Messageable.send) for non-interaction contexts...
see that reference kwarg?
.reply(whatever) is just .send(whatever, reference = ctx.message)
!d discord.ext.commands.Context.reply
await reply(content=None, **kwargs)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
A shortcut method to [`send()`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Context.send) to reply to the [`Message`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Message) referenced by this context.
For interaction based contexts, this is the same as [`send()`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Context.send)...
yes
go to sleep then
Too much Caffeine in me
- Pi4b/5 exist now (it cost me about maybe 120usd for my setup I think, but include 8GB RAM and 256GB NVME SSD, and also active cooling with a case)
- 900Mbps sym internet with 1Gbps ethernet cable
- Oh yeah? What about latency when I run an IDE backend on it
- The information is very outdated at this point
Also clearly I am not asking base cost related thing, literally just the electricity it consume
just trying to help, don't have to rude about it.
also notice the keywords: old, removed
I'm not trying to be rude
I am just stating fact because I don't think you have read what I asked
Also noticed the keyword: how much power, my raspberry pi (´;ω;`)
Definitely don't need advise on why I shouldn't use a raspberry pi
Insane as in too expensive or too cheap?
I would say it's cheap
However, I would still recommend raspberry pi under:
- you have reliable power
- you have reliable and fast internet now/plan to have (independent of whether you are going to get a raspberry pi)
- Not high electricity cost
- plan to use for 3y or longer
Guys Can ask Some Questions 😭
@bot.command(name="ping")
async def ping(ctx, user: discord.Member):
await ctx.send(f"{user.mention} Wake up!")
await asycio.sleep(5)
await ctx.send(f"{user.mention} Wake up!")
await asycio.sleep(5)
await ctx.send(f"{user.mention} Wake up!")
await asycio.sleep(5)
await ctx.send(f"{user.mention} Wake up!")
await asycio.sleep(5)
await ctx.send(f"{user.mention} Wake up!")
How do i make this work 😭
The base cost isn't negligible. Not selling your hardware is opportunity cost whether or not you choose to factor that in
Also this seems completely obnoxious, and you haven't said what you're trying to do or what isn't actually working
How to make it repeat without having a 5 generation long awaits
Heres my question

Yeah ill just scrap it
No it's not
This is why I put it to 3y even tho it should be even in about 18 month
Like, you should really really consider that part before buying one
Opportunity cost is a thing that exists. You can't just say it doesn't
I'm confused
When did I say it doesn't 
"No it's not"
Oh:
No, it's not "negligible"
Idk how I could miss that to make it so ambiguous
Sorry, oops
lol
But yeah tbh I don't know the secondhand market for these things, how they depreciate etc etc
Well, my not very good calculation just assume that if you ain't using it, it siting somewhere and act as a dust collector in your house/room or whatever
Ideally if you are comparing the two strategies assuming you already have one, the VPS option should be weighted assuming you could sell it
otherwise it's not a fair comparison
too cheap. thats such a good deal
Ye, fair
I mean, the main benefit I see for the raspberry pi is more you can host local applications and run stuff for you without need to connect outside internet (unless what you running needs it)
Such as I would just run PyCharm/other jetbrain ide backend on it
Oh yeah how can I forget this requirement:
You need to learn to research the combination of components of whether it is possible, and also assemble stuff yourself
You also need to install your operation system and also handle the safety on the device to the internet
@bot.command(name="ping")
async def ping(ctx, user: discord.Member):
if user:
for i in range(0, 5):
await ctx.send(f"{user.mention} Wake up!")
await asyncio.sleep(5)
else:
await ctx.send("No user found.")
Wow i Didn't expect for someone to Fix the command :o
Thank you so much
Just added some conditions and a for loop. You are welcome! 
range with one arguments actually treats it as stop
start becomes 0
just readability ig
real problem is he spelled asyncio wrong💔
though the IDE/Text editor should yell at him
also he forgot to await send
It's good practice to use the start value when you're learning coding (this is why I used it for this example), But yes, range(5) works just the same
How to make the bot delete its own message but doesn't delete others message
I just use purge just to delete it 😭
await ctx.send("Delete this message after 5 seconds.", delete_after=5)
Does it also work on ctx.reply?
mb ur playing cs2
anyway Thanks homie
ctx.reply IS ctx.send*
-# * with the reference parameter set
!d discord.Message.delete
await delete(*, delay=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Deletes the message.
Your own messages could be deleted without any proper permissions. However to delete other people’s messages, you must have [`manage_messages`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions.manage_messages)...
this exists too
Alternatively use slash commands and reply ephemerally
Ephemeral means it only appears for the person you're replying too and it can be dismissed right?
it appears for the person who did the interaction
.
my bot broke
arre baapre baap send traceback
:stare:

why theres 4 Nova here...
the nova's are multiplying
man i cant stop making 10 generations of elif statement 😭
show code
i deleted it and asked ChatGPT...
nice one mate
like i was supposed to know that
idk either
How does age related to fault
Couldn't see the relation between
Lots of people that know programming are young and still in school these days lol
Ok
you can manage your time :shocker:
Im 14 broo why u bringing me down w you
i ain't bringing nobody
Im still stuck at pagination 😭
Pagination?
yes
Like pages?
yes
what issue you have with it?
remembering it
?wdym remembering it
Just keep googling whenever you need it eventually itll be burned into your mind
you mean storing the state?
like uh exam? need to remember the important stuff but forgets right after the test starts?
...You get exam on discord bot pagination???
all you need to remember:
you have multiple page, and you have button(or other thing) to switch page
other thing you just go to docs and see how to use the component, and create the logic
in reality you either just have code saved from prev bot
copy from some github
or just live code it
you don't need to remember the exact code, there are no reason to
uh github and google colabs don't mix in well
?
Uh google colabs does the same thing but different at the same time
same same but different...
again I don't see any relation in between, github is just somewhere that store code, and google colabs is somewhere you run code
?
uh how do i explain this
saying something is same and different at the same time give no context
man im so confused rn
You can also save colab notebook code to your google drive
¯_(ツ)_/¯
Isnt it save by default tho so you just have to open the old one
its not that uh i dont how to save im trying to explain uh things from github doesn't guarantee works... ig??
Well, does your code guarantee to work? Neither
nope
And if you are confident that your code is better than what people use and share
Live code is always an option :)
im confident that my codes are bad
pagination is considerably more annoying than for loops, dont be upset if its a struggle for you rn
What
trying to run a bot on my computer but it says this
Cd to the project folder
give me a minute my computer is being very very slow
got there and I put that file in my projects folder
When you run the command install -r requirements.txt it's essentially looking for the file requirements.txt in the current directory you're looking at in command line.
So you'll need to change directories to the correct directory
Ok
pi 6 don't exist yet
Also consider these
- Hardware assembling skill
- Device security management
Please someone expert in vps (virtual machine) to help me. write to me privately.
Stop spamming
I use a raspberry pi 4 for hosting my bots (java and python) and it works great 👍
Nice
only thing to worry about is electricity getting interrupted or the internet failing, but that rarely happens
says something different
You forgot the pip
ok
nvm found it
If you are just starting out making bots I recommend that you use slash commands. Prefix commands will only give you problems down the road. (Won't be able to be in more than 100 servers)
Not sure this matters, but figured I'd ask. If I want the response portion of my Discord Bot to use text-formatting like Bold/Italics etc, should I have it pull from a webpage using markdown, or html for the text-formatting?
What does "pull from a webpage" mean here
Just use discord markdown
Bold
**Bold**
I'm working on my first ever Discord Bot to pull formatted text from a website. The bot will be used to provide Study Bible notes for Bible passages and I would like for the responses to retain the text-formatting of the study notes that I'll be hosting on a web page. If that makes sense.
That way the bot's response to something like !John 1:1 will look good instead of just being plain-text.
Where you get this text from and how you send it to discord are separate, and as said you'd use discord's markdown syntax for the latter
I'm just doing it for my server
Ah okay I think I understand. I will want to source text using discords syntax and when it gets pulled into the channel it will be properly formatted.
that's pretty sick
Oh lmao
Discord will format the text when it displays it to users, yes, like this example
Appreciate the info 🙂 I'm gonna get busy getting this done. It's a big task.
This actually makes things a lot simpler for me too now that I don't have to create separate html pages for each book. I can just put it all in either one big text file (or more likely) individual text files.
Since it's a pretty small amount of text, local text file is fine. Heck this is small enough you could load it into memory once at startup pretty reasonably
If I were to go the route of text file. Would it be best to do one monolithic text file per chapter? Or should I do a separate text file per chapter? Or does it not matter?
Doesnt particularly matter IMO
Is there a way to make my bot work in User to User DMs / GCs? (example: like Heist, RoUtility, etc..)
You can make user installed commands that they can execute in dms yes
What about group chats?
Don't see why not
Well the "User Install" already enabled but the bot working only in servers (even if servers that the bot didnt got added)
but there no slash cmds in user-to-user dms / group chats
How are you doing that? How are the commands declared?
im using @app_commands.command & @bot.tree.command
But how are you making them user install?
Like i didnt touched the developer portal, im just sync it in the code
No, in code
Commands aren't automatically set to be user installable unless you mark that in code
await bot.tree.sync()bot.tree.add_command(example..())

none of those make your command user install
!paste they mean show your code
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.
they want to know if you are marking them as user slash commands as far as what im reading
https://about.abstractumbra.dev/discord.py/2024/04/11/user-installable-applications.html assuming you're on discord.py
Hello! This post is all about User Installable Applications and how to set them up.
yep
https://paste.pythondiscord.com/C2MA here part of my code for example
Don't sync in on_ready, or really do anything in it unless you understand how that event works
Im still lost, im marking the slash cmds worng?
The question why the slash commands working in guilds, bot dms, but not in DMs / GCs
You need to stop syncing in on_ready before you do anything else
Or you are going to lock yourself out entirely
Right, so I've managed to finally get the first book of John typed out into Discord compatible formatting. I can read from the file. I'm just not sure how to plumb everything together to have it send me a verse when I issue a command. All I know how to do at the present time is read the entire file. What ways that are easy for a noob like me to just get the verse I want from the bot and nothing else? I'eve tried attaching the file here but it's not working so I put it here if you're interested to see what data I'm trying to get info from https://hastebin.com/share/udejuhoboc.vbnet
I'm trying to have my bot just give me a specific note for a verse via a command, like !John 1:1.
What part are you actively having trouble with? Setting up a bot? Making a command?
Also it's strongly recommended to use app (slash) commands instead of outdated text (prefix) commands
I've got a bot working. I'm just not sure what strategy is the best fit for what I'm looking to achieve.
Yep, I can make a command.
That's about the extent of my knowledge lol
I can create a bot, open the file and create a command and that's pretty much it for the time being.
from discord.ext import commands
import logging
from dotenv import load_dotenv
import os
file = open('John-1.txt', 'r')
f = file.readlines()
newList = []
for line in f:
newList.append(line.strip())
print(newList)
load_dotenv()
token = os.getenv('DISCORD_TOKEN')
handler = logging.FileHandler(filename='discord.log', encoding='utf-8', mode='w')
intents = discord.Intents.default()
intents.message_content = True
intents.members = True
bot = commands.Bot(command_prefix='!', intents=intents)
@bot.event
async def on_ready():
print(f"We are ready to go in, {bot.user.name}")
@bot.event
async def on_message(message):
if message.author == bot.user:
return
await bot.process_commands(message)
bot.run(token, log_handler=handler, log_level=logging.DEBUG)```
This is what I've managed to do so far.
Where's the command?
Oh, I've not got that far yet as I was focusing more on opening the file and such.
I've got a prefix listed just not the command yet.
That's probably a good first step
Well, the reason I stalled on the command is because the command will change depending on what book I'm looking to get notes from. So for example !John 1:1 would be the command to find notes from the book of John and then if I wanted to look at notes for a verse in say, Matthew, it would then be a different command !Matthew 1:5 for example.
Then you could make multiple commands. Or one command that takes in a parameter
I wasn't sure how far to go in the code without figuring out the appropriate strategy as I'm not looking to waste a lot of time figuring a problem out only to find that it's not really helping and there is a better/less complex way heh
And again noting this
got it to run but I changed the prefix to / not !
Click here to see this code in our pastebin.
I'm actually struggling with wanting to use a command or just have the bot act on seeing the words itself. So like if I were to just type "John 1:1" in the channel, it knows to give me the study notes for that verse.
Another thing I was thinking of, if the above would be too difficult. Would be to use [John 1:1] or [Matthew 2:5] meaning anything within the "[]"'s the bot can pull study notes for those verses.
Anyway, I changed the command to use / instead of ! and have a command:
async def hello(ctx):
await ctx.send(f"Hello {ctx.author.mention}!")```
thats not a slash command, thats just a prefix command with forward slash as a prefix...
slash commands are when you type forward slash, a popup appear for you to choose a command
Oh, I see.
Bots that "try" to figure out if someone wants to invoke it rather than having a specific invocation are obnoxious more often than not
Yeah, I can see that being an issue. I may just opt for using [] instead.
what's wrong with using a command?
This bot will hopefully be used in a large apologetics server I'm in. If someone uses the / command, wouldn't it hide the command that was used?
If people can see the command used to invoke the bot, I think that would be best for usability sake.
/ commands very specifically make it easy to see the command that was run
and run it yourself
Oh! Well if it allows others to see the command you used then I'll use a command then.
As you can probably tell, I'm not too privy to what Discord can and cannot do lol
File "/home/fleabeard/PycharmProjects/DiscordBot/main.py", line 15, in <module>
client = Client(command_prefix="!", intents=intents)
NameError: name 'Client' is not defined```
I'm confused as to why I get this error?
discord.Client, it's a class from the discord library
Forgive me, is there a problem with my import that would keep me from using this class? I have:
from discord.ext import commands
from discord import app_commands```
no, imports just change how you use it. you need discord.Client if you have import discord
Okay, hoping I understand this correctly. I updated my line to client = discord.Client(command_prefix="1", intents=intents)
File "/home/fleabeard/PycharmProjects/DiscordBot/main.py", line 36, in <module>
@client.tree.command(name="hello", description="Test slash command.", guild=GUILD_ID)
AttributeError: 'Client' object has no attribute 'tree'```
Clients don't come with a tree made for you
just use commands.Bot or attach a tree
Yeah, I was following a guide that was 8 months old. Apparently a lot has changed between then and now lol
not in term of Client and Bot
you can still define the CommandTree for Client, it's 1 more line of code
client never had a tree attached
This is my terrible code if it's helpful https://hastebin.com/share/sejaficobe.python
You shouldn't be syncing in on_ready
whatever guide you're following is awful and not official
you made a class but didnt use it
one of y'all should make a server where people can invite there discord bots and show them off lol
wait why are client and bot mixed together
lol, mostly because I don't know what I'm doing. I'm very new to all this.
whatever guide youre following, its probably a bad one
this is the official example of discord.py slash command
also i would suggest you learn a bit of python first, like making simple command line program to get at least the basics, and continue from there for more python knowledge
Thanks, yeah I'm going slow and trying supposed easy steps along the way lol
The project I'm trying to achieve is supposedly very simple to most people.
I'm pleased with how easy it was to get the bot to go online and join my server lol
Nothing has caught on fire yet, so that's a big win for me.
I think I got slash commands working. I just started over completly.
from discord.ext import commands
from discord import app_commands
import logging
from dotenv import load_dotenv
import os
#grab discord taken from .env file
load_dotenv()
token = os.getenv('DISCORD_TOKEN')
#basic logging for our project
handler = logging.FileHandler(filename='discord.log', encoding='utf-8', mode='w')
#setting up intents our bot needs for discord
intents = discord.Intents.default()
client = discord.Client(intents=intents)
#manually specify intents that we need
intents.message_content = True
intents.members = True
client = discord.Client(command_prefix="!", intents=intents)
tree = app_commands.CommandTree(client)
@client.event
async def on_ready():
print(f"{client.user.name} has logged in successfully")
await tree.sync()
@tree.command(name='ping', description='Use it to check bots latency')
async def ping(interaction: discord.Interaction):
await interaction.response.send_message(f"Pong! Latency: {round(client.latency*1000)}ms")
@tree.command(name="hello", description="Test slash command!")
async def hello(interaction: discord.Interaction):
await interaction.response.send_message(f"Hello {interaction.user.mention} how are you?")
#run the bot
client.run(token, log_handler=handler, log_level=logging.DEBUG)
you should not be syncing in on_ready, or you are going to lock your bot out of publishing slash commands
on_ready happens randomly and frequently
Are you saying to remove the await tree.sync() from the on_ready?
Or, should it go somewhere else entirely?
you should be syncing your tree only when you decide you want to
it's a heavily rate limited operation
When would you suggest one should sync their tree? I've not the foggiest idea of when/where it is appropriate. I just know all tutorials see to do exactly what I have done.
yeah because they have no idea what they're doing
it's entirely up to you where you put it, because it should be your choice when it happens
Ok, I'll comment my code to mention it may need to move out of the on_ready portion at some point unitl I can fully understand what's going on lol
If you leave it in there, again, you will lock yourself out of that API
Welp, better look into what on_start and syncing tree means in a broader sense than what I know of now (which isn't much! lol)
I hope I'm safe for now as I don't run the bot but a few minutes for testing.
Or you could just remove it 
I've been at this for 2 full days now lol. I think it's time to take a break 😄 Thanks for all your help.
it works now
my code for my bot it has ban, kick, mute, unmute, unban, clear warning maybe
use sql for saving warns or whatever, not json
and use threads for tickets
and
make sure to handle errors
oh yeah don't sync in on_ready, use a command
also wait what, why do you have two bot.run and importing twice
I have vscode open and did ctrl f and there is only 1 bot.run
https://hastebin.com/share/anogekivaf.python I think this is better to see the code
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
use asqlite for asynchronous sql
sorry, forgot to mention that earlier
also, you should use user_id as a PRIMARY KEY so it allows for indexing -> Faster lookup
Does primary key automatically index?
This is my first discord bot that I wrote the code for
I also suggest you don't make commands which are only thin wrappers on discord functionality that already exists. It adds nothing while reducing security and auditing
Ok
Yeah
Oh nice
https://hastebin.com/share/ubedecalon.python I don’t know if is secure
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
do @silent messages behave any differently when composed by bots?
If your using d.py, you’d have to use the silent kwarg
But yeah other then that ig it works the same
Yes because I believe this is purely send client sided
Like how auto text->emoji work such as :)
a bot cant timeout someone who has the permission administrator?
No, administrators cannot be timed out
would it be faster to iterate through every role a user has to remove the admin role or just remove every role
Btw at a timescale of network request, doing either basically take same amount of time
C:\Users\honem\Downloads\discord_bot_with_packages>python mod_bot.py
Traceback (most recent call last):
File "C:\Users\honem\Downloads\discord_bot_with_packages\mod_bot.py", line 12, in <module>
GUILD_ID = int(os.getenv("1290077081325277206s")) # Ensure this is set in your .env file
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'
C:\Users\honem\Downloads\discord_bot_with_packages>
https://hastebin.com/share/obugiwigeb.python code
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
The environment variable you refer to doesn't exist
!paste next time use this instead of whatever other pastebin in this server, thx
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.
Locating roles with administrator would have less of a chance of rate limits. I am concerned why you would need to do this though.
You can batch remove role I am pretty sure
If it's on the same member
!d discord.Member
!d discord.Member.remove_roles
await remove_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Removes [`Role`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Role)s from this member.
You must have [`manage_roles`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions.manage_roles) to use this, and the removed [`Role`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Role)s must appear lower in the list of roles than the highest role of the client.
Yeah you are right, was not seeing the Modify Guild Member in the discord docs.
looking for ways to optimize my anti-nuke
what if i pre loaded the roles that has admin upon turning the bot on or upon joining a guild
The better way to make anti nuke works is not giving random permissions to random people
You don't need a bot to do anti nuke, when the bot offline and someone nuking your server its over
this isn’t a one server bot
it’s a public discord bot
it isn’t for me
Then it is even more of a problem
People looking for anti raid, anti nuke bots because they are too lazy to setup their server correctly so it would not happen in the first place
Real
Can someone tell me whats the problem in my code? it doesn't error and doesn't work :(
async def on_message(message):
if bot.user.mentioned_in(message):
await message.reply("Hello, you mentioned me! 😊")
await bot.process_commands(message)
there's nothing wrong with it 😭
can you print message.mentions to test
still don't work and still no traceback errors
wdym doesn't work
are you able to even listen for message eventse
im new to bot.events i only know commands
no like, are you getting an message events at all?
i think so
ok, wdym it doesn't work here?
Big server owners are targets of account compromises and then the person that takes the account nukes their server
There have been several big servers that have been hit this way
you do realise you can't do anything to a server owner
I suppose that's true, but my statement is still true of moderators of those servers
if a moderator got their account compromised well idk what else to say
anyways my point is, you rather prevent it than fixing it when it already happened
Can't really prevent a moderator from being compromised or going rogue, can you? Unless you got a glass bowl thing that can look into the future lol
I mean you got the point, choose what you trust
ok i have a conclusion i made my friend test my code and it work for him while it didn't mine, so its either the google colabs cant do it or there smth i missed in google colabs
mentioned_in is a real thing?
!d discord.Client.user
property user```
Represents the connected client. `None` if not logged in.
hm indeed it is
where you run the code shouldn't change anything
did you restart your bot?
multiple times
i just gave up and made it command
and you printed message.mentions?
fair enough
Does the bot have message_content intent (You have to enable this in discord developer portal)Did you told the bot it have message_content intent? (intent = discord.Intents.all() or intent.message_content = True)- Did the bot have the right to receive&send the message on the channel
Don't think the bot needs message content intent to see the contents of the message it is being mentioned in
Oh right I forgot
It was mention🥴
My brain just didn't notice that part when I wrote the message
i did all
@commands.cooldown(1, 10, commands.BucketType.user)
how to edit the msg that say ths command is on cd
wait
okay thank you 😊
i cant find where i could rename the cooldown notice
well you can't "rename"
you can do like
@command_name.error
async def command_name_error(ctx, error):
if isinstance(error, commands.CommandOncooldown):
await ctx.send(...) #Use the attributes from CommandOnCooldown
so uh i have to use ctx.send/ctx.reply for the message if its on cd?
sorry for ping
wdym?
You have the ctx, you can choose to just ignore it or reply with an fancy message saying its currently on cooldown
@burnt quiver this
did i just got rick rolled...
So, you have ctx, you can send/reply whatever you want using that ctx
If that what you mean "custom"
like this
the very bottom
CommandOnCooldown
Do what I did
^
You can send whatever message you want
does it work if its on cd?
:stab:
😔 Command_name is the name of the command
@bot.command()
async def ping(ctx) -> None:
...
@ping.error
...
I think I mispelled it, check the docs
^
you didn't misspelled it
its google colabs itself i think
its still the same
CommandOncooldown != CommandOnCooldown
Did you redefine commands somewhere
discord.ext.commands should be a module, not a Command object
can you explain?
>> from discord.ext import commands
>>> commands
<module 'discord.ext.commands' from '/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.13/site-packages/discord/ext/commands/__init__.py'>
>>> commands.NOT_EXIST_THING
Traceback (most recent call last):
File "<python-input-2>", line 1, in <module>
commands.NOT_EXIST_THING
AttributeError: module 'discord.ext.commands' has no attribute 'NOT_EXIST_THING'
This is what you would see normally
So you must have re-defined commands in some way
uh i saw different
I don't know how you have re-defined it because I cannot see your code
and this is the command anyway
@commands.error
async def command_name_error(ctx, error):
if isinstance(error, commands.CommandOnCooldown):
await ctx.send("Youre on Cooldown", delete_after=5)
We would need to see the whole code to debug this
But you might have make a command where the name call commands
Which would cause the exact issue you see here
Anything in this file above that code could have redefined what commands refers to
hol up
Also below
On a higher scope than the error, yes, but not in the same scope
Yep exactly I described
You overwrite the commands module with the commands Command
Therefore you cannot use the commands module
What you name things matters, you don't want to name any variables/functions/classes the same as anything else you're using (like an imported module)
I gotta rename the commands command?
Yes
oh
just use the kwarg in bot.command
Or import the module under an alias
isn't
@bot.command(name="commands", aliases...)
async def prefix_command(ctx...) -> None:
easier
uh idk
all you'd have to do is change the function name
if you define the name kwarg in bot.command(), it will overide the function name
-# Idk if I'm making this more confusing
*It will respond to the name defined in bot.command() in discord, instead of the function name used by default
yes thanks, I think that's much easier to understand lol
uh
Anyway
Thank you guys for your help
i really really appreciated it
-# chatgpt just made it more confusing ngl
chatgpt thinks 3 isn't a prime number. You need to stop using it if you want to actually progress
i only use it if im stuck then ask yall here if possible
i even have discord.py masterclass always open
so i just go there for the code
Replace chat gpt with Google search :)
Fixed that and it’s been working for about 16 hours now
Alright friends, I have a discord bot now working that can take / slash-commands. How should I go about taking this command and having the bot search a local text file and reply with the appropriate info?
async def test(interaction: discord.Interaction):
await interaction.response.send_message(f"How cool would it be if this was a Bible verse pulled from a text file?")```
I'm hoping to use a command structure like [text-to-be-searched] if that makes sense?
How much memory does the text file hold? How would you search for it?
you could just load it once into memory at startup rather than reopening the file every time someone runs the command if it's small enough
Presently the text file is 11.9kB but this file will have more text added to it over time so the filesize will certainly increase.
I'm certain that once the text file is 100% completed, it will fit more than comfortably in RAM.
How much ram do you have
8GB
The entirety of the english bible is around 5 MB
Yeah, this will probably be just a bit under 5MB once completed as it's just study notes for most not all verses 🙂
Soooo how will it not fit into memory 
No, I said it will fit more than comfortably in RAM 😄
oh then just do that
So how does one accomplish that exactly? Would I just be opening the text file into RAM in Python? I'm very much a newbie to not only Python but Discord overall lol
The simplest bit is yeah just read the file into memory, store it in a string
Depending on what you want to do with it, you could do something more complex
Cool!
Like you could bucket it into verses, like with a str : str dictionary
Thanks, I'll get to googling how to read the file into memory and storing it in a string.

Oh, that is my old code I've since abandoned lol. So does this:
f = file.readlines()
newList = []
for line in f:
newList.append(line.strip())
print(newList)```
Load the text into memory and store it as a string?
Well, as a list of strings for each line
but yes you'll have all of the text in memory at that point
Nice! I'm almost there then haha thanks
I'm not sure if a list of strings for each line is the best approach. Or if I should do it some other way that's more effective that I'm not aware of.
It again depends on what you want to do with this text
If it's just for a lookup of verse name -> corresponding text, a dictionary that maps a string (verse name) to a string (its text) seems appropriate
Oh, I just want the bot to give me info from that list for a specific verse. So if I type [John 3:16] It will give me the study notes appropriate for that verse.
Then yeah I'd recommend using a dictionary for this
#populate the dictionary
all_text = ... #somehow load all of the text. If it's already split up for you by verse, great, if not you'll have to do it somehow
verse_map = {}
for x in ...:
verse_map[verse_name] = verse_text
#in your command
await interaction.response.send_message(verse_map[the_verse_they_want])
Would me formatting things in this manner work well for a dictionary? https://hastebin.com/share/udejuhoboc.vbnet
A dictionary is just a mapping of one object to another
it's your choice what those objects are
Thanks, I really appreciate your helping me in this. I'll study up on dictionaries in python 🙂
Interesting, dictionaries seem a whole lot like sql lol

The key/value pairs is what gives me sql vibes lol