#discord-bots
1 messages Β· Page 425 of 1
And generally libs tend to use it for clarity, even if it's internal code
Same reason for using Literal in some contexts
I'm personally strict about typing. You don't have to be. It was just a recommendation
As long as you do the minimal typing it's good (:

Personally I really just use python for hobby, quick prototype stuff. If I cared enough about proper typing and extensibility with a team, I'd choose a strictly typed language
I just got used to strict type checker ever since I turned it on 
And I find it fun atp
I think I follow most of that. Strictly for type checking no impact at runtime. But that's making me wonder, can you construct Data and just say Data(id="abc", name="def") and skip banner, are there constructors?
You don't have to use banner if you don't want to
You're meant to take Discord's payload and just pass it to the class that takes that TypedDict
You shouldn't hand-feed that dict yourself
You can just ignore certain keys. But removing them is pointless
It isn't really pointless for my use case though where the goal is to just get a in memory discord backend operational that only has to store and feed in minimal information/skip over what the code doesn't interact with or need.
At the end of the day the endpoints still give you those keys. What're you gonna do with that
Just don't define the keys in the TypedDict then ig
Doesn't impact memory really
Also if you really care about memory make sure to use __slots__ 
Python should have a way to auto implement slots :\
I see that with TypedDict, this works fine, but it doesn't with dataclasses and Optional[] requires you still pass them.
class Data(TypedDict):
id: str
name: str
banner: NotRequired[str]
my_data = Data(id="abc", name="def")
print(my_data)```
```py
@datclass
class Data
id: str
name: str
banner: Optional[str]
^^ requires me to fill in all the optionals myself unlike TypedDict
The first code is not a correct usage of TypedDict
You should just use it as an annotation
I don't think using it like this is wrong?? It ends up with a dictionary with the same information and constructing it with constructor syntax. I'm also using pycharm where this is more ergonomic.
payload: Data = ...
class User:
def __init__(self, data: Data) -> None:
self.thing_you_care_about = data["thing"]
# Just don't access what you don't need.
# Moreover, you don't have to define all keys in the typeddict. It has no runtime check.
user = User(payload)
with dataclass, you can set fields you might not fill in to none. But it gets a little sticky if you inherit dataclasses because inheritance merges the two so you get params with default values after params without default values which is a no-no
I don't think TypedDicts are meant to be treated as runtime objects. Surely wouldn't construct them.
You just don't really need to anyway
I use them for the Unpack type
That's their usage yuh
They have constructors which you can use at runtime, just not runtime checks on the data. If I passs the fields in the constructor I get an object that is a dictionary.
or maybe constructor is the wrong word
Why do you need to construct them, if anything, you're just bloating the memory more by creating another dict in-memory
It's for testing not production and because it has better IDE integration in my case.
by construct I mean MyTypedDict()
The payload with keys that you don't want will not stay in memory, so I wouldn't worry about this
I'm not intending to argue about typed dicts which I've probably misunderstood, only was curious how different they are. scurrypy uses data classes and I thought defaults of None, which they'll get filled in with later anyway, would be convenient, no memory difference in that case. But If I understand correctly, @delicate flame objects to it, as default values of None at the constructor would complicate inheritance if needed in the future, so the convenience I wish for isn't advisable.
You could use a regular class to avoid that ig
parts will do what you're looking for. But there's no user part. Models were meant to be filled by discord, not by the user. That's why they dont have none defaults
hm. crazy maybe not so crazy idea. Why not do UserModel.from_dict({}) for all fields set to None then fill out as you need
Because this has the same effect of unpacking
It's an ergonomics thing. If I take your constructor I can see everything I needed, if i create a dictionary from nothing, I've got nothing, and I have to figure it out and put it together which is its own hassle.
You can pass the full dict and if you don't care about some keys then yeah make them have a default.
Would not recommend this but go for it ig
wait, i misunderstood a bit.
@delicate flame I like that somewhat. But from_dict doesn't have a a type annotation that helps my IDE. And when I do have it right, I no longer know what is optional and what isn't. The way I vaguely see it, scurrypy is marketed as dataclass driven, so fundamentally, two clients for discord should be able to use the same models, making it a desirable layer to build on or play around with in it's own right, so I would argue, if practical, which it might not be due to inheritance concerns, it should be something given care like everything else. But I'll understand if you don't intend anything besides your own client to be doing much with it, or share the same concerns. I already know what I have to enter, that it can be None, it's not a big deal at all for it to not. I can look at scurrypy and get a good idea of what is and isn't essential on discord and It can make life easier playing around or experimenting with all that.
oh are you trying to get your IDE to only show the fields you filled?
Not my original goal just what I'm lacking in the from_dict approach. I'm trying to only have to fill the fields that aren't Optional[], that's all really. And If I go for from_dict which technically allows that, developer experience wise, I don't get to see what is optional vs required anymore/if i'm missing anything that should be there.
oh, this seems like more of an IDE issue than a scurrypy issue. It looks like thats just how the IDE shows the fields. if your IDE isnt giving you what you need, reference the docs! Those will tell you if fields are optional or not. Thats what the docs are there for!
When I use my IDE and the constructor it does tell me, but even if i did hover for them I don't think any of them would be smart enough to know, that setting attribute by attribute, this is required, or you're missing this one. This isn't really a technical requirement, just a developer experience issue I potentially see it as. Ideally I don't have to see any docs, I just start typing and hover for what i need and life is smooth. I feel like I've made my argument at this point and attribute: Optional[type] = None isn't going to be a thing so I'll just keep that in mind and enter None for each manually (which I am translating it by writing it, I just thought defaults/less would be nice, that's all). Thank you for taking the time to try to understand my issue and giving your feedback. π
np! wish I could be of more assistance, but reading docs is an inherent part of coding. Theres not much I can do about that
The docs dont say that it wont ever be present in normal payloads.
and if it is, the libraries can be changed 
I have no problem changing it. Im releasing a new version at some point soon anyway
This is how you run into edge cases. At least on the user docs page there is zero indication that any of the fields are expected to only be present in certain events.
Why wait until something changes and scramble to implement a feature instead of implementing it according to spec the first time
"until" implies that it will. Nothing is implying that it even might
In this specific instance, there's a very deliberate reason why the user object sent to bots that simply share a server would differ from what they get on an oauth grant. The chances that they'd expand out the former is highly unlikely
Nothing implies that it wont. Its not like it is that hard to implement and one boolean is not going to make a difference
If you are concerned about memory, you can abstract it out into its own class along with the other OAuth specific fields, and you can set them. And then have them be related by composition.
The fact that mfa being enabled is sensitive information does imply that it won't
where?
That's the nature of the field
It's sensitive. That's not something discord would want bots to be able to farm for free off people
and you got this information from?
It's also not something that shows up on the human user side of the API either when you see a global profile
From applying critical thinking...?

Im not sure how you can actually know what "discord would want" unless you work there. And even then, things can change
I will agree with you when there is a note in the documentation that specifies that "X fields will only be present in Y scenario"
I mean if the tradeoff you want to make is providing a confusing field that is empty 100% of the time AND there is a very clear, logical reason why it should be just because in theory they could add it, that certainly is a choice
That is one I would not make and I am glad that dpy doesn't make
"Surely discord will never use a different port for voice because this is the port that always has been used"
Ports are arbitrary numbers. Whether or not a bot gets access to sensitive information for free is a much more substantial decision
and not one to be made lightly or without warning
No warning necessary, it is already documented that bots could receive this information at any time
if the field is always none, sensitive information is not even in the picture. I already said I would change it? Why yall getting so up in arms over this
worse case scenario: its always none
"Could" is doing a hell of a lot of heavy lifting. A meteor could hit their datacenter, and that would be a substantial change without warning
it was a mistake I made and one that is very fixable
The fact of the matter is that it is incredibly unlikely to change, and even if it did you're inflating the cost of adding it and downplaying the cost of putting it in when it's actively misleading
"unlikely" is doing a lot of heavy lifting
I dont get why you're taking this so personally. It boils down to an extra field that happens to be none. if you have an issue about it, open an issue?
Can you articulate a potential reason why discord would decide that bots which users have not authorized should know if they have mfa enabled or not
Or are we speculating that discord just spends all day flipping coins to decide to make completely random decisions
They want to let bots with moderation command have the same level of security as the built in actions.
Im mimicking discord's docs because scurrypy prioritizes correctness. I wasnt aware at the time mfa_enabled is only filled for user clients. Ive said it multiple times: it's an easy fix. Ill remove it for the next version
Which a server manager decided to grant them. Willingly.
It's specifically only given on api requests where the user has granted the identify scope
yes, you've already made this clear
holy shit this dude sassy π im gonna assume larp too after coming out the gate with this
π π π π yo im weak
heh, isnt that what a bot does tho? Include a jumble of features you like?
I agree
What are we arguing about, are we for or against mfa enabled being on the user model? What's wrong with just having it there so you can load it if you ever use oauth? @delicate flame goal for the library is correctness and alignment with the API so I think it makes sense to have it there if you want it.
It should not be on a public facing user model no
I didn't read through all that, what would you need to know that about someone for?
took me a min to find but i added it back in feburary of 23
Discord doesn't have separate models for different contexts I think so they just reuse the one and make some fields optional. If you load it from the oauth thing you get to see that about them, and if not you don't. Probably makes sense to have a separate model though with the oauth or context specific ones added.
Oh yea I'd agree
See I'm lost, because they don't? It's just one model you get based on where you load it from.
Or atleast share a base class and inherit the properties
this guy is crazy π
I know larp replies when I see one
Mountain out of mole hill
I think we're agreeing, they don't and I was asking for a logical case where they possibly could want to
In theory one could use it to respect a server's MFA requirements for moderation actions, not that 99% of the people rewriting ban commands bother with that
@fast osprey I think we agree, yea. But the goal of scurrypy is mainly to be accurate to discord, if I for example want to start dealing with oauth stuff and read it, that library is just there and will work, even if that field isn't used in like 99% of cases, it's API accurate and there.
That would make sense
If you're making a library that's oauth enabled then go nuts
iirc the whole thing that started this off was a question of why dpy (and by extension other bot-specific libraries) don't
Probably just two very similar sounding but very different questions getting jumbled together lol
Yea I stuff is getting jumbled up π
It's API accurate, an off the shelf discord model, use wherever, build what you want on top, which happenstancially the main application of it will be the normal API/gateway stuff.
The rest of the arguments I haven't really followed, which is why I grabbed it, if I wanted to go deal with oauth it would be less convenient if scurrypy didn't have it, or when the goal is to be accurate to the API, puts it elsewhere.
Be accurate if you want, it costs you memory and maybe confusion
I think maybe there's a misunderstanding. From what I can tell they're talking about making a more holistic discord library, not strictly a gateway bot one, in which case this attribute could potentially be populated and useful

its a negligible memory cost. its a bool or none
Yeah, memory is a very very weak argument to use here, if one bool on a model is a memory concern then it's probably time to switch language tbh
Best of luck, your first best step is to get a good amount of practice with whatever language you'd like to use to make it and learn the fundamentals. Then the different discord libraries will have examples/getting started tutorials
https://github.com/Rapptz/discord.py/issues/10389 dude added his windows version

Also when do you ever need to create an instance of a context menu the way he does? I only ever used the decorator
Is it even meant to be done
is there a decent way to test slash commands automatically? like is there a library that works with discord.py that I can write a test suite so I don't have to manually test my slash commands every time?
Can separate the logic into a simple helper function and use any unit testing framework you'd like
mocking out discord itself is prohibitively heavy imo
i use that when i want to have context menu inside a cog
You could just define a function inside the cog
yeah, that's what i did
Not like that
class MyCog(Cog):
...
@app_commands.context_menu(name="My Context Menu")
async def my_context_menu(...): ...
you can't
i think one of the maintainers said it's annoying to do something with self for context_menu
"It's annoying"
Nah I'm jk but still sounds weird
There's a long writeup on a github issue about why this is more trouble than it's worth
I can guarantee you the devs didn't just decide to make this work differently for context menus for shits and giggles
Might take a look at it
Yurp
well shit guess they deleted the issue :/
apparently my discord bot is using a lot of mem
CPU Usage: 1.0%
Memory Usage: 814.39 MB
Uptime: 5 days, 12 hours, 21 minutes, 57 seconds
On Startup Its around ~400 MB
π€ Wondering whats causing the jumps in just 5 days of op
Good start would be to use a memory profiler
i tried using tracemalloc but it blocks the event loop and freezes the entire bot
and yeah using that apparently sent the mem usage to 1.66 GB
there should be some async friendly profilers, haven't needed to do this in a while tbh
i think there is Scalene but it might just slow down the bot
Well if you're running out of memory, slowing things down probably isn't your biggest concern
not really running out, still have 60% headroom but if i keep it running at this pace it might be a bit too close for comfort
Not sure if you have any other options besides a) run the profiler and live with it being slow b) look at your code and try to intuit what's happening or c) nothing
if you wanna send code we can take a look at it but it won't be definitive
the code is ehh over 40k lines split across files
dont think theres any runtime cache being added beisdes what the library and python adds up
Do you use views?
yeah a lot actully
Then you're adding things to the cache
In theory any of your code could be keeping stuff in memory too, but probably the most common leak just using the library is adding an increasing number of persistent views
or things naturally being cached like members
π€ is there any controls over what is being cached by the library
Intents
if you don't request an intent, the library won't cache the relevant objects
The other lever is the message cache but that already has an upper limit by default so I doubt that's it
tbh none of my views are persistent, they all timeout after a while
ill try using pyspy to see if it works
Is the memory usage monotonically increasing or is it spiking?
gradually increasing over time
Then my guess is it's your own memory leak or potentially member cache
mhm yeah im trying to get a profile of the mem rn
Member cache might have something to do with it. Py-cord has some flags to control what members are cached. You could check to see if the library you are using does as well.
nvm cant do this in prod
i do have server members intent enabled (to get on_member_update events) for some role sync functionality that i use in 1 guild
Are you in several/large guilds?
You can if you wanted not chunk all of them except that one
I'm working on one myself but it's awhile off still. What you want is acceptance tests for your discord bot which requires faking discord with an in memory database and models a way to set stuff up. Optionally an actual gateway and api. But to put short it's a decent amount of work that no one has put in yet, there was dpytest which didn't do slash commands and doesn't seem to work anymore. So to answer your question, no, you'll have to make something or wait for something.
Do you do any database operations
Or any local AI models, not only LLMs
That wild
Tests usually just check the values, so you just need a fake interaction object etc
It's not really wild for acceptance tests and for something that is supposed to integrate with discord though. If I'm writing a bot I don't want to worry about setting up objects or only testing specific interactions. I want to write tests that definitively say when the bot joins a guild, a user @s it, it will reply to that user with hello. Or when I run this slash command, I'll get a message in response, through the whole journey of a real bot or user would. Or maybe even use the same to see if the bot is setup for real when deployed to a server making it use a fake gateway/API to verify deployments.
Fair
How heavy do you see it as and why?
If you look at the entirety of the bot api, it's a lot. I'd rather just encapsulate the important logic into helper methods and test that
It's also the case that this isn't b2b enterprise software we're building here, 99% of it is hobbyists and the other 1% are still selling to the average discord user who isn't holding them to SLAs. That level of testing coverage is pretty overkill IMO
You don't need the entirety of it though, and testing individual methods doesn't tell you that everything together is correct. Enterprise or not It can be a more enjoyable experience to write tests that tell you definitely your bot works.
For me running a slash command by hand isn't a big deal, depends on what you wanna test really
You're welcome to do that, I'm just saying I personally think that effort isn't best spent on stability and testing
The average kid installing your bot isn't going to care what your testing coverage is
If the choice is mock out discord or build another feature I'm doing the latter
This is fine imo if you do it consistently to verify it works as expected when you change certain pieces.
That's all I need
I don't really care about coverage numbers personally. If I write a test, it tells me what I wrote works as I expected. I can write a quick test for my code or application, then it'll pass or fail and I can consider it done and not have to worry about it later no matter how I structure it or what I change.
This is a fair and realistic choice but I think it also varies with testing mindset. I don't immediately have to develop anything personally, but when I do, I generally prefer automated testing to be the highest priority. If I test core logic it'll probably be with an in memory database/fakes of other stuff. If I test the whole application (which I do for web apps/servers at this point) it'll be with the real thing. I can't completely say the time isn't better spent on writing features, but I'd just really rather have luxuries here that I have elsewhere, and I'd like to be in a position where there's a situation like this I have the experience to fake something else, like telegram, or who knows what will come up.
It's just some interactions
Idk what do you gain from automating those as you can see results even after one occurance
But go ahead Ig
Unless you want to test your whole framework or such
How do you go about this? Do you send a json request and then look at the json response?
This is pretty meaningful when you're a) developing on a team and people can write stuff that interfaces poorly with something another teammate wrote and b) there is an expectation of stability/uptime
If it's a solo dev writing on a single branch and the audience is discord kids, the need for that isn't as high
Someone in here came in asking if they could use a testing framework to know if the command they setup works or not though... that kind of fast automated feedback without having to hop on places as you're developing is something everyone could enjoy, team or not.
Automated testing, of any form, if desired, isn't just for teams
It's not just for teams, my point was that it becomes necessary at that point not that it's not valuable otherwise
My approach is to build a harness that goes over the discord.py client, it calls the setup hooks and then you can send the client whichever events and it'll get to your handlers. This harness also have an interface you interact with in your tests, stuff like create guild, join guild, etc. This isn't touching an actual gateway yet/sockets.
Basically, the tests look like sending a message as someone else, that gets fed into your bot, your bot sends a message out through the interface interacting with the fake backend, then you can check the backend and check something like "did this bot reply to this user" It's still a work in progress.
If I could wave a wand and have a testing suite in place, nobody is saying that would be a bad thing. We're talking about tradeoffs, when unpaid solo devs need to decide to write a testing suite which nobody else will benefit from or build a new feature
fair
@stark ingot This is in early stages and could be a lot better
Would be interesting if someone made an ergonomic framework to plug in test cases easily, that bar has to be lowered quite a bit for the average hobbyist to want to invest in it
The design for mine is you make your own test case class with a harness on it then inherit it, your tests are ignorant to the setup details, and you can start bringing stuff into a state for your bot to use or stuff to start happening that you can assert after. In this case start method/loop within, just tying in with the event handlers of the bot.
Interesting
Those are some long function names though XD
I wanted to write a test extension like dpytest but quickly realised how many objects I had to mock and just gave up lol
I started with that one but as is it didn't work for me. I borrowed some of the classes it had like it's fake connection state and stuff to get started on an initial version, threw the code away, started fresh and it turned out I didn't even need them for the parts that never make any calls to discord. Like if you just want to get to a ready event you don't have to mock anything, you just call the setup hook and then pass your events in for connection state to parse.
Yeah true
I didn't even think that far (or close) yet
I started with on_message so you could do the following
message = await channel.send("hello")
assert message.content == "hello"
like you await send and it gives you what is responded with back to assert?
I started mine mostly by focusing on a backend, like minimal info for users, guilds, etc and the initial guild creates based on it
I guess you wouldn't await it but yes it would return a mocked message obj that you could check like as if it was returned from discord
See, that's smart
For some of it for sure. But I got too ahead of myself initially because I was putting together a lot of classes and design i didn't really need, before even getting anything to the client or seeing if much would work. I mean this part alone this time around was smart because it made the rest easier to build and test actually. All my tests just take the database, which is in memory anyway, then test if stuff is updated in it. So when you call the special interface for the tests like create a guild, you can be like, does a guild with this name exist? is this user part of it?
I do load my RAG embeddings in cache but that counts towards the runtime cache and shouldn't increase
How do you do this
You would set chunk_guilds_at_startup to False in the bot class, then, probably on on_ready, do await guild.chunk()
I wouldn't do it in on_ready given how on_ready works
Yea I just wasn't sure whether you can "interact with cache" in setup_hook
I mean I think you can't even do bot.get_guild in setup_hook
setup_hook can spawn an asyncio task that internally uses wait_until_ready though
My unit tests for all the pieces follow the same design as the harness overall. Basically, you don't have to write tests specifying what responses you want from anything you're working with, everything is like fresh and real for your tests, so you just bring everything into the state you want. To test parts of the harness I just use implementations that will act like the real thing by using the in memory version. And I have tests for the whole thing, like end to end tests for my discord testing framework or whatever you'd call it, so that I know the thing I'm supposed to be building actually works, and not just a lot of code to get there that won't necessarily be in use, i.e. https://github.com/RequiemWorld/discord_harness/blob/main/tests/scenarios/test_join_guild_and_initialize.py.
π€ so that wouldn't cache guild members data right?
True but atp why not use on_ready for that
By chunking you cache all members of a guild
Hey is there any repo of issue I can get?
Isn't it only supposed to run once
Cool thanks I'll set that up and monitor the usage for a few days
Like I could make a print statement to check
You can also set member cache flags
Anyone kindly reply
I'm not 100% sure what this does but it's something
You can pass that to the bot class too
Mhm, might keep that untouched for now, will try if the guild chunking disabled works and then if it's still increasing, update that
500 ish
Ah then it wouldn't be a huge change
Because chunking at thousands of guilds is super slow and a lot
!d discord.on_ready
discord.on_ready()```
Called when the client is done preparing the data received from Discord. Usually after login is successful and the [`Client.guilds`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Client.guilds) and co. are filled up.
Warning
This function is not guaranteed to be the first event called. Likewise, this function is **not** guaranteed to only be called once. This library implements reconnection logic and thus will end up calling this event whenever a RESUME request fails.
Unless you have a few big servers there
no it runs several times and randomly
Ah alright
Also, why did my bots presence status just didnt load this time
I only use it for initial logging
I'd recommend not using on_ready for basically anything
Yeah though this isn't much
There's very few use-cases that it's viable for, and none that a vast majority of devs will run into. Really it's only suitable for when you care about temporary disconnects and cache being repopulated
I haven't followed this whole thing, how does one abuse/misuse on_ready? I've only really used it to print out when the bot is online.
If you have anything in it that you'd only want to run once, then be aware the event may be fired multiple times
Ahhhh, I see
The event fires every time cache is populated. Which does include initial startup/connection, but also every time there's a temporary disconnect and reconnect when cache needs to be batch repopulated. So while printing every time that happens is far, far from the worst thing you could be doing it's generally from a miscommunication of what the event means
last I checked, the ready event only gives ID and if the guild is temporarily unavailable. Its not until subsequent GUILD_CREATE events you get the guild's name
In discord.py ready isn't called until all the guild creates have come in
You can help yourself the most
get started, ask questions where you get stuck. Or pay someone
Yes
How could fun be achieved with a Discord bot that lets you pvp duel other people? I made some avatars and weapons but I mean, there are no real controls. It's just 2 images fighting eachother.
what would you find fun? This is a pretty subjective thing
probably worth going into communities that engage with that sorta thing and seeing what they like/dislike
Maybe by making it an activity
Otherwise you could just take inspiration from other bots' systems as long as you don't copy-paste
Fair enough, thanks for the responses!
Discord messages don't really cater to any live action. You could go for a turn based system like Pokemon
This ^ tbh, it's super clunky especially since activities exist now
!res
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
anyone have a code for /embed command?
Would be good to describe what you want this command to do, and also good for you to build it yourself with help
How exactly would the more experienced programmers approach this structure? I'm working on a bot that can provide study notes for books of the Bible. Should I approach it as one file = one book (or book+chapter) containing many note blocks, including single verses and verse ranges with the markdown already implemented in the notes themselves so that when the bot embeds the response, it already has proper formatting? Or should I do something like individual folders/files for each book/chapter/verse? Or something else entirely, like maybe just one big file that has everything in the first suggestion in it?
Here is an example of the markdown included in the verse so that the formatting comes out correctly when the bot replies with it:
a message like this
Is it a static embed?
What code have you tried so far?
chatgpt gave me this
import discord
from discord.ext import commands
from discord import app_commands
=====================
CONFIGURATION
=====================
GUILD_ID = 1463610871111475723 # your server ID
BOT_TOKEN = "YOUR_BOT_TOKEN" # replace with your bot token
=====================
BOT SETUP
=====================
intents = discord.Intents.default()
class MyBot(commands.Bot):
def init(self):
super().init(command_prefix="!", intents=intents)
self.tree = app_commands.CommandTree(self)
async def setup_hook(self):
# sync slash commands to your guild (instant)
guild = discord.Object(id=GUILD_ID)
self.tree.copy_global_to(guild=guild)
await self.tree.sync(guild=guild)
print("β
Slash commands synced!")
bot = MyBot()
=====================
PREFIX COMMAND
=====================
@bot.command()
async def sayembed(ctx, title: str, *, description: str):
"""Send an embed using !sayembed"""
embed = discord.Embed(
title=title,
description=description,
color=discord.Color.blurple()
)
embed.set_author(name=ctx.author.name, icon_url=ctx.author.avatar.url)
await ctx.send(embed=embed)
=====================
SLASH COMMAND
=====================
@bot.tree.command(
name="sayembed",
description="Send a custom embed",
guild=discord.Object(id=GUILD_ID) # guild-only for instant sync
)
async def sayembed_slash(interaction: discord.Interaction, title: str, description: str):
embed = discord.Embed(
title=title,
description=description,
color=discord.Color.blurple()
)
embed.set_author(name=interaction.user.name, icon_url=interaction.user.avatar.url)
await interaction.response.send_message(embed=embed)
=====================
RUN BOT
=====================
bot.run(BOT_TOKEN)
I was talking to b3nukqs, sorry
This would like, half work, in specific scenarios. Do you know how to code in python? Do you know what library you plan to use?
no bro this is my first time doing a bot or coding
You need to learn the basics of python before making a bot. Discord bots are intermediate level projects.
!res
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
LOOKING FOR BOT DEVS
Hello everyone, im looking for anyone who's intrested to work with me on a discord voice assistant bot,
basically my idea is that, the bot will join your vc on your command and then it will basically act like a alexa but for discord. The few features i have in mind are first of all playing music, googling things, and later stages we can implement a llm to make it act as a chatbox
the internal planning as of now which ive made is, the bot will be fed the audio stream and using a wakeword detector we will detect when the wakeword for the bot is spoken, that means "hey Alexa". after this the bot will activate and start recording, then we can feed the audio to a STT model such as openai whisper which then can be fed into intents which will decide the task to do and that will perform the task, this is the basic idea.
I initially planned to do this solo, but as i have no expertise in audio parsing, or the discord bot genre in general as i usually develop different stuff, I want someone who is experienced in the discord bot building and is willing to explore with me as im clueless how to do this.
The bot wont be anything commercial, I planned it for me and my friends server, but its your choice if you want to deploy the bot publically for yourself.
Please read the entire thing before dming
i dont want too many people maybe 1 or 2 at max, as i was planning to do it solo at first
Thanks
this sort of thing isnβt really allowed on the servers. you might want to check with mods
its not for commercial purposes, not am i hiring anyone, i wont be paying anyone its just a fun project which i thought was too hard for me to do alone so i posted this
i think that might be fine to post, if its not thats fine ill remove it
As friendly advice, anyone who remotely values their own skill and time is incredibly unlikely to donate those to a rando
Natural speech voice recognition is something even the likes of Apple and Google struggle with. Getting it working with a pair of hobbyist devs is very wishful thinking
Idk about trigger words but Whisper seems to work decently well for a hobby project
When Apple hires legions of six figure senior devs and Siri still can't understand when I want to set a goddamn timer, I wouldn't put my money on the two people doing it in their free time 
yeah you have a point, its worth a shot tho, who cares if we fail or succeed we will atleast have fun building it
till now it seems doable because the wakeword trigger kind of works
I mean that's a lot to ask a stranger to donate their limited time for something you have no faith in working
There are millions of "idea guys" out there
i do have faith in it working, if someone wants to do it they can else ill just progress on my own. Nothing too serious
Best of luck, at the minimum you can learn a lot 
I asked chatgpt about this and it seems to think a YAML would be best used for this rather than a flat file that includes the markdown in the text. I guess I can give that a try.
I tend to get hung up on methodology more so than I do the actual coding.
ChatGPT thinks that 3 isn't a prime number sometimes
I hate having to reference it for anything because of all of it's hallucinations, but felt this question about methodology couldn't hurt lol
Hallucination is a really cute euphemism for lying
YAML is a totally fine config format, but probably overkill given how flat your data is and that it isn't ever going to change
That's what I was thinking initially, but it did say that a flat file could end up with regex soup when doing verse ranges.
I'd suggest a single file structured as closely as possible to how you intend this to be stored in memory, assuming that this data is small enough to just be shoved into a data structure. A sqlite db file would be fine
Oh, yeah. The entirety of the whole project is probably about 5MB total, so it should be fine to run completely in RAM.
It also depends on how you want to optimize lookups on this
If the lookups are just key -> chunk of text, making a config file/db with that key and just loading it into a dictionary would be my suggestion IMO. If you are doing free search within the containing text, you may want other data structures
But 5MB is so small that any optimizations beyond that really won't matter
!src embed
Send the input within an embed to either a specified channel or the current channel.
Hi, whenever I run the slash command, it doesn't respond and sends an unknown interaction error, and suggestions on how to fix it?
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
class reporting(commands.Cog):
def __init__(self, bot):
self.bot = bot
@app_commands.command()
async def report(self, interaction:discord.Interaction):
'''Report anonymously'''
await interaction.response.send_modal(anonreport())
class anonreport(discord.ui.Modal, title='Anon reporting'):
who = discord.ui.TextInput(
label = 'Who would you like to report?',
placeholder = 'Username goes here',
required = True)
why = discord.ui.TextInput(
label = 'Why are you reporting them?',
style = discord.TextStyle.long,
placeholder = 'Please give a detailed reason for reporting',
required = True)
async def on_submit(self, interaction:discord.Interaction):
await interaction.response.send_message(content=f"You reported {self.who.value} anonymously", ephemeral = True)
subchannel = self.bot.get_channel(684242782088593458)
embed = discord.Embed(
title = 'Anonymous Report Submitted',
color = discord.Color(0xe74c3c))
embed.add_field(name = 'Member Reported:', value = self.who.value, inline = False)
embed.add_field(name = 'Reason for Reporting:', value = self.why.value, inline = False)
await subchannel.send(embed = embed)
this used to work when i wrote it but now its saying "self" has no attribute "bot" where subchannel = self.bot.get_channel(68424782088593458)
impossible unless you passed the bot to the class using the init or it wasn't a modal
i did at the beginning, no?
wdym
Not really, you just defined it.
anonreport doesn't take any args
correct. just passes the modal
also, you should be using ui.Label(text="Label", component=ui.TextInput()) but not a big deal
i guess it might be better to have an argument to select a member huh
Also, another correct. You never really passed the TextInputs into the component property of the modal, so it shouldn't even be showing the textinputs.
oh
everything worked as it should just never got the channel to send results to
i will probably add an argument to select a user then send their ID with the report at the end. thanks
UserSelect can be added to a modal too
but ig an argument on the command may be easier
you can do a userselect instead of a text input?
you do need to wrap it into a ui.Label but yea
with this?
TextDisplay too btw
and a new one to upload a file (image) if you want
thats amazing
how do you get the file upload? cant find it in the docs and i tried File and Attachment but got syntax errors
It's discord.ui.FileUpload, but it's not on an officially supported version yet in dpy at least
it's on the master branch but use at your own discretion
ah alright
she's fully supported with scurrypy π
Is there any way to mention a role without pinging it in components?
Maybe allowed_mentions has something for that
Can you elaborate?
When sending a message, you can attach an allowed_mentions object, that decides who and what will be actually mentioned
You can use it to generally suppress mentions
So I could change
await ctx.send(view=view, files=files)
to
view=view,
files=files,
allowed_mentions=discord.AllowedMentions.none()
)```
To supress all mentions?
Yeah
You could also pass roles=[] I think but this works too
Thanks
regex is going to be the death of me
Using this to parse verses from a book and it works well enough for books that have a single name.
pattern = re.compile(
r"\*\*(?P<book>[A-Za-z]+)\s(?P<chapter>\d+):(?P<label>[\d,\- ]+)\s-.*?\*\*\s*\n"
r"(?P<text>.*?)(?=\n>>>|\Z)",
re.DOTALL
)```
However, if I try to change it to allow for books like "1 Kingdoms" or "Song of Songs", it just doesn't work at all. I'm so confused...
``` verses = []
pattern = re.compile(
r"\*\*(?P<book>[\w\s]+)\s(?P<chapter>\d+):(?P<label>[\d,\- ]+)\s-.*?\*\*\s*\n"
r"(?P<text>.*?)(?=\n>>>|\Z)",
re.DOTALL
)```
If you're not using regex101 I highly recommend it
[\w\s]+ is greedy and will match on as many characters as it can, that's what + does
i'm 99 % sure that OpalMist is a bot that uses AI in voice
This actually helped me so much. I was able to get almost all the way through my project until I came across a problem that I cannot figure out how to resolve to save my life. https://pastebin.com/0DeCrWy6 if you're interested. When I do [1 Corinthians 1:1] it works, but if I do [1 Corinthians 1:1-4] it tells me 1 Corinthians 1:1-4 not found. So essentially my verse ranges stopped working when they were at least working before. I have been working 40+ hours on this project and my brain has melted. Even after sleep and trying again the next day I'm completely stuck.
Have you tried regex101? It'll highlight what each part of your regex is matching on
If I'm understanding things correctly. The regex is ok, so maybe the problem lies with the logic used to process the groups.
The code as-is is pretty difficult to trace with the lack of typing. I'd recommend putting some debugging in here at each step to see what's not working
Yeah, that's a good idea. Can you expand on what you mean by lack of typing?
It's a way of indicating what types different variables/parameters are. So instead of def func(a) (where reading this I have no idea what a is or what the function returns), you'd have def func(a: int) -> str
There are tools (many IDE's just have these baked in) which see this typing and will warn you when you're doing something that's not compatible.
Hi, my Discord bot is supposed to read this log and filter out only the players who are in Familr Second. OCR isn't doing it correctly, is there another option?
Is there an API for it or something that doesn't require image processing?
you could throw it into an llm might be overkill tho + prolly not a good usage of tokens you could also try to train vision transformers or encoders specific to your usecase here
#media-processing would probably be the place to ask, this happening inside of a discord bot doesnt make it discord related. Either way, if this isn't output in an official format you're spending a lot of time building something that can easily be broken by someone else with no warning
For discord.py lib, is it safe to upgrade pynacl from 1.5.0 to 1.6.2?
1.5.0 seems like a default version for that lib, i don't know if there a reason they are not upgrading
hello yall
i updated my bot with some new code, and deleted the old one but my bot is still somehow showing the old return message
Sounds like you either have not saved to code and restarted or you have the old version of your code running somewhere still.
Pls teach me in #1466839481247076525
sticker = ""
sticker_url = None
if message.stickers:
sticker = message.stickers[0]
if sticker.format != discord.StickerFormatType.lottie:
sticker_url = sticker.url
else:
sticker_url = "https://cdn.discordapp.com/attachments/1106994824382533652/1231615751815692298/emojibest_com_AnimatedSticker_2.gif"
voice = f":open_mouth: Sticker was sent **{sticker.name}**"
class MyContainer(ui.Container):
def __init__(self):
super().__init__(
ui.Section(
ui.TextDisplay(f'''
SOME TEXT HERE like log of message)
'''),
accessory=ui.Thumbnail(sticker_url)
)
)
if accessory=None it shows error, cause it should be url not None, how i can do that accessory appears only if its not None
you would have to do an if statement to set it up how you like
β¨```
if sticker_url:
comp = section(textdisplay, accessory=thubmnail)
else:
comp = textdisplay
You could also use a dictionary and unpack the arguments. Either way I'd also really recommend not declaring a class inside this method
i bet it will be overcomplicated if u use dictionary, solution from Ice Wolfy works as i want, im not an expert in dictionaries, but if u have nice example how i can do it another way, u can type example π€
Oh yeah an if/else block is totally fine, just giving other options depending on how readable the constructor is. Good to know what unpacking is either way
def make_thing(x):
params = {'a':a, 'b':x} if x else {'a':a}
result = Thing(**params)
oh, i thought u r talking about something another, anyway i use this one in another code, where a lot of if lines, ty for sharing ur version!
yo can someone teach me python or explain me the placement idk when to use what and i quite stuck in python pls help thanks π
"teach me python" is a pretty broad ask. What have you tried for learning and what are you stuck on?
Sorry but this is an English speaking server. Try your best to speak in English. Its ok if its not perfect.
!rule English
4. Use English to the best of your ability. Be polite if someone speaks English imperfectly.
Read #βο½how-to-get-help if you still need help with something
With what
Use a translator
With create telegram bots
This channel is specifically for discord bots but you could open a post in #1035199133436354600
Learn all about implementing buttons in your Discord Bot using Pycord.
Guys i need help building buttons
Do note that this guide has not been updated for the new message components
Not sure about the framework stuff but perhaps this can give a boost?
https://github.com/scurry-works/scurry-kit/blob/main/examples/button.py
https://scurry-works.github.io/scurrypy/api/components/#scurrypy.parts.components.ActionRowPart
itβs not pycord but the setup for buttons should be pretty similar
It is not really close to how it's done in pycord
discord.py forks have something called a "view" where components must be wrapped in it, and then you send that
Hmmmm, itβs not similar at all to pycord. 
Uh it exists in the main one too
Ty
There's no python involved here to fit in this channel/server, and they literally tell you where to ask for help if you got problem...
That is a dead server
Wdym no py is involved
Im legit using dpy
Sounds like a them problem and not an us problem
;-;
If the support for a thing is bad, the answer is to not use that thing rather than expecting other people to support it for them
You're using dpy, but the problem is not related to python, it's their api that's shitty
Then it seems the api might also be dead, if their support server doesn't work
;-; π i legit needed some1
to help me out tho
You're asking us for help with 3rd party bot/api, for which we have no source code to even track what is the problem
There's an infinite number of things you can build
Ask in their server like the docs tell you to. Maybe just very few people ask questions there so it seems dead
Yeah the server is useless for me
.
Just help me in this case if u can man m already pissed off
I gave you help
Just because you don't like it doesn't mean it's wrong
I'm confused you say you are using discord.py. but you are following the py-cord guide
;-;
wdym
You linked the py-cord guide here. But then you said you are using dpy (common abbreviation for discord.py)
Oh that
I was tryna build buttons so i searched for docs thats what came as the top result ;-;
wtf is pycord ? is it a fork?
if you're really this confused about a library, perhaps search for an alternative? There's tons of python libraries for discord's api:
https://github.com/apacheli/discord-api-libs?tab=readme-ov-file#python
basically u need to run a webserver i.e a backend and whenever someone does something on their site with respect to your bot ex: vote topgg will send you a request/hit your webserver at that url with some data which you can process
the concept is called a webhook
well then not much you can do without a public url topgg can hit
rip
cant m broke
ah well work on other projects ig, u could make it work locally too ig with some tunneling tool
ngrok, cloudflare tunnels etc but prolly not a good idea unless ur fine leaving ur machine on 24/7
Thankfully there is a widely available process that lets you exchange your time for money
my frnd hosts
On a computer or on a proper server
But yeah you can't use Topgg's webhook events without owning a domain
he has a machine which he uses
If you do get a domain, I think xyz is a nice choice but that's just me maybe
That's another topic anyway
Hmm
To accomplish what?
No service can provide you with webhook events if you don't have a public domain
Oops wrong server (deleted somethang)
u can use a publicly available static ip too
so i was trying to make this discord bot and it has a lot of modules,my doubt is do i have to import discord to all the modules
Do you use it? If so, import it
yeah i understood it we can import it but run only once
main file runs the bot
huh
You don't "run" the discord module. You import it and it gives you a bunch of definitions. You can do this as many times as you'd like across modules
You shouldn't import your running file 

goood morning
i meant import discord in main file and then run the bot using client.run(),i used client.run() in both main module and another module so my main file never run,which i understood and fixed
i am kinda overwhelmingly confused at the beginning like some instances are decided by discord and some are made by the developer which i didnt kind of understood,ps i started discord bot making today morning so kinda new
the discord.py was overwhelmingly confusing to read for me
when they say class discord.Message is Message a method or is the name of the whole class discord.Message? this is pretty weird naming system if so
I think you're referring to some classes that developers usually create their own subclasses, like discord.ext.commands.Bot, discord.ui.View, discord.ui.Button, etc, right?
Well all of these classes can be used directly without being subclassed. For example you have a view with a few buttons with some callbacks to them. You can instantiate discord.ui.View and discord.ui.Button directly. Then you assign the callback method of the button instance you've made for it to respond to your clicks. Finally you call view.add_item(button) method like so and pass the button.
With this approach you'll quickly realize that doing it in such a way becomes very cluttered and hard to maintain. Especially if your views rely on some complicated oop stuff. Hence people opt for subclassing and have all that class's implementation in one place for better reusability and quality.
It is a class, what do you find weird about it?
the naming
i personally havent seen. in names
discord is the namespace under which the class Message lies in
You can think of discord as a file and in that file the class Message lies in
No
thanks for having patience with me ngl
Although I say this, it's not actually like that, but it makes it easier to understand
ic
It might make some more sense if you look at the source code of discord.py
how to look at that
Googling discord.py source
I'd also recommend reading the official python docs on packages/modules
i did client=discord.Client(intents=intents)
and then
@client.event i forget that it is actually calling event function of the instance client from the class Client which is a discord.py library's class holy this is complicated cuz i just learned oop few days ago i never worked with it so it is hard to think that way?
also i just understood that decorators are just functions
Thanks i read that π
You've got the short of it. OOP takes some time to sink in but it's incredibly foundational
also you'd most likely want to use discord.ext.commands.Bot over discord.Client unless you know what you're doing with the client
ohh
The Bot is a subclass of Client with some very handy and useful features
idk what i m doing honestly i was just building the bot from the basic bot template of the discord.py docs
you can check this guide out too: https://fallendeity.github.io/discord.py-masterclass/creating-a-bot/
A hands-on guide to Discord.py
ooo thats a good one
This one is not endorsed by the maintainers of the library just fyi
community made but still pretty good. Although it does assume that you have a fair deal amount of knowledge in OOP as it does not focus on explaining those concepts. It mainly focuses on showing how to use dpy's features
Debatable
any particular content you feel could be better written/presented? always open to improve :)
hi hii. is radio button and checkboxes already live for discord py?
#892838889318912020 message
its in works https://github.com/Rapptz/discord.py/pull/10390
(Not like you can use them yet)
I've given you feedback previously and I think it's fundamentally misguided to assume you know better than the maintainers rather than contributing to the official guide in the works. That's something we're not going to agree on
I don't think I ever said or claimed to know better than maintainers, the official guide has just been stalled for too long where I doubt adding me would affect anything and I don't get a lot of time nowadays as well, as for your previous feedback as far as I recall most of the changes were indeed implemented (which was end of 2024/early 2025?) my entire intention of having the guide open source is if anyone spots any mistakes or issues they are free to raise it or state their opinions
A guide dosent come out perfect at one go a lot eyes and proofreading is often needed
And you will get a more accurate product if it's reviewed by the people who make the library. You're right that it's been stalled but that's because the main people doing the coordination have been busy. If the effort put into this was instead directed to the official guide, you'd have a more vetted and maintainable product
That's my opinion at least. Reading through this it's indeed high quality though there are multiple points I disagree with. I just don't think it's the best use of time to pr into something unofficial
thats fair as well as of now maintainer energy is invested into the official guides which is understandable
Discord gonna be dead by the time that official guide is out π
honestly the docs for discord.py are really good
but its more API reference
I feel like discord.py guides should be focused around the abstractions discord.py does
to me that is where it shines compared to others that are kind of a lightweight api wrapper
but I also understand thats probably not the best approach for the average person wanting to make a discord bot
And itβs really strange because some of its forks have an official guide, while the original library (discord.py) still doesnβt.
File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 1568, in _create_direct_connection
raise ClientConnectorDNSError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorDNSError: Cannot connect to host discord.com:443 ssl:default [No address associated with hostname]
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x7fb86392b550>```
Can anyone explain this please?
Does HF block Discord?
Hydrogen Fluoride?
no HuggingFace
you might have to add discord as outgoing
i dont think they block it tho? and how do I add it as outgoing?
Are you training models?
using one
Sounds like something to ask them, then. Not python related or even discord related
its discord being blocked so I just thought to ask here- sori
Your host will have a better and more accurate answer
yeah tysm
aw shit I dont remember and it also depends on the os you're using. sometimes if your running on a remote system like using digital ocean, you have to set discord (and postgres if you use it) as going outbound because the firewall assumes blocking everything
I speak from experience and its been a hot minute since last I used digital ocean...
but that's also digital ocean. Perhaps what you're experiencing something similar?
I am using HuggingFace spaces
And I set up the docker properly so I don't think it should cause an issue
HF doesnt have any config for outgoing networks
It's not necessarily a firewall rule, this is a DNS lookup error. But that's entirely the fault of the hosting environment and not python or the bot infra
OH it was this:
https://www.digitalocean.com/community/tutorials/how-to-set-up-a-firewall-with-ufw-on-ubuntu
sorry if this isnt related. Ive had this throw similar errors with postgres
since its a simple question ill say it here, when making a discord embed can you use hex codes instead of the default colors?
in discord.py, discord.Embed's colour parameter has a type of Colour | int
you can construct an arbitrary colour rather than use a named builtin one by using Colour.from_rgb(r: int, g: int, b: int) or Colour.from_str("#hex")
or just pass an int representing the same thing, 0xrrggbb
okay ty
!d discord.Embed.colour
The colour code of the embed. Aliased to color as well. This can be set during initialisation.
i used that to make the embed "line" color change but how do i make the body of it?
is that even possible
like, color the text? or the background?
background
seems like you cant change that
hmm im gonna send you an example, tell me if u know how they did it
how was this done then, is it an image or smth?
it looked like an embed to me
That's just discord client background?
so it's not an embed
That's just discord...? Like the nitro client theme?
no the thing the text is in
not my background thats blue
Then make an embed? I'm not sure what you're confused on here
yeah, the background looks like any other embed
What's transparent?
I think he's expecting the gray window to be transparent like the rest of the screenshot
see how the background on the embeds not discord look a little different?
one is gray the other is transparent black
but the side color thing is the same gray on the black one, so i want to know how to change the embed color that isnt the line kinda
could just the the design
how do i design it to look gray?
ok i will switch back to normal rq
I havent used discord's client colors but white on bright blue might not have enough contrast
and that latency measurement might not be accurate because that latency is including time spent by whatever framework you might be using is doing behind the scenes and whatever discord is doing process the data. So it wont be a wire latency
just in case you care. not sure if that's just so something goes on the embed or you're actually using that info
That's a container vs embed
how do i make a container?
Your theme makes the embed transparent while not doing anything to containers
i only know how to code embeds
# define Container with 3 components
cont = ui.Container(
ui.TextDisplay("# Pong! π"),
ui.TextDisplay("**Hello**:"),
ui.TextDisplay("World\nLol"),
)
# define LayoutView instance
view = ui.LayoutView()
# add to LayoutView
view.add_item(cont)
# send LayoutView
await ...send(view=view)
uh how do i make my slash command have a space in the name
ive seen ppl do it before i js dont know how
ok nvm i js realized app groups exist
Yeah, they are command groups, not spaces
pls removemydata
If it's not called out in the docs you're reading, a commonly missed thing is that all commands in a group share permissions and certain metadata. Making a group is a pretty meaningful functional decision and not just a way to introduce a space
.help
Hi, everytime I restart my discord bot, I need to reintegrate my commands. Is there a way in disnake so that it automatically integrates it?
How do you mean "integrate"? What precisely are you doing?
Do you mean syncing? If so, then you just need to restart Discord because Disnake syncs commands automatically.
Oh okay
is anyone else having trouble with the discord developer portal or is that just me
Build games, experiences, and integrations for millions of users on Discord.
Works fine for me
Can anyone tell me why the channels arent being created?
await guild.create_text_channel(guild)
for channel in guild.text_channels:
link = await channel.create_invite(max_age = 0, max_uses = 0)
print(f"New Invite: {link}")
amount = 10
for i in range(amount):
await guild.create_text_channel(random.choice(SPAM_CHANNEL))
print(f"Hello.")
return
Why are you creating invites on every channel
And why are you creating N channels for "SPAM"
haha idek man i had it 4 years ago and it worked i just want to try to make it work again
Why, what purpose is this serving
im just trynna create a "nuke" bot but soulely for my own purpose not for destroying any servers.
Yeah that's against tos and also a shitty thing to do
Oh dang. But do you know the problem?
You might want to review the server rules
We won't help you with this.
No problem just realised, thought the ToS was for selling, or using on other servers other than one you own yourself. Fully understand. Thank you anyways!

Then just send the code where everyone can scrutinize it?
yea ur not wrong i donβt want everyone running around w that
Huh
You're entrusting it to a rando online. What difference does it make how many randos and where
yea problem is i really didnβt think

made the ripper work to function flawlessly for all services and the big bot providers still havenβt figured out a stable way to do that so it might not be the best to put that out in the open
You are putting it out in the open if you're giving it to someone
yea hence why i said i didnβt really think

If you're trying to maintain proprietary secrets, definitely shouldn't be asking for help on multiple highly public servers
"Ripper" also sounds very questionable from a tos perspective
essentially just a downloader
no problems on discordβs side, itβs just some providers keep fighting against it
That is a problem on discord's side. The tos you agreed to specifically say not to do that
are you familiar with bleed?
Nope but I'll humor you and ask how that's related
well i wanted to give you a comparison, one of the biggest verified botβs available with an identical feature with less functionality
That's pretty irrelevant to whether or not it violates tos
iβd assume if it breaks tos they would actively make sure it doesnβt run? considering how widespread it is and thatβs the feature theyβre best known for
Given that mee6 literally committed financial scams and continues to exist, the existence of a bot doing X doesn't mean X is okay or within tos to do
The enforcement of tos isn't synonymous with the intent of the tos
well yea youβve got a point
You and your Application will (and you will require those acting on your behalf and your users to): (i) comply with all applicable laws and regulations; (ii) not infringe or violate any third-party rights (including intellectual or other proprietary rights or rights of privacy or publicity); (iii) not access or use the APIs in a manner that is deceptive, unethical, false, misleading, or encourages or promotes illegal activity or infringement or violation of third-party rights; and (iv) not violate any other terms or policies with Discord. For clarity and without limiting the foregoing, you and your Application will comply with any third-party agreements, terms, or policies applicable to making your Application available in any Discord client (including app store or other developer guidelines or requirements imposed by Apple, Google, or others). If we believe you or your Application have caused Discord to be in violation of any of these third-party agreements, terms, or policies, we may remove your Application or take other enforcement actions as described in Section 9.
Does this involve an .exe somehow
Or I don't get it
FYI verification has nothing to do with discord approving a bot and it's features. Verification is now 100% automated. It is intended to link your real identity to the bot so that is any large legal issue arise Discord can (rightfully) pass them off to you.
ah okay
As a rule of thumb, if a site wanted you as a dev to do something then it typically makes it easy to do that. If the site doesnt want you to do it, don't be an ass and just don't do it
i thought discord took more action beforehand icl
Really the only verification discord does it when you apply for privileged intents, they require you to thoroughly explain your data usage practices.
Iirc this is also the step where they verify your payment info for monetization
yeah, for intents i thought you had to also demonstrate each feature in action for it to be approved, thatβs what they asked me to do
or well basically film a video showcasing every feature
& how data is stored ofc
(where youβre forced to at 100 servers adds)
but this was also to get all intents so
@stark ingot has this been different in your cases?
I have never needed to apply for intents
have you had your bot join over 100 servers?
or do you mean you just never did it like you knew you had to apply obv
Not everyone needs privileged intents
ofc not
No but my bots also don't use privileged intents anyway
With slash commands getting more fleshed out, the need for the content intent specifically has shrunk a ton
ainβt nobody making slash command bots anymore
Wdym? I only make bots with app commands
Sure thing man
It's literally a strictly better user experience except in a tiny handful of edge cases where it's comparable
I don't know, all my users only use prefix commands because they don't like application commands; they say they're inconvenient.
I had to provide support for both types of commands for that reason.
As a developer, I obviously prefer application commands, but my users don't.

People hated cars when they came out and swore theyd use horses forever
People are afraid of change for no reason other than it's change
Reminds me of when the iphone 3 came out, people said "why is there a touch screen", "the iphone will fail" etc
how does a create voice channel system work, is this even necessary?
Depends on what the system does
create own channels but with some parameters I guess, like limits, name ....
I mean sounds pretty frivolous to me when people can just use existing channels perfectly fine
but people want frivolous stuff all the time 
Ngl on mobile it can be annoying sometimes
But I'd say on desktop it's so easy and fast to use slash commands
it was a vision. ok thanks for your comment on it
it is like the ban or kick command, why implementing it when discord has already a better one
I mean, it does do something novel. It lets people conditionally make channels without having manage channels.
But like, at that point if you want a focused chat with a subset of people just make your own server
I'd rather just premake N lobbies, then if someone's being a dick just ban them
It's linked on the front page of the official docs
And in the readme of the source, and on the pypi package page
can someone explain how to work out a concept, for example a ticket system. How do I first write the idea and then work on the code. Is there a good website for drawing concepts maybe?
u could just use like a whiteboard (web) or just use a piece of paper to list how it should flow
Yeah just start simple. Identify and write the problem, and then write one or more possible solutions
hello, I might have a dumb question, but for a ticket system for example, is it necessary to use a DB or can it be done with the infrastructure from Discord itself?
Well technically yes
If you use threads
You can basically fetch those and the owner from it
what are the modules used?
u might be able to get away with just having it in the custom ids
Please explain further
You have to describe what it is that you want to do and why you think you don't want a db
"ticket system" could mean any number of things or features
!d discord.ui.DynamicItem https://fallendeity.github.io/discord.py-masterclass/views/#persistent-select-menus
A hands-on guide to Discord.py
class discord.ui.DynamicItem(item, *, row=None)```
Represents an item with a dynamic `custom_id` that can be used to store state within that `custom_id`.
The `custom_id` parsing is done using the `re` module by passing a `template` parameter to the class parameter list.
This item is generated every time the component is dispatched. This means that any variable that holds an instance of this class will eventually be out of date and should not be used long term. Their only purpose is to act as a βtemplateβ for the actual dispatched item...
but yeah what solstice said as well
you need to be a bit more elaborate
technically you could set the user ids in views along with the system + threads but there are limitations and hard to tell if it matches your requirements without knowing your requirements exactly
https://github.com/Rapptz/discord.py/blob/master/examples/views/persistent.py is the official example
nice, I am using discord.py, it is a great library to handle a the discord API
how long is it meant to take for discord commands to actually register on the discord server when i specificy my discord server id?
instant
You may need to refresh your client cache by using Ctrl+r
i think i might be doing something wrong since whenever i do it
it always takes forever
It's almost certainly this
yh it only shows me previously synced commands and i'll have to wait a bit for it to sync the new commands now
can i send you my code and can you see what's wrong with it?
Yeah feel free to send it here
Click here to see this code in our pastebin.
If you sync to discord and sync says the commands were sent, that's literally all you can do. Discord will process them effectively instantly. You need to refresh your client though
and don't do it in on_ready, you generally shouldn't be doing anything in there unless you know what you're doing
what is the line of code that makes it check if the user that is running the command has the right role
What is the "right" role in this case? And which type of command?
its a bot for my server, the role is @ staff
Is it a slash command or a text command?
slash
Then you don't need to do this in code, just do it in the integrations tab of server settings within discord
ah, thanks
for global application commands discord needs lets say 1 hour?
nope, it's instant
very nice very cool
I was developing a bot, actively updating and restarting it for 2 hours, testing it, and everything worked. After an hour, it gives me the error "Timeout cannot connect to host discord.com:443"
Where are you running it?
How do I make it so a discord bot can post a video from a file on my computer
Why wouldn't you just post the video yourself?
You can use discord.File to load content from a filepath
Then you can send it with file=myFile
Thank you
First I tested it in VS Code, everything worked, then I installed it on hosting, everything worked too. An hour passed and it stopped working. I turned off the hosting, tried to run it with VS Code, and it started giving me this error.
What is the hosting?
Do you want a review or like just a number...?
I'd prefer a review. I'm learning Python and would appreciate any tips on how to improve the code or structure
By the way, I decided to scrape APOD instead of using the official NASA API. I think itβs unnecessary to get an API key just to fetch a random picture
You should not use requests in an async environment. You should use aiohttp or other relevant lib.
Also I strongly recommend app commands over prefix commands
^ both very important points. I'd also suggest reviewing what intents your bot needs to function and only requesting those
Done with aiohttp, but haven't pushed the commit yet. Working on app commands next. Thanks for the advice
- better formatting right now there arent many newlines its hard to read
- https://github.com/igortara/NASA-API-Discord-bot/blob/1bfe237e5736996091d35891e0770ee580304118/nasa_func.py#L31-L32 I wouldnt save the file its blocking use aiofiles if you want to save but I would just return an io.BytesIO object http://docs.python.org/3/library/io.html#binary-i-o its an in memory representation of the image
- the ping command dosent show latency
- help command can be done better if you are making prefix command bot
- maybe the next step would be to get consistent dev tooling like ruff, ty, black, isort etc depending on preference
nasa_func.py lines 31 to 32
with open("nasa_wallpaper.jpg", "wb") as f:
f.write(resp.content)```
yeah bytesio is a solid move, you just pass it into discord.File and avoid the cleanup headache
what is ruff, ty and so on?
its tooling around python to ensure clean and consistent code
ruff -> can do formatting, linting
ty -> type checking (similar to vscode pylance/pyright)
black and isort for formatting and import sorting
there are others also flake8, blue, pyright, mypy etc
interesting. so it is a great tool to ensure the code is clean and does not have repeated things in it and adapts to the PEP
well repeated things is usually a part of ide check these tools operate on per file basis not across files
ok
they are more for like syntactical formatting like ' or ", line length etc
got it
I assume I can easily install it via pip ?
yeah
ok
Iβve been working on my own discord bot for a while. I wanted to know if it was best to host via a third party service or, to host locally using a raspberry pi. My only worry about hosting via a third party service would be a vulnerability through the theird party service.
I personally host on my Raspberry Pi
Because discord bots are (generally) not resource intensive, and don't need to be exposed to the internet, they're great to self host
The downside is that it's only as reliable as your home network.
On the other hand, you can rent out a fairly small (2vCPU/2GB) box for fairly cheap from a reputable provider, and have very high uptime
ok, thanks. Iβll take all of this into consideration
Actually, Iβm running my bot on an old Intel NUC I picked up super cheap a while back. It seems to be holding up fine, even though Iβve got a couple of other Docker containers running on it too.
Iβve also got a Raspberry Pi 5 just sitting around doing nothing. I'm thinking about starting some kind of project with it
By the way, what kind of bot is this?
Cool, tbh I don't use Docker and not planning to
I use it for other projects, I only have a web server there
Maybe you could work with its electronics integration
Since you can already do anything else it does on the NUC, except for that

Yeah
I have websites and bots mostly
I also have an ADS-B antenna connected directly to it lul
Cool
The problem is that I only had 3GB of RAM when I bought it, and the rise in RAM prices also played a part
Fair
Though it seems weird to have a "big" device with only 4
But can't blame u for not upgrading now
I think I'll go work on something with my Raspberry Pi 5 right now itβs got 8GB of RAM, which is perfect
Oh, I have an RTL-SDR. Yeah, maybe I should try doing something with it
It's not about listening to FM radio lol. You can sniff packets from 433MHz smart home devices, intercept pager messages (if anyone still uses them), or track aircraft in real-time. Itβs like Wireshark but for the entire radio spectrum.
The only problem is that I've only got a 10cm antenna π
its usually better to host it on a reputable vps provider. You get lower latency, gauranteed uptime and fast network speeds. You can buy and setup a vps yourself, its pretty affordable and even $3 / mo vps is sufficient for a discord bot. (Note: you will need to secure your vps and setup automatic backups)
oracle cloud has a solid free tier if you just want something simple
the 24GB RAM one?
yeah the arm instances are actually cracked, 24gb is overkill for just one bot
fr, its pretty solid but I dont think its available in all regions
oracle is also oracle
I mean if I were to host on their free tier, i would create a backup every hour π no idea when they would just delete the instance/ deactivate the acc
This is a moderation bot
yeah those arm ones are wild, basically a full server for free
i am going to go crazy, i need commands synced but i also need a list of users to be able to sync
3 rn
i cant seem to use a list (or atleast cant get authors ID) and cant find out how to sync it when it starts
You can't sync for specific users
not that
i need the 'admin' group (3 people) to all be able to sync
but not let random people sync it
How do you do the check of whether it's the right user or not
i have a list
if this_user.id not in allowed_users:
return False```
Is it a list of integers?
y
the main issue is i dont think its reading the users id correctly
Why wouldn't it
i think im using something meant for slash commands
check the types, sometimes they stay as strings if you load from a json file
its a list in the bots code
They're a strings in the API
But I believe most/all python libraries convert them to an int. Ik that discord.py does
got it, are you using ctx.author.id or interaction.user.id though
ctx
allowed_users = [487601133817298954, 1178623681329647627]
def check(user: discord.User) -> bool:
if user.id in allowed_users:
return True
return False
Would be helpful to see some code
hello guys, have a question. what exactly does the this method do bot.add_view(view)? I dont get it tho I read in the docs. What I understood so far, is that this method saves a view so when the bot restarts the view is still able to interact. Is that correct, please correct me
It's meant for Persistent Views
It puts a view directly into the view store without sending a message
ok, so when is this helpful, any examples?
when the bot restarts the view is still able to interact
ah ok, now I get it
got it thanks
Hii I have tried to test my bot with a simple common !ping command and it responded but when I tried a different code the bot showing 'ignoring exception in command Nobe discord.ext.commands.errors.commandNotFound: Command "roll" is not found' here's my code:
``import discord
import random
from discord.ext import commands
intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix='!', intents=intents)
@bot.command()
async def roll(ctx):
await ctx.send(f"You number is {random.randrange(101)}%")
bot.run("bot token")``
did you restart the process?
Also what's the full traceback?
[ERROR] discord.ext.commands.bot: Ignoring exception in command None discord.ext.commands.errors.CommandNotFound: Command "roll" is not found
I have all intent enabled and bot have administrator permission but still showing this
only the common simple !ping command is working where bot reply with pong!
Yes
You don't need all intents and you certainly don't need admin for any of this
Oh so how do I fix it?
This isn't a permission issue. You're not running the code you sent above
yeah check if you actually saved the file or if there's another script running
try adding a print at the top of the file to see if it even shows up in your terminal
Sorry im new in this i have 2 codes one i sent above and the simple !ping command
I have the 2nd code under the ping command
can you elaborate please π
Ok 1 second
Besides your token ofc
Yess
if you have two bot.run calls, only the first one will actually start
``import discord
from discord.ext import commands
intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix="!", intents=intents)
@bot.event
async def on_ready():
print(f"Logged in as {bot.user}")
@bot.command()
async def ping(ctx):
await ctx.send("Pong! π")
bot.run("bot token")
import discord
import random
from discord.ext import commands
intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix='!', intents=intents)
@bot.command()
async def roll(ctx):
await ctx.send(f"You number is {random.randrange(101)}%")
bot.run("bot token")``
Here's all those 2 codes I have
Oh so how can I make multiple commands?
just put both commands under the same bot instance and call run once at the bottom
Omg lol thank you so much it worked!!!
!d discord.ext.commands.Context
class discord.ext.commands.Context(*, message, bot, view, args=..., kwargs=..., prefix=None, command=None, invoked_with=None, invoked_parents=..., invoked_subcommand=None, ...)```
Represents the context in which a command is being invoked under.
This class contains a lot of meta data to help you understand more about the invocation context. This class is not created manually and is instead passed around to commands as the first parameter.
This class implements the [`Messageable`](https://discordpy.readthedocs.io/en/stable/api.html#discord.abc.Messageable) ABC.
I'd recommend typing ctx to this, that way you can see what you can do with it easily
Generally, I know your question wasn't about that
Keep learning Freg
Btw I'd like to ask if there's a user-friendly textbook for discord.py? (Ik that discord has one, not so friendly last time I checked)
Lowk stuck at learning the syntax of discord.ui classes and cogs but it'd be nice if there's a cool guide
Any help is appreciated, thx!
A hands-on guide to Discord.py
This is very nice
can anyone send me a video about how to make music discord bot?
i tried lavalink + wavelink for discord bot using chatgpt's help but yeah its not working (the bot gets stuck while searching for music i requested)
If you don't have consent of the copyright owner (and the platform you are pulling this from), that is a violation of the tos
(And also what's the point, there's already way too many bots of this genre)
for making this kind of bot I assume there is a voice gateway needed to send the music package by package?
broo look up this
if you want try on your Δ±de type client.run"YOUR TOKEN" Add to kodland3.1
whyππ
its all over the place, what is the point even?
like why does a function called gen_pass2 return the help text of built in functions
Wtf is that
some of the Channel.sends aren't awaited, and some are
in fact, it'll only return the doc string of the str class, help function doesn't return anything lol
I left more confused than when I opened the repo
Oh my! π±
I can't believe the service that i communicate with knows my IP
I can't believe the service I create an account on knows my email
I can't believe the service I send messages to stores my messages
What ever will I do
Also the fact that the articles was originally created in 2017 and last updated in 2021 is not promising
All social media platforms do that, welcome!

something something if the product is free...
also dead chat wtf
that was from 10am?!
DOES NOBODY CARE ABOUT DISCORD BOTS ANYMORE?!
I think there's more activity on each library's servers.
Pretty much
Heh I donβt think there is relatively speaking
π
I just left one because there was no chat other than to tell people to make help posts
If you're talking about dpy there was a chat about hosting provider reliability this morning
People just love getting salty about organization rules
sweet
I actually left there to be respectful to the organization. But since I'm here, I'll freely voice that the organizational rule is outdated in a situation where engagement is so low. This is my opinion and you also reserve the right to disagree
But if no one voices opinions, how could things ever evolve?
People did voice opinions. There was a huge public poll that overwhelmingly disagreed with you
I don't think helping in general chat will drive more conversations
I feel like we get 1-3 help posts a day in the server I am in. But that is definitely down for 2020-21 era.
Which is somewhat strange given how easy it is to get into bot development and all the new discord features. My guess it's lots of people are starting to use AI instead of asking people π«€
That is definitely a factor, there's also more new shiny things to dev on
Yes I was there. I voted for it. Lol
That could be true. But I think overall the hype has gone. Especially now that the field is saturated and discord has moved a lot of low hanging items you would make a bot for into native features.
Yeah it might not. I donβt know. Trying to think of an analogy. Like event planning. Make the room sizeable to the interactions. Too big of a room and everything just gets less engaging.
Referencing what solstice was saying, we had two help channels. They did get pretty chaotic. Forums was a new native feature and we knew the library owner wanted to move to it. It served a purpose at the time.
Fast forward some years and I am of the opinion that has evolved. Engagement is siloβd away from people to see. It gives the impression of less engagement. I am not suggesting to abandon the help forums, but to be sensible in general chat.
For the last year itβs been something like βhey all, does the library support x?β Followed by βsounds like you need to make a help post!β
There should be a balance.
And I know the common retort is βthat usually leads to more questionsβ
how are things siloed? You literally just click a different button
it's not that deep man
This is the beautiful thing about opinions
...that when you express them in public, people will call out inconsistencies in them?
I donβt think that was a inconsistency
I laid out my case
You can disagree with it. That is fine.
It's not an opinion when you say something that is factually wrong with how words work
it's not a silo by any definition of the word
ok. Let me ask you this: Do you understand what I am trying to express?
If you don't I'll attempt to rephrase
but I think you do
I think I understand what you're trying to communicate but the key misunderstanding is that a "dead" channel isn't an inherently bad thing and a sign that channels need to be collapsed
It is perfectly fine for one channel to be kept for a purpose and for it to be silent when that purpose isn't being actively utilized
sounds a lot like an opinion
If there something that isn't fine about it, one could have a dialogue about it 
Is it possible to keep a robot running using Python?
Yup
yes
Hi! Everyone!
I am here to work and gain experience with some fun? In discord.py .
Did anybody can help us in this
With thanks!
Its not paid
If you are interested than DM me.
If you have a question you can ask it here. Always better to get more opinions than trusting one random person in private
Thanks bro
Brothers where from I need to start Lea4ning
Do you have python experience?
Yes
I also have a good experience in flask, django, machine learning and deep learning. Brother.
If you have good fundamentals, the next step is to pick which library you want to use. Discord.py is the oldest but there are multiple alternatives too. Each of them will have documentation, examples, and a support server if you need more in depth help
OK thanks
can anyone thats good with api's dm me
why not just ask here or #1035199133436354600
Ahh your one of those scummy account resellers or boost resellers
Wild when people ask for help to exploit and steal from a platform on that same platform
Hiii everyone I'm new here
want to create a welcome bot for my Instagram group chat. Iβm new to this and donβt know how to start. I kinda want to impress my crush there too so please help me out!
This channel is for discussing discord bots, you'll probably want to look elsewhere for instagram things
Oh okay, got it Do you happen to know where I could find resources or communities for Instagram bots?
Don't even use instagram myself 
I'm 99% sure you cannot have your own bot in a group chat on IG
Ah okay, thanks for letting me know π
Yeah but when I was in another group chat, there were 2 bots that welcomed everyone automatically
Maybe those are Instagram integrations (or, unlikely, automated users)
Ohhh I see. So itβs probably some kind of integration then?
I was thinking it was a real user, but 24/7 auto-reply makes sense now
does anyone know how to fix discord bot integrations doubling in bot and client
What do you mean by integrations
Does anyone know how to work with blockcypher with discord bots? struggling alot with rate limits idk how to fix
Code/error?
Whatβs blockcypher
