#discord-bots
1 messages · Page 401 of 1
this channel is for discord bots not telegram bots, you might receive some help in #1035199133436354600
this is not discord bots
Hello all. What's we all working on
fishing minigame
not made much progress
as a discord bot?

Any reason why no progress?
What you having difficult with?
I assume you're stuck somewhere.
Coz no way you're procrastinating.
sort of, yeah
its ok i just started
and did a bunch of other projects beforehand
!CODE
Is command_prefix required with slash commands?

Parameter 'command_prefix' unfilled
import discord
from discord.ext import commands
import os
from dotenv import load_dotenv
# Load env file
load_dotenv()
class Bot(commands.Bot):
def __init__(self):
super().__init__(
intents=discord.Intents.default(),
activity=discord.Game(name='League of Legends'),
status=discord.Status.online
)
exactly what it says
So the argument is required even with slash commands?
yeah, pretty much
if you have no use for text commands, opt for discord.Client instead
!d discord.Client
class discord.Client(*, intents, **options)```
Represents a client connection that connects to Discord. This class is used to interact with the Discord WebSocket and API.
async with x
Asynchronously initialises the client and automatically cleans up.
New in version 2.0...
Unresolved attribute reference 'load_extension' for class 'Bot' 😄
ah, i see
Client doesn't support extensions
i say have a command prefix for commands like ?sync, then you can swallow the CommandNotFoundError in your error handler
You can set the command_prefix to something empty like ()
commands.Bot still supports prefix commands so
I still need to import in every cog
from discord import app_commands from discord.ext import commands
sucks
what do you expect lol, a import *?
technically could do that.. if you import them in one file
# cogs
# - __init__.py
from discord import app_commands
from discord.ext import commands
# - ext.py
from . import app_commands, commands
wait huh? thats real?
Probably not ideal if you have the message content intent
yeah
Is it possible to make a bot that adds users directly to any server with the help of a command? e.g if users verify themselves on the bot and give consent would it be possible ?
the simple way would be... Give the user an invite and then they click the "Join server" button
Bots cannot add users to servers directly except through the guilds.join oauth scope
Sorta. So when you "authorize" an app on discord, that "app" can make you join discords. It's how those discord jails work.
I personally don't think that should even be a feature at all
They asked about a bot specifically tho. You cannot use the guilds.join scope with the bot one
The bot specifically cannot. However if you get the user to authorize an app, the bot should be able to run api requests to make people join servers
Ah, true
TBH, if you have to rely on people being forced into a discord server for it to be popular then you're doing something wrong
All you need is that code
From what I understand the flow they're describing is an actual reasonable use of the guilds.join scope
My comment still stands. However there are ways.
They didn't describe anyone being "forced" to do anything though
The only way I think it could be used properly is if it was used as some sort of game where you solve puzzles or something
give consent
If you're using the API to make someone join a discord server you're forcing them into it.
Then just send them an invite link.
What they're asking allows them to perform validation before allowing this person into the server
Which is entirely valid
Its not forcing if they're literally consenting to allow the application to join servers for them before-hand.
That's literally what the guilds.join scope is for 🧐
I mean technically but people are idiots
Still does not mean they're being forced into any guild
- they never really said anything about trying to make the server more popular or anything, that's just an assumption.
This could totally be for a specific feature they're trying to implement, we don't know.
Anyone know why my bot continuously posts raw userid’s in embeds? I’ve even added caching to my code to try and stop it but it just keeps happening. User.mention never mentions the user or rarely does
It has nothing to do with your bot, it's the Discord client not having it cached because you don't share a server or something
correct, it has to do with the client cache and not the bot.
mentions are basically markdown meaning it's just text, if the user hasn't been found; it fallback to text which is what you see @vale herald
Thank you sir
What is the different between tree.command, slash_command and app_command?
And is app_commands the recommended way to create slash commands?
discord.py uses tree.command (same as bot.command but for slash commands) and app_commands.command (same as commands.command but for slash commands), i believe (bot.)slash_command is pycord
How can i create my bot to become an authorized app to the user similar to this?
What are you trying to accomplish?
I want to make it access username, avatar and banner to verify their user
Verify? Verify what? And at what point are you doing that? Are they already in a guild the bot is in?
Its not to dissimilar to them clicking a reaction for a role. They are already in the guild
Then your bot already has access to all of that information
but if all they're doing is clicking something, you're not actually verifying anything
except their ability to click something (which selfbots can do just fine)
The whole point is for them to be able to use commands outwside the server
oh like user install app commands?
you don't need this flow (oauth) to do that
you can publish user install commands just fine without oauth
then where can i publish my tos, privacy policy, etc
the whole point of authorizing it is for ease of access on their dash
you would still have all that in your bot's about section
you don't need oauth to have that
Or wait
. Is this the window for deauthorizing a user install app? Haven't seen it in a bit and might be mistaking that for the oauth deauthorize window
hey so this is my code and I was wondering if its possible so that if the user picks one role from a dropdown then the other roles of that dropdown (if any) gets removed
FYI I'm pretty sure you can do self-service exclusive roles from the onboarding menu without needing a bot at all
Are you wanting it to be permanently removed because of the role they selected or just temporary in that view of the command's instance?
Your going to want prefix commands usually. I use them to create bot moderation commands that can only be executed by my discord account. Helps me have dev commands while not having the commands take up space in my list of slash commands
Aside from editing the message view, how can I reset a select menu?
Because currently I am editing the message view and it causes errors for me
So are the tree.commands only used to sync and group app commands? I'm still new to app commands
Permanentaly
btww does anyone know any free options to host a bot?
i tried oracle but they dont accept my card
!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.
tl;dr free hosts are shit, scams, or both
I am fine with having a shit host... just reccomend me any
Then find youself one
There are countless of free host websites, but be careful of your data
You won't know it's also a scam until you get scammed
Do a little bit of work and rent a legitimate vps
disable requires code grant in the dev dashboard
i run this code:
import discord
class MyClient(discord.Client):
async def on_ready(self):
print(f'Logged on as {self.user}!')
async def on_message(self, message):
print(f'Message from {message.author}: {message.content}')
intents = discord.Intents.default()
intents.message_content = True
client = MyClient(intents=intents)
client.run('my token goes here')
and it outputs:
2025-02-18 21:14:29 INFO discord.client logging in using static token
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/discord/http.py", line 801, in static_login
data = await self.request(Route('GET', '/users/@me'))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/discord/http.py", line 744, in request
raise HTTPException(response, data)
discord.errors.HTTPException: 401 Unauthorized (error code: 0): 401: Unauthorized
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/decentrala/bot.py", line 77, in <module>
bot.run('token')
File "/usr/lib/python3/dist-packages/discord/client.py", line 860, in run
asyncio.run(runner())
File "/usr/lib/python3.11/asyncio/runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/discord/client.py", line 849, in runner
await self.start(token, reconnect=reconnect)
File "/usr/lib/python3/dist-packages/discord/client.py", line 777, in start
await self.login(token)
File "/usr/lib/python3/dist-packages/discord/client.py", line 612, in login
data = await self.http.static_login(token)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/discord/http.py", line 805, in static_login
raise LoginFailure('Improper token has been passed.') from exc
discord.errors.LoginFailure: Improper token has been passed.
how can i fix this error?
make sure the token is the correct one
how do i make sure
by going to the dev portal and getting a new one
well i did make a bot
from which page did u get the token?
A hands-on guide to Discord.py
I dont think they ever said they were using discord.py
highly likely since the code they provided is almost a carbon copy of the code example in the discord.py README
TBH that is not super complex code so that does not necessarily prove anything either
i suppose
i need some help
i want to create a system where i give a folder with photos and videos and the bot to automatically post in on a channel, is that possible?
like pfp and banner command
but my own photos
ye but i don't know python at all🥲
You should probably learn python before making a discord bot.
i have the knowledge to edit a code but not to make it from scrap
like if u see a command i know what to change at it to make it better for me
but have no idea to create it myself
for example i managed to make a system that deletes photos and videos that have a discord link hidden in them
The pattern of "I can only edit code" generally is a signal that someone doesn't fundamentally understand it. They don't understand why the code was made the way it was, or more importantly have the ability to question it when there is a ton of really shitty discord bot code out there. This process is going to be very slow and painful, and you will wind up with brittle code that you will struggle to fix or diagnose unless you take time to learn the fundamentals
- learn python
- make simple programs
- keep going over the basics
- learn more and go over that
- keep on coding till you can code in python
- look up any api wrapper and choose one
- learn discord.py (or one of the others)
- code simple bots
- add more functions to the bot, keep you code clean
- keep at it and try everything you can do
- make a decent bot
- profit maybe?
import discord
import openai
import os
openai.api_key = os.getenv("OPENAI_API")
TOKEN = os.getenv("MY_API_TOKEN")
intents = discord.Intents.default()
intents.messages = True
client = discord.Client(intents=intents)
@client.event
async def on_ready():
print(f"Logged in as {client.user}")
@client.event
async def on_message(message):
if message.author == client.user:
return
response = openai.ChatCompletion.create(
model="gpt-4",
messages=[{"role": "user", "content": message.content}]
)
reply = response["choices"][0]["message"]["content"]
await message.channel.send(reply)
client.run(TOKEN)
output:
shouldnt send ur api keys
ImportError: DLL load failed while importing jiter: The specified procedure could not be found.
its wrong
dont send your API keys
somebody can easily gain acess to your account and rack up a bill
under your card + name
be careful
i swear its wrong
you're not understanding
you sent your API keys
the key that says, hello openai im a user i want to use your service
if you pay for it then somebody can use your API key and rack up bills under your anem
done
Also you may want to read the terms of service and dev policy more closely before shipping user data to openai
Who says they did not?
Given that they're violating it and asking for help in a server that tells you not to violate tos, it's a fair assumption
Not quite sure how you came to that conclusion?
Because they are sending user data to a third party without capturing the user's consent?
(potentially also violating the the ai training clause depending on the openai settings on their key, but that's been defaulted off)
I don't understand your questioning. If he read the TOS he'll either ignore what @fast osprey said or respond with "I did." and if he didn't he'll go read it or ask questions.
Alternatively he could just not read it and not give a damn and just do what he wants anyway until it all goes wrong.
But it's a fair assumption that if someones sharing their API key they probably didnt read the TOS
It's okay. Wolfy just likes to argue with people to seem superior😂
This message would have been good to lead with. I thought a different part of the TOS was being referenced as there was no context to the original message.
Dont bring things that happened on different servers here, also dont make claims about me that are untrue.
You might be able to tell others what to do. But you just yapping to a screen right now. Nobody brought anything from another server, so learn to read and Ill make any claims I see fit. Have a good day
can anyone help me https://discord.com/channels/267624335836053506/1341620663051358318
Your user variable is a int, (most likely the user id)
You need to use that ID to fetch the User object
how do i do that?
!d discord.ext.commands.Bot.fetch_user
await fetch_user(user_id, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Retrieves a [`User`](https://discordpy.readthedocs.io/en/stable/api.html#discord.User) based on their ID. You do not have to share any guilds with the user to get this information, however many operations do require that you do...
how do i set that to a variable?
how you normally set a variable...?
just do user = await fetch_user(user, /)?
well its just the await is the weird part idk
also what is the /
just an empty tuple?
No, its a method of your Bot
No, u only need to give the user_id to that method
since im using discord.py this seems more relevant
i cant get this to work either though 😭
for i in range(len(lbIDs)):
userID, points = lbIDs[i]
print(f"LB Position: {i+1} User ID: {userID} Points: {points}")
user = await Client.fetch_user((userID))
role = discord.utils.get(user.guild.roles, name="🌍Geoguessr Expert")
await message.author.add_roles(role)
embed = discord.Embed(description="Success", color=discord.Color.green())
await message.channel.send(embed=embed)```
Traceback (most recent call last):
File "C:\Python\Python311\site-packages\discord\client.py", line 449, in _run_event
await coro(*args, **kwargs)
File "c:\main.py", line 5766, in on_message
user = await Client.fetch_user(int(userID))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Client.fetch_user() missing 1 required positional argument: 'user_id'
Pretty similar things
Are you using discord.Client or discord.ext.commands.Bot as your bot?
discord.Client
what is this code part of
an on_message event?
as of now yes
and are you storing discord.Client in a client variable?
i dont know what that means
how are you defining your bot/client's instance
does any of this seem familliar to you
client = discord.Client()
bot = discord.Client()```
Hmmm, do you know the basics of python?
maybe? i dont even know anymore
yeah so in your code switch the line
user = await Client.fetch_user((userID))
to
user = await client.fetch_user(int(userID))```
Client is the class, client is your instance of that class
you cannot call methods on the Class itself but on the instance
I recommend that you first learn Python before creating a Discord bot.
Traceback (most recent call last):
File "C:\Python\Python311\site-packages\discord\client.py", line 449, in _run_event
await coro(*args, **kwargs)
File "c:\main.py", line 5767, in on_message
role = discord.utils.get(user.guild.roles, name="🌍Geoguessr Expert")
^^^^^^^^^^
AttributeError: 'User' object has no attribute 'guild'
so you want the member object not the user object

do
member = message.guild.get_member(userID)```

and do member.guild.roles
replace user with member?
I dont see why you can't just do message.guild.roles but I don't have any context so sure
Traceback (most recent call last):
File "C:\Python\Python311\site-packages\discord\client.py", line 449, in _run_event
await coro(*args, **kwargs)
File "c:\main.py", line 5767, in on_message
member = await message.guild.get_member(userID)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: object NoneType can't be used in 'await' expression
oh my bad
also get_member() is not an asynchronous method
yeah I know I edited my message after like 5 secs
:D
Can someone help me?
don't ask to ask, just ask the question
Guys, what discord library you think is the best?
Ok i have the problem with tokens and. Bots like i was lost my accaunt where i was have the bot faman vas jebo and idk how someone posted my token on github and idk what to do
See
It will auto invalidate it for you
Discord works with github to invalidate tokens
Your token will be auto reset
I need help with choosing the library
Yo thanhz
Look at them all and see which one you like. There is also Hikari, which is completely different from dpy and its forks.
Idk rlly what i do to someone post my privacy on github but Everything will be fine.
Access your support options and sign in to your account for GitHub software support and product assistance. Get the help you need from our dedicated support team.
Ok
https://docs.github.com/en/communities/maintaining-your-safety-on-github/reporting-abuse-or-spam even better
Ok
It doesn't have good slash command support
What support do you think it doesn't have?
Did you ask an AI and then it show you a discord.py 1.7 code??
discord.py is on 2.5.0
They said "doesn't have good" not "doesn't have"
Some people dislike OOP (CommandTree), they say it's "complicated" but never actually explain why or what they struggle with lol
Reading is hard :blobpain:
Because they never bothered learning OOP properly
TIL

Nextcord,Pycord, and disnake have better app commands systems imo
can i see some example syntax?
open their examples directory on github
Gotta mention that you're a moderator* in the pycord server and friends with the maintainers of the others lol
But I do agree that it's easier to use them in the forks for ""beginners"", as it's only one conveniently named decorator away 
who is
ah i see
So which of them you suggest?
You can take the nextcord and disnake examples, replace bot.slash_command with bot.tree.command (and a few other things) and they're mostly the same lol
Personally discord.py, though yeah you're asking someone else
It's not discontinued, yeah?
In discord.py the application commands are very confusing for me, the other libraries do it better
And it supports slash commands, UI dialogs, etc.?
everything yes
Also I'm thinking about pycord - is it better?
For me yes
And your guide is better
better is subjective. I dislike it but you should use what feels better for you
I've heard that it's unstable
Any of those 3. I use Pycord personally but nextcord has been doing good work as well
They have some releases that break the whole library
well they've had... some issues... but they are functional
Pretty much every library has had some sort of issue
what's confusing about them?
using tree.commands and having to manually sync commands.
As reliable as a open source volunteer run project will be
Other libraries do everything automatically.
But current release is stable?
Yeah
@pale zenith didnt you or one of the dpy dudes mention something bad about this?
!d discord.Message
class discord.Message```
Represents a message from Discord...
also how tf do you forward a message on discord.py
oh im stupid
have to rebuild my documentation for the next release, WOOOO YEAHHH
Yes. Syncing should be done manually, in my opinion, because during development you (mostly) are editing command bodies, and rarely need to actually sync your commands to discord.
Sometimes (quite often) when you sync, your commands disappear for (some) users and that's something that I think should be minimized
Syncing every time you restart just adds extra startup time (because syncing has some kinda strict rate limits) and you're just making unnecessary requests to the API to change - quite literally - nothing
Unless these libraries keep track of the previous commands pre-restart and compare before syncing, I don't think syncing should be done automatically at a library level
Command limit? Actually there is no problem since it only syncs the commands that actually changed for example if you have 50 commands and only 5 changed then it only syncs those 5 commands and keeps the previous versions of the other commands
^ automatic syncing is not the same as syncing everything on startup
Yes, the act of syncing inherently does that. That's what the bulk edit app commands endpoint does
But it still fucks it up sometimes. It's real inconsistent and that actually annoys me lol
"Oh but it adds extra complication" - ok sure, you need to run one command whenever you update one of a set of specific things, but like, once you learn you need to do that, it ain't that deep lmao
Anyway as I said before, people should try each library and use what feels best
I've seen this conversation a couple times, and whenever I look at the slash commands examples provided by different frameworks. They all literally look the same to me and then I get confused on why people call one better or easier to use/understand
same
The main difference is when you want to do anything more than add the command. IE options and command description/name.
Pycord, nextcord, and disnake are more similar than discord.py
I'm working on adding new features and enabling slash commands for the bot. Any help or feedback is greatly appreciated 👍
I feel the whois commands are really pointless because 95% of the time they do not display more information than what I can see by just clicking on ur profile
Unexpected error: Failed to convert moneyyyyyyyyyyyyyyyyyyyyyyyyyyyy to Member
Do app commands always try to convert discord.Member to a User if the user is not a member?
discord.app_commands.errors.TransformerError
Not the same as discord.ext.commands.errors.MemberNotFound
How can I handle errors that are related to Member conversion?
Code?
App commands don't try to convert anything with native supported types. You tell discord what that type is, and that's what discord gives you
@app_commands.command(name="whois")
async def whois(self, interaction: discord.Interaction, member: discord.Member = None):
So my idea is to catch it with
elif isinstance(error, app_commands.errors.TransformerError):
embed = discord.Embed(
description=f"{custom_emojis['x_emoji']} I could not find the user `{error.value.id}`.",
color=discord.Color.red()
)
But wouldn't app_commands.errors.TransformerError cover more than just member conversion?
Is there any way to specify to only catch member conversions?
How are you even passing in a member it can't transform?
User ID
I think you need use an union of User and Member for that to work
Or it just breaks when you don't select from the autocomplete list idr
That will just accept both User and Member objects for the command to run
Unexpected error: Command 'whois' raised an exception: AttributeError: 'User' object has no attribute 'roles'
So if the user ID is not a member, we want to catch the error and say that we can't find the member
I guess you could check the specific transformer
if isinstance(error.transformer, app_commands.MemberTransformer)
https://github.com/Rapptz/discord.py/blob/master/discord%2Fapp_commands%2Ftransformers.py#L616-L624
discord%2Fapp_commands%2Ftransformers.py lines 616 to 624
class MemberTransformer(Transformer[ClientT]):
@property
def type(self) -> AppCommandOptionType:
return AppCommandOptionType.user
async def transform(self, interaction: Interaction[ClientT], value: Any, /) -> Member:
if not isinstance(value, Member):
raise TransformerError(value, self.type, self)
return value```
Not sure why discord sends invalid data instead of throwing a client error
Because it's a valid user ID
Why am I getting:
Unresolved attribute reference 'transformer' for class 'AppCommandError'
Unresolved attribute reference 'value' for class 'AppCommandError'
'MemberTransformer' is not declared in __all__
My code:
from discord.app_commands.transformers import MemberTransformer
@staticmethod
async def on_app_command_error(interaction: discord.Interaction, error: app_commands.AppCommandError):
elif isinstance(error.transformer, MemberTransformer):
embed = discord.Embed(
description=f"{custom_emojis['x_emoji']} I could not find the user `{error.value.id}`.",
color=discord.Color.red()
)```
can you paste the full traceback
This is just warnings in Pycharm
how can I make a discord bot?
dpy masterclass
* if they want to use discord.py
I fixed it with
elif (isinstance(error, app_commands.TransformerError)
and error.transformer.__class__.__name__ == "MemberTransformer"):
embed = discord.Embed(
description=f"{custom_emojis['x_emoji']} I could not find the user `{error.value.id}`.",
color=discord.Color.red()
)
without having to import anything
But it looks ugly
I can't because MemberTransformer is not exposed in the all list
from discord.app_commands.transformers import MemberTransformer if u wanna import it directly from the file
Problem is
'MemberTransformer' is not declared in __all__
u can ignore that warning
or continue using this
I'm getting these ugly warnings in Pycharm
you can pass a datetime.time into tasks. Look at the docs for the library you use to find the argument name
huh
Might aswell list them all at once for future referencing
Known Python Library Guides
- discord.py (Unofficial)
- pycord
- disnake
- nextcord (and disnake ig)
- hata
- interactions.py
Known Python Libraries
Remember that all of them implement the same API, each in its own way, and there is no good or bad; it is a matter of personal preference.
See more libs at https://libs.advaith.io/#python
@discord.ext.tasks.loop decorator has a time= parameter, and it'll run at that time every day:
from discord.ext import tasks
import datetime
MIDNIGHT = datetime.time(hour=0, minute=0, second=0, tzinfo=datetime.UTC)
@tasks.loop(time=MIDNIGHT)
async def my_task():
... # runs at midnight
of course you may want to change the date or timezone based on what you want, but that's that general idea
thankyou
How to Use Markdown Escape in Discord? If Discord Used HTML, I'd Use Telegram Bot's Formatter
-# for some reason the translator wrote all the words with a capital letter
Is there a ready-made formatter, similar to how I did TeleBotPlus.HTML?
\ is the escape character
\*\*hi\*\*
with backslash **hi**
without backslash hi
Thank you
What symbols besides _ and * need to be escaped?
if you use discord.py:
!d discord.utils.escape_markdown
discord.utils.escape_markdown(text, *, as_needed=False, ignore_links=True)```
A helper function that escapes Discord’s markdown.
!d discord.utils.remove_markdown
discord.utils.remove_markdown(text, *, ignore_links=True)```
A helper function that removes markdown characters.
New in version 1.7...
_ * ``` ~
- -# * > at the start of lines
Possibly more
ignore the \ above the formatting does not want to work
is there any way to tell when someone votes on a poll
if your looking for a telegram casino full source with lots of game modes and custom ones dm me i will showcase you. i also have miniapps for the casino incase your wondering.
!d discord.on_poll_vote_add
discord.on_poll_vote_add(user, answer)``````py
discord.on_poll_vote_remove(user, answer)```
Called when a [`Poll`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Poll) gains or loses a vote. If the `user` or `answer`’s poll parent message are not cached then this event will not be called.
This requires [`Intents.message_content`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Intents.message_content) and [`Intents.polls`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Intents.polls) to be enabled...
Is discord.js better than discord.py?
Its in JS, so I have no idea
what do you want to compare
they both implement all the features of the API
If you want to us JS you will be much more successful using discord.js
For a High end bot, managing schedules, player stats, and AI features also (xAI API) and some other moderation stuff.
API latency is generally going to be the most significant factor in speed. And this won't differ for different languages or libraries
personally, I really dislike the way you make commands in djs (both slash and prefix) and I love the way you make components in dpy (and forks)
for those two reasons alone, I'd use dpy over djs and recommend dpy over djs
Python has better libraries, and I want better speed and performance too.
So based on the criteria of speed and performance I have to choose, any suggestions?
As a meta suggestion, you will not get an unbiased answer to "is X or Y better?" in the official support server for X
speed and performance will matter on your app more than it will on the library
discord bots are fairly IO heavy and usually dwarf whatever CPU bound stuff the library is doing
Bots are extremely IO bound, you're not mining bitcoin here you're sending a bunch of network requests and waiting on them
so usually what ends up happening is people start doing like, image generation which is CPU bound and can take some time (relatively speaking) on the same event loop as their bot. but you can have the same problem in JS, though I assume it would be less common because unlike in Python, JS is by default async and most libraries are built around callbacks or async
I will provide bot the template and it has to input the necessary values and regenerate the poster
the language in which you write a bot heavily influences performances, that's not the point of the original question tho
Yep, so I am looking to pick one between js and py
Just select the one that is most comfortable for you; neither of the two libraries is better than the other, it's subjective.
Hmm, ok 😁
But it won't affect performance right?
Try it and see
if you're looking for performances you don't pick js nor python
discord.asm 
Anyway to do a custom of this in a way, but without removing the Discord one so you can have your own warning about something else related to something else?
Imma assume its not possible, but still gonna ask tbh
indeed not possible
alright, ty
kinda figured, just looking a way to give a warning when they open up the modal, but in a more formal way like discords way. But I think there is no way besides doing a confirm message in the modal or just saying a message where they open the modal.
You're not installing a discord library into the python environment you're running
use py -0 to view all the python interpreters you have installed. use py -<VERSION> -m pip install discord.py to install discord.py into that verison.
py -<VERSION> -m pip install discord.py doesnt work
i got python 3.8.64
thats the interpreter
Are there any others?
If not you can omit the version part
nope
wait no i have python 3.8.10
hi, can anyone help me remove my linkvertise system into my code?
remove into?
a captcha idk#
What are you trying to accomplish and where are you having trouble
i am trying to accomplish a credit feature into my bot but instead of link vertise (the original one) i would like it to be a captcha or like a math question idk
what does a credit feature mean?
can i just dm u

i've never tried py with major minor and patch at the same time but py -3.8.10 -m pip install discord.py should work
then you'll want to py -3.8.10 bot.py to run a python file
it's important that the versions match up otherwise your interpreter won't be able to find the package (since it was installed for a different version)
C++ is generally picked, but for discord bots it's not necessary to do so.
So the best languages for discord bots would be py or js
there are other easier languages that provide C++ like performances, like rust (easier because its rules make you write memory safe code unlike C++ which doesn't have such rules) and go (which is even easier than rust I've heard)
Make sure you have import discord at the top of your main.py file with your other imports aswell
Module not found is the error you get from the import line lol
You would get a name error if you missed an import
My thoughts exactly 😂
anyone able to help me here?
You should reset your token immediately, firstly
a) you're on windows, sudo isn't a thing
b) you shouldn't be running pip commands raw on windows, it's ambiguous which python installation you're installing into. Use py -m pip and pick which version you want to install into or
c) use a venv instead
and no worries happens to all of us
im so new to like all of this so im just trying whatever i read
well whatever you're reading is geared for linux lol
u familiar with asyncio tho?
just on the tutorial im watching to learn the basics
if you're watching a video, these videos are shit across the board
I'd strongly recommend reading vetted articles from the basics and working your way up
you got any suggestions?
Depends on what you're trying to learn
well
Have you set up and run a python project at all?
i mod for a virtual reality football game
!res ?
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
yeah, KIVY, Tkinter, basic python, searching algorithms
but i want to make a bot that can display and update a football league table
Presumably some of those things required you to install pip packages yeah?
yeah KIVY requires pips and .kv files
how are you gonna do that?
so installing whichever discord package you want to use (there are several) will follow the same theory. Not whatever this video is telling you to do
thats the fun part, i dont know
like your own football league table or spamming requests to fifa?
a league table that can:
receive the names of teams from a user
recieve results of games from a user
display results from a user when requested
display a league table
what ?
empty callable
I'm assuming he will be web scraping from his own site or another online source for his table
sorry i got interrupted by a chore haha
i edited my message
its a league table for a Virtual Football game
as people create their own teams and play against each other
Probably start with getting a hello world bot working before you get carried away in details
thats my goal
soo like you're gonna filter all of that in a db? and write a discord bot that can update that db?
i always set a final product for myself
yeah its like a glorified spreadsheet
make it
well time to learn
lets find some articles online
i assume IONOS will have some good info as they are a web hosting company
There's plenty of resources on fundamentals like installing pip, running your code, etc. Whichever discord library you choose will also have documentation and examples
web hosting company
i dont think i need help installing PIPs anymore thats all done
just actually making the bot now
Which discord library are you using?
ugh wtf how can i write a function that takes gibbrish and a list of words and check if that gibbrish manages to be one of that word?
thank you very much
what is a intent? it doesnt say on the website
thats rude willi
😭
Sorry hahah im a pain I know
nw it's a learning exercise
So from what I gathered intents are like user access levels but in discord bot form?
why are there are soo many combinations of a word 
wor, owr, row, <- just 3 for three words?
no
wro, rwo
😭
Not quite. It's basically your bot telling discord what kind of info it wants
what are you even talking about 😭
okay wow i have alot to learn
"My bot needs to know when someone reacts to a message, and when someone sends a message, but doesn't need to know when someone joins a voice channel" etc etc
There's a full list of the intents linked on that page
OH
thats so much easier to understand
thanks for putting it like that, that actually makes sense in my head
nvm its just factorial 
https://docs.python.org/3/library/itertools.html#itertools.permutations may be useful if you actually want them
These are the notes ive taken so far. Everything seem correct to you?
But im now getting a problem whilst running it
This says you're trying to declare a class called client but that's not in your code I can see
it has been called but its got my token so i hid it
the error doesnt match your code
oh yeah ignore that, thats from a while ago
runs
main.py
gets error
file tree shows nomain.py
oh alright
that screenshot is from before attempting to run it
to me, it looks good. i recommend checking out how to make actual commands next
the error im getting now doesnt even fit on my screen
!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.
how do i paste the error from the terminal
by selecting it with your mouse cursor and pressing ctrl + c
where it says 'token' is just a placeholder as i removed mine
it doesnt say that in my code
You've got something wonky in your python environment
NO I THOUGHT I FIXED THIS
you can also just move your token to another file, say token.txt:
<your token here>
``` ```py
bot = ...
bot.run(open("token.txt").read())
or set up a .env file: $ pip install python-dotenv ... TOKEN="..." ```py
from os import getenv
from dotenv import load_dotenv
load_dotenv()
...
bot.run(getenv("TOKEN"))
I HATE VENV
what did env do to you 😔
i might cry
im fed up off pips, IDEs, venvs
i genuinly cannot get this to work at all
ive been doing this for 4 hours now
You most likely are just layering stuff videos tell you to do on top of each other
rather than starting from a blank slate
i might honestly just uninstall and reinstall VSC
and since you don't understand what you're doing when you do it, you have no clue if that's hurting you later when you try to do something else
this isn't a vsc thing
anyway to just like reset?
VSC is just a text editor
that isn't going to change how your program actually works
i might just delete my files and restart everything
okay right im getting a fresh USB drive
and making a new folder
right im starting a fresh slate
can you run me through how to properly set things up
Before you even think about vsc, what matters first is your python environment
okay im listening up, ready to do this
vsc is literally just an editor on top of text files. The python installation is what actually runs the code
so what should i do first
anything i should do with the python installation to 'reset'?
Either go into it, see what you've installed and adjust, or just reinstall python entirely
up to you
now following the installation tutorial via that website you sent
oh for god sake not this problem
yay i fixed it
class Client(discord.client):
TypeError: module() takes at most 2 arguments (3 given)
????????????
discord.Client
Learn what an ide is and how it works
or a text editor like VSC
why do people need to be so rude about things
we all start somewhere
You just shouldn't make a bot as your first ever programming experience, will be demotivating
It’s not my first experience
Learn at least the basics off a course or something
I’m just not familiar with how venv’s work.
That’s why I didn’t ask for venv help in here
That wasn't rude. That's the truth. Get over it. Just because you want to skip steps and make shit code because you don't know what your doing doesn't make me rude for telling you how it is
You can open up a thread in #1035199133436354600 if you wish, though learning by doing and researching yourself is also nice
Was just a generalization of your questions before
We help you with specific issues that are actually related to bot code
Making ‘shit code’ gives me a basis to work on thanks. I’d rather make something crappy and be happy with it and then upgrade it as I learn then spend hours upon hours making nothing and then trying to piece the puzzle together at the end
Having a ‘shit’ product gives me motivation, thanks.
dang ty
Takes 15 minutes or less to learn what an IDE is. Sounds like you are just lazy
I know what an IDE is they teach that shit in school.
Dang, y'all can disagree with their learning method and suggest other things without insulting them
You ever had trouble with an SSL error?
I’m getting one when running my code, can’t find any fixes online. I’m so stuck
Apparently my SSL is the wrong version number?
Don’t even know what an SSL is to be honest with you
Something to do with Network Protocols
Yeah it's a security protocol for signing requests using certificates. What version of python are you using?
3.13 I believe, downloaded from the python website
I tried updating my certificates earlier. They didn’t help anything
It's not the certificates, it's the version of ssl your python environment is using
Well if he would've kept it civil instead suggesting that I'm being rude
Okay, how should I go about fixing this?
And you reinstalled python?
I reinstalled it earlier today yeah, but I did have 3.13 from the website and 3.12 from the microsoft store installed at the same time. Maybe that’s the problem
I might completely uninstall all instances of python and redownlos 3.13 from the website again
I would recommend that, and not installing any packages
except for the discord package you want
Okay got you. I’ll do it now
OH MY GOD
SOLSTICE SHARD I CANNOT EXPLAIN HOW GRATEFUL I AM FOR YOU
I WILL FOREVER PRAISE YOU MY FRIEND
ITS WORKING
you did something pretty fundamentally screwy on your previous environment
glad it's working though 
I have no clue what I did
But i’m grateful it’s fixed
It’s only up from here. Thank you very much my friend
All working too!
6 hours on 😂
I will say that bots layer on several concepts at once, including but not limited to OOP + asyncio + network + callbacks etc. If you try to learn all of these at once, you will have difficulty
What one do you suggest I learn first
OOP concepts are incredibly important in almost any language and any framework you will find yourself using
Sorry let me rephrase: Where should I go after completing the quickstart page
Yeah I have heard that commonly. I’ll have a look into it
In my opinion, you should do focused learning on the base concepts before trying to build a bot. You can elect to not do that, which is your call. The library fully documents all of the methods available to it, and there are examples in the repo too depending on what you want to do
I mean I just primarily want to learn how to make discord bots
Even if all you want to do is brain surgery, you still need to learn how to hold a scalpel first
God damn…
Don’t even know where to start though to be honest, python has so much too it
There aren't any shortcuts, these frameworks build on top of lots of things and if you try to skip those things you will be in way, way deeper just copy pasting code you don't understand
You can learn those things while building a bot, but you do have to stop to understand them independently or you'll just layer on more copy pasting
What do I need to learn though, like I don’t know where to start and build up from
These concepts are good to start with, roughly in that order. I think a resources page was linked earlier, but also just the official python tutorial is quite comprehensive
Okay thank you!
https://docs.python.org/3/tutorial/classes.html for example is the official resource for learning about classes and objects, which frameworks like dpy use incredibly heavily
Honestly i’m just reading up on some of the VERY basics again. Things like text and some things I missed out on
The chapters in https://docs.python.org/3/tutorial/index.html are a good start for general concepts to think through, in order
if things like data types/structures are rusty, then yeah advanced concepts will be super painful
:D https://github.com/Gnomeslayer/Gnomeslayers-Trivia working on a trivia bot
Hiii, ive made a discord bot recently ive coded the bot to send a word from a words.json file and scramble it now i want the bot to track if the user sends the correct answer or reacts with a certian emoji witch will skip the game and start a new one displaying the answer when the user gets it correct it should say they did and then start a new game this worked before after no chances of the code just bot restarts and now its not working correctly is anyone able to support me?
Which part is broken?
The tracking part and the skip part, before i had the bot codes just to track messages and wasnt doing anything to with the skip part now ive added the skip part aswell it doesnt seem to be tracking the message or allowing the user to skip
It's unclear what you want by "tracking" or "skipping"
Well "track" is ambiguous
His entire thing is confusing
You get message events sure, but what are you trying to do when you get a message
Soo let me explain better sorry,
the bot will start a game this game gets a random word from words.json file and scrambles it the bot then replys with the scrambled word and adds the 🔄 react to it the aim is for the user to unscramble the word so say the world is Hello the bot will send for the game unscramble the word Elhlo now the user needs to either correctly guess it this can be done by replying simply with Hello, hello, HELLO ect, or the user has the option of reacting to the 🔄 and after one reaction it will skip it and output the answer allong with sayinng it was skipped and starting a new game.
@fast osprey @drifting arrow dont know if thats easier to understand ^
You're doing to have difficulty doing this with reactions. Reactions are severely antiquated for user flows
You should use a ui button
ive just recently learnt ui buttons ill try implementing that then
With the button, you declare what happens when someone clicks it directly
i wanted to make it adventurly so say 2 people had to react for it to skip hence why didnt do the button
You can do that with buttons, it's just tracking state
okay
Otherwise if you want to do reactions, you will need to make a global reaction listener and then figure out if that's on a message you care about and then what you want to do. People can react to any message and your bot gets that event
defo confusing for my brain ahah it also tracks the streak and stuff but ill see how it goes
ahh ok
You can also use buttons for things like this hint, or even for users to submit guesses directly to the bot rather than through a message
ok
I was thinking this also💯
I don't think performance matters here in the case of discord bots, because Python or JS are sufficient here!
The top bots out there are built using py or js (like mee6, carl, Probot, etc.)
there are few cases where you're not going to be I/O limited
Yeah this works so much better thankyou
just need to edit the messages now
You can edit the containing message within a button callback via interaction.response.edit_message
I need help with my bot command: It is saying that there is no bot command called snus
isn't there suppose to be a paramater in bot.command()?
@bot.command(name="snus")
async def snus(ctx, *, query:str = None):
it takes the function name otherwise so it doesnt matter
Make sure you're running the code you think you are, then send us the full code
Full code. Not just this command
If you don't know where the problem is then you need to send all of it
Then send all the code
Are all functions uniquely named?
You can use a paste service if needed
yes
well i got nothing
Is there other commands on this specific file and do they work as well?
its not a file
!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.
yes it is. you have to save your code onto a .py file.
thus, it's a file.
On this .py file, is there other commands? and do those commands work?
well there is other cmds in the py
yes
all other cmds work
Assuming all commands on that specific .py file that holds this "command" work.
And assuming you're following the same format for other commands,
do me a favor and rename the function snus to "gnome" and run your code.
and attempt to run the command "gnome"
.
ok
There's an infinite number of things that could be wrong here. We can either waste our time guessing them one by one, or you can just send the code
ATM I am assuming it's a naming issue.
@drifting arrow
Alright then the only answer is you compare the differences between a command that does work and this command and figure out what's wrong.
you only need to check the @bot line and the function line
gl guessing I suppose. Takes 2 seconds to copy paste
Lol im bored enough :P
And you've already wasted what 10+ minutes taking screenshots of tiny chunks
I don't use text commands anymore, nor do I use "@bot.command" is that correct?
Btw @slate swan is your other "commands" the on message event?
im not sure
i need to check
lol
Just share you code.
I can't help you troubleshoot any further since I've now concluded you have NFI
You should be using a .env file..
Enable necessary intents
intents = discord.Intents.default()
intents.message_content = True # Required for reading messages
Use commands.Bot for prefix-based commands
bot = commands.Bot(command_prefix=PREFIX, intents=intents)
@bot.event
async def on_ready():
print(f'✅ Logged in as {bot.user}! Prefix commands are ready.')
@bot.event
async def on_message(message):
"""Ensures commands still work if on_message() is defined."""
if message.author == bot.user:
return
await bot.process_commands(message) # ✅ FIX: This ensures commands like `.snus` work!
@bot.command()
async def snus(ctx, *, query: str = None):
"""Fetches data from Snusbase API based on user input."""
if not query:
await ctx.send("❌ Please provide a query. Usage: .snus example@gmail.com")
return
try:
url = "https://beta.snusbase.com/api/search"
headers = {
'Authorization': API_KEY,
'Content-Type': 'application/json'
}
payload = {"query": query} # Adjust based on API requirements
response = requests.post(url, headers=headers, json=payload)
if response.status_code == 200:
data = response.json()
if not data:
await ctx.send(f"🔍 No results found for `{query}`.")
return
formatted_data = json.dumps(data, indent=2)
response_message = f"📊 **Results for `{query}`:**\n```json\n{formatted_data[:1900]}\n```"
await ctx.send(response_message)
else:
await ctx.send(f"❌ Error {response.status_code}: {response.text}")
except Exception as e:
await ctx.send(f"⚠ An error occurred: {str(e)}")
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.
ooh cool AI code
Enable necessary intents
intents = discord.Intents.default()
intents.message_content = True # Required for reading messages
Use commands.Bot for prefix-based commands
bot = commands.Bot(command_prefix=PREFIX, intents=intents)
@bot.event
async def on_ready():
print(f'✅ Logged in as {bot.user}! Prefix commands are ready.')
@bot.event
async def on_message(message):
"""Ensures commands still work if on_message() is defined."""
if message.author == bot.user:
return
await bot.process_commands(message) # ✅ FIX: This ensures commands like `.snus` work!
@bot.command()
async def snus(ctx, *, query: str = None):
"""Fetches data from Snusbase API based on user input."""
if not query:
await ctx.send("❌ Please provide a query. Usage: .snus example@gmail.com")
return
try:
url = "https://beta.snusbase.com/api/search"
headers = {
'Authorization': API_KEY,
'Content-Type': 'application/json'
}
payload = {"query": query} # Adjust based on API requirements
response = requests.post(url, headers=headers, json=payload)
if response.status_code == 200:
data = response.json()
if not data:
await ctx.send(f"🔍 No results found for `{query}`.")
return
formatted_data = json.dumps(data, indent=2)
response_message = f"📊 **Results for `{query}`:**\n```json\n{formatted_data[:1900]}\n```"
await ctx.send(response_message)
else:
await ctx.send(f"❌ Error {response.status_code}: {response.text}")
except Exception as e:
await ctx.send(f"⚠ An error occurred: {str(e)}")
fr
account is probably run by an AI too 
lol
im not ai
you sure?
That's what an AI would say
cuz you seem to be incapable of following any instructions
Calm down.
@drifting arrow should i tell mods 
Give him a chance
nevermind
We don't allow/appreciate ableist slurs. And, everyone should chill.
Don't need to antagonize them.
@slate swan, use the command !paste, go to that link, and paste your code there. It's easier for us to read.
Could you open a help thread? #❓|how-to-get-help
You will need to send us the link as well
This is still just this command and two other unrelated lines
i fixed the problem
but i dont think there is a api for beta.snusbase
so i cant use it for my bot
rip
An api for snus is wild
snus
yo i need help with this code, it says ❌ No results found for {query} or invalid response but it showes all the information found in the py but doesnt send through the discord bot https://paste.pythondiscord.com/P5XQ
what was your prompt in that terminal?
wym prompt
well it's a terminal. what did you put in it to get that output?
the 1st image
i did .snus and the email
but it showes in termnial instead of pasting in discord
that response doesnt have "data" as a key
You might want to a) log the response itself and b) not use requests in an asyncio application
they did log the response itself. they printed the whole JSON
line 47
"data" in response
ok
how did you miss this
and saw this instead which was to a completely different person
Using commands doesnt work, asked chatgpt multiple times and didnt help at all.
chatgpt thinks 3 isn't a prime number sometimes
don't use it for anything you don't personally understand. It can and will repeatedly lie to you
will need some code
wym
Like your code
There isn't a reliable way to find what invite someone used
how so
What do you mean how so
cuz like if you do !createinvite, the bot creates an invite linked to the user
do you mean that thats the problem
Not reliably, discord doesn't tell you this by design
Hey umm my chatpacker is working fine but the imports is having a problem i installed everything
i had all of these packages installed when i first had pip
And i have it imported
The heck is a chatpacker
a bot that talks
to users
anyway how do i fix that problem cuz i have the dependcies installed
What happens when you run your code
also you shouldn't be using requests in an async application
use aiohttp
my code doesnt include async
So you're making a synchronous discord bot...how?
!paste - i gotta see this
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.
Click here to see this code in our pastebin.
ok WHY
Why are you hitting discord pretending to come from a user browser
wdym
wdym wdym
it's your code, it's right there
either you're intending to do this, or you copy pasted it from someone who is
this isn't how bots behave and it is super sketchy
That's interesting content you got in that link on line 10
But it looks like it just spams pings with messages from given link
Actually
It contains racist stuff
Did you copy the code from the internet, replace the original link with this one, and ignore the comment on the same line?
Yeah <@&831776746206265384> this stuff is pretty sketchy, they get a token from some unseen place that they feel the need to test against a user endpoint, then send a bunch of racist/homophobic stuff to a channel pinging someone
!ban 1274466637202067509 We don't allow mass DM bots, nor racist & hateful speech, on this server. Nor do we help with projects that contain this type of content.
:incoming_envelope: :ok_hand: applied ban to @lofty crag permanently.
Interesting. I'm surprised this is still a text command and not a slash command
🤔
i'm trying to get a list of members with a specific role, here is what i'm attempting
await discord.Guild.get_role(1334390638120276010)
print(discord.Role.members)```
i keep getting this error:
Traceback (most recent call last):
File "C:\Python\Python311\site-packages\discord\client.py", line 449, in _run_event
await coro(*args, **kwargs)
File "c:\main.py", line 5771, in on_message
await discord.Guild.get_role(1334390638120276010)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Guild.get_role() missing 1 required positional argument: 'role_id'
yeah because discord.Guild.get_role() first argument is self and not role_id
you need an instance of discord.Guild, not the class
and the second line you also print the members from the class discord.Role
seems like you need basic OOP knowledge first
@hollow night
You can only send a single modal at a time.
You can maybe send two buttons each of which open a different modal, if that's what you want
i believe you can send buttons as response to modal submits
Yes you can! you just gotta send a message along with it
Or can you just do buttons? never done straight buttons
yeah. so you'd just chain those to make almost a multi step form
I wonder if I could respond a modal to a modal? 🤔 BRB testing something
:( nope just buttons
components v2 might be something interesting for later
any eta on releaase date?
lmao fair
No modal improvements tho :(
It's basically just an alternative to embeds
^ I don't get why people are excited for this
Instead of improving existing components and taking suggestions serious, they are adding new components to replace embeds
the day when discord listens to people will be a miracle
nothing new
though iirc some people mentioned that this update was sort of "blocking" modals/components updates
to be proven though, i don't really trust/believe it
Oh, interesting
hey I'm new to python, and came here idk if asking for help is allowed but if someone can slide in my dms and help me. I have the script just need some help please 😭
Channels are made for help, ask your questions in the appropriate channel, asking random people to go in DMs is weird
sorry, i don't know if links are allowed here and don't wanna get banned
!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.
im trying to change server vanity using api but it asking for password verification, and when i put pass for mfa it said incorrect pass, but when i use that same pass for vanity change manually then it works
you're probably doing it wrong
bots can't change the vanity
yea, ik that, im using acc token
yes, thats what im not getting what wrong im doing
wait lemme show you code
against tos. will get your discord account banned
That's not allowed
hmm
who know how to work discord.js? im trying to make an ,fortnite shop command that uses https://fortnite-api.com/ shop endpoint to get the fortnite shop data so i can see whats in the fortnite shop in the chat using the command
I already have my api and its keep giving me errors
I could try to make it in python
im using the https://fortnite-api.com/v2/shop endpoint
is that my issue?
I was told that the API is difficult to work with, and that people should use a wrapper 
Python: https://github.com/Fortnite-API/py-wrapper
Node.js: https://github.com/Fortnite-API/nodejs-wrapper
The JavaScript wrapper on their organization seems to be deprecated.
Alright thank you, ima see if the links you have provided will help. I'll text here if i get an error again
@timber dragon Hi, im back i did my command ,fortniteshop and it said "Failed to fetch Fortnite shop data." ima show u my code for fortniteshop.js
const { Client, Language } = require('fnapicom');
require('dotenv').config();
const API_KEY = process.env.FORTNITE_API_KEY;
if (!API_KEY) {
console.error('Error: Missing FORTNITE_API_KEY in .env file');
process.exit(1);
}
const client = new Client({
language: Language.English,
apiKey: API_KEY,
});
module.exports = {
name: 'fortniteshop',
description: 'Get Fortnite Item Shop data!',
async execute(client, message, args) {
try {
const shopData = await client.shop.entries();
if (!shopData || shopData.length === 0) {
return message.channel.send('No items in the shop today.');
}
const shopItems = shopData.map(entry => {
const itemName = entry.name || 'Unknown Item';
const price = entry.price || 'N/A';
return `• **${itemName}** - 🪙 ${price} V-Bucks`;
}).join('\n');
const embed = new EmbedBuilder()
.setTitle('🛒 Fortnite Item Shop (Today)')
.setDescription(shopItems)
.setColor('Blue')
.setTimestamp();
return message.channel.send({ embeds: [embed] });
} catch (error) {
console.error('Fortnite Shop API Error:', error);
return message.channel.send('Failed to fetch Fortnite shop data.');
}
}
};
😭 😭 😭
Using py-cord, for some reason the bot claims it can't ping everyone for my cross server system yet it has the permissions for the channel, but not the role at that would be considered unsafe. If I turn it on for the role, it says it has the permissions. Any ideas on what's wrong here? This is being ran in a slash command.
permissions = channel.permissions_for(ctx.guild.me)
required_permissions = [
permissions.send_messages,
permissions.view_channel,
permissions.mention_everyone if role_id != -1 and not ctx.guild.get_role(role_id).mentionable else True
]
print(required_permissions)
if not all(required_permissions):
missing_perms = []
if not permissions.send_messages:
missing_perms.append("Send Messages")
if not permissions.view_channel:
missing_perms.append("View Channel")
if not permissions.mention_everyone and role_id != -1 and not ctx.guild.get_role(role_id).mentionable:
missing_perms.append("Mention Roles/Everyone (You have a role ID attached but I can't ping it!)")
missing_perms_string = '\n'.join(missing_perms) #this is so bad, can't have new lines in f strings directly.
return await ctx.respond(
f"I don't have the required permissions in {channel.mention}. Missing: ``{missing_perms_string}``",
)
How does @tasks.loop(seconds=30) handle errors? For example, if I run a separate function within that task, if that function errors will the task be terminated or only until the next 30 seconds goes by it will re-run?
i believe if a task errors, it is completely destroyed
IME it doesn't get re run
It's an absolute disaster if it errors
Please do not error your tasks.loop.
🤔 Im in a bit of a sticky wicket
yeah i have a loop in one of my bots that occasionally sends a really long messages, gets bonked by discord, and the task completely dies 🥴 i should get around to adding some proper error handling to it
My bot sends a "question" with an attached button.
How do I detect who has pressed the button and update the parent script that sent the button so my on_message event knows?
!paste
https://paste.pythondiscord.com/4CTA <- main script
https://paste.pythondiscord.com/EJMQ <- the buttons
The command is "test_question" for now. It will send the question, I need to find out who has pressed the button so that main script knows, so my on_message event also knows lol
I dont particularly want to put the on_message event inside of the butons file
you can view.stop() from inside a view, and await view.wait() from outside a view to wait for view.stop() to be called. you can update an attribute on self from inside the view, which can be accessed from the outside
you can wrap this up into a little function that sends a view, and returns who clicked a button
doesnt view.stop() stop the bot from listening to that interaction entirely?
yes. are you trying to have a live feed from inside the view to outside?
I need the button to be able to be pressed multiple times by many users. If the view stops because a single user has pressed it, it defeats the purpose.
when will you stop listening? after a certain amount of time?
IDK when, but it's a trivia bot, The questions pop up and people can either submit a text response, earning double points or view the hints (options really), and earn a single point.
And I need to be able to detect if someone has viewed the hints or not.
sounds like it'd be easier to just handle all of that inside the view callbacks than trying to propagate it up
How about a hint button just do the exact same but with the hint
Just with the hint and edit the score
Well you still need a way to store who pressed what exactly
Alright I came up with a hacky sacky solution
:D
!paste
Buttons file: https://paste.pythondiscord.com/5GVQ
Commands file: https://paste.pythondiscord.com/FQ4Q
:D I store the buttons view and just store all my stuff there :D
And there's no way this will ever cause me issues at any point in the future. Yep. I see no issues being caused by this whatsoever
Is it possible to use a image i have download on my pc for a embed logo?
if so what url do i use for the logo?
what library
"import discord" discord.py
i belive that. Still new so im not 100% sure
thx
Also is there a way to call a embed without a slash command?
"call a embed"?
You can send embeds any time in any channel you want (where your bot has permissions ofc)
Not sure what you mean with "call a embed"
Like i want my bot to brodcast a embed every 20 min for example. How can i do that without using a slash command?
whats the traceback say?
thats also
dont do that
just dont do that
why did you define your command inside a function
what is this?!
Python code
Bump
You say the role isn't mentionable and it's per channel, but you're still checking the role? Lol
Enabling the perm in the channel means all roles can be mentioned; the specific role permissions are overridden in that case.
also the reason for your error is that it needs to be a raw string or the path needs to be POSIX
I'm getting the user permissions using channel.permissions_for, which should be self-explanatory. What is the correct way to get channel perms?
why define ur cmd in a function?
That's correct, but you are also checking if some role is mentionable, remove that part
Just wondering if i could get a suggestion regrading this im making multipurppose bot one of its features it it tracks messages sent in chat and gives the user xp for that and xp is used to rank up this is amazing but this is global and the only way i know of making it server based is structing a json file like this:
Server SERVERID
User USERID
Xp Serverxp
and ive realised when were tallking over 10k people it quickly becomes a very big file, i already have a file called userdata and that has around 10 lines of data per user is there a simpular way i can do this?
You shouldn't be using a json file to track application data, period
using a database?
Yes
i did look into using mongodb i dont really know what the best one is to use ive always used json files
any database is better than json, and any other database is better than mongo
Asterisk before the mongo apologists @ me, there's nuance
how dare you not like mango!!
never heard of such a db
okay ill look into it thanks
Sqlite3 is kinda bad icl
idk postgresql but imma try it
why
that doesn't say a lot but ok
thats an issue with javascript and not sqlite
sqlite on python works fine
!pip asqlite - there's even async versions of it too
Whats the best way to format a dataframe for display on discord, since discord doesnt have complete markdown support?
yo I need help with this snusbase code
what's the question?
the cmd keeps having a error code
which is?




