#discord-bots
1 messages · Page 399 of 1
classmethod datetime.strptime(date_string, format)```
Return a [`datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime) corresponding to *date\_string*, parsed according to *format*.
If *format* does not contain microseconds or time zone information, this is equivalent to:
```py
datetime(*(time.strptime(date_string, format)[0:6]))
```...
@viscid hornet I think I got it to work 🤷♂️
@bot.tree.command(name="info-dayz", description="Shows DayZ server information.")
async def info_dayz(interaction: discord.Interaction):
payment_remaining_time = datetime.strptime(server_info['Payment_remaining_time'], "%Y-%m-%d %I:%M %p")
current_time = datetime.now()
time_remaining = payment_remaining_time - current_time
if time_remaining.total_seconds() > 0:
days = time_remaining.days
hours = time_remaining.seconds // 3600
time_until_payment = f"{days} days, {hours} hours"
else:
time_until_payment = "Time has passed!"
embed = discord.Embed(title="DayZ Server Information", color=discord.Color.green())
embed.add_field(name="Server Name", value=server_info['name'], inline=False)
embed.add_field(name="Password", value=server_info['password'], inline=False)
embed.add_field(name="Start Time", value=server_info['start_time'], inline=False)
embed.add_field(name="Time until next payment", value=time_until_payment, inline=False)
await interaction.response.send_message(embed=embed, ephemeral=True)
dude you dont need all this
i told you just to parse the end time into a datetime object and then put the timestamp in that format
I'd like to note I use chatgpt to help me with this
dt.strptime("some string here", "your format here") then ts = int(end_dt.timestamp()) and then send <t:{ts}:R>
!rule 10 - there's a reason we have this rule
AI tools aren't reliable, especially for coding
Its not purely AI, and I know that
Chatgpt will keep literally lying to you. I don't know how many times you need to be told that you need to stop using it and actually learn on your own
Once I actually have the time and ability to learn, I will
For the time being, I will do my best to understand as much as I can and attempt to learn
Or you could just learn properly
What's the "proper" way to learn it
Read articles on individual concepts, do small focused exercises to cement your understanding of those concepts. Don't ask chatgpt to shit out wrong code you don't understand and then hope strangers will fix it for you
I'll have to do that when I have free time, right now I have school and alot of work to do each day
Once I switch schools I will be able to take an elective that teaches python though
Then do it then. What you're doing in the interim is reinforcing bad habits and you're asking people to spend their time for free to help you reinforce those bad habits
It really doesn't take that much time to read an article on how something works and try it. You're wasting just as much time trying to get people to fix ChatGPT's outputs. There's not an excuse here
What does a Discord bot usually cost?
To build? Run?
probably to comission
To sell
Would depend on many things
- What the bot does
- How much work was needed to go into the bot
- What the creator charges
- What the buyers budget is
- Is hosting included?
- Is support included? For how long?
- What are other people selling a similar thing for
Also not a remotely python related question
not sure if this is allowed or related, but where do people usually commission for these sorts of things?
!rule 9
how is that asking for paid work? i'm asking WHERE to get paid work, not FOR paid work
Fiverr or similar really
@umbral flare When you had a DayZ server, did you by anychance go through nitrado
Yes
Do you know how to have a bot get info from the ADM log files
5. Do not provide or request help on projects that may violate terms of service, or that may be deemed inappropriate, malicious, or illegal.
!rule 7
7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.
@slate swanWhat I'm asking doesn't violate anything, and as for rule 7 im not entirely sure
meant to send rule 7
Well its for my bot so I'd guess it'd be allowed here
day z servers and their logs have nothing to do with discord bots
It does when I want my bot to get the info from its log files and send the info into my server for killfeeds/stats/playerlists/locations
What you do inside of a discord bot doesnt make it discord bot related if it's not specifically the interface with the discord api
It uses an API which I've seen discussed here, I just don't how to get the API or use it
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
that is the api you'll get help for in this channel
Okay
did you install discord.py with the optional voice dependencies? your command should've looked something like pip install "discord.py[voice]"
oh ok
pip install discord.py[voice]
like this?
@vocal plover
i only did pip install discord.py not the voice
ok
it installed
is that all i need?
i add the toke
token in the little brakcets
@vocal plover
@vocal plover the same problem happened
Do pip install audioop-lts
i did it
You're missing intents kwarg
Judging by your code you only need the privileged message content so,
intents = discord.Intents(messages=True, message_content=True)
client = commands.Bot(command_prefix=",", intents=intents)
I prefer to explicitly enable the required intents but you could also the the default method of the Intent class and then enable message content
ok so like how do i put it in the code
Take a look at all the intents
You have already put it?
it should be client.run
ok
Yeah
Go to the dev portal and enable message content intent
In your bot
Go to your application and under the bot tab
Yeah enable message content
Your command says it needs an argument
and you aren't passing it in when you're calling it in discord
Either
a) your code doesn't need that argument, in which case remove it or make it optional or
b) your code does need it, so you pass it in
I gave you options
idk what to do
even if you say so, that specific error is not due to code specifically but because you're using the bot in the wrong way
Hello Everyone
If you're not willing to engage with your code and make decisions, you're better off hiring someone
huh?
^
this is a decision you make
Do you know what an argument is
nope
So then how can you answer if you need an argument if you don't even know what an argument is
whatever you prefer
look the way they implemented the features of discord, especially interactions like app commands or buttons, and choose whatever you prefer or find more comprehensive
Performance, quality of docs, speed of feature release, and support community are also things you may wish to consider
I like to share this site for comparisons
https://libs.advaith.io/#python
It does seem to be down rn but it will probably be fixed soon.
iirc you can suffix with #python, hrefs
Functionally both of these will serve you fine, the docs are more or less the same thing, the primary difference is how slash commands are handled:
- Nextcord implements them in much the same way discord.py did (and does) prefix commands
- discord.py uses command trees, which is structurally different
Both have roughly the same in terms of an external ecosystem, both have enough users to get reasonably good support, you can't really go wrong either way, write a small both with both and see whch you enjoy using more, because that's what's important really
I recommend that you remove the N-word from your code as it is a racial slur
FDSAJKFDSJAJV
You okay?
totally fine
No
its part of my vocabulary
i just need help bro dang just tell me what to change
You're not asking for help, you're asking for someone to do it for you lol
which maybe someone will do but it ain't gonna be me for free
it's also against the server rules
Could just change it temporally for a screenshot and change it back after if you prefer
well ok
yeah best to get rid of the slurs and maybe someone will help you well maybe
who puts racial words into a discord bot. come on do better and grow up
and if you a grown human, what went wrong in your childhood?
it is better to clear these kind of words from your voc, because it can cause dispute or other uncontrolled behaviour
In addition, this word, like in your ready event, was used in slave times, for example, in the USA. It is a derogatory word and not used nicely. So please be aware of the origin of this word. It is not a word to throw out of your mouth.
@royal shore Your previous message was removed. Please avoid using slurs in code when asking for help on the server
But not all of us are from the USA and in some countries that speak Spanish it is part of their vocabulary and it is not an offense.
?!!!!!!!!
Yeah, I speak Spanish
I have addressed the user and clarified the situation, this discussion does not need to continue in the channel
anyone know why a json file would be wiped after 11 trbes would register into the command? essentially you do /register to log your info and it then sits on a json file
it seems after we gather around 11 tribe datas, it just wipes the whole filef or some reason
Don't use JSON as database ^^
ive never coded with a database before 😦
SQLBolt provides a set of interactive lessons and exercises to help you learn SQL
!pypi asqlite
!pypi aiosqlite3
Which one is recommended?
Both are good - the first one is just from Rapptz and may be easier to get started
anyone know what code you could enter so your command will check to see if there is pre-existing data for the entry, if there isnt. It gives a request back to state their registered but it just adds another entry into the db?
trying to get it so the bot reads the data in my db first then will just add on top o fit without it wiping any extra data
Hey
can anyone here help me make/develop a discord bot that will have 1000s of users? Itd be a coinflip bot with a balance system and payments.
Hey, you might want to re-read rules 6 and 9 of the server
Its not for payment
thats the thing
Not at least "Real Money"
Yeah, thats still a no dawg
ok
Generally there is a way to to
INSERT ... ON CONFLICT UPDATE ... in sql.
Where is the record already exists (using a primary key to ensure uniqueness) it will preform an update command instead
we're not your personal assistants and take orders like that.
neither is this channel an AI prompt chat, so with that mentality you won't get much help
deleting your message order and then send "?" isn't gonna help
also reading the error will give away the issue instantly, so you can fix the error yourself with the help of the internet
a balance system and payments
if this is real world money, doesn't that count as gambling?
No, Its in game money from a minecraft server
donutsmp
is it against the TOS to wager in-game currency outside of the platform?
No. Because the way its set up is you pay the minecraft account that goes to a discord currency and you can withdraw that and you get paid the money ingame
its allowed like that
theres anotehr casino like it with 2000 members
for donutsm
well if it's allowed then i have no objections
Would you be willing to make it?
TOS apply to currencies with *Real-world value, so if this currency is reasonably traded or exchanged for legal tender then it would apply (otherwise not)
whats wrong with this code?
I had to really zoom in to see the 20x20 res error... Anyway, it's an indentation error probably due to an unfinished statement above ```py
if value1 == value2:
@bot.command() # expected an indent block
wait where do i put it at?
what line
put what?
I am just explaining why you're getting the error, there's isn't much info for me to give any other advice
oh my bad sorry but look a this
the command isn't the issue
then what is
the issue is an unfinished statement above the command
above what?
the command
I don't know what line your command starts at
the entire command
nvm i fix it thank u
is there an easy way to have your discord bot detect when you and/or others are live on twitch and send an automated message in a specified text channel announcing it?
yes there is, since there are bots that do it
look at the twitch api
10-04 rubber ducky
also, is my bot supposed to run off of one .py file or multiple? i assume it would just be one as it is a program. with that in mind, the bot could potentially have thousands or tens of thousands of lines of code, correct?
it can be multiple files
use cogs
ahhh okay okay ty
and split some logic into files, e.g. database, maybe some helpers/utils, etc.
I'm considering writing a project management bot, think (simplified) Jira in Discord. As prior art I only find very bare-bones projects; the most advanced I guess would be KanbanCord, but a) I think it's a missed opportunity not to use channels/forum posts for tickets, and b) it has no concept of a sprint, which is a must-have for me.
Are there existing tools that I'm not aware of? Is this just a bad idea?
And one technical question: Can a forum post be moved between forums?
Are there existing tools that I'm not aware of? Is this just a bad idea?
Probably no such existing bot as it's very niche and probably won't be used a lot; but you can try to write such a bot and see how it performs.
Can a forum post be moved between forums?
No
the bot could in theory replicate the post, but redoing its message history would be annoying, so forum tags might be simpler, e.g. mark a set of posts to be done in the current sprint and let users filter by todo + sprint
if filtering by tags is too inconvenient, perhaps the bot can use a second channel to periodically outline the current backlog / sprint tasks?
Big downside of forum tags is they sort with or
tag1 or tag2
Not tag1 and tag2
o, i forgot tags don't intersect 🥺
@slate swan I am interested in your bot let's talk.
dont worry about it
import requests
import asyncio
YOUR_CHANNEL_ID = 1331683490860896290
def load_users():
with open('users.txt', 'r') as file:
return [line.strip() for line in file.readlines()]
async def check_users_status(channel, users):
online_users = {user: None for user in users}
while True:
for user in users:
response = requests.get(f'https://api.roblox.com/users/get-by-username?username={user}')
data = response.json()
if data and 'id' in data:
user_id = data['id']
game_response = requests.get(f'https://api.roblox.com/users/{user_id}/onlinestatus')
game_data = game_response.json()
if game_data['IsOnline']:
if online_users[user] is None: # User just joined
online_users[user] = True
embed = discord.Embed(title=f"{user} has joined the game!", color=discord.Color.green())
await channel.send(embed=embed)
else:
if online_users[user] is not None: # User just left
online_users[user] = None
embed = discord.Embed(title=f"{user} has left the game.", color=discord.Color.red())
await channel.send(embed=embed)
await asyncio.sleep(30) # Check every 30 seconds
intents = discord.Intents.default()
intents.message_content = True
client = discord.Client(intents=intents)
@client.event
async def on_ready():
print(f'Logged in as {client.user}')
channel = client.get_channel(YOUR_CHANNEL_ID)
users = load_users()
client.loop.create_task(check_users_status(channel, users))
client.run('')```
My error^ I'm trying to make it send an embed when a user joins a game but its giving that error
you entered the wrong url.
so https://apis.roblox.com/users/{user_id}/onlinestatus?
apis isnt even a api is it
you're just entering the bad URL. Try to post:
https://users.roblox.com/v1/usernames/users
with the next json value:
{
"usernames": [
// Username u want to search
],
"excludeBannedUsers": true
}
requests.post(url=..., json=....)
what would i made json=?
{
"usernames": [
// Username u want to search
],
"excludeBannedUsers": true
}
i know that but for requests.post(url=..., json=....)
Literally what is above?
You should also use aiohttp (installed within discord.py) and use the built-in ext.tasks submodule to create loops
how to determine if a user has a banner, animated icon, and a custom emote in there statuses?
If a user has a banner, then user.banner is not None, to check whether they're icon is animated, check if user.avatar.animated is True
!d discord.User.banner
property banner```
Returns the user’s banner asset, if available.
New in version 2.0...
What library are you using?
Looks like these are the 2 examples they have
https://github.com/Rapptz/discord.py/tree/master/examples/app_commands
I have also seen this recomended for a more in depth guide
https://fallendeity.github.io/discord.py-masterclass/
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.
You leaked your token, please reset it asap
Looks like this is the solution
https://github.com/aio-libs/aiodns/issues/86#issuecomment-1674906449
I have never seen this before though
Probably close to the top of the code
ok
right after imports should work
Sounds good, nextcord is a very good library from what I hear
i can help i sent you dm
@discord.app_commands.user_install(func=None)```
A decorator that indicates this command should be installed for users.
This is **not** implemented as a [`check()`](https://discordpy.readthedocs.io/en/stable/interactions/api.html#discord.app_commands.check), and is instead verified by Discord server side.
Due to a Discord limitation, this decorator does nothing in subcommands and is ignored...
see examples
it's a single deco yea
What can I use instead of
async def cog_load(self):
self.battlemetrics = Battlemetrics(self.tokens['tokens']['battlemetrics_token'])
await self.announcer.start()
```?
cog listener?
I have 2 cogs that need to start a loop on cog load. However only 1 loop is starting
And the other loop doesnt get initiated
Ended up moving the await self.announcer.start() to the __init__ section
it works ¯_(ツ)_/¯
it should work just fine in cog_load() if you don't await it, because Loop.start() isn't a coroutine anyway
oh lol
you had unintentionally awaited the return value of Loop.start(), an asyncio.Task that was running the infinite loop
so your method probably got stuck waiting for your announcer loop to stop before it could run the next line
Hello. I'm created music discord bot using python.I want host it AWS EC2 ubuntu server but I got this yt-dlp module you tube loging cookies error I'm try cookies add manually but still don't work. Please anyone can help me fix this problem.
!rule tos
5. Do not provide or request help on projects that may violate terms of service, or that may be deemed inappropriate, malicious, or illegal.
!ytdl - actually easier to understand
Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.
For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:
The following restrictions apply to your use of the Service. You are not allowed to:
1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service; (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;
3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;
9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
I don't understand can you help me
Youtube does not allow streaming music via Discord bots
Thus, you will not get help for it here.
You won't get help to breach YouTube's terms of services, no
ok thanks bro.Did you know alternative ways fix this proble?
By removing any of your code that touches youtube
Make your own music or find a platform that gives you permission to stream music
spotify api could be a good one to use
spotify has terms in their tos, too
^
A platform has no incentive to give you free rights to redistribute content and screw over their creators lol
it can fry when roaches decide to find their way inside it too.
would roaches survive the cpu temp first tho 👀
they can
they love heat esp in the winter lol
damn 
after all they can survive an atomic bomb
only way to kill them is line your laptop/pc with roach killer chemicals that they will most likely eat.
but even then they still could die inside of it after laying eggs.
💀
wait this is a thing?? wtf??
wait there's guild install too??
holy shit, i feel like such a dumbass for doing ```py
@allowed_installs(guilds = True, users = True)
It's just syntactic sugar shortcuts
upgrade to 2.4
eh, it's just the parameters of the function
!d discord.app_commands.choices
@discord.app_commands.choices(**parameters)```
Instructs the given parameters by their name to use the given choices for their choices.
Example...
does it have to be exactly those choices?
or can the user still just put in whatever they want
Choices are choices
it does
autocomplete does not
oh fuck yeah. i'm definitely gonna use this
Limited to 25 choices tho
oof maybe not then. autocomplete might be a better way to go
is this an Invite object or a static link?
!d discord.Invite
class discord.Invite```
Represents a Discord [`Guild`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Guild) or [`abc.GuildChannel`](https://discordpy.readthedocs.io/en/stable/api.html#discord.abc.GuildChannel) invite.
Depending on the way this object was created, some of the attributes can have a value of `None`...
Does dpy have a app command version of this https://discordpy.readthedocs.io/en/stable/ext/commands/api.html?highlight=is_owner#discord.ext.commands.is_owner
Or do I have to make my own
I don't believe so, but you can set a slash command to only be visible and usable to specific people and roles from the Integrations tab in server settings
I would need perms for that server and there's no way I would have perms to do that in every single server
if you want to make bot owner only commands you should make them prefix since you can hide prefix commands from users, but if you really don't want. Make it a test-guild only command
Yeah we sync it to an admin guild, but that guild has both admins and owners, we only want owners to use those commands not admins
We'll just make our own decorator for it ig
You can hide app commands by making them guild commands and setting default permissions along with settings in the integration settings.
Hello guys
i have peaked
Should I list all updates for each event or just the latest one?
getting the
even tho they are enabled in dev portal
You need to enable them in the code as well.
did, chat gpt'ed it
but still the warning is there
tried disable and then enable again too
and did you pass it into your bot constructor
intents=intents
yes
should i reset token? i am runing this app after like an year now
if you saved and everything, then you either have the wrong token, or you changed the intents for the wrong bot (on the dev portal); most likely
probably not possible but imma recheck
worked
that token was so old, idk maybe that caused the issue
nice
await interaction.response.send_message(poll=discord.poll(question="test",answers=['testanswer1','testanswer2']))
i ran this and it said module isnt callable
Poll*, it's a class
please read the docs https://discordpy.readthedocs.io/en/stable/api.html#discord.Poll
spoiler: it doesn't take answers like that
i hate classes
welcome to OOP!
tf you mean it dont take answers like that??? 😭
probably should have guessed that the first problem would be the thing i put in there with no rhyme or reason

did you check the docs?
i dont know how to read python docs imma be real
talking about the discord.py docs
i saw def add_answer() so im guessing its this
they're fairly easy to understand
yup!
its still saying its not callable
big P
oh mb
discord.poll would be the file (module) discord/poll.py
isnt there a way to test certain lines and not the entire program
Usually you can use breakpoints and stuff, but I'm not sure they play so well with async stuff
i kinda figured but i had to figure out timedelta
also suprisingly simple
do the slash commands work as classes
nvm im dumb
lol
it is send_message() as per the docs
mb
import discord
from discord.ext import commands
import os
TOKEN = "hided"
intents = discord.Intents.default()
intents.messages = True
client = commands.Bot(command_prefix='!', intents=intents)
@client.event
async def on_ready():
print("BOT READY")
@client.command()
async def hello(ctx):
await ctx.send("hello")
client.run(TOKEN)
``` why the bot doesnt respond
when i say !hello it doesnt respond
You do not have the message content intent enabled. You need to have this to read message content.
message content intent is missing
fuck man i was so close
I strongly recommend that you do not use prefix commands though. Slash commands will be easier in the long run
turn on the message content intent like the others said, and make sure its enabled on the discord dev portal for your bot too
they save bandwidth
they dont come to you to check if you've called them, saving energy aka bandwidth
when i added it ,it showed this problem
File "C:\Users\dv\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\client.py", line 858, in runner
await self.start(token, reconnect=reconnect)
File "C:\Users\dv\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\client.py", line 787, in start
await self.connect(reconnect=reconnect)
File "C:\Users\dv\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\client.py", line 711, in connect
raise PrivilegedIntentsRequired(exc.shard_id) from None
discord.errors.PrivilegedIntentsRequired: Shard ID None is requesting privileged intents that have not been explicitly enabled in the developer portal. It is recommended to go to https://discord.com/developers/applications/ and explicitly enable the privileged intents within your application's page. If this is not possible, then consider disabling the privileged intents instead.
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x0291F9B8>
Traceback (most recent call last):
File "C:\Users\dv\AppData\Local\Programs\Python\Python38-32\lib\asyncio\proactor_events.py", line 116, in __del__
self.close()
File "C:\Users\dv\AppData\Local\Programs\Python\Python38-32\lib\asyncio\proactor_events.py", line 108, in close
self._loop.call_soon(self._call_connection_lost, None)
File "C:\Users\dv\AppData\Local\Programs\Python\Python38-32\lib\asyncio\base_events.py", line 719, in call_soon
self._check_closed()
File "C:\Users\dv\AppData\Local\Programs\Python\Python38-32\lib\asyncio\base_events.py", line 508, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
Did you look at the error?
read the error
surely it's marginal, right?
yeah
Depending on your setup you can get rid of the gateway all together which is more than marginal
think of it like this - a waiter who is constantly coming up to you and checking if you wanna pay the bill
(prefix commands, takes lots of energy)
hm okay. i rarely need that concern to be honest, since very few people use my bots
and a booth where you can pay your bill at (slash commands)
is the og discord.py still around?
from 2015? yea
i don't know if that's an accurate analogy
what are these?
bookmarks and reminders maybe
save any message to DMs to look at later, and schedule a message to be sent at a later time
.bookmark
Your input was invalid: You must either provide a reference to a valid message, or reply to one.
The lookup strategy for a message is as follows (in order):
- Lookup by '{channel ID}-{message ID}' (retrieved by shift-clicking on 'Copy ID')
- Lookup by message ID (the message must be in the current channel)
- Lookup by message URL
Usage:```
.bookmark [target_message] [title=Bookmark]
!remind
expiration
basically those commands
i find myself using these fairly often
bookmarks when i see an interesting message i may want to look into later, and reminds if I want to get back to someone on a topic later
not formal enough to need a dedicated knowledge management app or todo app
sure yeah
what's the best way to implement a reminder / todo system?
as in how do i implement a date and time? could i parse one through regex?
yes
yep
i already have a function for this: ```py
def parse_time_string(self, time_str: str) -> int:
total_seconds = 0
time_units = {
'y': 31536000, # years
'mo': 2592000, # months
'w': 604800, # weeks
'd': 86400, # days
'h': 3600, # hours
'm': 60, # minutes
's': 1 # seconds
}
pattern = r'(\d+)([y|mo|w|d|h|m|s])'
matches = re.findall(pattern, time_str)
for value, unit in matches:
total_seconds += int(value) * time_units[unit]
return total_seconds
is there a way to determine if user has a animated avatar and a custom or animated emoji in there status
yes
how
animated avatar hashes start with a_
and thats gonna be a work around to determine if user has nitro….
no because not every nitro user has an animated pfp
then the custom activity has an emoji field which has an animated field to know if the emoji is animated
and yeah it's not 100% sure the user has nitro with that
ok
will for some/lots of people be accurate, but not everyone
what else do i do other than banner :o
no reliable way, I'm pretty sure
You don't because discord doesnt tell you if someone has nitro intentionally. Why does it matter if they do?
word
Because you have the wrong names for the flag object
!d discord.PublicUserFlags
class discord.PublicUserFlags(**kwargs)```
Wraps up the Discord User Public flags.
What happens when it doesn't work? What does "work" mean here?
Also you really shouldn't be spawning channels for tickets. Use threads
Can you delete your messages and use the paste service, this is too hard to read
!paste
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.
good god
@knotty cedar ^
regex to parse the date/time, store it in a database. on startup, loop through all of them and create a task for each one
that part is important otherwise your reminders won't be persisted across restarts
regex to parse the date/time
should i do what danny did with r. danny and parse for "today at" and "tommorow at"?
yeah, or this
!src remind
Commands for managing your reminders.
how would it know the timezone?
r. danny has commands for settings timezones
I am trying to figure out how to make a datetime input rn. I dont want to store a timezone of a user but I also dont want the user to have to input it
well you don't have many options there
yeah...
i'll implement in Xd Xh Xm Xs then
I personally find this more convenient as a user
i'll parse for X days X hours etc as well
-# Another reason that timezones should not exist
How do I color text? I've tried using escape characters and code blocks, but it doesn't show up on mobile.
discord lacks in that regard which is a big shame. There isn't much you can do unfortunately
The code over here seems to be colored properly, even on mobile, but when I try and replicate it, it never works...
how are you replicating
Code formatting can be applied and work on all (most?) platforms. This is shown below but you can replace py with many languages and formats. ANSI color codes are platform dependent and often do not work on mobile
!code
how do i split my commands in multiple files? And what are "cogs"?
ah yes them dam cogs 
Cogs are classes that contain events or commands, and if there are multiple Cogs, they are known as extensions.
I'm not sure if Cogs are created the same way in all libraries
Extensions are just external files that get loaded into the bot. Whether they contain cogs or how many is an implementation choice

ah maybe not then dont worry
how do they make the title clickable
It's not a title, I think it's part of the description
!d discord.Embed
class discord.Embed(*, colour=None, color=None, title=None, type='rich', url=None, description=None, timestamp=None)```
Represents a Discord embed...
it is a title but okay
It is not the title as it is not larger, the title has a larger font than the description and other embed fields.
🙈
Hello,I made a discord bot in python and I want to host it with a free how,does someone know a free hosting for discord bot?
!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.
I would invest in a basic VPS for around $5 a month
But that's just me, because I wouldn't trust a free VPS
can I have one link button that when someone presses this button, the embed's footer changes?
no
URL buttons don't have a callback (i think)
the callback is pre-defined by discord
why? whats your use case?
I want when someone sends an mp3 file, my bot to download it, upload it to my database and give a link to the user so that he can download the file, and I want to put the link to a button, and when someone presses this button, after the user presses it, the footer of the embed where the button is, changes and says how many times the button has been pressed
"I want when someone sends an mp3 file ... give a link to the user so [they] can download it"
what?
they already have the file
and discord already lets you send files
this would make sense if it was a pastebin, not if it was discord
it's for a server with unreleased songs that in the past they had a term and their server shut down because of the songs and so it's a way that their server won't be termed
@bot.command()
async def testing(ctx):
def check(message):
return message.author == ctx.author and message.channel == ctx.channel
await ctx.send("What would you like capitalized?"),
msg = await bot.wait_for('message', check=check)
await ctx.send(msg.content.upper)
this line of code made my bot reply with:
D_CordBotAlpha
APP
— Today at 5:02 PM
<built-in method upper of str object at 0x000001703168F7E0>
to be honest I'm just looking for a way to test it, I don't intend to run it on a bot, I just saw it on another server and I liked it
you need to call upper since it is a method
await ctx.send(msg.content.upper())```
i should have hit tab in pycharm lmao
thanks boys, i thought i gave my bot a stroke for a second 
!code for future
dms can't be termed 
!rule 5 - and also this
5. Do not provide or request help on projects that may violate terms of service, or that may be deemed inappropriate, malicious, or illegal.
how do i get the author id from a discord message when another person is reacting to the message?
for example, i wanna this message get my id and the reaction get the other person id
which is kinda the same person
Cached messages can be accessed with Reaction.message
if it’s not cached you’ll need to do a lookup using the message id. Though I don’t know if on_reaction gets triggered for uncached messages
Otherwise you can use on_raw_reaction_add to get the raw data which includes a message ID that you can get/fetch
https://docs.pycord.dev/en/stable/api/models.html#discord.RawReactionActionEvent.message_id
-# Above link is for pycord, if you are using something else you can probably find something similar on those docs
is that the same for discord.py?
yeah, it should be
!d discord.Reaction.message
Message this reaction is for.
bosh
!discord.reaction.member
It should be similar but idk for sure because I dont use discord.py
that's strange
now i don't know which gets the member
trying to acess the reaction owner
who made the reaction
are you using the on_reaction_add event? if so, it's the second parameter of that event which provides the user/member
i'm using on_raw_reaction_add
then you have to manually get/fetch the member from payload.user_id
oh right, there is payload.member as well
!d discord.RawReactionActionEvent.member
The member who added the reaction. Only available if event_type is REACTION_ADD and the reaction is inside a guild.
New in version 1.3.
the problem is that i get error when i try using the payload:
which is reaction: discord.Reaction
anyways
i just added a checker, and it was suppose to be raw version not reaction
i got the wrong relative
also, why trying to import the package it shows an error?
how's your file structure
if you're on the same level as your cwd, you don't use relative imports - you use regular imports
i'm assuming you have a database.py file inside your cwd?
client.user.id
Hey guys i don't know if that is a glitch with me or not but I can use my bot anywhere even if the bot not in the server so is there something to disable from portal to fix that?
Change the context to just guild installation
That's a user installed app
Hey! I am having a troubled related to my code...
So i am trying to send dms to multiple users but when i try to test it the bot is unable to send dms to users which i have valid id's of.
The bot is in same server as they are also ids are valid but it gives an error
User with ID [ID] not found.
What is the code & user id
async def send_test_dm():
users = get_user()
for user_id in users:
try:
user = await bot.fetch_user(user_id)
if user:
embed = discord.Embed(title="Test DM", description="This is a test DM to check if the bot can send messages.", color=0x1a52f9)
await user.send(embed=embed)
else:
print(f"User with ID {user_id} is None.")
except discord.errors.NotFound:
print(f"User with ID {user_id} not found.")
except Exception as e:
print(f"An error occurred while sending DM to user {user_id}: {e}")```
here it is and the user id is mine.
def get_user():
with open('user.json', 'r') as f:
users = json.load(f)
return users
also the ID are stored in a String format
remove your try except and let the normal error print
ok
that's likely the issue
!d discord.ext.commands.Bot.fetch_user
await fetch_user(user_id, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Retrieves a [`User`](https://discordpy.readthedocs.io/en/stable/api.html#discord.User) based on their ID. You do not have to share any guilds with the user to get this information, however many operations do require that you do...
its weird but discord is not being able to find the users
the error which i am getting suggests discord is not being able to find the users
print the user id, because i can fetch_user on you easily
both with string and int
its kinds wierd
raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10013): Unknown User
i even tried printing
and it prints?
async def send_test_dm():
users = get_user()
for user_id in users:
print(f"Attempting to fetch user with ID: {user_id}")
user = await bot.fetch_user(user_id)
print(f"User: {user}")```
What does it print?
Attempting to fetch user with ID: 12648712739817328
2025-01-28 14:15:01 ERROR discord.client Ignoring exception in on_ready
then the error shows up
.
whom's id is that?
mine
nope
@errant moss
1314084551265357876
i even entered it manualy
json isnt a database 
Show your files, because it works fine for me tbh
its kinda large... I have not arranged code in cogs
vscode?
search for "12648712739817328" in all your files
you likely have that somewhere
or the user.json file is not saved properly
the bot is able to get the ID.. But not able to find the user
it gets the wrong id, so no
your user.json file is likely not saved properly or you're reading from the wrong file
your code gets the ID 12648712739817328 which is not your id
and not a user id at all
discord wasn't existing at that time
wtf i just noticed now its fetching wrong id
that id was "generated" <t:1423086088> - so not possible
that will work
yeah it worked
12648712739817328
@slate swan but why is it fetching this id
i dont have it anywhere
using vscode?
i just found out🤣
use the magnifying glass icon on the left (ctrl+shift+f or something like that) and search for it
i had 2 json file user.json and users.json... the users.json had my id
okay so, i need the reference in the docs about the list of those who reacted, can anyone give me an href?
!d discord.Message.reactions
Reactions to a message. Reactions can be either custom emoji or standard unicode emoji.
there you go
a list of discord.Reactions to a message
Thanks a lot... I was just on verge of giving up on the project xd
thought i'm using on raw reaction add function
so it's kinda different
oh then you'll have to manually form and store a list
every time a reaction is added, update the list
this seems pretty weird tho and there might be a better option for whatever your use case is
then guess i change it to on_reaction_add, searching it here
or actually
just get the message using the message ID and then check this
!d discord.RawReactionActionEvent.message_id
The message ID that got or lost a reaction.
I forgot about that
thx brother 
okay so, which function is related to stage/voice stuff?
i need that to check how long a person was in a voice chat/stage
that’s not something that’s provided to you and needs to be tracked on your end (comparing time difference between join and leave)
how do i do that?
is there a function that checks the on joining
and on leaving?
yeah, check out on_voice_state_update event.
You can tell different events apart based on the input arguments values
- A user joined a channel if
before.channel is None and after.channel is not None - A user left a channel if
before.channel is not None and after.channel is None
You can obtain the current time using datetime.now() of both join and leaves, and subtract these datetimes to receive a timedelta object
i see, also on_voice_state_update it doesn't seems to have a way to grab the user
unless
member is the first argument
thanks, also how do i convert the time to minutes or seconds?
!d datetime.timedelta
class datetime.timedelta(days=0, seconds=0, microseconds=0, milliseconds=0, minutes=0, hours=0, weeks=0)```
All arguments are optional and default to 0. Arguments may be integers or floats, and may be positive or negative.
Only *days*, *seconds* and *microseconds* are stored internally. Arguments are converted to those units...
how do i grab all members that joined the voice chat?
hello I need some help with a discord bot building like I want a discord bot that plays music,how can I script it?
!d does this for you btw 
love blessing my eyes by opening dpy docs
uhhhmm, i'm using on_voice_state_update i don't know if i can do that
there's a .channel attribute
!d discord.VoiceState.channel
The voice channel that the user is currently connected to. None if the user is not currently in a voice channel.
on_voice_state_update takes in 3 parameter: member, before and after.
before and after are of the type discord.VoiceState (https://discordpy.readthedocs.io/en/stable/api.html?highlight=on_voice_state_update#discord.VoiceState)
If you scroll down that link you'll find the channel attribute which is of the type VoiceChannel or StageChannel (you needn't worry which type you end up getting since they both have members attribute) and thats the type which you need
youd mostly want to use the voicestate from the before argument you get which is the orignal vc which you want to get the members from
if thats what you want
how do i check if the channel is private?
Define private. Just whether or not @everyone has view?
i have no idea, the guy who contracted me told me to see a document i don't have acess
so i don't know what he want with private voice chat
guess i should ignore that step form the docs i received from my client
Hard to implement stuff without the requirements lol
yeo
guess i should just ignore that part
since i have no idea what to implement
how do i check the time that two people made voice chat activities together
such as gartic phone
!d discord.Activity
class discord.Activity(**kwargs)```
Represents an activity in Discord.
This could be an activity such as streaming, playing, listening or watching.
For memory optimisation purposes, some activities are offered in slimmed down versions...
i assume discord.Activity.name would have this as "Gartic Phone"
okay next i need to know how to check when the user started an activity, not just gartic but any activity
in voice channel
thought i don't know if this fits in on_voice_state_update
nope - it's not a voice state
yep, then... is there another listener function related to activity?
querying my local database for it
uhmm, can i see an example?
There is a presence event
oh yeah i shut my laptop so it stopped reading rows 
@fast osprey i decided to search my own database with dpy's docs in it 
can you link me to it?
!d discord.on_presence_update
discord.on_presence_update(before, after)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Member) updates their presence.
This is called when one or more of the following things change...
okay so, i'm lost on getting the time where the old update the member started the activity
and when they ended their activity
The event fires when they change their presence
i see, but how do i use it? I wanna get the how many time a member was doing the activity, as well the others
im having an issue where I can integrate my bot with a server, but the bot never actually joins the server. Maybe im missing something simple since its been a while since I worked on this bot, but has anyone run into something similar?
The bot runs and doesent throw any errors at me, tried removinf the integration and readding it, made sure it had the right scopes and intents, re did token etc
it just never shows up as a user on the server
what scopes are you choosing?
applications.commands
For the bot to show in the server I belive you also need to select bot
ty i remember that process now, i knew it was something dumb on my part
yep that did it
!d discord.Member.activity
property activity```
Returns the primary activity the user is currently doing. Could be `None` if no activity is being done.
Note
Due to a Discord API limitation, this may be `None` if the user is listening to a song on Spotify with a title longer than 128 characters. See [GH-1738](https://github.com/Rapptz/discord.py/issues/1738) for more information...
!d discord.Activity.start
property start```
When the user started doing this activity in UTC, if applicable.
!d discord.Activity.end
property end```
When the user will stop doing this activity in UTC, if applicable.
okay so, in activity is it possible to list all the participants of the activity?
probably not
it's because i'm working on a collective point gaining system
all those that was in the activity gains points
i doubt this is possible
my bot no longer has the "supports slash commands" badge, and slash commands are not showing up. Are these things correlated or coincidental?
this is a "new" bot using code of mine that has previousley worked fine.
Make sure you sync the commands and then use ctrl+r to refresh your discord.
Also I believe that the commands need to be global for your bot to get the badge
No one will help you if you don't give more details or the code
from discord.ext import commands
# Create an instance of the bot with the required intents
intents = discord.Intents.default()
intents.message_content = True # Allows reading message content
bot = commands.Bot(command_prefix='!', intents=intents)
# Event when the bot is ready
@bot.event
async def on_ready():
print(f'Logged in as {bot.user}')
# Command that sends the rules
@bot.command()
async def rules(ctx):
rules_message = """
ℝ𝕦𝕝𝕖𝕤
𝒓𝒖𝒍𝒆 1: 𝒖𝒔𝒆 𝒕𝒉𝒆 𝒄𝒉𝒂𝒏𝒏𝒆𝒍𝒔 𝒂𝒑𝒑𝒓𝒐𝒑𝒓𝒊𝒂𝒕𝒆𝒍𝒚.
𝒓𝒖𝒍𝒆 2: 𝒏𝒐 𝒑𝒊𝒏𝒈𝒊𝒏𝒈 𝒆𝒗𝒆𝒓𝒚𝒐𝒏𝒆 𝒇𝒐𝒓 𝒏𝒐 𝒓𝒆𝒂𝒔𝒐𝒏 𝒂𝒕 𝒂𝒍𝒍 𝒐𝒓 𝒑𝒓𝒐𝒎𝒐 𝒓𝒆𝒂𝒔𝒐𝒏𝒔.
𝒓𝒖𝒍𝒆 3: 𝒕𝒉𝒓𝒆𝒂𝒕𝒆𝒏𝒊𝒏𝒈 𝒐𝒓 𝒂𝒃𝒖𝒔𝒊𝒏𝒈.
𝒓𝒖𝒍𝒆 4: 𝒊𝒏𝒂𝒄𝒕𝒊𝒗𝒊𝒕𝒚 𝒊𝒔 𝒂 𝒅𝒆𝒎𝒐𝒕𝒊𝒐𝒏.
"""
await ctx.send(rules_message)
# Run the bot with your token
bot.run('**TOKEN**')```
and it's not working
what does "its not working" mean to you
guys can someone give me a script for a discord bot that plays music on a vc?
ty
Only use that example if you want to use discord.py though. Also make sure you are following discord TOS when playing the music
This is not what you want to see when you're setting up a new repo for a discordbot XD
better than your token getting leaked and not knowing about, tbf
true true
turns out I forgot to delete my zip file before uploading my repo lol
I shared this a while ago, but i've been tweaking it and fixing bugs here and there
What originally turned out to be a quick 5 minute job, in and out. turned out to be like several days lol
I can't connect
So what ya'll working on
Do ur guys use replit or?
replit is an environment for prototyping small sites. Not for hosting long-living processes.
!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.
If you are trying to run your bot on replit you are probably getting an error. It seems replits certs have expired based on reports in another server.
Thx
So what else can I use
For coding or hosting?
^
ya like for the bot
For coding or hosting though
Coding is where you type the code and run it to test and make sure it works
Hosting is where you run it 24/7
-# This is a very simplified definition
Replit is fine when it is working and not broken.
If you have a computer you can install an IDE, some of the most popular IDEs for python are Thonny, Pycharm, and VS Code
My computer has no space left😭
Too much stuffs for skl
Is there like a template for something that I can use for the bot?
You tecnically do not have to use an IDE but it makes things easier.
You can also use notepad or notepad++
It depends on what library you are using
It is also recommened to have a strong understanding of the python basics before making a discord but, but that is up to you.
Im not so good at python tho🥲
Yeah discord bots are not a beginner project, but we wont stop you from doing it.
You could start with a few smaller projects and work your way up to discord bot.
👍
There are probably free bot hosting websites out there, but they're free for a reason.
Most bot hosting websites will charge you around $5 USD (i think?) a month to host your bot and they usually have 24/7 uptime.
I find it affordable if you wanna run bots on small groups of servers etc. They aren't meant to be powerful but if you're popular enough you can afford a better hosting, at which point you'll move from the general pterodactyl hosting services you find around to a more dedicated machine which can cost a bit more
This is just from my personal experience and what I've seen people do.
IMO, anything that markets itself as a "bot host" is scamming you. There's no such thing as a bot host. There's just machines. Anyone trying to sell you that (free or otherwise) is trying to take advantage of lack of experience.
Industry recognized, legitimate hosts will give you a box and let you do whatever you want with it. Small ones can run cheap, but none will be free forever unless there's a catch
Most people just want to upload the code. Click a button. and see har har funny bot things.
You get what you pay for, and for what you mentioned "give you a box", do you honestly think you're getting that for 5 bucks a month?
Yes? I have a hetzner cloud vps for less than 5 euro a month
Ic
Thx

Some of us just googled "bot hosting" and clicked the first link
With hosting there's not a singular correct answer. But the ratio of self-marketed "bot hosts" I've seen that are either a) overcharging or b) literally a honeypot scam to get your token is in the high 90%'s
Oh, the ones I use are legitimate services. In fact there's a really good Australian one I use who has been incredibly responsive whenever I needed help adjusting. He doesnt host just bots he also hosts games as well. And it's awesome.
I won't give the name because I dont wanna "advertise" but I can if u dm me.
I believe he's Australian.
idk. I wanna believe he is.
Don't put your token into files you send to people, or remove it before sending
also code you sent doesn't match the error
Oh oh sorry I generated a new one
That's what happened Im not sure why
How do u read the codes so fast
But it is in str tho
your traceback clearly has a line that's literally client.run(token). That's the code it's running
if the code you're looking at doesn't have that exact line, then you're not running the code you're looking at
token is none
But didn't I set token = os.getenv("My_Token")?
That doesn't mean it's not None
Im not sure wdym by None then😭
If you don't know what None is, then you might want to do simpler projects to learn
Do u know how can I fix it?
By learning what None is
What are some simpler projects
Basic coding challenges to start with. It really depends on how you learn. But things like a bot layer on several concepts and you're trying to learn all of them at once
Did you create an env file with My_Token = TOKEN_HERE?
token is a variable used in client.run(token)
Which should be in the env file
None is none. basic human english
Thx for helping
bruh
the concept of None (null, void etc... may be strange for new coders)
is there any way i can upscale the resolution of my 16x16 pixel art?
have the pixel art not be 16x16?
sorry man, it's just what i got
then, unfortunate

I mean you can upscale it
Make a 160x160 photo where each pixel from the 16x16 is 10 pixels wide
Or something like that
that pic is blurry indicating some linearity or anti-aliasing filters... you can definitely upscale any pixelate arts like that to any resolution as what EasternFarmer said try upscaling using any image processing software you have or whatever tool or method you use and then implement the image without the aforementioned filters search for some parameter like "Nearest", "Sharp" or "Point-sampling"
what software do you suggest?
anything really maybe pixelart, gimp or adobe photoshop
anything programmatic?
only check for putting image filter as "Nearest", "Sharp" or "Point-sampling" see what option you might get, also check if you can use pillow module for implementing the image in your bot code
need help with my whole bot's code. it doesnt start, always ratelimited, responds to slash commands without issues tho. just need help to optimize it, i'll be very thankful!
2k lines
!paste
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.
^ along with any errors or logs you get
I wondering can tell me is my code is efficient or not
I send the code in dm
Why do you need to send it in DM?
You are allowed to send code here, if it is too long use the paste service in the message a few above this
need help with my whole bot's code. it doesnt start, always ratelimited, responds to slash commands without issues tho. just need help to optimize it, i'll be very thankful!
2k lines
i'm gonna send it in dm as i don't really want it to be seen by everyone
i'm gonna send it in dm as i don't really want it to be seen by everyone
you're asking for help in a server of 400,000 python programmers
but you don't want them to see your code
what?? 
well, it's a pretty known bot so yea
i don't
unless it's something that breaks TOS, why are you hiding the source code?
why does that matter?
!paste - @broken folio put your code in here and then share the link
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.
Highlighted text exceeds size limit (512 kB)
do you have a repository?
nah
you should probably make one then
but that's for later
can you share just the file you're having issues with?
that's the point, i don't know what's making it be ratelimited and not start
!traceback - and also this
Please provide the full traceback for your exception in order to help us identify your issue.
While the last line of the error message tells us what kind of error you got,
the full traceback will tell us which line, and other critical information to solve your problem.
Please avoid screenshots so we can copy and paste parts of the message.
A full traceback could look like:
Traceback (most recent call last):
File "my_file.py", line 5, in <module>
add_three("6")
File "my_file.py", line 2, in add_three
a = num + 3
~~~~^~~
TypeError: can only concatenate str (not "int") to str
If the traceback is long, use our pastebin.
can i just send you it in dms?
fine
there's no issue, i just need help optimizing it
zip it and send it to me
are you being rate-limited on discord operations or something else?
yes, the bot wont start, right when i run my python file it already says ratelimited, please wait 60 seconds, goes on for like 5 mins saying the same msg and then just stops & never starts
send the traceback please
there's no error
the bot starts sending member avatar updates in servers right when i run it (without being ready) & also does slash-commands
and the output?
i tried making the member avatar updates by setting a cooldown for each channel but, no luck
could you send the snippet that you think is doing this?
don't send the full code
i have noo idea what is happening
there are like 6 slash commands & etc, idk what's causing it
but the bot has gone bigger and i think something is up
must be before the on_ready function
"It says already ratelimited" what is "it" and what precisely is it saying
user avatar updates are done without it being on_ready, slash commands are used before it starts too
try waiting for that period of time, also, you mentioned that your file is 2k lines big, why not use cogs? (aka separate files for each command)
waiting does not help, it goes for like 5 minutes and then stops trying
!d discord.ext.commands.Bot.fetch_guild
await fetch_guild(guild_id, /, *, with_counts=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Retrieves a [`Guild`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Guild) from an ID...
yis
simple enough
What triggers this log? Actual resource level rate limits tell you what the resource is. This message typically happens when chunking large guilds
the code is an absolute mess
Why is this bot generating invite links to a random channel in every guild it joins and saving that to local storage (with no user input, instruction, or consent)
Reeks of backdooring
discord is not a default module installed in the standard library. You need to install it
I want to make a bot that posts a message to bunch of channels across several servers with a role ping (Basically a new bot.) Server admins can add the bot and subscribe a channel to the bot in the specified channel with the role id to ping. I'm wondering which would be better in terms of API rate limits: have the bot send the message directly or have the bot make a webhook and then use the webhook?
webhooks
Is there a ratelimit for all discord webhooks by one ip I should be aware of?
Are you sharing that ip with someone?
It's about the ip, not the host itself
if randos are using the same ip, then you need to get off that host if you want your stuff to work reliably
I think it's a dedicated IP as the bot has never had issues before
Things not breaking before doesn't mean it's right
Just takes one idiot rando to spam discord on that ip to bring you down as well
The hosting service should be pretty clear about this
Is the reason announcement channels dont work is because you want the role ping?
Is possible to make custom status without activity?
Yeah, you just cant use the discord emoji field, only unicode emojis
How you do this might depend on the library you use
It should just be as simple as activity = discord.CustomActivity(name=...) in dpy and forks
Ty friends
pip install discord.py first
Only if they want to use discord.py, it is not the default that everyone should use.
Also btw they got there problem solved in another channel
ah alr then
Let’s say I wanna create a discord bot but it should also save data to a DB and then I also want frontend made in JS with something like Next.js as framework and shadcn/ui as UI library because it looks nice, how would these even communicate with the discord bot?
It really depends what this front end materially does
Well it’s really just for stats
Like the data collected with the discord bot might just be how many times a specific slash commands has been executed in the past 24 hours and then that’s gets saved to a relational db and the frontend just reads from that i guess
But if I have a function defined that fetches let’s say an API endpoint and checks if it is alive for like random quotes and so on, i want that functionality on the frontend to show
This wouldn’t be ideal with a db
what is fetching from the api? The bot, or this frontend?
I’m gonna try to word it better.
A discord bot has a slash command that will monitor an API endpoint and check to see if it’s alive, let’s say it does this every 300 seconds, basically once it’s ran it should return a status or boolean indicating it’s up and I want my frontend to take use of that return value.
and why wouldn't a database work here?
Though I have no idea how to access it from the frontend, maybe this value can be saved to a relational db like sqlite and then read, but this wouldn’t be ideal if there are a lot of entries I would like to believe, and with that I mean around 1000 entries a day, instead I thought of either IPC or a FastAPI server that gets access to those statuses somehow.
I’m just assuming it’s not ideal to write and read from a db every 300 seconds and sometimes it’s not exactly 300 seconds all these API endpoints may have been monitored at different times so it could read/write every 5 seconds or so
That's an insanely insignificant scale for what sqlite even handles
Generally I strongly recommend going with the simplest approach. If you overoptimize for scale you don't have (and don't even anticipate having), you're going to make unnecessarily heavy solutions
Polling a db at that scale is completely fine
even lightweight databases like sqlite are rated for thousands of reads and writes per second, once every 300 seconds is pretty much nothing
Oh ok, well in that case that might just be the option, to use discord.py for the bot which is the backend and that will write results/statistics to the database and then next js for the frontend which will read the database and display them nicely on the frontend dashboard for the bot
FastAPI wouldn’t even be needed with this approach
it might be better design to have a single source of truth, a fastapi app for both reading and writing statistics
that way you won't have duplicated schemas on your nextjs backend and the discord bot, both accessing the database
so it would be the discord bot with the slash command let’s call that file bot.py and then a fastapi app let’s call that server.py and the bot should just send a request to the fastapi endpoint that handles this and then the fastapi will store the info in the db and will also have routes for reading data with different filtering options and the next js app just requests those fastapi endpoints for reading data (or maybe also write data)
Which of those two processes does specific things is up to you. But probably the most meaningful choice here is make sure that you are running these in two separate processes
yeah well i will need to run the bot, fastapi app and next js separately so i guess i should be fine
Honestly i’ll try my best and then ask for further help but now that I have a plan i’m gonna have to experiment a lot and do some trial and error
So thanks for the help, i finally have a project structure to follow.
At some scale you might want to consider message queues or sockets or something, or just to do it out of curiosity. But IMO this is a fine start and is like 99% likely to be totally functional for what you're trying to do
bot and fastapi app can run on the same host. vercel for next.js and your database
Anyone know how access this because in the discord python library i can't find it
https://discordpy.readthedocs.io/en/stable/
I trying get the example so i know how to use the code correctly but i can't find it
can't find what?
I need a example like this or else i can't correctly learn the code block do
But the example i can't find it
they don't often have examples
It's also not clear what you're even trying to do
Sorry my english IS VERY SHITTTY*
So could i how use the code block when i don't understand how use it
you don't need an example to learn how to use the function, the docs are good enough
Well i'm new to python discord library, i still trying understand the basic
What do you want to do?
I just wanna know how python discord library work and to understand how code block work too because is confusing
You can't understand the documentation?
Like opening a example
One fo my friends said you can open the code block and see a example ho wot use it
Hmm discord.py I think it doesn't have a guide for new users, if you can't understand how it works you can change to another library that has better help for you
What library should i use?
Mmm py-cord has an excellent guide, I learned very well from it, do you want the link?
Sure send it in my dms!
sure
discord.py also have example codes
Thank you, that what i was looking for
https://fallendeity.github.io/discord.py-masterclass/ also a detailed guide and tutorial on discord.py
A hands-on guide to Discord.py
Thank you, i will have it save
Will be very helpfull
I mean running the files separately, I have the bot functionality and setup in one file and the fastapi in another
I will have to run both separately e.g.:
python bot.py
python api.py
right, in different processes
the way I'd do it is make a container for each, put them in docker-compoes and just run docker compose up
So it runs directly both of them?
Instead of having to open two terminal windows and run them that way
Yeah that sounds good
you'll still want two terminal windows if you want to look at both of their logs at the same time. but if you don't it can run in the background if you use docker compose up -d
Hi everyone I have a problem with my .env file with the variable the terminal the variable cannot be found
your variable name is most likely wrong then
@proud vector
copy the command you ran and the full output, and put it in a pastebin, ask in #python-discussion . This isn't about discord bots.
ah guy quick question how to i move from py-cord to discord.py ?
is it as simple as "pip uninstall py-cord then doing dis.py ?
