#discord-bots
1 messages · Page 413 of 1
It just won't run the other lines.
Alright.
Your priority should be fixing your error handling otherwise you're just guessing
Got it.
I got the error now, it was in the Discord_logs file.
The same exact thing that you said.
No attributes to send_message.
If you want to send messages after the initial response, you should use interaction.followup.send(...)
Oh thank you! Didn't know this as I usually work with the prefixes instead.
Also, how can I use my slash commands like in gc's and DM's?
You would need to make them user install
Yep fixed.
I have a few Questions ❓
Is it possible to connect a discord bot to a chrome extension ?
If so then would it be better to try and get AI to generate the code for me and I will in blanks or pay someone ?
If I were to pay someone make it for me do you have recommendations ?
- Yes, but you should use JavaScript instead and utilize raw APIs with no wrapper/framework
And I’m not even going to bother with the other questions
What does it even mean to "connect" a bot to an extension? What do either of these things do?
I appreciate the input this is very helpful
The bot will communicate with chrome extension, like keeping updates on news or something like that
Or show what new mods come out for latest version of Minecraft
Ok forget what I said
I thought the discord bot would be embedded into the extension itself lmao
Well idk how to implement that so good luck
So what's the end goal? You have some bot monitoring something on discord and then putting it in your face via your browser?
It's fine, it's my fault I should of been more clear on what I meant
More like it monitors website that I like to keep to upgrade on and downloads anything like video because I fine it annoying when videos get taken down for someone reason
Then where does discord play into this at all?
Why wouldn’t you just make the extension itself do that?
The bot will store information in the correct channels
So this website, whatever it is, is the source of the information.
- You can have a discord bot that monitors it, ideally using a RSS or pubsub feed or whatever, so long as it's within that site's TOS
- You can have an extension that does the same in your browser
- There's really no reason for these things to talk to each other
Idk, I got invested into making a discord bot that download stuff like videos and post information after doing some research I found out I can't just have bot do all that by itself,
My troubles is that I need to keep postnet note because I very forgetful
He clearly wants to make a torrent client
😭 nah im playing
What's torrent client?
Something that lets people share stuff online, anyway let’s get back on topic
This will be a lot more productive if you actually give specific examples. "When X happens on specific site Y, I want a bot to do Z"
Sounds like that thing that is virus but makes it looks it's a normal file
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "C:\Users\pirat\Desktop\Roulette 1\python\.venv\Lib\site-packages\discord\app_commands\tree.py", line 1187, in _get_app_command_options
raise CommandNotFound(name, parents)
discord.app_commands.errors.CommandNotFound: Application command 'help' not found
[2025-07-23 22:18:53] [WARNING ] discord.http: We are being rate limited. GET https://discord.com/api/v10/channels/1395556685644562512/messages responded with 429. Retrying in 0.78 seconds.
[2025-07-23 22:18:54] [ERROR ] discord.client: Ignoring exception in on_ready
Traceback (most recent call last):
File "C:\Users\pirat\Desktop\Roulette 1\python\.venv\Lib\site-packages\discord\client.py", line 481, in _run_event
await coro(*args, **kwargs)
File "C:\Users\pirat\Desktop\Roulette 1\python\cogs\admin\admin.py", line 954, in on_ready
await self.post_panel(channel)
File "C:\Users\pirat\Desktop\Roulette 1\python\cogs\admin\admin.py", line 805, in post_panel
await self._update_status_panels(channel)
File "C:\Users\pirat\Desktop\Roulette 1\python\cogs\admin\admin.py", line 783, in _update_status_panels
msg = await find_embed_message(channel, panel_title)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\pirat\Desktop\Roulette 1\python\cogs\admin\admin.py", line 61, in find_embed_message
async for msg in channel.history(limit=200):
...<5 lines>...
return msg
File "C:\Users\pirat\Desktop\Roulette 1\python\.venv\Lib\site-packages\discord\abc.py", line 1890, in history
data, state, limit = await strategy(retrieve, state, limit)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\pirat\Desktop\Roulette 1\python\.venv\Lib\site-packages\discord\abc.py", line 1832, in _before_strategy
data = await self._state.http.logs_from(channel.id, retrieve, before=before_id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^```
You underestimate how much bots can actually do on their own, bots do nothing more than call functions that you write, you’re only limited by how much skill you have
i changed a /command and its never dissaprearing its there for ever
I want bot to download videos, models assets, news article, Minecraft mods
From where
Form selected websites
Then select them and tell us what they are
you being vague about it isn't a good look
Man we know it’s selected 😭 you don’t need to restate that it’s selected
Hang a minute I need to find them
To save you trouble, a vast majority of established sites specifically have clauses in their TOS to prevent you from doing what you described unless they have a published API/feed
wait
News article: IGN, Crunchyroll, the guardian.
Models assets: open3Dlab, renderhub, VRmodel.store.
Videos: from the mentioned news articles, YouTube, tiktok, and other social medias.
Mods: nexus
Sorry if I been to vague, I don't mean to be, let me know if you want to me to try again
IGN (Ziff Davis) Terms of use:
(ii) use any robot, spider, site search and/or retrieval application, or other device to crawl, scrape, database scrape, screen scrape, harvest, gather, extract, retrieve or index any portion of the Services,
Crunchyroll Terms of use:
Attempt to access, search or meta-search the Site with any engine, software, tool, agent, device or mechanism other than software and/or search agents provided by Crunchyroll or other generally available third party web browsers (such as Microsoft Internet Explorer, Mozilla Firefox, Safari or Opera)
Guardian terms of use:
Other than as expressly set out in these terms and conditions, or otherwise approved in writing by the Guardian, you shall also not use, or facilitate, authorise or permit the use of, any (i) “robot”, “bot”, “spider”, “scraper”, “crawler” or (ii) other automated device, program, technique, tool, process, algorithm or method (whether for data gathering, mining, collection, reading, scraping, extraction or other purposes), in each case, on or in relation to the Guardian Site and/or the Guardian Content.
Hopefully you see the pattern here
Even just to gather for information on the latest news they provide ?
If they don't make an exception for your use case, which they don't, then it's against their TOS
The guardian though, for example, has an RSS feed
not all sites will
Can't I use keyboard and mouse script to make it seem like a human interaction?
This isn't about tricking them
this is about you using a bot to violate TOS, which is against this server's rules to help you with
Well I just wasted a punch of paper
iirc there are some decent RSS bots, and you're welcome to make your own within the terms
If you didn't know or couldn't tell, I'm autistic, dyslexic, with short term/ repetitive memory.
If that helps to understand why I'm a bit clumsy and vague when I was trying to ask for help
You're good, it's just useful to read the terms of systems you're using (or ask for advice)
Do you reckon I could pay someone to make it work if it doesn't go against their TOS ?
There isn't a reasonable interpretation of what you told me that would be within their TOS
unless you contacted each of these companies and got an exemption
Well that's a bummer, it would mean I have to it all manually and here I was thinking I could automate things to free up my time
I appreciate you being very patient with me, I know not many people are.
If it's purely for your personal and only personal use, they might make exceptions
Crunchyroll also has an RSS feed apparently, worth looking into how those work
IGN too
I will write that down on my important notes
RSS is really common, there are loads of extensions and bots to subscribe to them
thank you for your help and information you provided.
Hey anyone have any idea why my commands won't work? I've tried resetting stuff, kicking it only to reinvite, changed the symbol, changed the name, looked at hierarchy, and changed the token. Any ideas?
i can help you
dm me we can fix on call !
Not super comfortable on calls. Any way we can do it over text?
just send it here, no need to call...
class MyMenuView(discord.ui.View):
def init(self):
super().init()
# Define your select menu options
options = [
discord.SelectOption(label="Option 1", description="Description for Option 1"),
discord.SelectOption(label="Option 2", description="Description for Option 2"),
discord.SelectOption(label="Option 3", description="Description for Option 3"),
]
self.add_item(discord.ui.Select(placeholder="Choose an option...", options=options, custom_id="my_select_menu"))
@discord.ui.select(custom_id="my_select_menu")
async def select_callback(self, interaction: discord.Interaction, select: discord.ui.Select):
# This function is called when a user selects an option
selected_value = select.values[0]
await interaction.response.send_message(f"You selected: {selected_value}", ephemeral=True)
@bot.command()
async def showmenu(ctx):
await ctx.send("Here's your menu:", view=MyMenuView())
That didn't work the way I thought, but I'm not sure what's wrong with it
any errors?
nope. Runs fine just doesn't work when I type the command in discord
Not sure what lib stands for. I'm still new to this so I'm kind of building as I learn sort of thing
Been messing with the auto fill thing
library?
I'm using PyCharm if that's a library. I also use Visual Studio for my other things
no like discord.py, pycord etc
okay then I don't believe @discord.ui.select(custom_id="my_select_menu") is a valid decorator, where did you get this from?
if you're thinking about discord.ui.button decorator, then sadly it won't work the same
I was. Should I take it out or replace it
yes remove it
then in your
async def select_callback(self, interaction: discord.Interaction, select: discord.ui.Select):
```You don't need the the `select` parameter and rename the function to `callback`
okay now its throwing errors at me
feel free to send it here
erm
remove the select parameter and rename the function to callback
y'know what are parameters and functions right?
yes
oke then just do that and it should work
more errors. Did I miss a parameter?
yeah no you're changing the parameter, not function
a function is def function_name a parameter is def function(parameter1, parameter2)
AHHHHHH I was mixing them up
Should I change the add_item function as well? Or does the self portion not count as a function?
add_item is a function yes, why?
cause it's throwing an error
I did that. Now it runs, no errors, but still isn't working in my server I have my bot in. I try my command and nothing pops up
What's your logging like? Maybe get it to send a message in a specific channel when it comes online so you know it's working properly
If it's not responding it could be it's not getting the commands
I don't remember how to do that and I seem to be missing my notes for how to show if the bot is online in the channel
Do you have logs set up?
yes
Hello
!d discord.ui.select
@discord.ui.select(*, cls=discord.ui.select.Select[typing.Any], options=..., channel_types=..., placeholder=None, custom_id=..., min_values=1, max_values=1, disabled=False, default_values=..., row=None)```
A decorator that attaches a select menu to a component.
The function being decorated should have three parameters, `self` representing the [`discord.ui.View`](https://discordpy.readthedocs.io/en/stable/interactions/api.html#discord.ui.View), the [`discord.Interaction`](https://discordpy.readthedocs.io/en/stable/interactions/api.html#discord.Interaction) you receive and the chosen select class.
To obtain the selected values inside the callback, you can use the `values` attribute of the chosen class in the callback. The list of values will depend on the type of select menu used. View the table below for more information.
Basically, the decorator create a new select menu, and you need to put the options, placeholder etc. there
Also I am not sure how well custom id would work there
So therefore if you don't have any reason to have a custom id, you should remove it
You really only need to declare custom id if you're doing persistence (so that the persistence tier can pick up later interactions)
otherwise the library generates a random one and then assigns it on the handling object too
Ye, or you want to workaround the library, however not recommended
import tracemalloc
tracemalloc.start()
import discord
import traceback
import os
import asyncio
import aiohttp
from dotenv import load_dotenv
from discord.ext import commands
from utils import checks
from utils import constants as c
from discord import Webhook
from utils.mongo import init_db
load_dotenv()
class Bot(commands.Bot):
def __init__(self):
super().__init__(
intents = discord.Intents.all(),
case_insensitive = True,
strip_after_prefix = True,
help_command = None,
command_prefix = '!'
)
self.persistent_views_added = False
async def setup_hook(self):
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
await self.load_extension(f'cogs.{filename[:-3]}')
print(f"Loaded cogs.{filename[:-3]}")
await init_db()
async def on_ready(self):
print(f"{self.user.name} is online - all services available.")
async def on_command_error(self, ctx, error):
if isinstance(error, commands.CommandNotFound):
return
elif isinstance(error, commands.NotOwner):
return
else:
raise error
async def on_application_command_error(self, ctx, error):
if isinstance(error, discord.errors.CheckFailure):
return
else:
raise error
async def on_message(self, message: discord.Message):
try:
if message.author == self.user:
return
await self.process_commands(message)
except Exception as e:
print(f'Error in on_message: {e}')
if __name__ == "__main__":
bot = Bot()
bot.run(os.getenv('TOKEN'))```
my setup hook isn’t being called? im not getting any errors but im not getting my print either - im only getting 1 print from on_ready
What's the folder structure
Also consider using pkgutil to discover modules rather than looping over the file system yourself. This is going to be really brittle depending on what your cwd is
No, your setup_hook() is called but either one of the conditions isn't getting fulfilled:
os.listdir('./cogs')is empty.- or
if filename.endswith('.py'):is None.
Try to debug it this way:
async def setup_hook(self):
print("Loading setup hook")
for filename in os.listdir('./cogs'):
print(filename)
if filename.endswith('.py'):
print("loading", filename)
await self.load_extension(f'cogs.{filename[:-3]}')
print(f"Loaded cogs.{filename[:-3]}")
await init_db()
Or it's not called because they aren't using discord.py
Thank you
yeah im using pycord and setup_hook doesn’t exist in pycord
whoops
thanks everyone though!
I hate py-cord so much on their design choice of using the discord name...
afaik that decision was made at a time when it was believed discord.py was permanently discontinued, so it was meant to be a drop in replacement
Anyone knows how i can make a reload command for my bot without pulling it offline that can free resources and displays "an under maintenance message" when its being done
why you need to take it down for updating tho
cant you just keep it on and either make the changes on 2 different instances
or from one using a test guild
or use another bot for dev
Its just that i have seen other bot owners do it. Just curious how to pull it off
Python natively lets you reload modules with importlib
i dont see other bots do the "maintenance" part, i see them reload the extensions to apply changes
I see. Just looked it up
I have no idea what this is tbh . I am making it from scratch , like picking up concepts while i make it
Basically they update the database schema for some change so they need to migrate all the database data to the new schema
They might take some time and you don't want any other operation on the bot at the same time
Not necessarily making changes to the code itself. Just reloading everything just incase it slows down.
I see
in case it slows down
because of mem leak or something like that? then you should find the cause and fix it
When you say reload "everything", what is this "everything"
all the libraries. Freeing resources
You're good. It just helps to dig into the motivation behind questions
Any meaningful conversation starts with actually having a tangible resource constraint, then running a profiler to find the specific thing that is consuming those resources
I see. Its just that i am kind of new to this and its hard for me to get into much technicality 😅 . Mb honestly for being ambiguous. Basically I am trying to make a mini game economy discord bot but i have no idea where to start so i just started making some commands, reading from documentation and watching some tuts on a basic setup :3
That's good, start in steps. My big recommendation here is to solve problems you actually hit, not ones that you think you might. Preemptive optimization is a massive time sink especially for the inexperienced.
Also if "tuts" means unofficial YouTube "tutorials", all of those are garbage
I see. But then how do i learn discord bot development. Any swift ways except the documentation( its overwhelming).
Learn to become comfortable with the docs rather than relying on some random youtuber in their basement to do it for you (they do it horribly wrong)
I see. So its just break it and make it for now
Reading docs and translating that into code is probably the most important skill in development imo
Generally there are examples which are a good starting point
Yeah i am trying to get rid of "Letting copilot do it for me" addiction. So i just have the documentation open in the back
also what do i use to save user data? I looked up and postgresSQL seemed like a good option since ik basic SQL and queries.
dunno abt mongodb honestly
oh yeah
Thanks for the intel. Much appreciated.
It's worth understanding what relational and nonrelational data means when making that decision, but there's like a 90% chance your data is relational
Is your code running? You are going to have to give a bit more information if you want help.
||Well you better go catch it||
Yeah, it's running. What should I provide?
||Ask it why it's running and what it needs||
I tried to go back too a commit that worked, but the application is still not responding
Code?
From? Which file?
all of it ideally
Whe should start with the main file ig
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.
Best way to fix it is to try to debug it by adding print("something") to the main functions that should run. For example one in your on_ready()to make sure the bot is running. Then pick a command that you're testing, then add another print on its first line to see if the bot is actually running it. You should also try the events like on_message() if they are running. Then there are two possibilities:
- if you see the prints, it means the bot runs perfectly but there are issues with the commands or likely with your intents that you have to enable on the developer portal but that's an issue that you should see on your cmd/log.
- if you don't see the prints, then that means whatever function that didn't run the print wasn't ran by the bot. In this case there are a few possibilities why it's doing this.
Can you take a look over my code
It's better to write your logs to a file especially for something like a bot you might not want to be staring at.
Open a file in append mode and write to it whenever something notable happens making sure to include the current time. There are libraries that offer better functionality but that would be enough at first
I briefly checked and what I mentioned in my reply is what will solve your problem.
There's a lot to cover in this code. A good bit of things that are not good practice or will straight up break. But the main one is that you're overridding on_message, which you really should not ever do unless there are specifically cases where you don't want commands to be processed Strike that, it is a listener. Nothing I can see in here would intercept commands, but that's not to say nothing else anwywhere in your code wouldn't
But what can it be?
You're not running the bot you think you are, you're sending messages somewhere the bot can't see, or there's something in the rest of your code interfering
Before the commit all was working, but i rolled back and it is still not working
Putting a log in on_message would be a good first start
I can let you look at the repo if u want.
What do you mean with a log?
Just a print
Put a basic print, send your command and see if your bot sees it at all
In the on message listener?
Then either you're running a different bot or you are sending messages somewhere the bot can't see
The bot as all perms on the server. And i am running only 1 bot
I also reseted the token
What exactly does "all perms" mean
Administrator
You absolutely shouldn't be doing that
And i send the commands in a public channel
It is a testbot
It worked perfectly before
Why would you test something you don't want to do
Either way, this probably means you aren't running the bot you think you are
But how? The console is giving me the bot back that i am running
The console doesnt give anything by default, that's your code
Also I have no idea about nextcord or if their syntax is supposed to be this
But you should ensure you're doing a message listener properly
I print the bot name at the start so i know which bot i am running
So now the possibilities are that you aren't actually getting message events at all, or that you've registered a listener incorrectly
Can you show your listener code now? After this change
Pastebin.com – das Paste-Tool Nr. 1 seit 2002! https://share.google/fugZCnPd0VD8Xprmk
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.
!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.
Can you change the bot.listen to bot.event to see if your print triggers?
Still not responding
Are any of your other events or listeners triggering?
Yeah
At this point I'm inclined to guess it's a quirk of nextcord
Might want to ask them for help
Does the bot even run?
In theory yes
Yes why you ask?
is there a way to detect when players get your servers guild tag and when they remove it?
https://github.com/PanierMehl/Antonio/
My bot is not responding to commands. All Tokens are expired no worrys
I asked them but no responding
I guess just wait or review the rest of your code to see if anything would remove or otherwise interfere with that listener
You can also use get_channel and pass in the channel id to triple check if your bot has the permissions you think it does on the channel you're sending messages to
@brazen raft i am here
Folder modules
Wait when did slash commands have anything to do with this
what else could it be?

What is your initial problem? What are you doing, very specifically, and what are you seeing
The bot is not responding to any command
What do you mean?
/ping for example
Application commands
When you type that, do you see the popup with that command?
The application is not responding
Show the code for that command
#Ping_Command (V5.1)
@nextcord.slash_command(name="ping", description="Checks for a response from the bot",
description_localizations={Locale.de: "Prüft auf eine Antwort vom Bot", Locale.en_US: "Checks for a response from the bot"})
async def ping(self, interaction: Interaction):
latency = int(round(interaction.client.latency * 1000))
p = ""
c = ""
if latency < 150:
p = self.trans["commands"]["ping"]["p"]["e"][interaction.locale]
c = config.green
elif 150 <= latency <= 300:
p = self.trans["commands"]["ping"]["p"]["g"][interaction.locale]
c = config.yellow
elif latency > 300:
p = self.trans["commands"]["ping"]["p"]["u"][interaction.locale]
c = config.red
information_icon_png = File("pictures/information-icon.png", filename="information-icon.png")
information_icon_url = "attachment://information-icon.png"
r = Embed(title=self.trans["commands"]["ping"]["r"]["title"][interaction.locale], description=f"**{p}**: {latency}ms", colour=c)
r.set_thumbnail(url=information_icon_url)
await interaction.response.send_message(embed=r, file=information_icon_png, ephemeral=True)```
Put a print at the top of this method and see if you get that
Got a output
Thats wierd
Then you have an error in here you're swallowing
Check or remove your error handling
Here is the error handler
https://github.com/PanierMehl/Antonio/blob/main/bot.py
I would recommend removing it, or stepping through it and ensuring there aren't any paths that errors could be swallowed
Bad error handling is way worse than no error handling
information_icon_png = File("pictures/information-icon.png", filename="information-icon.png") may be taking too long to load and that will cause the bot to not respond.
Try to use
await interaction.response.defer(ephemeral=True)at the start of your code then replaceawait interaction.response.send_message(embed=r, file=information_icon_png, ephemeral=True)withawait interaction.followup.send(embed=r, file=information_icon_png)
Instantiate an object aint really take that long
We won't know if it's a timeout or something else until they fix their error logging
How hard is it to get approved for message content priv
5
Its not really a difficulty thing. If you have a valid use case according to discord -> you get approved. If your usecase is invalid according to discord -> you get denied
Ok Ty
I just wasn’t sure if they were super strict or whatever. Believe mine is a valid use case
There are exceedingly few valid use cases that are deemed novel enough
Doesn't hurt to try, as far as I'm aware there isn't any negative effect of being denied an intent apart from being denied
I know there is already a bot for this but I wanted to make one where someone can go ! With a command and they store the information to the command
Would that be something that discord normally approves?
Do you mean a message content based command? (aka prefix command) Discord explicitly says those are not a valid use case for the message content intent
Things that you can't functionally accomplish without message content. They're not going to enumerate all use cases
https://support-dev.discord.com/hc/en-us/articles/5324827539479-Message-Content-Intent-Review-Policy
Basically dont use prefix commands and you are halfway there
Got it ty guys
Can you send my the discord server that you get on tag ?
It's discoverable afaik, you can go to it from the tag
odd. It's linked on the home page of the docs though
Do you know the vanity of the server ?
Thx
Is there a way for a bot to know if I already posted the same blender model in a channel ?
.
Example :
If I mode a post with my blender model download
It not let me repost the same model unless changes were made.
is there a discord.py server?
yeah, the one you see 5 messages up
ty
Did, still no response
You need to fix your error handling and get the actual error before trying random things and hoping it'll fix it
I don't completely understand you, but you could check the file hash, not sure if discord consistently modifies the attachment when uploaded though, it might lead to different hashes.
That means it's not a timeout issue and the problem is that your code is blocking at some line.
But i dont find any error
Because your error handler is bad
Like I said, you either need to exhaustively go through it and ensure you receive errors in all cases, or get rid of it
How can i ignore files with git on commits
Huh
so that a file is not included in the commit
Just don't stage it for commit?
https://github.com/youkononame/ekonn this might be a lot to ask but if anyone is willing to quickly look over my code and tell me if they notice any issues would be appreciated <3
Don't have time for a full code review of everything, but can stream of consciousness bullet point out some things.
- Don't do anything in on_ready. It doesn't work like you think it does. especially don't sync in it, syncing is highly rate limited and should be done only when you have decided specifically that you want to. Briefly looking through you have at least one on_ready listener that also does this.
- Don't ask for default intents. You don't need all of them, I guarantee it. You should review the intents and pick out the ones you do need.
- Use pkgutil to find python modules rather than looping over the filesystem yourself. It will be a lot more condensed and robust.
- You can use GroupCog to simplify cogs that only contain a single group rather than needing to declare the Group manually inside of the cog
- SimplePageSource.format_page doesn't need to be async, there's nothing async in it.
- You don't need to defer -> immediately edit_original_response. You can save a call by just responding with edit_message. ex line 50 of pagination.py
- I'm unsure why some of your cogs have staticmethods seemingly randomly? You can use bot.get_cog to get the instance of that cog.
the pagination was stolen, i shouldve looked it over
the rest of the problems are entirely my fault lol, i work on fixing them in future projects
thx for the advice <3
just curious, what should i do instead of putting stuff in on_ready (ex. loading user info from db)
Depends when you want that thing to happen
if you just want it to happen once at startup, you can create an asyncio task during startup
(that task can use await bot.wait_until_ready() if it relies on a discord connection or populated cache)
Things that you want to happen during startup can be put in your bot's setup_hook, which is automatically called for you once (between login and connect)
okie :D
@fast osprey i got it
Yes, the error handler just swallowed these and it was one thing that some commands took too long
and ping dependency
is there an abstractive way to deal with emojis with discord py?
i want to deal with unicode emojis and user-made emojis in the same way
@fast osprey did you know anything about autocomplete
I use it in a few places yeah
PartialEmoji, maybe, or just Emoji|str
https://github.com/PanierMehl/Antonio/blob/main/modules%2Fvoice%2Fcog.py#L22
What is wrong with it... I get a different error every time I fix one.
What is your latest error
Ignoring exception in on_interaction
Traceback (most recent call last):
File "/home/container/.local/lib/python3.10/site-packages/nextcord/client.py", line 504, in _run_event
await coro(*args, **kwargs)
File "/home/container/.local/lib/python3.10/site-packages/nextcord/client.py", line 2087, in on_interaction
await self.process_application_commands(interaction)
File "/home/container/.local/lib/python3.10/site-packages/nextcord/client.py", line 2176, in process_application_commands
await app_cmd.call_autocomplete_from_interaction(interaction) # type: ignore
File "/home/container/.local/lib/python3.10/site-packages/nextcord/application_command.py", line 1131, in call_autocomplete_from_interaction
await self.call_autocomplete(self._state, interaction)
File "/home/container/.local/lib/python3.10/site-packages/nextcord/application_command.py", line 1153, in call_autocomplete
await self.children[option_data[0]["name"]].call_autocomplete(
File "/home/container/.local/lib/python3.10/site-packages/nextcord/application_command.py", line 1200, in call_autocomplete
value = await focused_option.invoke_autocomplete_callback(
File "/home/container/.local/lib/python3.10/site-packages/nextcord/application_command.py", line 1099, in invoke_autocomplete_callback
return await self.autocomplete_callback(
File "/home/container/modules/voice/cog.py", line 117, in radio_autocomplete_handler
await inter.response.send_autocomplete(choices)
File "/home/container/.local/lib/python3.10/site-packages/nextcord/interactions.py", line 738, in send_autocomplete
choice_list = [{"name": choice, "value": choice} for choice in choices]
TypeError: 'NoneType' object is not iterable```
Arent you supposed to return anything from the autocomplete function
sure, the list
yeah you just set a local variable and that's it
chat any discord bot ideas youd enjoy using? im looking for some fun simple pet projects, id host it so youd acc be able to use it
So just do
return choices = [
name
for name in self.radio_stations.keys()
if current.lower() in name.lower()
][:25]```
Instead of
```py
choices = [
name
for name in self.radio_stations.keys()
if current.lower() in name.lower()
][:25]```
Just note that there is not really a way to determine if an emoji is a valid "discord emoji" other than just comparing it to a list of "discord emoji"
You meant to ask this in #esoteric-python?
the bot just takes too long for a simple command even though its response time is 22ms
That problem is still going
You probably have blocking code then
either a 404 or a timeout error occurs
Wjat do ypu mean with blocking code
Do you have much experience with asyncio or async programming generally?
You can always defer interaction responses, and then followup with the content
In Asyncio all the coroutines (the async functions) run in an event loop. These coroutines can be paused and can resume execution again. This is what allows concurrency. If you run something like time.sleep(4) within the functions, this is considered blocking code, that means the entire event loop will freeze for 4 seconds. So basically you cannot use standard blocking code like time.sleep requests.get etc in your functions. If there exists blocking code then you need to use asyncio.to_thread
ideally you would use natively asyncio friendly versions wherever possible and lean on to_thread as a last resort
(also to_thread won't help with cpu bound operations)
Yea it's best to offload cpu bound tasks such as image processing on a different python process altogether
Anyone know any free good discord bot hosts
that will keep my discord bot on 24/7
without me having to interact or anything
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.
"free" "good", pick one
see the embed above. there are some options
alr thanks
you can also search up "free discord bot hosts" on google but most of them are bad. but you pay for what you get
If you can't identify the product being sold, you are the product being sold. These aren't charities
i did lol most nodes are full or its paid or its sketch or smt
well, that's just how it be
It's very basic economics if you stop to think about it.
If there existed a free product that people could use to make money off of indefinitely, why wouldn't they. And how would that product sustain itself if nobody was ever forced to pay for it.
never heard of it
I have plenty of times and none of it good
sounds about right
Hi everyone,
I'm looking for a Python module (or library) that can query multiple types of game servers — ideally something that supports most popular games like:
- FiveM (GTA V)
- DayZ (Steam Query)
- MTA:SA (Multi Theft Auto)
- Minecraft (Java/Bedrock)
- ARK, Rust, CS:GO, etc.
You will probably need to find a separate library for each game. Also it depends on what you mean by query. If it is simple enough you might just be able to use requests. Although you should probably ask in a non discord bot channel
But it doesn't always work, for example like with a modal
What do you mean woth that?
Not much, just basic things
I would recommend starting there and learning asyncio more deeply
you should be able to describe what blocking code is and identify it in what you write
using non blocking async compatible libraries such as aiohttp/httpx over requests, aiomysql over mysql-connector etc.
Wdym
Defering doesn't help at all if the defer itself takes 3 seconds due to blocking code elsewhere
Just defer at the top of every command
Why not
(as long as the command logic doesn't crash)
I mean not literally every single command but the command where you expect the no found error
That error should not be expected, it's indicative of a problem somewhere else in this case
defer should only be used if you reasonably believe it will take 3+ seconds of processing on that interaction. It shouldn't be a reaction to time being wasted where you don't know why or where it's being wasted
Will Discord handle this by retrying to give the role?
Can u just give me an example?
There are nothing tell you that whether the server have issue before or after handling the query, and the library wouldn't attempt to retry it automatically
@fast osprey is it possible that I should use aiomysql instead of mysql?
You should just use aiosqlite
Insufficient reason, why?
I have blocking code, and i alledem chatgpt and he says that my db querys can cause this
Because from what I’ve seen aiomysql is old
!pypi aiomysql
Fair
but mysql will work differently then sqlite
My problem is that probably my db querys are blocking my code
But you can also use old stuff
That’s gotta cause some kind of dependency hell
And i have knowlage of aiomysql. I dont know anything about asyncmy
It’s literally just a different library name from what I’ve seen
Okay can u just take a short look over my code and just tell me if the Migration is easy ?
Last release is only 2 years ago, that is not even that old, if it works there is no reason to change
I just like new stuff man
Traceback (most recent call last):
File "/home/container/.local/lib/python3.10/site-packages/nextcord/application_command.py", line 955, in invoke_callback_with_hooks
await self(interaction, *args, **kwargs)
File "/home/container/modules/voice/cog.py", line 102, in voice_radio
voice_client = await voice_channel.connect()
File "/home/container/.local/lib/python3.10/site-packages/nextcord/abc.py", line 1830, in connect
await voice.connect(timeout=timeout, reconnect=reconnect)
File "/home/container/.local/lib/python3.10/site-packages/nextcord/voice_client.py", line 362, in connect
await utils.sane_wait_for(futures, timeout=timeout)
File "/home/container/.local/lib/python3.10/site-packages/nextcord/utils.py", line 570, in sane_wait_for
raise asyncio.TimeoutError
asyncio.exceptions.TimeoutError
I just got an error that i triggered like 10 minutes ago
So it is caused do the blocking code right?
but I've never had the problem
Since 2 years and now puff
That might be due to the issue where the port for voice connections is ignored by discord.py and anything that reused some of discord.pys code. I would ask nextcord if they have a fix released for that.
It is not only the voice commands
then it is probably the blocking database calls
Can u take a short overlook if thats right?
Nothing in that file seems to be async
So thats the blocking code?
Any request to the database, so pretty much every function in that file. I am not super good at async stuff tho so I cant explain it anymore
Bro this isn’t even aiomysql, idk why you were saying this
I said i have knowlage for aiomysql
Bit i had a other db before that could not handle aiomysql
Yo why is your naming so inconsistent in the modules directory lol
Yeah you need to make that entire class async
gei guys, im currently self-studying ML and wanna get into it deeper i just started recently. But to making koney with ML in any way is hard so it will take years before i can even start. I already know python so is learning to make discord bots a good idea to make some level of income(300-500 bucks) while not being fully invested in it?
Absolutely not
This is such a saturated market where like 99% of the user base refuses to pay anything
Fr!
is there another python niche u would recommend? id wanna go off python but if i must i will, just trying to find a solution if it exists.
If you want to make money? Go on a freelancing site, see what people are hiring for. Probably mostly web dev id imagine
But that's not a convo for here. Maybe #career-advice
got it, thanks.
I use aiomysql and it works as intended 🤷
Everything is synchronous there... You'll need to use an async compatible lib and async def all database functions and await them whenever you call those functions. Also it's highly recommend to setup a connection pool.
But still, idk why you wouldn’t use the more current version that also looks the exact same on the surface level
hi everyone
Does discord.py is not used anymore and changed to Py-Cord?
No, discord.py is still the most popular framework AFAIK.
So, when I learn Discord Bots I learn only discord.py?
Or do I have to learn Py-Cord too?
You can choose any library, you don't need to learn several/all. Some libraries might have advantages (and disadvantages) over discord.py, one advantage of discord.py would be its popularity — it's the one most people are using.
So, discord.py is the best option to learn, right?
I haven't written enough discord bot code to have an informed opinion.
It's very subjective
They are all more similar than they are different though unless you choose hikari
Did you use py-cord before or only discord.py?
What's hikari?
It's another discord library that was made with very different design principles
d.py, but mostly because we (Python Discord) already use it for all our bots.
discord.py differs from Python Discord?
Python Discord is this server. discord.py is a Python library.
Alright I will learn discord.py
As I saw some videos on it and it seems easy
Those videos are all horrible
The people who know what they're doing contribute to the library documentation, they don't make videos
I hate reading + I was taking a look
Up to you what you do but these videos aren't reviewed and say objectively wrong things. Id suggest getting comfortable with reading because that's where the actually correct info is
reading is required for any dev works
if you just watch videos without reading into any of the documentations, its just copying and not learning
if you encounter any other problem that has no video that has code inside youll just get stuck
You should be using tutorials specifically recommended by the library you choose. The top 10 "python discord bot tutorial" by SEO are all outdated, bad, or both
They probably should though, lectures and other teaching platforms all use visual aids for a reason
No they really shouldn't. These people aren't being paid
they're not going to waste their time producing in a medium that takes more time to produce and more time to edit when a perfectly capable medium already exists (documentation). They shouldn't cater to people with bad attention spans
It's something in demand that people are currently using inferior substitutes for. If correcting that is a waste of time then that's certainly a perspective to have
Though I can sympathise with not wanting to make explanation for idiots videos for free
People can demand things all they want, that doesn't mean it's a good idea especially if they're not willing to pay for it
So i mustuse aiomysql
You can use that or the other library recommended by a user above
But can u recommand it too?
I would personally recommend spending the time migrating off of mysql entirely, it's pretty shit
It's the exact same syntax (mostly) and a little better performance so go ahead
Mariadb is decent
Haven't used maria personally, I mostly use postgres or sqlite but #databases talk I suppose
Wich lib do you recommend
For?
The mirhration from pymysql
Well you'd have to pick a db to migrate to, which is largely dependent on your personal needs
aiomysql or asyncmy
I don't have opinions on any mysql libraries because I don't use mysql
well, not in a while after I had firsthand experience with its issues
You can go with asyncmy for maximum performance, but if you are super familiar with pymysql (eg it's errors) then go with aiomysql since it's built on top of pymysql
What issues 👀 if you don't mind sharing
not full syntax support, multiple vulnerabilities. Would eventually run into scaling issues
I heard it will take care of it for you. That is why I asked
Btw the fact that it error means it doesn't take care for you
@fast osprey @whole shoal i changed it to the asyncmy but still no responding
Use asyncio debug mode to determine what exactly is blocking
How
@test_c.subcommand(name="send_a")
async def send_a(self, inter: Interaction):
await inter.response.send_message("A")
```
the application is still here not responding
it is an easy command
Nope
That's your first issue
But my error handler did not block any errors
Did you put any debugging in? Are you getting into that function at all?
Ill try
Nothing
my error handler
If you put a print at the start of that command and you don't get it, there's something else wrong
No print
Oh wait
I got prints, like 20s after the command
Then asyncio debug mode
^
I got an error
And this is the debug stuff
https://paste.pythondiscord.com/MYYA
How do I make a bot?
pick a library, follow that library's getting started guide
I just found out bot ghost is getting shutdown
Think it already happened
Unlikely
Oh
they shut it down for exactly that reason
@fast osprey did you can help with this information?
You should be getting asyncio debug information about a method blocking for too long. How are you enabling debug mode?
I did
No like what method are you using to enable debug mode
Bro botghost sucks
It locks basic features behind a paywall
What do I use then?
Your own programming skills, duhhh
.
What else do you use?
I'm asking for help Bc idk how to........
You don’t put “discord bot dev” in your bio and then be completely unable to write one yourself
No need to berate them.
You will need a solid amount of programming experience, have you done many projects in python already?
oof
they obviously cannot use programming skills, botghost is for users who don't know how to program
Thats what I need....
well, there isn't an alternative; botghost was like squarespace of discord bots lmao
since you're not going to bother coding--just like the last person i interacted with who also used botghost--you'll have to use a combination of AI (chatgpt, gemini, claude etc), some Python knowledge, and a free hosting service for a discord bot
coding would be the best method; you're probably not doing anything complex with the bot
learning the basics of python and slapping the bot on a free host recommend using orcale cloud free tier is all it takes
there should be a specific use case that existing bots cant do that you would want one
if you want something you will try to make it
if you dont bother making it you dont really want it
Using AI is a bad idea in the long run
well yeah
use what you have provided
Anyone knows a good source to learn from?
Full course of discord.py from zero to hero
Have a pdf for python
Is there a playlist?
If someone is explaining will be better but send the pdf
It completely depends on what skills you're coming in with
look at their documentation and mess around. Thats what i personally did
- most bots are pretty basic and dont have insane amounts of features like bleedbot
I want playlist do you have?
nah
oh
There are no good videos on this topic. This isn't a visual concept
Tell me your roadmap learning discord.py
Have a pdf for python
Give me it
Yah, gimme 2 mins
Sure tyt
Can't send pdf in this server
Send it in my dms
Yah I'll send
dm’s 📩
https://paste.pythondiscord.com/WACA
I migrated from pymysql to asyncmy and now the giveaways are not ending anymore
Your error handling here is pretty rudimentary. You won't get any output in some cases
https://paste.pythondiscord.com/PLPA
error
ERROR:root:HTTPException while fetching message None: 400 Bad Request (error code: 50035): Invalid Form Body
In message_id: Value "None" is not snowflake.
You're passing None into fetch message, but you really should never need to fetch messages especially if it's one your bot sent
so whats the fix
Why are you trying to fetch a message in the first place?
to edit it
You don't need to fetch a message to edit it
okay so just get_message
That's not a method either. But either way, the value you're passing into it is None which is going to be a problem
i printed it and it is not none
message_id 1400110534430560386
get_partial_message(message_id, /)```
Creates a [`PartialMessage`](https://discordpy.readthedocs.io/en/stable/api.html#discord.PartialMessage) from the message ID.
This is useful if you want to work with a message and only have its ID without doing an unnecessary API call.
New in version 1.6...
you can use this with a channel + message id to get a partial message (which you can edit) without needing to do a full message fetch
still
ERROR:root:Unexpected error processing giveaway 13910610: 400 Bad Request (error code: 50035): Invalid Form Body
In message_id: Value "None" is not snowflake.
Traceback (most recent call last):
File "c:\Users\domin\Downloads\Antonio-2\bot.py", line 473, in check_giveaway_ending
await message.edit(embed=embed, view=None)
File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\message.py", line 2072, in edit
data = await self._state.http.edit_message(self.channel.id, self.id, **fields)
File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\http.py", line 370, in request
raise HTTPException(response, data)
nextcord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In message_id: Value "None" is not snowflake.
code now?
is it possible you're exceeding the character limit? Also what is printing out the whole "Value None is not a snowflake"? That appears entirely disconnected from the error
What fo you mean
there's a limit to how long messages can be
you will get that 400 error if you try to send a message longer than that
But where
You're sending a message, yes? That message has content
do you know how long that content is?
It worked before i added the New db and the error handler for it
that wasn't my question 
i aksed chatgpt and he says this
✅ Solution:
Replace:
message = channel.get_partial_message(message_id)```
With:
```py
message = await channel.fetch_message(message_id)```
This properly fetches the full message object from Discord, including its ID and content, so you can safely edit it.
chatgpt is stupid and this is factually wrong
Okay
yeah just used get_partial_message to edit a message and no problems at all
what's the length of prize?
(datetime.datetime(2025, 7, 30, 16, 4, 11), 1400131879524503553, 900100165397008465, 1398399119453851828, 84390392, 'Test1', None, 1)
That looks like the entire row
how about winner_mentions
I had previously stored time as bigint and now as timestamp Maybe it is because of this change
how would that impact the embed you're trying to send?
Mayby the timestamps
Don't see anything in the code you sent that sets timestamps on the embed
^
You are crafting a message that discord is saying is badly formatted. I'm about fairly certain it's a problem with that embed specifically
I will send it in a sec
giveaway_end_time 2025-07-30 14:04:11+00:00
message_id 1400131879524503553
guild_id 900100165397008465
giveaway_id 84390392
channel_id 1398399119453851828
prize Test1
participants_data None
finished 1```
that's not what I asked 
oh winners mention is not in there
what is "there"?
winner_mentions = ', '.join(f"<@{winner_id.strip()}>" for winner_id in selected_winners)```
Why do you have a random for each loop that just does nothing
Try this. On this specific line, 473 , change embed=embed to content="a"
If it works, then it proves that the embed you're trying to edit in is what's causing the problem
Isn’t winner_id an integer or am I just guessing
What are you stripping here
Yeah
You can’t strip an integer
I am French and on Visual Code Studio I cannot install Selenium in my terminal. Could someone translate everything into French in a private message please?
ERROR:root:Unexpected error processing giveaway 33514827: 400 Bad Request (error code: 50035): Invalid Form Body
In message_id: Value "None" is not snowflake.
Traceback (most recent call last):
File "c:\Users\domin\Downloads\Antonio-2\bot.py", line 472, in check_giveaway_ending
await message.edit(content="a", view=None)
File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\message.py", line 2072, in edit
data = await self._state.http.edit_message(self.channel.id, self.id, **fields)
File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\http.py", line 370, in request
raise HTTPException(response, data)
nextcord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In message_id: Value "None" is not snowflake.```
And you are positive that message_id isn't none
No, not in your db. In this variable at the time you're calling get_partial_message
1400137578044325990 yeah
print(message_id)
message = channel.get_partial_message(message_id)```
I get that exact same error when I pass None into get_partial_message
but i printed it for you
I don't think you're running the same code path you think you are
@fast osprey can i start earning anything with python i learaned alr all basics
okay now it workes after i set the loop time higher
but he will end this giveaway to early
I am fairly certain you have some edge case where you're pulling in a None message_id. Not all the time, but some fringe condition
Earning?
mayby it is bacaue i add some statements to the db and add the rest after a few secounds
You're probably running into race conditions yes
await inter.client.db.insert_giveaway(giveaway_id, dt_end, self.prize.value, self.channel.id, inter.guild.id, None, self.winners.value, self.requirement, value_str)
if str(self.requirement).lower() == "role":
mention_text = f"<@&{self.value}>"
elif str(self.requirement).lower() == "user":
if isinstance(self.value, list):
mention_text = ", ".join([f"<@{u}>" for u in self.value])
else:
mention_text = f"<@{self.value}>"
else:
mention_text = "Alle"
giveaway_embed = Embed(title=f"{config.giveaway} {self.prize.value} {config.giveaway}", description=f"Endet am <t:{int(epochEnd)}:f> oder <t:{int(epochEnd)}:R>", colour=config.green)
giveaway_embed.add_field(name=f"Gewinner: {self.winners.value}", value="Drücke den Button um teilzunehmen!\n\uFEFF")
giveaway_embed.add_field(name="Teilnahmebrechtigt:", value=f"{mention_text}\n\uFEFF", inline=False)
giveaway_embed.add_field(name="Anzahl der Teilnhemer:", value="0\n\uFEFF", inline=False)
giveaway_embed.set_footer(text=f"Verlosungs-ID: {giveaway_id}")
giveaway_embed.set_author(name=f"{inter.user.name} hat eine Verlosung gestartet")
giveaway_started = Embed(title=f"{config.giveaway} Verlosung gestartet! {config.giveaway}", description=f"Verlosung wurde in {self.channel.mention} gestartet")
await inter.response.send_message(embed=giveaway_started, ephemeral=True)
view = join_giveawy_de(inter.guild.id, giveaway_id)
msg = await self.channel.send(embed=giveaway_embed, view=view)
view.message = msg
embed_data = msg.embeds[0].to_dict() # Convert the Embed object to a dictionary
embed_json_string = json.dumps(embed_data) # Convert the dictionary to a JSON string
await inter.client.db.update_giveaway(msg.id, inter.guild.id, giveaway_id)```
mayby that was the case
You're inserting a record for a giveaway and then updating the message id later?
intents = discord.Intents.default()
token = token()
client = discord.Client(intents=intents)
client.run(token)```
Is this code still used? the `client.run()` and is it professional to use it with intents?
Not sure what you mean by professional but yeah it works fine. Though bot extension has more stuff
Alright
Is token literally just a function that returns your token
Yeah
From token.txt file
Also which is better run the function or a variable has the function?
Worth considering what intents you actually need rather than just grabbing all the defaults
I forgot to add intents.message_content = True
That's still asking for defaults you don't need
Isn't default() line for discord.py intents must be typed?
I set it to default cuz I am still new to the field
import discord
def my_token():
with open("token.txt", "r") as f:
return f.read().strip()
intents = discord.Intents.default()
intents.message_content = True
intents.guilds = True
intents.members = True
token = my_token()
client = discord.Client(intents=intents)
CH_ID = 1400396865647677471
@client.event
async def on_message(message):
if "users" in message.content and message.guild.id == CH_ID:
if message.guild:
await message.channel.send(f"Number Of Users In The Server Is {message.guild.member_count}")
client.run(token)```
Could someone tell how to fix this code here? I want to display members count in the server in a specific channel called `commands` with the `CH_ID`
Bro this is horrible design
I like it
Ok whatever, what errors are you getting, if any?
Can you try typing any message with the content “users” in that channel?
Nothing happens
Does the bot have read message perms on that channel?
It's not locked
And the bot has Administrator
Your bot should never have administrator
Why?
Because it doesn't need it
Maybe if I add ban mute etc
Then you can add the specific permissions it does need
It doesn't need all perms
Btw is there a way to fix my code?
Do you have privileged message intents enabled on your developer portal
If they didn't, there would be an error on login
Yeah
Oh
Why are you comparing the guild id with a channel id?
it could very well not be a channel ID
but it doesn't make sense to check if message.guild is None or not after doing id on it
Well he said there is a specific channel with CH_ID
Ah I missed that
Do I change it to message.channel.id?
If you want to compare the channel with the CH_ID, yes
Channels and guilds are different things, yes
IT WORKS
Congrats
Don't be too hard to yourself
if you've changed message.guild.id to message.channel.id then you don't need to check if the message was in a guild or not
but if you wanna compare guild IDs you need to check if the message was in a guild or not BEFORE you actually compare the IDs
@hushed ridge Use this instead
if message.guild and "users" in message.content and message.channel.id == CH_ID:
Alright
Btw I changed to client = commands.Bot(command_prefix="!", case_insensitive=True, intents=intents) cuz the one I was using was old version
I wouldn't recommend naming a variable client when it stores a completely different type
If I were you, I would just use prefix commands with a guild_only decorator
!d discord.ext.commands.guild_only
@discord.ext.commands.guild_only()```
A [`check()`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.check) that indicates this command must only be used in a guild context only. Basically, no private messages are allowed when using the command.
This check raises a special exception, [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.NoPrivateMessage) that is inherited from [`CheckFailure`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.CheckFailure).
If used on hybrid commands, this will be equivalent to the [`discord.app_commands.guild_only()`](https://discordpy.readthedocs.io/en/stable/interactions/api.html#discord.app_commands.guild_only) decorator. In an unsupported context, such as a subcommand, this will still fallback to applying the check.
The person I found on YouTube uses client = commands.Bot(command_prefix="!", case_insensitive=True, intents=intents) and it took much to find updated version of discord.py on YouTube
There is not a single good video on YouTube. They're all bad
Or frequently used important commands
People who actually know what they're doing contribute to the official documentation, not slap together a video for internet points
-# so glad that YouTube is getting restricted to 18+ soon /s
I found Arabic person and he's so good
And what experience are you drawing on to make that assessment?
I am just learning with videos in the start cuz docs for experts and will make it harder to learn
I am 19 ;D
If they don't even know how to name variables I don't have much faith in the rest of their practices
huh
YouTube is only going to teach you the bad practices...
My tip is that you should question what you're doing when you turn these things on. This is how you learn why you're doing what you're doing. Tias and give it a chance to fail, it's fine we all fail sometimes
client = SomethingThatIsNotAClient is classic textbook someone copy pasting stuff they don't understand
Yeah that's what I am doing
I will read the docs after watching the playlist
I want to understand how to code a discord bot then read advanced things
I want the basics
The documentation is the basics
But not a good choice for beginners
youre watching how to slap random things in python and make it works, not how to code a discord bot
Some experts here told me not to start with docs
Experts, or people who just told you what you wanted to hear
Oh man
I want to know basic commands and codes then I will read docs
Nope
there are code examples on the official repo btw
Wdym?
The docs are always a good source, even if they're boring sometimes
I hate reading xd
https://github.com/Rapptz/discord.py/tree/master/examples
YouTube isn't gonna do much more than showing the code for you to copypaste
You're talking to at least two people right now who are contributors to the library you're using, and you're calling these other random people "experts" because they're giving you snake oil
I don't copy paste
me copying but i need to see people writing it (badly) so i can follow word by word on youtube videos
I only watch YouTube to see what's this function or what's this word and what does it do
Like that not the code to copy paste
That is actually a good example
"And I will call this variable 'client' because the other youtuber im copy pasting from called it that too" 10/10 tutorial
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
I know you can name it anything you want
I don't call it client I will name it something else
But yeah I am learning
You are learning from the wrong place
I doubt the video is explaining what each thing is or even telling you the actual definition
The guy said you can name it whatever you want
But if you want to ignore people who clearly know what they're talking about just to do it easier, that's your prerogative
not only client
The guy is bad
you can name it whatever you want but i name this wrongly
definitely a good tutorial
My main goal is to know the definition of words and fn
I hate reading btw
That's why I don't start with docs
I know I have to read docs
sadly reading will be half your work
Once I finish basics I will Inshallah
I know but I never start with reading
I will hate the field
"I want to be a doctor, but I hate humans"
but I respect rules *
If you want to grow and build stable, extensible things you will need to become comfortable reading. I'm sorry that tiktok fried your generation but this is the truth. You need to work on your attention span or you're going to be recycling garbage
Bro I didn't say I won't read
You don't have to read the whole docs, that's dumb… you usually read the "getting started" part and then go from there to the parts you want to use in your code. Or search for it.
Reading the docs from the top isn't going to help with anything.
ok
Anyone interested in developing team?
What's the team mascot?
@client.command()
async def clear(ctx, amount=5):
await ctx.channel.purge(limit=amount+1)```
Why here when I do !clear if there're 3 reply messages it clears 1 and clear the rest of the normal messages?
Why is it that when I use !clear and there are 3 reply messages, it only deletes 1 of them and then continues deleting the rest of the normal messages?
What do you mean by "reply messages"?
.
Purge would not delete messages any differently
Red messages are the cleared
Why it didn't remove the Pong! 178ms
And also it doesn't remove old messages
await purge(*, limit=100, check=..., before=None, after=None, around=None, oldest_first=None, bulk=True, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Purges a list of messages that meet the criteria given by the predicate `check`. If a `check` is not provided then all messages are deleted without discrimination.
You must have [`manage_messages`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions.manage_messages) to delete messages even if they are your own. Having [`read_message_history`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions.read_message_history) is also needed to retrieve message history...
And from your screenshot this is probably a race condition on your client
Not a bug in purge
Wdym?
looked like you were spamming the commands so the message the bot reply is technically before your last command but the discord app chose to display your message first
The order you see your messages on your client is not necessarily the order they are stored on discord
I have to type them all?
ctrl r to reload your client, send the commands with a slight delay, and then run the clear command again
Also client mods are against the ToS
Yes
A parameter with = ... means it's optional, just like you declaring a parameter yourself in your own function
We want to program discord bots
PYTHON
In future, c++, js, java, ts
so what's the mascot
This, no point debugging an issue with the bot if this issue is very likely with the TOS breaking client
That’s a myth buddy boy
"myth"
@client.command()
async def ban(ctx, member: discord.Member, time: int, unit: str = "s", *, reason=None):
if unit.lower() == "s":
seconds = time
elif unit.lower() == "m":
seconds = time * 60
elif unit.lower() == "h":
seconds = time * 3600
elif unit.lower() == "d":
seconds = time * 3600 * 24
else:
await ctx.reply("Please choose a valid unit 's,m,h,d'")
return
await member.ban(reason=reason)
await ctx.reply(f"User {member.id} Has Been Banned For {time} {unit}! \nReason: {reason if reason else 'No Reason Provided.'}")
await ay.sleep(seconds)
await ctx.guild.unban(member,reason="Ban Expired")
await ctx.send(f"{member.id} Has Been Unbanned After {time} {unit}!")```
Can you guys rate my ban code and tell me what to add or remove?
ay.sleep() I imported import asyncio as ay
- What is the purpose of banning someone temporarily? Are they necessarily going to reform themselves in that time? Why not just time them out, which is already built in and far less disruptive?
- What happens if your bot restarts during that interval?
Timeout is limited it only restricts sending messages or joining voice but the user still stays in the server and can DM others. In serious cases like spam, NSFW, threats or advertising, I prefer that the user is completely removed even for a short time
Why not just ban them then
do you think they're going to stop threatening people after x seconds
Tbh its kinda useless
Temp ban adds weight It sends a stronger message sometimes the person cools off and apologizes after a day or two it's also useful for staff to take time before making a permanent decision
then you can unban them if they cool off
rather than assuming they will after an arbitrary period of time
it would ruin the fear of getting banned, wouldnt it
If someone is so problematic that it's a risk to let them simply exist in the server (not being able to talk), then I don't see why that would change in a short period of time
But they can send messages to members in the server
which isn't your problem
you can't moderate what people do in dms, you can't even see it
cogs have nothing to do with files. Cogs are classes
I mean which one do I use?
which one of what?
Cogs or single files
again, cogs have nothing to do with files
Like this
??
To access them I mean in main.py
Whoever told you that is wrong and misled
No one told me that
so you made it up from your brain, you conjured the term "cog"
😭
@fast osprey genuine question , is this a good way to format files for dc bots
Did I end the world? I am just a beginner just help me
Cogs are, again, classes. A file can have 0, 1, 2, 500 classes. Cogs have nothing to do whatsoever with your file structure
how long have u been coding for
You can split up your bot between files if and when it is valuable to do so. There is not a hard and fast rule, but newbies tend to heavily skew towards doing this when they have no reason to
a decade
"beginner"
"long" files are not inherently bad. Poorly organized ones are
Tell me how to format files and link them to main.py
Making a separate file per command is egregiously bad
patience is the key to success
Was it hard to send this?
The jury is split on file structure practices. There are however deep functional implications on what you put in which file which absolutely takes precedence over the vibe-based approach of "this file feels too long" that way too many people follow. I definitely suggest understanding what those functional implications are and making informed decisions
ahh
Generally you want to group together definitions (classes, methods, constants) that share dependencies and are interdependent/reloadable together
what were you coding at 8?
im good g
!warn 1392915121637953656 We don't allow advertising in our server or recruiting/hiring/asking for paid work. Please re-read our #rules
:incoming_envelope: :ok_hand: applied warning to @mental marten.
shivering my fucking timbers
9 *
I was learning about ChatGPT
Then I coded my first Linux Distro
openSUSE
why is the emoji not popping up
ive tried :Checkmark:
as well with the numbers version
<:Checkmark|1400679741543022794>
i'm not suree sry i'm not great with discord/discord bots
Are you on windows?
this does not matter
Have you tried Windows + . and enter an emoji there inplace of <:Checkmark|1400679741543022794>?
pretty sure when using an emoji it should be like this <@EMOJI-IDHERE>
hey
i need help
how did this bot get an invisible accent color that works on all appearance modes
that’s just discord’s default embed color when no custom color is set
not invisible, just using the fallback color scheme if that’s what ur asking
Nope, that’s components v2
you're right in some ways. according to the discord.py issue tracker, components v2 does have an "option to completely eliminate the side color bar of an embed." so even though the color field behavior for regular embeds is still there, components v2 lets you get rid of that colored sidebar completely. means the whole invisible/default color discussion would be pointless for those message types 🤷♂️
nothing's wrong with it being v2. just saying that v2 gives you the option to completely remove the colored sidebar that normal embeds have. so when you use that feature, there's no color bar to worry about at all lol
so ye that's still the default fallback color behavior same as it's always been. components v2 just gives you the option to remove the color bar entirely if you want. the "invisible" accent you're seeing isn't from v2, it's discord using the default embed color when no custom color is set
Uh, so youre saying embeds can have a separator and action rows in them?
^
I think I got it mixed up nvm
You indeed mixed up embeds with the new container component for some reason
hi whats the cog version of this
i forgot pls
the client part
@self.tree.command?
@app_commands.command()
@bot.event
async def on_message(message):logs_channel = bot.get_channel(1400865565580726376)if message.author == bot.user:
returnif any(word in message.content.lower() for word in bad_words): await message.delete() msgkerby = await message.channel.send(f"{message.author.mention}:\n\tYour message was deleted for containing a blacklisted word!") await logs_channel.send(f"A message from {message.author.mention} in {message.channel.mention} was deleted for containing one or more blacklisted words.") embed = discord.Embed(title="Message Content:", description=message.content) await logs_channel.send(embed=embed) time.sleep(2) await msgkerby.delete() await bot.process_commands(message)
I have this here code which is the code for my automod system.
(the bad words list is located elsewhere)
I tecgnically works a treat. I wish I could put everything in embeds, but I'm having trouble with mentions and stuff in embeds.
Anyway, I'm trying to figure out how to call out which specific words were blacklisted. Help would be very much appreciated.
Here's this in case it's easier to see it in colour.
Have you considered using the native automod for this?
Native automod?
huh
Looking at that page, there is no such thing in my server settings.
But also, I think I'd prefere my own.
If you're on mobile I think it's only supported on desktop
And the code you've shown is just strictly less reliable and feature rich than the built in one
I'm on desktop
I'm building the bot for a specific server, and the only automod feature we need is a couple blacklisted words. And I'm already building a bot for the server, so I think it makes more sense to just continue this way.
Works for me on latest official client. I'm always going to recommend using native stuff that works as it's just going to be more stable and reliable. You're not going to code better than the entire discord team
Also true about being less reliable, but it's my first discord bot. I expect to upgrade the code as time goes on.
fair I suppose.
But I'm set in my ways XD
(And, again. It isn't showing up.)
Ah, there it is.
Worth playing around with. You could just change your any to a for loop, but there are some pretty substantial edge cases I can see already in your logic
gl
👍
The other option here would be to make a compiled regex and output the match, slightly more complicated code but would be more performant
huh
I'll look into that.
(Only partly know what that means.)
Back to the topic of embeds, I now find myself with this problem.
I knew that it would be a little tricky, but I'm going to need it several other places in the bot so I'm going to have to figure it out anyway. This- technically works? Except- not at all.
oh actually
i think i have a really simple fix, even if it's temporary.
You can't mention in embeds (and cause a ping) afaik
And it won't render at all in titles iirc
You can mention from them, but yeah looks like you can't do it in the title.
thanks
Whuch really just means I'm using their username instead of display name, which is fine.
I'll probably build something that grabs the display name at some point.
It's just member.display_name
Ya it suppresses the notification, only notifies of its in the content
even better actually.
This is actually a huge help thanks.
If you don't want to notify, there's also the allowed_mentions param when sending a mention just for future reference
ok
is there a reason why you put ur entire program to sleep for 2 seconds?
since discord bot code is async, do use async sleep function asyncio.sleep() --that way the entire program isn't put to bed
do note that censoring words is like a whack-a-mole, you can't handle every possible case
the reason you may not have access to discord auto-moderation features is because 1) the server isn't large enough to have access to the community server designation, 2) the community server designation has not been enabled by a staff member
the none async sleep version is blocking
I- didn't think about the fact that I put the entire thing to sleep. Also didn't know that was a thing thanks.
I'm just censoring 2 to 3 single words. It's just f_ck, b_tch, and every couple weeks a random letter cause my mod team and members are ridiculous. I'm not really concerned with anyone getting around the automod.