#discord-bots
1 messages Β· Page 406 of 1
basics to advanced logarithms and little bit geometry
we are sleeping in 2 functions for 1 second
now let me show you the sync code that doesn't use async
cool
and you can see the difference in the total time
if need i can learn async library i learnt some library already like request bs4 time, and little bit os
but if i don't need i don't want to learn it
!e
import time
def say_hello():
time.sleep(1)
print("Hello")
def say_world():
time.sleep(1)
print("World")
def main():
start = time.perf_counter()
say_hello()
say_world()
stop = time.perf_counter()
print(f"Total time: {stop - start:.2f} seconds")
main()
:white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | Hello
002 | World
003 | Total time: 2.00 seconds
what's the difference here @slate swan ?
it's without async library
yes but what's the difference in the output
no not at all
xd
what do you think is it possible to do discord bot using api
without dc library?
hm
It's best
i said it
for theory
π
you did not understand
i did not say "i don't need async i want to make dc using api)
Not exactly. Async doesnβt make your functions faster. It just lets your program do more at the same time when itβs waiting on something so if you noticed we are using asyncio.sleep() which is asyncio version of the time.sleep() functions which allows for that first function to be called that sleep function is then called but since it's async your program keeps a tab there and moves on to the next thing which is the say_world() function.
so say_hello() is called it sees that there's the asyncio.sleep() and then moves on to the say_world() function it sees that there's another asyncio.sleep() so it's added to the queue
okk i understood it thanks
I mean wdym by that? You have to interact with discord's api in order to create a bot
no i just said it like a theory
like is it against tos to make bot
gets your auth
connect to your dc acc
and responds random user in dm if you are afk instead of u
example: hi
my dc acc: hello, i am afk wait for me
it's interesting
yes that's against tos because it's account automation
you would have to use a bot account for it to not be considered account automation
yes those use their api
thanks, i understood:z
discord doesn't like you using their api through regular user accounts
but i think
they don't have any def against those bots
algorithm
so it's free to make but it's against tos
there's just no reason on discord because you can do all of this with a bot account
like a bot is essentially just a discord user that you control with code
ye
that's grossly simplifying it but it's technically correct
ik it's against tos but i want to make same bot so i need to learn first how normal bot works and dc library
it's usefull
you can run ur acc and reply every user who sends dm
if you are afk
yeah but that's against tos?
I mean this is just going in circles now, yes it's possible no I don't condone doing it.
yes discord does ban for account automation
because if they see somoene making irregular reguests under a user account
it's gonna get flagged
if you report still no
U can use the API key for the discord bot even I used it to make my bot responsive
Like OpenAI key , openrouter
Ok well we don't condone nor can we discuss that stuff here so please move on @slate swan
ok
uh
:?
lol
anyone knows how can i display vs on my dc profikle
profile, i had it but it bugs sometimes
it removes from it automatically when i reset my vs
idk what does it means
nvm i did it
Yeah you still got like 9 years before you can learn AI
what kind of bot?
Iβm ready to send you my bot token
Dont ever do this, your bot token is similar to a password, it should not be shared.
Also if you need help you should ask specific questions. This is not a place to try and find people to make code for you. It also sounds like a quite complex project.
agreed
Agreed idk why these coders don't search on google or stackoverflow like ready to share bot token is not a solution
how do I remove the gaps between these progress bar emojis
def create_progress_bar(self, progress: float, next_rank: str) -> str:
# Get the next rank's end emoji
end_emoji = self.rank_data[next_rank]["bar_end"]
filled_segments = int(progress // 25)
# Build the bar parts - 4 segments total
bar_parts = [
self.bar_start if filled_segments >= 1 else self.empty_bar_start, # Segment 1
self.bar_middle if filled_segments >= 2 else self.empty_bar_middle, # Segment 2
self.bar_middle if filled_segments >= 3 else self.empty_bar_middle, # Segment 3
end_emoji # Segment 4 (next rank's end emoji)
]
return "".join(bar_parts) + f" {round(progress, 2)}%"
oh wait i am dumbn
can you show the bar_middle
your icons dont look like a square actually, it might be the problem there
oh wait could the size difference be causing this
yeah you're right
I am π
Nah i was referencing my deleted question about the .join line
Obviously nothing wrong with that but my eyes are half open so i thought its your problem there
Hello!
I've always coded bots in python (3.11) by putting the commands in the main.py file.
But as I keep adding commands, it gets complicated. I've tried to change my method by creating different files for each command, but nothing works...
I have a verification system that tells me when the file is loaded, but I also have another system that tells me all the synchronized commands.
# π’> LOAD
@bot.event
async def on_ready():
print(f"{bot.user} is online!")
# Sync
synced = await bot.tree.sync()
print(f"π {len(synced)} cmd sync.")
for cmd in synced:
print(f"Cmd : /{cmd.name} | ID : {cmd.id}")
# Load
for file in os.listdir():
if file.endswith(".py") and file not in ["main.py"]:
try:
await bot.load_extension(file[:-3])
print(f"β
{file} load with succes!")
except Exception as e:
print(f"β Error in {file} : {e}")
This tells me that the file is loaded correctly, but it also tells me that 0 commands are not synchronized.
breh
Think about it for a sec
what the sheep is doing here
What is your code doing in order?
seeing an on_ready event is like always a big red flag lol
Would it make sense to first load the commands and then sync or to first sync and then load the commands

Once you have sorted that out, use setup_hook to load your cogs and don't sync with on_ready
in main.py?
Don't even sync it setup hook, make a separate command and sync only when required
I didn't say sync on setup hook, I said load your cogs in setup hook
I would say commands
Oh
all good lol
He's talking about the code you sent
this code is in the main file
import discord
from discord.ext import commands
import os
import json
# :low_brightness:> INTENTS
intents = discord.Intents.default()
intents.message_content = True
intents.guilds = True
intents.voice_states = True
bot = commands.Bot(command_prefix='$', intents=intents)
# π’> LOAD
@bot.event
async def on_ready():
print(f"{bot.user} is online!")
# Sync
synced = await bot.tree.sync()
print(f"π {len(synced)} cmd sync.")
for cmd in synced:
print(f"Cmd : /{cmd.name} | ID : {cmd.id}")
# Load
for file in os.listdir():
if file.endswith(".py") and file not in ["main.py"]:
try:
await bot.load_extension(file[:-3])
print(f"β
{file} load with succes!")
except Exception as e:
print(f"β Error in {file} : {e}")
# :closed_lock_with_key:> TOKEN
with open("config.json", "r") as f:
config = json.load(f)
bot.run(config["TOKEN"])
just that
read this btw
Yes I can try to do that
Oh yeesss it works !! thank u !
My mistake, and now that you mention it, it makes sense. But I confess I've never done this before, as I'm just starting to learn discord.py, so excuse me!
Hey guys
Quick question, is it a problem if when I run a command, an error pops up in the console/output, but not in how the bot reacts/functions in the server? Is it okay if I just don't fix the error, will it have any consequences?
hai there could you explain what you mean and show the full error here?
I'm not specifying any errors, just theoretically
Uh, there are probably some errors that dont (I'm not sure) but most of the time it can cause your bot to fail
so you should fix it or use try blocks
fyi dont print exceptions because you'll strip the traceback
!e With traceback:
def add_three(n):
return n + 3
print(add_three("3"))
:x: Your 3.12 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "/home/main.py", line 4, in <module>
003 | print(add_three("3"))
004 | ^^^^^^^^^^^^^^
005 | File "/home/main.py", line 2, in add_three
006 | return n + 3
007 | ~~^~~
008 | TypeError: can only concatenate str (not "int") to str
!e With no traceback:
def add_three(n):
return n + 3
try:
print(add_three("3"))
except Exception as e:
print(f"Error: {e}")
:white_check_mark: Your 3.12 eval job has completed with return code 0.
Error: can only concatenate str (not "int") to str
see how the bottom says literally nothing about where the error is?
also guilds and voice_states are already enabled by .default()
i'm having trouble figuring out how to fix my code. what's happening is when someone makes a new ticket and they try to close it, it doesn't close and shows this warning on my vps:
[WARNING] miru.client: Unknown component for interaction received for component: 'close_ticket_button'. Did you forget to start a view?
You can disable this warning by setting 'ignore_unknown_interactions' to True in the client constructor, or by setting an unhandled component interaction hook.
but when i restart the bot and try to close the same ticket, it closes the ticket. how do i fix this? it's supposed to close whenever someone presses it. here's a video for better understanding. i'm also using hikari-lightbulb and miru
here's the code: https://pastes.dev/y6jRL0N5b3
gotta get to those 50 messages so i can talk in vc
actual hikari user in the wilds
kdkdkdkdkekdjdkd
Hi, real quick. I'm making a bot and I want to have it running on a server 24/7 without running it off my computer how do i do this and is it free?
You'll need some 'hosting' for it, and it's usually not free, no. A bot is very small however so you can ideally find a solution on the cheap.
Like, Hetzner has a $4/month tier
ah okay, thank you!
There may be a place where you could pre-pay and get even less than that. Also Amazon AWS has a free usage tier that MIGHT be enough to get you rolling.
You get 750 hours of EC2 for free from Amazon
(per month)
Just like it wouldn't be free to run your PC 24/7
So basically 1 EC2 instance running for the whole time and some extra time left
pretty much
Yeah, I guess the idea is to be able to run a full-time 'micro' instance.
How large is EC2 tbf
Oh well, very small
t2.micro / t3.micro
The only things that maybe better is the bandwidth compare to my raspberry pi
Yeah, it's not really trying to compete with stuff like that.. but rather to get you familiar with their ecosystem so you'll use it at work
Excuse me, sir, may I ask if discord.py-self is still usable at this time?
I tried the latest version available on PyPI, but when I used the commands, nothing happened. I am puzzled because I have already followed the documentation.
we dont help with self bots
Alright, sir, I apologize.
Ye
e
a
b
c
πͺ
omg ty
πͺ (I hope this is right)

Isnt it C++ after C
aww man
nah, holy c comes before c++
Cβ
C flatlining after a stroke at 54
does anyone know how to make a bot super react to a message?
not possible
well its not a discord bot, but its a selfbot someone's using that super reacts to their messages
Anyone up to teach me?
if you have any questions, feel free to ask them
Could you teach me?
I have done some coding before with a teacher.
But they left discord.
I don't have the fulltime to teach someone, but I suggest reading the docs, joining d.py's support server
and of course ask questions
Please.
!rule 5
5. Do not provide or request help on projects that may violate terms of service, or that may be deemed inappropriate, malicious, or illegal.
ik but i want it for my discord bot not an self bot
Here are some resources to learn python yourself:
https://docs.python.org/3/tutorial/ (official tutorial)
http://python.swaroopch.com/ (useful book)
https://automatetheboringstuff.com/ (for complete beginners to programming)
http://greenteapress.com/wp/think-python-2e/ (another decent book)
See also:
http://www.codeabbey.com/ (exercises for beginners)
https://realpython.com/ (good articles on specific topics)
https://learnxinyminutes.com/docs/python3/ (cheatsheet)
Bots cannot use super reactions as said above
Yeah but I want 1 on 1 calls.
alr
So if I have any problems.
That's something you get in school lol
It's their free time, so just ask questions in support servers and they will answer when they can
You could look on fiverr or something
But I don't want to pay π
Kind people do it for free.
Mean people don't :<
Oh definitely not lmao
my old teacher did it for free :<
you will :>
Can you just like show me you coding or something.
But it looks like they left discord when they realised /s
no...
Lots of free code on https://github.com
I don't want the actual code...
What
In short,
No one (most) people will not teach you one on one and you're gonna have to accept it
But what you can do is ask questions in support servers and people will answer when they can
https://discordpy.readthedocs.io/en/latest/api.html Read the docs, if you have any questions, I suggest joining the dpy server
ok
How did you start coding?
I started through tutorials online, while I won't say they are all bad, but often times they are outdated/insufficient
And you end up doing things the way it was done when they are better ways
So, I strongly suggest the docs and asking questions
What tutorials?
i do not remember them
Ehum
some choose to ignore it ig
No, and what soheab recommended
Yt tuts are not recommended and outdated
i started of python with OOP and basic C++ knowledge, id say it is much easier
going from nothing to discord bot straight away will be hard
since discord.py is advance and require you to already know the basic of python and can debug some of the error yourself
this is how I get stuck about 5-6y back but meanwhile were full time student learning other thing so didn't have the time to dedicate on it at that time
Anyone?
hikari is pretty niche tbh. You'll have better luck asking them directly. I literally haven't seen anyone in here ever use it
can someone teach me how to make discord bots pls? yt tutor doesn't work for me and outdated
youtube isn't a good educational resource to begin, especially not for this stuff
Are you having trouble learning python, or specifically how to use one of the discord libraries?
no i just want to learn how to make a simple discord bot
like everytime i use yt tuts its doesnt work always error on the line 4
But do you have the requisite python skills?
Have you made any scripts at all on your own?
I would suggest then that you take on much smaller, focused projects
This is like trying to start with building spaceships before you know how to make a wheel. You're not going to make much progress and get frustrated because bots layer on several concepts at the same time
hmm can you tell me where i should start??
The official python tutorial is quite comprehensive and layers on concepts one at a time: https://docs.python.org/3/tutorial/index.html
https://automatetheboringstuff.com/ is also a recommended resource for beginners. Once you have basics down, there's a bunch of sites out there with targeted practice problems/projects
Hi guys I'm wondering if it is possible to create bots like mee6/sapphire using python?
Kindly lmk.
Everything is possible, yes. So long as you have the skill to do so.
Mee6 is (or was, idk) written in discord.py unless that has changed recently. Same as many other popular bots
Thanks
Sapphire is made in d.js
But you can replicate it with dpy as well
how need discord bot?
I am python expert so if you need, please feel free to reach out

Hello guys, im creating a discord bot in python, but i have an error can someone dm, for helping me please ??
Look this is my main.py :
import os
import json
import discord
from discord.ext import commands
config = json.load(open('config.json', 'r'))
bot = commands.Bot(command_prefix='!', intents=discord.Intents.all(), help_command=None)
commands_files = [f"commands.{filename[:-3]}" for filename in os.listdir("./commands/") if filename.endswith('.py')]
events_files = [f"events.{filename[:-3]}" for filename in os.listdir("./events/") if filename.endswith('.py')]
for file in commands_files:
try:
bot.load_extension(file)
except Exception as e:
print(f"failed to load {file}", e)
for file in events_files:
try:
bot.load_extension(file)
except Exception as e:
print(f"failed to load {file}", e)
@bot.event
async def on_ready():
print(f"Logged as {bot.user.name}")
bot.run(config["token"])
and here is my command :
import discord
from discord.ext import commands
from functions import embed_color, footer
class HelpCommand(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.slash_command(name="help", description="Show help panel")
async def helpcommand(self, ctx):
embed = discord.Embed(
title="Help Panel",
color=embed_color()
)
embed.add_field(name="/add-ping", value="Add ping per day for a slot owner", inline=False)
embed.add_field(name="/backup", value="Backup your slot with backup key", inline=False)
embed.add_field(name="/config-channel-reset", value="Configuration of reset ping announcement channel", inline=False)
embed.add_field(name="/config-role", value="Configuration of role added for slot owners", inline=False)
embed.add_field(name="/create-slot", value="Create a slot", inline=False)
embed.add_field(name="/extend-subscription", value="Add time for a slot subscription", inline=False)
embed.add_field(name="/hold", value="Hold a slot", inline=False)
embed.add_field(name="/remove-ping", value="Remove ping per day for a slot owner", inline=False)
embed.add_field(name="/unwl", value="Remove an user from whitelist", inline=False)
embed.add_field(name="/wl", value="Add an user into whitelist", inline=False)
embed.add_field(name="/wl-list", value="Show all users into the whitelist", inline=False)
embed.set_footer(text=footer())
embed.set_thumbnail(url=self.bot.user.avatar)
await ctx.respond(embed=embed)
def setup(bot):
bot.add_cog(HelpCommand(bot))```
there is no / commands on my bot
did you sync?
why please ? Like when i start the bot there is no command on it ???
How we do that ???
also good lord please just ```py
embed.add_field(
name = ...,
value = ...,
inline = ...
)
also dont do this
dont help_command = None and then make your own
also fyi, don't print exceptions. you'll strip the traceback which means you wont be able to debug errors
If this is dpy or a dpy fork, this is either raising a lot more errors or they're using a way deprecated version
Name: discord.py
Version: 2.5.2
Summary: A Python wrapper for the Discord API
Home-page:
Author: Rapptz
Author-email:
License: The MIT License (MIT)
ik i use that
it someone who gave me the code, so i don't know how to code really
!res - get to learning then
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
@viscid hornet can u help me patch them
lmao dpy and commands.slash_command
i need the bot fast, but im starting learning
discord bots are a really advanced concept for someone who doesn't know how to code
you'd need to learn the language first, then grasp principles like OOP and async programming
THEN you can start making bots
There isn't a shortcut. You're either going to have to put in the time to learn or pay someone who already has
shortcuts will become setbacks 
i didn't make it, i found the code that why
where?
a friend of mine, he is "developper" and he put it on github
Well you can ask him to fix his own code
he don't know how π
the bot can be in javascript or no ?
Sure it could
okok
Never a dull moment in this channel
You'll pay for the whole seat, but you'll only use the edge.

Why are you brining up a message that is ~10 months old?
"sorry bad ping"
"I was scrolled up"
knowing legal things = nerd
Jsex
hii i need some hlep regarding my bot
You would find that you have better success if you just ask the question directly instead of asking for "who can help me" types of question.
can you help me?
idk. Can I?
yep dm me
No thanks
Just ask the question here
Scrims View Error: 'Scrim' object has no attribute 'scrims'
2025-04-20 16:13:54 ERROR discord.client Ignoring exception in on_command_error
Traceback (most recent call last):
File "D:\bot.venv\Lib\site-packages\discord\client.py", line 441, in _run_event
await coro(*args, **kwargs)
File "d:\bot\quotient-main\src\cogs\events\errors.py", line 115, in on_command_error
raise err
File "D:\bot.venv\Lib\site-packages\discord\ui\view.py", line 427, in _scheduled_task
await item.callback(interaction)
File "d:\bot\quotient-main\src\cogs\esports\views\scrims_btns.py", line 432, in callback
if isinstance(self.view.record.scrims, list): # Replace 'teams' with the correct field
^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Scrim' object has no attribute 'scrims'
@burnt quiver ye error he ye solve nai ho rha
You're looking for an attribute that doesn't exist
actually i had put attribute as teams but i dont know what the attritubute is
It's your code though
This reads like template code that you're changing stuff inside it that you don't understand
If you don't understand the code someone gave you, I'm not going to fix it for you
Good first stop would be whoever gave you this code
umm i didnt got you
@graceful gorge He's saying if you dont understand the code, you shouldnt be running it. How do you know it's not a virus?
LOOOOL
how do you create a discord bot in 2025? is still discord.py the go-to library? it's been a while since i made discord bots
the discord.py dev went on a hiatus for a bit a few years ago and it looked like it was gonna die as the king, but then he unleft 6 months later, so it remains crowned, yes.
the docs website has a quickstart guide for first-timers, which should help remember some stuff
yeah i remember that hiatus, but what about all the libs that were created/forked in the meantime? i see that e.g. pycord has some success
most are still around, but momentum is a helluva thing. iirc, this server almost switched to disnake, but then rapptz came back just in time and rendered the idea moot
also idk, it feels to me that discord.py is sort of dead even if still receiving updates
Honestly just choose what you like
No one is forcing you to only choose this over that
i mean, discord.py was the "blind" choice for a lot of time, now i was wondering if it was still the same
i also would like to use a library that is well updated and has a good dev experience
Both has its pros and cons, i use discord.py personally and have no problem at all
Both getting updates fairly quickly
is there somewhere i can compare that pros and cons?
Anyone know free discord bot free hosting 24/7 if yes then plz tell me in dm
There is not really a comparison that is up to date. Most pros and cons will come from the implementation of one feature
*disnake
Disnake is still alive? /j
on the topic of the current topic, then, why that one as opposed to pycord et al?
You could also go for Hikari or interactions.py, two libraries unrelated to discord.py with completely different designs.
Nvm interactions.py is kinda similar to dpy but not a fork.
There is also hata, which is different .
I don't remember the exact reasons anymore.
Iirc disnake has changed its design a bit and seems to have many qol first-party extensions
!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.
https://libs.advaith.io/
This is which have implemented what features
But to answer your question discord.py is still wildly used but not the go-to "default" option anymore
Compares Discord libraries and their support of new API features
not the go-to "default" option
source?
Ok thanks
Do you know python and OOP?
I know python
I have written a code for my bot
I have a discord module installed in my ide
But I don't know how to activate it in my own server
So I wanted help
The discord bot portal gives you an invite link to invite the bot
Ok
The fact that there are other options that people regularly use.
The existence of other options doesnt mean dpy isn't a default
That's the whole point of what "default" means
Hello, Iβm trying to make a Discord bot that sends a message whenever thereβs new stock available in the Grow a Garden Roblox game including fruits, gear, and the Easter stock. I want it to say which items are in stock or out of stock in a format like:
NEW STOCK!
Apple - In Stock
Banana - Out of Stock
β¦
The thing is, the only way to see the stock is by going up to the NPCs in-game and opening the GUI that shows the items. The game doesnβt have a public API or website that lists the stock, and the items arenβt sold as gamepasses or developer products, so I canβt check the stock from outside the game. I wanted to know if itβs possible to automatically read the stock and send it to a Discord server. Since I canβt run Roblox scripts in someone elseβs game, Iβm now trying to make a tool that takes a screenshot of the stock GUI, uses OCR to read the item names and stock status, and sends that info to Discord. If thereβs any better way to access the stock info (like through a hidden API, dev help, or webhook), Iβd really appreciate any advice!
In what way is discord.py default?
Default
a selection made usually automatically or without active consideration due to lack of a viable alternative
Please help
I'm not the one who said it wasn't, that's not how burden of proof works lol
Doesnt sound like your problem exists with discord or its api
It might be better to have users manually submit when new stock is added
Ok
OCR probably would be the best automatic option as like you said there is no API
-# I am assuming robox/the game allows this I dont feel like checking myself rn
You may wish to contact the developer and get a supported api or at least written consent that this is supported and not an exploit. Otherwise this could be against their wishes and violate community rules.
Using exploits to gain an unfair advantage anywhere on the platform
theres a open source api that does this
well only for bloxfruits
You can only do this by exploiting pretty sure
Ig you need to web scrape
(iirc it is not allowed to help with things against tos here)
Web scraping isnβt illegal, Google does it literally every day
As long as youβre not scraping sensitive stuff that could be used badly, itβs fine
Where in the rules does it say that?
It is not illegal unless TOS of the apps says that
google literally getting complains every day about its scraping so no one visit the actual website
Two way it could be illegal:
- Use/Distribution of copyright material without permission from the owner and not from fair use clause by applicable law
- Cause of financial loss due to the the traffic cause by the scraper and reduction of revenue cause by the scraper or its directly corresponding reduction of quality of content cause by the scraper (e.g. increase in latency to access the website)
Maybe more but at least these 2
Disclaimer: this is not a legal advice and I am not a lawyer
That's moving the bar here. Illegality is irrelevant; the rules say not to help with TOS violating activities
^^
Even if it's legal, still not allowed here
based on this comparison, it seems that currently there's no "best" lib, hata is the most up-to-date discord api wise
since i'm making a musicbot, I don't know if hata, that's using v8 of the voice api, it's more suitable for my use case instead of dpy that still uses v4
v8 is recommended by discord, so if your bot is primarily going to be voice you should probably choose a lib that has good support for it
List of what each version adds/changes https://discord.com/developers/docs/topics/voice-connections#voice-gateway-versioning
i'm here because i've started this project over 2 years ago and was trying to finish... but now that I think more about it maybe using a whole different language for it could be a better choice (like java for example)
I have never worked with sending events on the voice gateway so I cant offer much advice
hi im using the latest discord py from rapptz afaik and my code no longer works, and i was able to get it to at least start by doing the tiny fixes such as adding the bot.add_command() stuff. but now i can no longer run commands from cogs, gicing me an error about a missing ctx argument
@commands.command()
async def flip(self, ctx):
result = random.choice(["Heads", "Tails"])
await ctx.send(f"The coin landed on: {result}")
simple command that i have, giving me the error:
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: BasicCommands.flip() missing 1 required positional argument: 'ctx'
did i miss something?
can you show the full code?
theres like a gazillion different files that each have a cog in them so ill just show one with the relevant code
import discord
from discord.ext import commands
import random
class BasicCommands(commands.Cog):
def __init__(self, bot):
self.bot = bot
...
@commands.command()
async def flip(self, ctx):
result = random.choice(["Heads", "Tails"])
await ctx.send(f"The coin landed on: {result}")
import discord
from discord.ext import commands
import json
import traceback
# import cogs from the cogs module because i love organization
from cogs import basic_cog, mod_cog, games_cog, music_cog
# initial bot stuff
intents = discord.Intents.all()
intents.message_content = True
bot = commands.Bot(command_prefix="h/",intents=intents)
bot.remove_command("help")
# barebone events
@bot.event
async def on_ready():
print(f"online in {[x.name for x in bot.guilds]}")
cogs = [
basic_cog.cog,
mod_cog.cog,
games_cog.cog,
music_cog.cog
]
for cog in cogs:
bot.add_cog(cog(bot))
commands = cog.get_commands(cog)
for c in commands:
bot.add_command(c)
@bot.event
async def on_command_error(ctx, error):
form = f"{error}"
await ctx.send(form)
traceback.print_exception(error)
with open("token.json","r") as token_file:
token = json.load(token_file)
bot.run(token)
Dude why are you hard-coding the names of your cogs in your main file
So youβre actually supposed to do add_cog on the Class
Why are you adding the commands to the bot manually
Itβs more like await bot.add_cog(basic_cog.BasicCommands(bot))
Rather than basic_cog.cog
Because that doesnβt even exist
Yo how about you turn those cog programs into extensions instead
Just add a setup function in there
β
bot = commands.Bot(command_prefix="h/",intents=intents)
bot.remove_command("help")
β
bot = commands.Bot(command_prefix="h/",intents=intents, help_command=None)
so i organized my cogs in this sorta way to make it more organized for myself in this package sort of way
What they told you has nothing to do with file structure. It's how you actually get the commands into the bot
putting commands into a cog, then extracting those commands out and adding them manually yourself is pointless
would i add the commands within the cog class itself then? and not outside it?
No
Calling bot.add_cog(your_cog_object) automatically registers all commands within the cog to the bot. That's the entire purpose of using a cog
otherwise you could just declare floating commands and add them yourself
oh right, but if i havent done that then the commands simply just dont seem to exist apparently
that was the issue i had before the ctx argument thing
right...which is why you want to use add_cog if you're using cogs
either use add_cog, or don't use cogs
but i did use add_cog
no you didn't
not in the code you showed
Or, rather, you're trying to use it in addition to adding the commands apparently?
for some reason doing that worked yesterday
Because it worked doesn't mean it's right or makes sense
Or that you didn't also change something else
erm i fixed the issue somehow, i did ditch the manual command adding and it was some problem with how the cog object wasnt a Cog object
not sure what i did it was piss late at night, thanks all for bothering to help!!

If you're going to store stuff in external files, I highly suggest you make them extensions instead of this direct loading you have but it's up to you
Thats great, I feel so unmotivated to add new features to my bot bcs of legacy code but I also feel unmotivated to rewrite it
I wonder when we will get these changes
They are out currently
Is it supported by the discord.py package?
I dont use discord.py Β―_(γ)_/Β―
π π₯Ί
Some stuff for league of legends modding, notting too extraordinary like getting 3d model file from the web
not yet
Yikes dude thatβs the entire program
I need to figure out how buttons and stuff work
A hands-on guide to Discord.py
Bro this just saved my entire discord.py career
can I host 2 or more seperate bots on the same server or will discord start ratelimiting after a while
Unlikely but we have no idea what your bots do and discord intentionally doesnt publish the limits
It depends on IP. If the combined requests stay under the IP ratelimits then you will be fine. So smaller bots that make less requests are easier to do this with. As long as you control both of the bots and follow proper practices you should not run into many issues. What gets lots of people tho is using cheap shared IP hosting where a different customer has a bot on the same IP as you and gets everyone on that IP rate limited because of their bad code (intentional or not)
I think 3 bot is running on the same server and IP on my machine
It work fine
Man ykw ykw Iβm gonna make the most unoptimized bot possible just to mess with people on shared IPs
"unoptimized" is a really funny way of phrasing "attempted ddos"
Iβm gonna make API requests in my on_ready
Har har har
the bots mostly recieve messages and process them for bad words and such. Does discord rate limit incoming and outgoing messages the same amount?
There is no ratelimit on events that discord sends as they choose to send them
The limit is on api calls you send back to discord
You may also want to consider automod for the use case you described
Thank you!
its more of a data science project haha
π€¨
a social credit system kinda similar to china's mass surveillance
Greetings! Is anyone available to resolve my issue? The bot is saying that ctx.send takes up from 1 to 2 positional arguments, but three were given. py @bot.command() async def owner(ctx): await ctx.send(f"The current owner of the server is @", ctx.guild.owner)
You should replace that , with + ctx.guild.owner.mention and remove @ in the string
Bro why do you have an F string just to not use it
Smh my head
peak attitude
The syntax for f-strings is f"The value of x is {x}" (https://docs.python.org/3/tutorial/inputoutput.html)
You are trying to use the syntax for print() which is not how send behaves (also not how mentions behave either)
Hello, I have a problem with my on_message function. When I mark the words in the server, the bot does not send anything, and with the debugging tools that I coded, it marks an empty message or spaces when there are none.
`@bot.event
async def on_message(message: discord.Message):
if message.author.bot:
return
print(f"Message debug : {message}")
print(f"Message contenu : {repr(message.content)}") # Utilisez repr() pour afficher les caractères invisibles
print(f"Message type : {message.type}")
print(f"Message auteur : {message.author}")
if not message.content or message.content.strip() == "":
print("Message vide ou contenant uniquement des espaces reΓ§u.")
return
if message.content.lower() == "showstaff":
try:
# Charger les utilisateurs du staff
staff_users = load_staff()
if str(message.author.id) in staff_users:
embed = discord.Embed(
title="Membre du staff",
description=f"**{message.author.name}**, vous faites partie du staff.",
color=discord.Color.green()
)
sent_message = await message.channel.send(embed=embed)
await asyncio.sleep(10) # Attendre 10 secondes
await sent_message.delete()
else:
print(f"L'utilisateur {message.author.name} n'est pas dans le staff.")
except Exception as e:
print(f"Erreur lors de l'exΓ©cution de .showstaff : {e}")`
what intents are you requesting?
also if you're trying to implement commands (user says do something, bot does the thing) you should strongly consider implementing these as app commands instead
is leaking the discord shard id dangerous?
afaik no. Every bot has a shard id 0 for example
so showing it on stream is okay
you are still responsible for what happens with a bot you have registered
you do you but you're just asking to slip up and fuck something up
The token is really the sensitive thing, not shard id, but you have to ask yourself if the internet clicks are worth the risk
Can't lie, the bot has no value, and I won't leak the token, but in other plan i'll just stream osu! chiller
Again, the bot itself doesn't matter. If you do accidentally show the token or put in some way for someone to get the token, they can abuse it and discord will blame you
Why are you using an on message listener to define commands
Thatβs like very archaic code
Which internet tutorial did you follow dude
You should not be following tutorials in the big 25
~~ Whatβs wrong with tutorials some are great ~~
Discord bot tutorials are generally pretty bad. I looked at the top 10 results on google a while back and only one even mentioned slash commands (but did not use them). The only tutorials that are any good are the ones made by active community members of the libraries. Sites that just post one off tutorials will lead to you having issues (4 of the top 10 did not include intents which would lead to an error when running the code)
This dude is using code from medieval times bro
Fair enough
Pardon?
Even if a good unofficial tutorial did exist (which they don't)
a) it would be rare and
b) noobies aren't going to be able to tell the difference, they're just going to click whatever mouthbreather uploaded something on youtube
Chill lmao. An on_message event that does something depending on the message's content isn't uncommon at all.
The existence of (much) better alternatives, so-called "commands" does not mean the other solution is medieval.
Use py sent_message = await message.channel.send(embed=embed, delete_after=10) instead
Saves two lines of code
thank
Hi guys
I am thinking of making a discord bot
But can you all give me a topic for my bot??
I meant, what all can that bot do
If you don't have an idea you want to implement, start by just making a hello world bot
can someone join my bot dev team (dm if you want to)
Is there some kind of ORM I can use with SQLite? My code is not clean at all because I have to write a bunch of functions that talk to the database with raw SQL.
"Clean" is a pretty subjective thing that you could very well be psyching yourself out over
ORMs can often abstract away meaningful decisions and result in suboptimal queries
I got like 100 rows millisecond differences aren't gonna kill me
Neither is some raw query text
But I suppose nothing's wrong with raw sql
Either way more of a discussion for #databases
sqlalchemy should work with SQLite
anyone want to join my discord bot dev team
no
!rule ad
do yall think the ro-cleaner bot ban was fair
Do yall think the <insert name of random bot here> ban was fair

yes
Yes because discord do have the right to
I'm pretty sure last time I checked the ToS it state that somewhere
indeed
yes, because that bot sucked anyways
Afaik it was deserved
has anyone actually used the user-installable commands yet
yes why not?
Command not recognized ( when the button is clicked on a embed )
can someone help me> I am using @discord.ui.button
@azure tendon
Full traceback? Code?
@discord.ui.button(label="Product Terms", style=discord.ButtonStyle.grey, custom_id="product_terms", emoji=discord.PartialEmoji.from_str(""))
async def product_terms(self, interaction: discord.Interaction, button: discord.ui.Button):
await interaction.response.send_message(
"Product Terms\nProducts are provided as-is. Refunds or replacements are only given under our warranty terms.",
ephemeral=True
)
Clicking a button isn't a command though 
But what is the exact error and what is showing it?
there are no errors in the terminal, when I paste the command to bring up the embed with the buttons and click each button it says "Command not recognized"
it should display a message that i added for test
but its not
That's your bot sending that
It could potentially also be in some library you're using
maybe try and except error
can u send the full code
Hi bg, I have a problem with my ticket code. When I configure it in one server, it works, but in another, it returns an interaction failure.
can you send the full traceback
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.
Is there some detailed docs on clustering and sharding
can someone explain what sharding is? Is it if a single bot is on alot of servers and the connections are multiple or what exatcly is sharding?
what if a robot is on 1.2 mil guilds?
No, I don't have any errors
@fast osprey can you explain please. you seem expert on discord api, so your opinion and experience is key for all of us.
Don't nest class
It's really ugly and serves no real advantage
first of all it looks ugly
second of all are you gonna tab/space that much time
this is nested nested class
also this code looks like from 2 different people
cuz one view use the tutorial style of making ui components
class SubclassedView(View):
def __init__(...):
...
select = Select(...)
async def callback(...):
...
select.callback = callback
self.add_item(select)
the code is next level impossible to read for me cuz of super indentation it has
@dense moon if you're interested in discussing or learning more about Discord Bots, feel free to ask here π
Ok
If I'm learning python I have to learn ai ml bots separately... Or it is included that how it is connect with python, within python?
Learning Python doesnt include learning AI/ML/Bots. Those are separate but can be extended after you learn the basics
!resources have lots of beginner level materials for you to learn. Once you master the basics, then you can try AI/ML/Bots after that
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
I personally like "Automate the Boring Stuff" ebook
What can be extended python or... This..
Oh so you want to say..
That if I learn something else. From python.. My python knowledge will extent
yes. But for now, don't confuse yourself. Learn the basics of Python for now.
Ook so are u the one who made all the bots over here?
lol no.
Wut
Get a load of this guy
it's essentially horizontal scaling. it allows each "shard" to service a certain number of guilds, where each shard can be deployed on different machines, essentially allowing discord to load balance for you
go to processes sort by memory usage in descending order
this is horrible
class MySelect(Select):
pass
class MySelectView(View):
def __init__(self) -> None:
super().__init__()
self.add_item(MySelect())
or even just View().add_item(MySelect())
This seems like a persistent view issue, where you have error handling to handle unknown custom_ids
I have automod where some words are are blacklisted for my discord but that can't be it right?
And also when i use a command it sends it 2x ( Embeds )
I don't think it is design to run on different machine, but more like different thread on the same machine
*It never specified whether it suggested or suggested not doing so in official docs
well that would defeat the whole point of sharding, no?
That seems like your bot is running twice. Make sure you turn off any old instances of your bot
resource usage would be pretty much the same between not sharding and sharding and running it on the same machine
the idea is to enable developers to spawn many bot instances across many machines to split the load
Well, sharing required the machine to be largely coordinated with is difficult for multi-machine
Also it's probably for multi threading imo to take advantage of access to more CPU core to process differently, while easily coordinated
sharding does pose some issues when it comes to communication, but i believe the idea is that each shard is essentially self contained
most languages can take advantage of this by default within a single process. sharding is not necessary
discord bots are generally more memory intensive than CPU intensive because you're expected to cache of stuff yourself, and most of the actions that you do are IO bound
Sharding is necessary for discord when you have >2.5k server
i meant that sharding is not necessary to take advantage of multiple cores
So that's why so many library implementation just make so the shard doesn't exist and library handle the rest
Oh well, yes
Itβs fixed but the Command Not Recognised is still a problem for me after making a whole new folder and .py
But probably discord want to encourage such? Idk
i'm almost certain discord means for shards to be deployed on multiple machines. but its designed so that you could still deploy it on a single machine - but you really don't get anything out of it
Ye
Also idk why they set to 2.5k because most likely when you are at that point, you probably still don't have the infrastructure for multi machine
i'm pretty certain that even at 2.5k servers your CPU utilization wouldn't be as bad as your memory usage - sharding on the same machine wouldn't fix this
Nope, not really
Because I do have one running
your CPU utilization is worse than memory?
I mean both isn't bad
CPU ~10% and memory ~700-800MiB
how many servers?
4k or 4.5k now
4511 now
this is what i mean
It's also running on raspberry pi and also have regular backgrounds task every 2 mins
As part of the bot
background tasks every 2 minutes is negligible
If it doesn't run for at least 30s or to probably 90s where it send many of network request and db operation
Ok according to monitoring software, avg CPU is 6-8%
if a task is running at an interval more than like 5 seconds its basically negligible just because modern cpus do literally billions of cycles per second
and especially discord bots are so IO bound that it literally just does not matter to a CPU
Well, ye, tbf mostly network IO
but some old dumb thing before cause 100% CPU 10s every 2mins
usually when you have heavily cpu bound stuff you need to do occasionally it could be a good idea to make a separate microservice to handle that and use message queues
Because when I get stuff from db, it looks up dpy cache too many time to get structure response
like if you've got an image processing service. you can scale up and down your workers based on demand
So I fix it to not get the actual object
For mine one, not really, only when I do too dumb thing to the sqlite db
Then you should probably share code, errors if any, and the library you are using
Share code here?
Yes
Hello
I build an ai discord bot, basically it's powered by gemini pro
And hosted by render.
My question is there not much discord bot building tutorials available on youtube in in depth detail,so only reading discord.py documents is the only way to improve my bot or is there any other way too?
You can use the examples on the Discord.py repository, or any bot that has βgood dpy practices β, as the Python bot, RoboDanny (by Rapptz, owner of Discord.py) and others
And with that you can check how they build things and how you can improve the ones youβve made in base of that
You may wish to review the developer tos and policy when you implement an "ai bot". A vast majority of the people I see in here doing that violate the policy in one way or another
Pretty much only use resources officially recommended by people of the library you use. Most video and text based tutorials are wildly out of date and poor quality.
Ah late response sorry,Thanks for answers
really? hmmm
The main parts are
- No using message content to train models, which gemini does unless you're using their Paid Services and
- No sending user data to third parties without explicitly capturing their consent to do so*
(*unless you are treating google as a Service Provider, in which case you need them to agree in writing that they are following discord's terms on your behalf)
Are you guessing event names?
https://discordpy.readthedocs.io/en/stable/api.html#soundboard are the events related to the soundboard. There's a full event reference too
You shouldn't guess things, and you shouldn't rely on randos on the internet
Tbh I guess my own method/function names too
Sometimes I forget what my function is called and I just guess what it is and deal with it later
Any number of reasons why
could be that listener isn't being registered, could be you aren't subscribed to the relevant intent, or that you aren't doing the thing in a place the bot can see it happen
Your bot should never have admin
and you never need all intents
What if you actually use every intent
I have yet to see a bot use the typing intent
Yeah thatβs true
Which is also the one that by far fires the most
Probably the most useless intent
?
One cog I made detect how long the user type before they send messages
But doesn't work well on short messages sometimes
So it ends as a small experiment
I don't believe it require them in writing, Idk where you read that from
Like, e.g. I don't need VPS provider written agreement that they are going to follow discord term on my behalf
But instead, you read their term/privacy policy and make sure you are allowed to
Maybe read the dev tos
it specifically says if you want to use a provider as a service provider, meaning you give them user data without the user's consent, they have to submit in writing to agree they are acting on your behalf
Before using a Service Provider, you will require them to first agree in writing to only access and use the APIs and API Data for you and at your direction to provide you services to develop or operate your Application in compliance with the Terms, and for no other purpose (including their own). For the avoidance of doubt, Service Providers are acting on your behalf. You will ensure that each Service Provider complies with the Terms as if they are in your place, and you are solely responsible and liable for their acts and omissions, including noncompliance. When you stop using a Service Provider, you will ensure they immediately cease using the APIs and API Data and promptly delete all API Data in their possession or control. Upon notice, we may prohibit your use of any Service Provider if we reasonably believe that they have violated the Terms or they are negatively impacting us, the APIs or our other services, API Data, or the users, and you will promptly stop using them.
And the relevant paragraph of why you'd care if they were officially a Service Provider:
You will not share API Data with any third party, except in the following circumstances, subject to compliance with the Terms and applicable laws and regulations: (i) with a Service Provider; (ii) to the extent required under applicable laws or regulations; and (iii) when a user of your Application expressly directs you to share their API Data with the third party (and you will provide us proof thereof upon request).
Yep I saw this, but not that
I would argue it meant they are only acting on your behalf and you need to make sure they are only acting on your behalf to operate (your application which compliance to the term)
E.g. their Term of Service and Privacy Policy say that they wouldn't do this that ... which is compliance to what discord term of service is enough, instead of individual written that they would compliant compliance to discord term
that's not what the discord terms say
they don't give a damn what google's tos are
either a) you get user's permission to send their data to a third party or b) you treat google as a service provider, which requires written acknowledgement to comply with discord terms.
That read to me only written acknowledgement on whether they only act on your behalf
there's no other way to read this.
Before using a Service Provider, you will require them to first agree in writing to only access and use the APIs and API Data for you and at your direction to provide you services to develop or operate your Application in compliance with the Terms, and for no other purpose (including their own)
there nothing require the written statement to said specifically it compliance with discord term, as long as it comply with the term, as far as I can read it.
You can call me stupid if you want, idc
and also act on your behalf
I dont see where it says you need a "personalized written agreement that was made specifically in response to your request." Another services TOS/privacy policy are written agreements
please point at where google puts, in writing, that things you submit to it will follow discord's terms
the fact that e.g. said No data is being collected/stored for the service or used in any other way than the required would be compliance to the term discord specified, even thought they didn't specify discord (which is very logical)
also, I didn't specify google specifically, just the general idea on how you describe it
that is one thing
This says that a service provider has to comply to all of discord's terms when processing data on your behalf, and to agree in writing specifically that they will
you can't just handwave it and say "nah google's fine"
specifically
Where it comes from (*Misread I thought you say it means they have to specifically writing to you)
All of discord's terms when processing data on your behalf
Yes I can find an example of that, without saying it specifically compliance to discord
Idk, maybe:We don't store anything after the request?, You are the sole person that can access the machine unless you give the password to other people for the VPS provider?
We have not said this
I am pretty sure it wouldn't violate any terms of discord from my memory by not storing anything and not sharing it to any further third party
It's very low power
But how did you get 0.9 from, only running the bot on the machine?
But basically, it's good if it's usable in such way
Oh well
What do you used to host the bot?
Lmao
And it also somehow run Linux?
I recommend to have something to also monitor the system status
If it can fit in it
What does it run
More CPU issue imo
It's running 1/30 the max power of my raspberry pi
Do you know what OS it run // Did you even use a library, python or just some other code
Library that help you make a discord bot
!pypi discord.py 1 example from python
what library you're using is such a tiny, tiny thing in the scheme of the power your hardware draws lol
But what system does it use?...
Oh well
Nah, tbf, mainly interested in the hardware
I cannot calculate exactly because it's running many things but the power supply is 27W for a raspberry pi
Seems like a pretty random tangent and nothing to do with python
Meaning "should/why does my hardware use X electricity" isn't really a topic for this channel imo
can someone help me adding a function to my discord bot, can pay in crypto
may wish to review the rules
discord.py or discord.js?
personal preference for the most part
Literally two different languages
asks python or not python in official python server
!rule 9
can someone do it for free π°
Make it yourself first then ask people to help fix it
π
returning to bot dev after lowkey 2years, best lib rn? except dpy and hikari
discord.py is still pretty much the "default". though you have a lot more options now, and discord.py is not as actively maintained as it once was
Yeah
he said except lmao
Thatβs like the best library
Why would you want to exclude it
Crazy
just wanted to get updated with new options, dpy hikari disnake and pycord were the popular ones last time i was here
like?
Well he probably already knows that but just wants to see if anyone else has other opinions
Def discord.js, discord.go, discord.py
bro this is the python discord server
he's obviously talking about serenity-rs
ah
asking it inside of both of the servers
bro it's literally the same thing in different languages
just work with the one you know best
Not really-

not discord bot related but how do I learn a new language after i mastered the basic idea of a concept
i'm tired of these linear-thinking websites that only teach beginners
"a concept"?
yeah, like arrays, loops and such like that
i don't need to go through learning those concepts again because i know them
is there a way to just skip straight to the syntax
can just look at implementations of hello world type stuff
look at repos, reverse engineer
https://libs.advaith.io/
This has links to all of the major options
Compares Discord libraries and their support of new API features
Once you know a language or two, a 'cheat sheet' for a new language should get you most of the way.. here's a random one for Python that would be plenty to get, like, a Perl programmer onboard https://github.com/buildwithmalik/PythonCheatSheet
If the language has outright new concepts (e.g. dependent types), expect to take much longer to 'get' it.
hello, i've made a discord user app for dm usage purposes with slash commands, it contains multiple commands but mainly the vouch command that i can use with someone in their direct messages after a service, the problem is i have /my-vouches command which displays vouches taken from vouches.json in a format like this:
{
"voucher_id": id,
"voucher_name": "username",
"stars": 5,
"feedback": "review text"
}```
when i display the list using the command /my-vouches it only displays my vouches, it takes the voucher_id and if it's valid it displays and since i'm the person using the ocmmand it'll only display mine not someone else's vouches.
I want to change it so that it uses voucher_name and always displays from vouches.json but whenever i try i just break my code i tried chatgpt but it just makes things worse.
i can send the full code in dms if anyone is willing to help.
as for the other things:
vouchme.py (saves the vouches after someone vouches me)
```python
new_vouch = {
"voucher_id": self.user.id,
"voucher_name": self.user.name,
"stars": stars,
"feedback": self.comment
}
try:
with open(VOUCH_FILE, "r") as f:
vouches = json.load(f)
except json.JSONDecodeError:
vouches = []
vouches.append(new_vouch)
with open(VOUCH_FILE, "w") as f:
json.dump(vouches, f, indent=4)```
myvouches.py:
```python
user_id = interaction.user.id
user_vouches = [vouch for vouch in vouches if vouch['voucher_id'] == user_id]
vouches_per_page = 3
total_pages = (len(user_vouches) + vouches_per_page - 1) // vouches_per_page```
but the confusing part is that the part that displays the voucher's name inside the my-vouches command's embed has voucher_name...
```python
embed.add_field(
name=f"{vouch['voucher_name']} | {star_emojis}",
value=f":CutseyTalk: {vouch['feedback']}",
inline=False
)```
i'm so lost.
uh sorry for the big text but i don't understand how to change it without my code breaking
you shouldn't be using a flat json file as a database. Use a proper database
sqlite is a good lightweight starter db with minimal setup
also chatgpt is stupid as hell. It doesn't know that 3 is a prime number sometimes. You shouldn't use it to fix code
i'm not good with databases so since i'm hosting the bot locally i use json idk if .txt is a abetter choice but yeah idk what else to do
no, no flat files are good
not only are they hideously slow, one bad write and all of your data gets corrupted and lost randomly and there's nothing you can do about it
what else do you recommend? i want to host locally since i keep editing the bot and it's just pain to reupload to a hosting besides i don't know any hosting that offers database aswell
You can put a database wherever you want
including right next to where your bot is
sqlite is literally just a file
and how do i make it work? my code is a complete mess
half of it is chatgpt's help i understand the code but i don't know how to change to the database
It's a debugging process of isolating the behavior you want to change, finding the part of your code that's generating it, and changing that
chatgpt is a crutch and it's going to lie to you. You need to stop using it entirely if you want to get better
im trying but this code was pain to build up
well it ain't gonna get any easier
any errors?
Maybe do a little debugging to see if you're running the code you think you are
you're not doing any debugging. You don't know how your code is behaving
Also why is this a loop?
I thought discord.py library does that when an event occurs like msg sent
I think discord.py has an event loop built in
or what you trying to do exactly?
@slate swan
Yes but your else deletes confirmation. Confirmation never changes
The loop serves no purpose
I assume tak means yes and nie no?
ok, mhh treaky one. maybe sosticeshard can respond to this problem, he seems expert on discord.py
but a while loop is kinda weird for this problem, there is a better solution to this
@slate swan I think whenever you want to detect messages there is an event in discord py that catches them
Or just use buttons
Any kind of interaction flow will be easier to implement and simpler for users than expecting messages with specific content
if you want some kind of classy message "conversation" wait_for is better than a while True loop
but using ui is recommended and way way better
for choice, you have buttons or selects, for confirmation/cancel use buttons, for text input use modal
You can get user input from modals, which is part of the ui kit

anyone can code a discord boost bot / tuul?
If they could, they sure wouldn't just do it and give it you
duh $ ready
Well then I'd refer you to the rules
Code it yourself lil bro
alr got it, mane im jus trying to get it down in the pyπ
Wsg
why did you curse him
dropped his glasses
how?
i gotta see this
ooh
awesome 
well
!d discord.MessageInteractionMetadata
class discord.MessageInteractionMetadata```
Represents the interaction metadata of a [`Message`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Message) if it was sent in response to an interaction.
New in version 2.4...
i gotta see this
Bro stop guessing module names
....okay?
This guy has gotta be using ChatGPT to write most of his code
Cuz how are you βguessingβ event names and random parts of the discord.py library
That makes no sense
Looks clean 
It's a little weird to spend time making a user facing UI for information literally no user would ever care about but pop off I guess
Trevixis seems to care quite a bit about it...
?
For most time you write something as hobby is that you are the literal only user
i don't think building something pretty that you're proud of just for enjoyment should really be such a foreign concept
"A little weird" is pretty far off from "foreign concept"
hi is it possible for a discordbot to run another apps command?
the other app has a made /getrap function and then itemnames
bots cannot perform interactions
NO bro
Bro make your own command instead of trying to leech off someone elseβs
The frick
my guy it for a game rap checker i dont have access to their api
it so i can check every items rap and see what went up
alr, ill try that, ty!
If they're not giving you access to their api, maybe they don't want you doing this?
This would be considered a self bot, which is not allowed
lol
@stuck meteor The reason they didn't release the API to the public is because of people like you who want to create automated programs
That being said doesnt mean I can't help you find work arounds simply for the challenge.
I assume all the data is only available on discord and not a website?
Bro write your own rap checker
What even is a rap checker
oh
what, hows it support
Self-bots are explicitly disallowed for the safety of the discord platform and its users
You still had to hit enter, no? That is somewhat of a grey area. But automating slash command execution is not a grey area.
Since I am too lazy to think for myself or google it, I asked our favorite companion, ChatGPT.
So basically any automation on a discord account is considered a self bot.
I am not trying to be rude, it is just that self bots can cause a lot of harm so I don't want them to be suggested/normalized regardless of the TOS
Besides @slate swan, if you used some intelligence, some time, an excel spreadsheet, you could easily figure out what's worth monitoring and what's not. You'd even figure out when the high's and lows are for certain things
Just study economics and you'll learn everything you need to know to easily manipulate the market. You don't need a program to do it for you
already did it
r u dumb
recent average price lol
and ye the only thing their bot does is give the rap which i can find in game, i just wanted to see huge changes without individually searching everything
Bro Iβm dumb for not knowing your video game terms?
Ibn hmar
Nah your just dumb in general
This is why you wonβt just write your own RAP checker π
hi, when a guild member deletes a channel why is the member considered a User (in audit logs)? whereas the user is still a member of that guild
no, im troubling with discord audit logs and python here
Send code
Idk what to tell you other than it shouldnβt tbh
After review of the discord.py documentation
Being respectful is a basic requirement to participate in this server.
Please read our #code-of-conduct .
So that even if the member is no longer in the server, you can still recieve audit log info
If you attempt to get a member object when the user isn't in the server anymore, it would fail
and how do you think you get logic? By implementing code. Which we haven't seen, so we don't know what logic you're actually creating.
Just so you are aware the other user in the conversation was also not being respectful
you should have them cached in that case and you can do a cache lookup
I think heβs just confused about the βuserβ property being called user
Itβs supposed to return a Member object if theyβre still in the server
Hey everyone!
I wondered, does anyone else find the discord.py UI module kind of cumbersome to work with when developing complex ui behaviours with buttons, embeds?
I found it becomes a mess when you want to combine embeds + view interactions, and have complex flows where one view instantiates another, or things like undo, redo, etc
I see that most of the times you end up injecting the callback into the components in some way, or pass around references
do you have the code public?
my system only have 1 view for handling the game tho
I'm not saying that it's not possible but I often ended up passing variables around. Let's say you have a button that shows a modal
you want to create a flow like this
click button -> show modal
submit modal -> disable all components in the message and send a confirmation ephemeral message with confirm / cancel
confirm -> proceed with other stuff
cancel -> confirmation message deletes itself and enables all components in the og message
this becomes a mess pretty easily
mmh i guess when you use a view with multple decorators it's fine
but when you're talking about multiple views knowing about each other it becomes cumbersome
the first step, does the message actually have anything else other than the button itself
cuz you can spawn a modal with InteractionResponse
yeah i often combine messages with embeds
yeye i know
the fact is that im building a pretty complex bot and ended up building my own UI library on top with a Model View presenter approach
i was wondering whether this is a common problem, maybe there are other libraries around
or I could share my own as soon as its battle tested
For what, what will happen
they can log into that account with the token
on their discord client using dev tools
so make sure to reset it
does self.check not work on interaction cmds? I have it setup, but its not working anymore. Just curious on how or why its broken.
this would be the code if you need it.
class Bot(commands.AutoShardedBot):
def __init__(self, intents: discord.Intents) -> None:
super().__init__(
command_prefix="/",
intents=intents,
help_command=None,
tree_cls=MentionTree,
owner_ids=OWNER_IDS,
chunk_guilds_at_startup=False,
)
self.tree: MentionTree
@self.check
async def global_check(interaction: discord.Interaction) -> bool:
is_blacklisted_result = await is_blacklisted(
interaction=interaction
)
if is_blacklisted_result:
embed = ErrorEmbed(
title="Sorry...",
description="You are blacklisted from using this bot.",
)
embed.add_field(
name="Appeal",
value=f"You may appeal this decision by visiting our website and clicking [this link]({APPEAL_URL}). Please provide a detailed explanation of your situation.",
inline=False,
)
embed.add_field(
name="More Information",
value=f"If you think this is a mistake, please join our [support server]({BotData.SUPPORT_SERVER}).",
inline=False,
)
await interaction.response.send_message(
embed=embed, ephemeral=True
)
raise commands.CommandError("User is blacklisted.")
return True```
I mean, check exists, https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.check
Does it really get called with an Interaction object though? I thought it would be a Context?
Yeah i see that, I forgot abt that. Is there a way to do it for interaction?
I think once you have an interaction happening you'd need to add any other logic you need directly in your function that's getting called, but I'm not a discord.py expert?
Well its either they have another option or we make our custom decorator
We had to make a custom decorator for checking if a owner is running the cmd. Cuz they only do context n not interaction
Hmm, there's an extension package called discord-py-interactions that looks like it has some tricks
Yeah we just gonna make a decorator ig
Very stupid that dpy doesn't handle interactions a lot.
Ok
huh what. It absolutely does
interaction_check exists on the CommandTree, not the Bot itself
There is one?
Alr.
Well ty, check it out when I'm home
!d discord.app_commands.CommandTree.interaction_check
await interaction_check(interaction, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
A global check to determine if an [`Interaction`](https://discordpy.readthedocs.io/en/stable/interactions/api.html#discord.Interaction) should be processed by the tree.
The default implementation returns True (all interactions are processed), but can be overridden if custom behaviour is desired.
Aha, there you go.
It seemed funny that none of those functions wanted an Interaction arg
Alr
how can I set this up in the mention tree?
what is a mention tree?
mb, I meant CommandTree, we call it Mention Tree

?
You either subclass CommandTree and implement interaction_check in it, or use the @bot.tree.interaction_check decorator on the check
alright.
How to fix the error of Invalid Form Body when doing the interaction_check? This is an app cmd with options in it. But the options never load, is there a way to make it where the interaction_check is only happening after the cmd is ran? Instead of when you are doing args or something?
huh
the whole point of a check is to check before you run the command
checking after you run the command doesn't really make any sense
not what I really meant, what I meant was, where I type /blahblahcmd and it has the option of <option1> and its an autocomplete, how to make it where the check doesn't check autocompletes but only when the command is ACTAULLY sent ya know? Like when its trying to be ran.
if that makes sense
does that really fire on autocompletes? You could always check the raw interaction data to find the interaction type
Yes, it does trigger on autocompletes. It will return the error of Invalid Form Body and say its not valid as an option.
what's the full error and tb?
It shouldn't fire for autocomplete 
looking at the source, it does seem to be the case:
https://github.com/Rapptz/discord.py/blob/v2.5.2/discord/app_commands/tree.py#L1271-L1307 ```py
async def _call(self, interaction: Interaction[ClientT]) -> None:
if not await self.interaction_check(interaction):
interaction.command_failed = True
return
if interaction.type is InteractionType.autocomplete:
...```
async def interaction_check(
self, interaction: Interaction[ClientT], /
) -> bool:
"""Override the interaction check to handle blacklisted users."""
if interaction.data:
print(interaction.data)
if await is_blacklisted(interaction):
if not interaction.response.is_done():
# if interaction.type not in {
# discord.InteractionType.application_command
# }:
# return False
embed = ErrorEmbed(
title="Sorry...",
description="You are blacklisted from using this bot.",
)
embed.add_field(
name="Appeal",
value=f"You may appeal this decision by visiting our website and clicking [this link]({APPEAL_URL}). Please provide a detailed explanation of your situation.",
inline=False,
)
embed.add_field(
name="More Information",
value=f"If you think this is a mistake, please join our [support server]({BotData.SUPPORT_SERVER}).",
inline=False,
)
await interaction.response.send_message(
embed=embed, ephemeral=True
)
return False
return True```
Thats the code right.
Here is the error:
{'type': 1, 'options': [{'type': 1, 'options': [{'value': '', 'type': 3, 'name': 'tag', 'focused': True}], 'name': 'generate'}], 'name': 'sfw', 'id': '1309562961051914294'}
[2025-05-01 17:12:16] [ERROR ] asyncio: Task exception was never retrieved
future: <Task finished name='CommandTree-invoker' coro=<CommandTree._from_interaction.<locals>.wrapper() done, defined at F:\python-projects\Disutils-Team\PrivateEyes-NSFW\.venv\Lib\site-packages\discord\app_commands\tree.py:1149> exception=HTTPException('400 Bad Request (error code: 50035): Invalid Form Body\nIn type: Value must be one of {8}.')>
Traceback (most recent call last):
File "F:\python-projects\Disutils-Team\PrivateEyes-NSFW\.venv\Lib\site-packages\discord\app_commands\tree.py", line 1151, in wrapper
await self._call(interaction)
File "F:\python-projects\Disutils-Team\PrivateEyes-NSFW\.venv\Lib\site-packages\discord\app_commands\tree.py", line 1272, in _call
if not await self.interaction_check(interaction):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "F:\python-projects\Disutils-Team\PrivateEyes-NSFW\core\mention_tree.py", line 84, in interaction_check
await interaction.response.send_message(
File "F:\python-projects\Disutils-Team\PrivateEyes-NSFW\.venv\Lib\site-packages\discord\interactions.py", line 1004, in send_message
response = await adapter.create_interaction_response(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "F:\python-projects\Disutils-Team\PrivateEyes-NSFW\.venv\Lib\site-packages\discord\webhook\async_.py", line 226, in request
raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In type: Value must be one of {8}.```
Huh interesting
Now what I have done is,
if interaction.type not in {
discord.InteractionType.application_command
}:
return False```
it will prevent that error from happening or showing up.
Now I have no CLUE if that is the correct way of doing it. But thats what I am doing currently
you probably want this to return true as it'll likely ignore all non-command interactions, including autocompletes
No, this is a blacklist system, so I wanna return False so they can't continue.
if interaction.type is discord.InteractionType.autocomplete:
return True
...
But you do want to let the autocomplete interaction through tho
yeah im wrong on that, mb
so yes, it would be returning True, then handling the Blacklist interaction.
You were right mb
I rather have the autocomplete do its job, then when they run the cmd, it will give them an embed saying they are Blacklisted instead of it returning me an error.
You can add checks to the autocomplete callback using the check decorator.. not sure why it's still calling the global check as the autocomplete interaction is basically useless
Well, its just easier to do it how you guys just said, returning True, allowing the autocomplete to do its thing instead of people thinking there is an error in the bot or something.
Even if they do an autocomplete option, it will still return False for them if they are Blacklisted, then sends the embed and I am good.
thank you guys for the help. I am used to Hybrid cmds vs just straight interaction. So still getting used to Interaction cmds.
That still adds them to the tree at bot.tree upon adding the cog lol
The CommandTree basically holds all your application commands (slash, context). Subclassing it allows you to implement things like a global check (interaction_check) or an error handler (on_error).
Ohh
exactly what we have done xD
we have a whole subclass for it. Its actually nice.
Yup
hello, I am learning python. What is a discord bot?
a bot thats inside of discord..?
inside discord, oh ok
A discord bot is basically an automated user on discord
Now, should I only be doing checks on the autocomplete, or should I do all? Just incase?
Check out #bot-commands and #sir-lancebot-playground to see 2 discords bots (although they are rather poor examples of what modern discords bots are like)
I looked on the web and there is a documentation on the official discord webpage how to make a automated discord user
Yes, if you are learning python though you should probably not use the raw API as descibed in the discord api docs. Rather, finish learning the basics of python then choose an api wrapper library
ok, that means the documentation is wrapped in a module for python to reuse
Yes, all of the API requests are abstracted into a python module instead of you having to call https://discord.com/api/v10/guilds yourself for example
I see a gateway in the docs, kinda like a socket to stream data. There is also a chapter in the book for sockets in python
Yeah, I have never looked into the gateway closely but libraries will handle that for you as well
All of these libraries are open source too so you can poke in if you want to see how they implement that
My #1 bit of advice is do not follow any of the tutorials that you find when searching for "python discord bot tutorial". Only use tutorials that are recommended by the library you choose
I don't know how to set this up properly. I'm trying to make a cog file so that I can upload this bot for Discord on a free hosting server on render.com.
ModuleNotFoundError: No module named 'cogs'
Full trackback?
Why are you trying to import your Cog
Anyways good night I canβt help much here