#discord-bots
1 messages · Page 312 of 1
thats the best i can do sadly
its just simply member.name for username and member.display_name for display name
i dont have any of the documentations on me lol
!d discord.Member.display_name get one
property display_name```
Returns the user’s display name.
For regular users this is just their global name or their username, but if they have a guild specific nickname then that is returned instead.
ty
Getting a role object using id
add_roles
for username aswell hehe
finding for long time
tysm u r W

The user’s username.
The user’s global nickname, taking precedence over the username in display.
New in version 2.3.
i want that each should come one by one not on one line how would i do that
!d discord.Embed.add_field - set the inline argument to False
add_field(*, name, value, inline=True)```
Adds a field to the embed object.
This function returns the class instance to allow for fluent-style chaining. Can only be up to 25 fields.
These ones
you should fix the user creation date
isnt the display name...?
yes same question like why its showing time
alright got it
that would be a display name lol

yeh or u can say it global
user name is zac_the_catlover
Nah, that's the global name, it will be used as the default server nickname
Try and check what both return
tell me hwo
I suppose you can count it as that
Global name
embed.add_field(name="Username", value=member.name, inline=False)
embed.add_field(name="Global Name", value=member.global_name, inline=False)
embed.add_field(name="Display Name", value=member.display_name, inline=False)```
The API returns both. Display name is deprecated and global name is the correct terminology
It's new in discord.py 2.3, that's likely why
So global would return Catlover, but if they changed their nickname in here display_name would display the new nickname correct?
Discord being discord
or am i just on a whole different topic XD
2020-05-16 18:47:32.545000+00:00
2022-01-25 14:46:34.432000+00:00
i doesnt want the time how can i removed it ?
@naive briar am i correct or completely wrong XD
or are yall saying global_name is the exact same at display_name
No, no
😭
If you're talking about Discord, probably
yes
But I assumed that you're talking about discord.py
!d discord.Member.display_name
property display_name```
Returns the user’s display name.
For regular users this is just their global name or their username, but if they have a guild specific nickname then that is returned instead.
i mean let me test it
Since Discord will use the user's global name as the default nickname for every server
!d discord.utils.format_dt
so global name is better i guess in a way, but i like display name
well thats nice to know now... didnt know about global lol
Use this 
huh didnt get
!d discord.utils.format_dt
discord.utils.format_dt(dt, /, style=None)```
A helper function to format a [`datetime.datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime) for presentation within Discord.
This allows for a locale-independent way of presenting data using Discord specific Markdown...
also my roles are showing like this
Because it's a list of roles objects
!d discord.Asset
class discord.Asset```
Represents a CDN asset on Discord.
str(x) Returns the URL of the CDN asset.
len(x) Returns the length of the CDN asset’s URL.
x == y Checks if the asset is equal to another asset.
x != y Checks if the asset is not equal to another asset.
hash(x) Returns the hash of the asset.
for user creation date you should do a timestamp
they look cleaner
yeh fixing
@turbid condor
??
give me a sec ffs
how could you make this remember giveaways, like ones that havent been finished yet
like if it restarted or crashed or sum
Not sure but you will need to create a task to check if the giveaway has ended and also store the end date and time of the give away in the db
Database
Where should i put?
no crap 😭
what host are you using...
A panel my friend hosted for me
weird...
Why?
never seen the website before
At least it will auto keep alive
The part where you are assigning the role
i have a host too
which is bot hosting net
idk if its the best, but its free :)
im poor 😭
@turbid condor rate my credits command :)
Haven't seen it
Make everything inline = false for credits
but then it makes it long :/
and it does to much XD
i have to add this so discord server doesnt inline with special thanks to
embed.add_field(name="\u200b", value="\u200b", inline=False)
The credits won't look good on mobile
it never does
mobile = poopy
also uh
can you tell me if this is correct..?
latency = round(bot.latency * 1000)
server_count = len(bot.guilds)
user_count = len(bot.users)
command_count = len(command_list)
cpu_usage = psutil.cpu_percent(interval=1)
ram_usage = psutil.virtual_memory().percent
disk_usage = psutil.disk_usage('/')
network_stats = psutil.net_io_counters()
network_inbound = network_stats.bytes_recv
network_outbound = network_stats.bytes_sent```
are these correct or false?
idk if psutil is good, but ive been using it for the cpu and stuff like that
@turbid condor ^
Its good
so it is calculating correctly?
Yes
oh okay then
@turbid condor can i send you some code in dms and you review it? rather not send it here XD
i dont use GitHub XD, ill just send a paste okay?
You should if you are looking to get into coding it is a good thing to save your code
yeah ill do that some other time XD
Seems like your bot is using more disk then you have
Try running it on pc or use pydroid app
Token-Generator 🤨
very rules following
Yes
Where
5. Do not provide or request help on projects that may violate terms of service, or that may be deemed inappropriate, malicious, or illegal.
here
@vapid parcel
like how r u doing
embed.add_field(name="User creation date",value=formatted_creation_date,inline=False)
#formatted_creation_date = format_dt(ctx.author.created_at, style='F')
if ctx.guild and member.guild == ctx.guild:
embed.add_field(name="Joined Server", value=f'<t:{str(member.joined_at.timestamp()).split(".")[0]}:R>', inline=False)
embed.add_field(name="Account Created", value=f'<t:{str(member.created_at.timestamp()).split(".")[0]}:R>', inline=False)```
uhh
?
is there an issue?
if it works, then it works?
not my problem
cry abt it ig
@vapid parcel ayo see my problem here bud
embed.add_field(name="User creation date",value=formatted_creation_date,inline=False)
formatted_creation_date = format_dt(ctx.author.created_at, style='F')
do you have a code for slash ban kick ect commands please
no, we dont just code for you but we can help you with problems you face
facing error saying that discord.ext.commands.errors.CommandInvokeError: Command raised an exception: UnboundLocalError: cannot access local variable 'formatted_creation_date' where it is not associated with a value
!e ```py
counter = 0
def increment():
counter += 1
increment()
@slate swan :x: Your 3.12 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "/home/main.py", line 6, in <module>
003 | increment()
004 | File "/home/main.py", line 4, in increment
005 | counter += 1
006 | ^^^^^^^
007 | UnboundLocalError: cannot access local variable 'counter' where it is not associated with a value
you are trying to access a varriable not defined in your scope
Those commands already exist in discord with objectively better functionality
@slate swan :warning: Your 3.12 eval job has completed with return code 0.
[No output]
blud really suggests using globals
Saturday, May 16, 2020 11:47 AM
now getting this output from this tho i just want that year month and day only

@slate swan :white_check_mark: Your 3.12 eval job has completed with return code 0.
1
suggesting to use globals isnt a help at all
Shouldn’t be using globals like this
Bro was talking shit and now hes getting shit talked 😭
you dont care then why you help

💀
💩 code
how can i do like this like if we mention then it aslo give other user info
You need to be more specific
What other user info?
Like when i mention other user aswell for ex
!userinfo @still spade
Like this it shows other user info aswell
What other user info?
presumably whoever was mentioned?
i think he means this?
i showed him this, and he wanted to copy and idc if he does
but im sure thats what he means
Discord already shows all that 🤷♂️
nuhuh
you do code review?
If you're using discord.py (or any fork of it), you can see the attributes (left side) of the Member object:
https://discordpy.readthedocs.io/en/stable/api.html#discord.Member
Then in the embed, you just add fields and set the values, like their image shows
#1035199133436354600 has a Code Review tag just for that
does anyone want to make a bot together
i only want 1 person to view it, i kinda dont wanna post it publicly like that lol
what type?
we can see, ive worked with multipurpose bots
i can make game, utilities, music, moderation and all types of commands
YouTube, Spotify, sound cloud, all off the list lol
if i can trust you then sure
since when is sound cloud off
they closed their api
of course, i wanna know abt the bot and what it is
so its off the limits now
ohh dang
i have a video on it
i do have music in my bot, but it will be removed soon, because it breaks youtubes ToS and i didnt know that
sure
Yes like if i mentioned my sample bot so i have see hes info like that
does anyone want to work on a discord bot project?
sure
what r you working at rn
no idea
wdym
you must have a bot or two
if you asking people to work with u
@oak abyss ??
no im asking to start a new project
oh
sure but i need to see if you are capable enough
you can come on dms if you want
@oak abyss ??
?
ive prob got more experience then you buddy
anyways yes dms
add me bro

Sketchy shit..
ahah
I mean I’ll do it but it’s not one of my strengths
Is there any place where i can refer to someone else's discord bot text based game?
How could I fix this?
Traceback (most recent call last):
File "C:\Users\berka\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\app_commands\commands.py", line 828, in _do_call
return await self._callback(interaction, **params) # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\berka\Desktop\folder\main.py", line 96, in post
await interaction.response.send_modal(modal=Modal)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: InteractionResponse.send_modal() got some positional-only arguments passed as keyword arguments: 'modal'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\berka\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\app_commands\tree.py", line 1248, in _call
await command._invoke_with_namespace(interaction, namespace)
File "C:\Users\berka\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\app_commands\commands.py", line 853, in _invoke_with_namespace
return await self._do_call(interaction, transformed_values)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\berka\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\app_commands\commands.py", line 842, in _do_call
raise CommandInvokeError(self, e) from e
discord.app_commands.errors.CommandInvokeError: Command 'post' raised an exception: TypeError: InteractionResponse.send_modal() got some positional-only arguments passed as keyword arguments: 'modal'```
randmon_number = random.randint(1, 1000000)
class Modal(discord.ui.Modal):
def __init__(self):
super().__init__(
"Post"
)
self.emworks = discord.ui.TextInput(label="Commission", min_length=5, max_length=1500, required=True, placeholder="write here!", style=discord.TextStyle.paragraph)
self.add_item(self.emworks)
async def on_submit(self, interaction: discord.Interaction) -> None:
work = self.emworks.value
async with self.bot.db3.cursor() as cursor:
cursor.execute("INSERT INTO a (number, user, text) VALUES (?, ?, ?)", (randmon_number, self.emworks.placeholder, interaction.user.id))
await self.bot.db3.commit()
channel = await self.bot.get_channel(1066505917929111587)
await channel.send(work)
@bot.command(name="sync2")
async def sync2(ctx):
await bot.tree.sync()
print("This command work")
await ctx.send("all commands should be synced")
@bot.tree.command(name="post", description="Post's your commission")
async def post(interaction: discord.Interaction):
await interaction.response.send_modal(modal=Modal)
```
Last line interaction.response.send_modal(Modal())
I’m on mobile right now so the code doesn’t really make sense to me but that’s why I got based off your trace back error
You need to initialise your Modal object
Dam, I already done that but I'm still going through an erro
error*
File "C:\Users\berka\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\app_commands\commands.py", line 828, in _do_call
return await self._callback(interaction, **params) # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\berka\Desktop\folder\main.py", line 96, in post
await interaction.response.send_modal(modal=Modal())
^^^^^^^
File "C:\Users\berka\Desktop\folder\main.py", line 52, in __init__
super().__init__(
TypeError: Modal.__init__() takes 1 positional argument but 2 were given
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\berka\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\app_commands\tree.py", line 1248, in _call
await command._invoke_with_namespace(interaction, namespace)
File "C:\Users\berka\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\app_commands\commands.py", line 853, in _invoke_with_namespace
return await self._do_call(interaction, transformed_values)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\berka\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\app_commands\commands.py", line 842, in _do_call
raise CommandInvokeError(self, e) from e
discord.app_commands.errors.CommandInvokeError: Command 'post' raised an exception: TypeError: Modal.__init__() takes 1 positional argument but 2 were given```
randmon_number = random.randint(1, 1000000)
class Modal(discord.ui.Modal):
def __init__(self):
super().__init__(
"Post"
)
self.emworks = discord.ui.TextInput(label="Commission", min_length=5, max_length=1500, required=True, placeholder="write here!", style=discord.TextStyle.paragraph)
self.add_item(self.emworks)
async def on_submit(self, interaction: discord.Interaction) -> None:
work = self.emworks.value
async with self.bot.db3.cursor() as cursor:
cursor.execute("INSERT INTO a (number, user, text) VALUES (?, ?, ?)", (randmon_number, self.emworks.placeholder, interaction.user.id))
await self.bot.db3.commit()
channel = await self.bot.get_channel(1066505917929111587)
await channel.send(work)
@bot.command(name="sync2")
async def sync2(ctx):
await bot.tree.sync()
print("This command work")
await ctx.send("all commands should be synced")
@bot.tree.command(name="post", description="Post's your commission")
async def post(interaction: discord.Interaction):
await interaction.response.send_modal(Modal())
```
drugs
do you know a single security bot that deletes links on scan?
if it thinks its a virus?
i kinda made my own for that, if it starts with www or https or http it will scan it through virus total, if it thinks its a virus then it deletes it, there might be a lot of fake flags but i think its pretty cool
Where are you calling the Modal class
Don't call it like that, its not how it works.
Can I get the command itself from a slash command (hybrid_command)?
ctx.message.content works when the command is called via a prefixed command but is blank when the command is called via a slash command.
could you abreviate on what your doing/trying to do
I have a command called /when, when users call it the bot replies with the time difference to a predetermined date
When using prefixed commands i had .when reply in all lowercase and .WHEN reply in all uppercase. I am running into issues having uppercased commands within my slash commands so I was instead looking to get command itself.
I can get the command typed easily when its a prefix command, but I cannot find a way to get it when its a slash command
if it's just a hybrid, you can just get them from Context.invoked_with [works for slash and prefix], slash command can't really be case insensitive, so you can directly just do Context.command.qualified_name
discord.ui.Modal only takes keyword arguments, so super().__init__("Post") is causing an error, you can do super().__init__(title="Post"), but i think it's best if you rewrite them this way instead, ```py
class Modal(discord.ui.Modal, title="Post"):
emworks = discord.ui.TextInput(...)
...
it's a lot more cleaner
drugs
worked perfectly for my prefix command, but I can't get my slash command to be uppercase. Don't think I can but I am not worrying about it since this is suck a clean way of doing it for my prefix command. Thanks.
welcome
How do I make slash commands using discord.py?
discord.py 2.0+ slash command info and examples. GitHub Gist: instantly share code, notes, and snippets.
``line 4, in <module>
from discord_slash import SlashCommand
ModuleNotFoundError: No module named 'discord_slash'`
i tried to fix it still not working
`from discord.ext import commands
import discord, string, random, os, json, mysql.connector
from discord.ext import commands
from discord_slash import SlashCommand
intents = discord.Intents.default() # You can adjust these based on your bot's needs
intents.typing = False
intents.presences = False
client = commands.Bot(command_prefix="/", intents=intents)
slash = SlashCommand(client, sync_commands=True) # Initialize SlashCommand extension`
anyone help plz
Don't use that module if you already use discord.py
discord.py has built-in support for slash commands so you don't need anything else
so what to do
should i remove from discord_slash import SlashCommand
Remove everything related to discord_slash
ok
And read through https://gist.github.com/AbstractUmbra/a9c188797ae194e592efe05fa129c57f to know how to make slash commands with d.py
discord.py 2.0+ slash command info and examples. GitHub Gist: instantly share code, notes, and snippets.
Is it normal that drugdown menu only can use once?
No you can use it multiple times
@slate swan the bot is working now but command dont get registered
😭 idk why
Continue reading the page
Especially the syncing part
oke
do most bots do 30 days or what? i kinda wanna know what most bots do for security reasons?
It's your choice how much age you want the account to be
ill prolly keep it 30 tbh, i mean if i really need to, i can just ban alts XD
class discord.Interaction```
Represents a Discord interaction.
An interaction happens when a user does an action that needs to be notified. Current examples are slash commands and components.
New in version 2.0.
Error is pretty self explaining
And slash command in discord.py use interaction instead of ctx
You named it ctx instead of interaction and now it's complaining about not knowing what interaction is
Check this
Are you referring to interaction.response.send_message?
What is not working specifically?
catty .-.
Hi 🐈
I'm good, as usual. How about you?
not bad, just exams are going on currently sob
Me? 
I never used disnake, so no
class disnake.MessageInteraction```
Represents an interaction with a message component.
Current examples are buttons and dropdowns.
New in version 2.1.
cant seem to find view property from anywhere
sob
!d discord.Interaction.defer first use this on top of the code
No documentation found for the requested symbol.
whoa
You need to defer the intersection if you need more time to respond
!d discord.InteractionResponse.defer
await defer(*, ephemeral=False, thinking=False)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Defers the interaction response.
This is typically used when the interaction is acknowledged and a secondary action will be done later.
This is only supported with the following interaction types...
Returns the follow up webhook for follow up interactions.
hey
is a serverlist against ToS?
doesnt give an invite, just shows the servers the bot is in.
Should be fine with just member counts
okay so thats good?
cuz i know if it makes an invite and invites you to all the servers it breaks the privacy ToS or whatever
!ytdl 
Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.
For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:
The following restrictions apply to your use of the Service. You are not allowed to:
1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service; (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;
3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;
9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
this is breaking youtubes ToS
we cant help you here if you are breaking ToS in some way
yeah
when i heard abt it breaking ToS i was sad, i had a whole bass booster for it a volume control and like everything
i was really sad :/
yep, but soundcloud you could use, but api is closed so you are really limited ig
You can't? 
I remember you can accept discord.File or discord.Attachment for the user to input files
Use it as a typehint
Use asyncio.subprocess.create_subprocess_exec instead of subprocess.run. You should also probably find asynchronous alternatives for other operations you're doing there
bro didnt read anything we said 😭
oh suppose i have a command that yk calculates some stuff using this lib
!pip strmath
thats cool
For conversion they're still going to use ffmpeg
Aren't they
but whenever i do something like 9**99999999 bot crashes,,, i was thinking to do something with asyncio.wait_for then use 3 second or n second tmeout
do yk if it is possible?
I thought they said they were going to provide the bot with a file instead of a YouTube URL
YouTube allows human users to download content as far as I know
not anymore
.
you need yt premium
just read it...
Why is the download button still on the platform
premium
Oh right
youtube just being an L
real
like normal.
In any case the command is still ok if it accepts a legal file, no?
"we lose money" not like you are losing 10b a year bro 😭
It could be any file
Doesn't sound like it
If it's been downloaded it means the user subscribed to YouTube Premium
If it's been downloaded from YouTube
i think, from youtube side its okay to add premium and stuff, they also now dont allow ad blockers, main source of their income is just ad
sobb
You won't be able to await anything during the calculation to allow the wait_for to process
you can download without YouTube premium
just not through youtube
Downloading YouTube content not through YouTube sounds fishy
That doesn't sound legal, if you're talking about mp3 downloaders
strmath.evaluate is synchronous, i was thinking to use Thread but ig it was blocking the main event loop smh
i was informing 😭
how do you think it works in bots..?
Do these downloader websites have YouTube Premium that they can download content?
tbh idk how they do it
no lol
sed, i need to now remove math command, wait i have an idea
but it does break youtubes ToS thats all i know
The GIL probably wouldn't allow it
GIL?
Why? Use a math API, make a request to it and send the response
Global Interpreter Lock
it doesnt need to keep the mp3 file forever XD
hmmm
XD
oh fk
But why do you need it as a file? For the ffmpeg command?
hes using mp3
i used to spell interpreter as interepter 
😭
do you have any math api link? :3 would be helpful to me 
isnt it basically using discord as file host?
yall hear about the file host for discord? they are changing it to max 24 hours or sum now
yh
with new ex, is and hm param to attachment endpoint
where ex refers to the expiry of an attachment
oh thankie
You can create a discord.File from an io.BytesIO
!d discord.File
class discord.File(fp, filename=None, *, spoiler=..., description=None)```
A parameter object used for [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.Messageable.send) for sending file objects.
Note
File objects are single use and are not meant to be reused in multiple [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.Messageable.send)s.
huh linux is weird
here let me ask a question.
@bot.hybrid_command(name="codechallenge", description="Sends a random coding challenge with required difficulty")
@commands.guild_only()
async def codechallenge(ctx, difficulty):
available_difficulties = ', '.join(coding_challenges.keys())
if difficulty not in coding_challenges:
error_embed = discord.Embed(
title="Error",
description=f"Invalid difficulty level. Available levels: {available_difficulties}",
color=0xFF0000
)
await ctx.send(embed=error_embed)
else:
challenge = random.choice(coding_challenges[difficulty])
embed = discord.Embed(
title=f"Coding Challenge ({difficulty.capitalize()})",
description=challenge,
color=0x5865F2
)
response = embed
await ctx.send(embed=response)```
how can you make a hybrid command do the options like app commands normally do..?
for difficulty it would show easy, medium and hard, how to do that basically?
That is called choices, see the example for more info
examples/app_commands/transformers.py lines 80 to 87
# In order to support choices, the library has a few ways of doing this.
# The first one is using a typing.Literal for basic choices.
# On Discord, this will show up as two choices, Buy and Sell.
# In the code, you will receive either 'Buy' or 'Sell' as a string.
@client.tree.command()
@app_commands.describe(action='The action to do in the shop', item='The target item')
async def shop(interaction: discord.Interaction, action: Literal['Buy', 'Sell'], item: str):```
!pypi DiscordDatabase it's cause of this 
And of this https://github.com/Exenifix/postgres-auto-backup
not reading all of that gonna be real
await member.remove_roles(role)
discord.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions
my dc bot has admin perms and for some raeson it gives me an error
Your bot can't remove the role
Check if the role you are trying to remove is higher in hierarchy than the bot or not
wdym?
class Difficulty(Enum):
easy = 0
medium = 1
hard = 2
@bot.hybrid_command(name="codechallenge", description="Sends a random coding challenge with required difficulty")
@commands.guild_only()
async def codechallenge(ctx, difficulty: Difficulty):
available_difficulties = ', '.join(coding_challenges.keys())
if difficulty not in Difficulty:
error_embed = discord.Embed(
title="Error",
description=f"Invalid difficulty level. Available levels: {available_difficulties}",
color=0xFF0000
)
await ctx.send(embed=error_embed)
else:
difficulty_name = difficulty.name
challenge = random.choice(coding_challenges[difficulty_name])
embed = discord.Embed(
title=f"Coding Challenge ({difficulty_name.capitalize()})",
description=challenge,
color=0x5865F2
)
response = embed
await ctx.send(embed=response)```
Thank you for the help :)
In role settings check if your bot's role is lower then then role you are removing
it is
how do i fix it?
Move it above the role you are removing
thank you
god that is so stupid how is that a thing??? like what it makes no sense
Role hierarchy is very important. If it didn’t exist, anyone who had kick/ban perms could do it to anybody, even administrators
wtf 
yall i have a problem. im tryna edit an embed with discord-webhook, but idk how to edit fields from the embed.
right now it keeps adding new fields to the embed each time it edits the message
do i send the code as a file or can i just send it all in a message
its 39 lines
lmao
why does this exist
whats the namespace for using large int as slash command option type
talking about dpy, in disnake its commands.LargeInt ;-;
dosent have one make a custom converter
ye
@bot.command()
async def add(ctx, id, ammount):
with open("bank.json", "r") as f:
users = json.load(f)
user = ctx.guild.get_member(int(id))
if user == None:
await ctx.reply("لا يمكنك إضافة عملات لشخص غير موجود في السيرفر")
else:
await open_account(user)
users[str(user.id)]["wallet"] += int(ammount)
await save(users)
await ctx.send(f"تمت إضافة {ammount} عملات ل {user.mention} بنجاح !")
async def open_account(user):
with open("bank.json", "r") as f:
users = json.load(f)
if str(user.id) in f:
return False
else:
users[str(user.id)] = {}
users[str(user.id)]["wallet"] = 0
await save(users)
return True
async def save(users):
with open("bank.json", "w") as f:
json.dump(users, f)
Why the data* is not saved in the json file
when I use add command
the wallet still 0
JSON is a convenient and easy-to-read data storage protocol that's widely accepted by most programming languages. However, we caution against its use for storing and retrieving data in an asynchronous environment like a Discord bot.
- It's a file-based data storage, which makes it vulnerable to race conditions
- You'll need to implement your own synchronization primitives to avoid corrupting data
- If you're not careful, you could accidentally wipe your entire JSON file.
Solution? Use a database. Recommended schema are SQLite, PostgreSQL, and MongoDB.
- Async libraries exist on pypi for each of these
sqlite --aiosqlite(or Danny's wrapper,?tag asqlite)
postgresql --asyncpg
mongodb --motor - Databases organize your data into tables, and are fast at inserting, retrieving, and removing records
- You can impose uniqueness constraints to ensure against duplication
- The Python libraries enforce synchronization for you
- The query language is intuitive, you can get running with simple queries in just a few hours!
JSON is pretty much widely accepted as a poor data storage medium for Discord bots. The only reason it’s still used is due to tutorials perpetuating the false idea that JSON is a valid choice
Speaking of databases, PostgreSQL wasn't as hard as I thought
Should've tried a little earlier
Doesn’t it use a similar structure to JSON, or is that MongoDB
MongoDB is
But the wacky syntax scared me 🫠
what wacky syntax 
INSERT INTO spooky
@tasks.loop(seconds=1)
async def send_potato_pics():
send_potato_pics.stop()
potato_links = [links]
channel_id = priv
channel = client.get_channel(channel_id)
if channel:
embed = discord.Embed(title="Random Potato Pic", description="Enjoy this distinguish potato!", colour=discord.Color.yellow())
embed.set_image(url=random.choice(potato_links))
await channel.send(embed=embed)
new_interval = random.randint(10 * 60, 60 * 60)
send_potato_pics.change_interval(seconds=new_interval)
send_potato_pics.stop()
send_potato_pics.start(interval=new_interval)
@client.event
async def on_ready():
send_potato_pics.start()
Terminal:
2023-10-14 19:08:50 ERROR discord.ext.tasks Unhandled exception in internal background task 'send_potato_pics'.
Traceback (most recent call last):
File "C:\Users\-\AppData\Roaming\Python\Python310\site-packages\discord\ext\tasks\__init__.py", line 239, in _loop
await self.coro(*args, **kwargs)
File "c:\Users\-\Desktop\Vale\Scripts\Pepsi_Fish\main.py", line 136,
in send_potato_pics
send_potato_pics.start(interval=new_interval)
File "C:\Users\-\AppData\Roaming\Python\Python310\site-packages\discord\ext\tasks\__init__.py", line 392, in start
raise RuntimeError('Task is already launched and is not completed.')
RuntimeError: Task is already launched and is not completed.
The message gets sent by the bot but idk why that thing appears
thats why you dont start tasks in on_ready
oof
well i found a solution to it
and im stupid for not having thought about it, which is just putting:
if send_potato_pics.is_running():
return
lmao
Can I use SQLite on mobile, or any other databases?
can anyone help my commands aint getting synced
`@bot.event
async def on_ready():
try:
await bot.change_presence(activity=discord.Game("JarRat-Builder by BotX"))
print(f'Logged in as {bot.user.name}')
except Exception as e:
print(f'Error in on_ready: {e}')
await bot.tree.sync()
@bot.event
async def on_command_error(ctx, error):
if isinstance(error, commands.CommandError):
await ctx.send(f"An error occurred: {error}")
`
also im using @bot.command()
anyone??
you are syncing in the except block
how do i fix it tho?
well maybe move it out from exept block 
how?
inb4 just alt+tab
...
its shift + tab ;)
dammit
@slate swan how do i fix it :/
how do you even make a discord bot?
and also like what level of experience in python is discord bot programming for?
is it possible
you use a library that interacts with discords gateway
what library?
you can write bots at any "level", but you'll understand more if you know the basics
oh discord.py right?
yep
i do know the basics but not too much beyond that
im mostly into gamedev anyway
if you actually know some basics then you should have no problems at all
basics, by my pov is a high level understanding of things like concurrency, apis, http, sockets, oop, etc..
if you know those, you're good to go imo
yes
ok then nevermind 😂
anyone??
i have no idea what any of those are
not just the gateway. the whole api
Can you paste your whole code
ok
You don't really need all of that knowledge to get started with discord.py
literally just pull out it out of the except block
well you have two options, either learn these stuff before making a bot, or your can make a bot and learn these stuff overtime
But it's a good to know kinda thing
how to do that 😭
we were joking about that earlier because shift+tab is really all you have to do
you just have to unindent the part where you sync the tree
and it pulls it back into the function scope
i was mostly just wondering im not actually too intrested in making a discord bot
FYI the things i mentioned earlier is not just specific to discord bots (not even python), these are things you'd likely come across as a game developer if you ever want to add multiplayer to your game
didnt work the command didnt get synced 💀
i know, ill get into those more in the future
i did try a tutorial on multiplayer once and it left me completely confused
Do you know how or can help me out with it?
show code
i want to send a embed with link of a attachment on that same message that ive send, is it possible? if yes could you please send me the code? i use nextcord
We don't code for you and send you the code. You come up with your code, and we help you into fixing the issues you're facing.
sure i can send you my current code
What problem are you having
Also, is the code written by ChatGPT or similar
no, all by me
i want to have the image as a url in the embed
Are you asking how to do that
yes because my method using attachment://filename.suffix doesnt work
i dont want the image as thumbnail or image in the embed but as a hypelink in description if that possible
You cannot set the url of an image
Also, you said you don’t want it to be an image in the ember, or a thumbnail but those are the 2 main ways to pass an image
for an arguement for a hybrid can you make it have like a limit of how many letters can go in it or something?
idk how to explain what im asking lol
instead of saying letters lets say characters i guess.
I don't think so
damn
!d discord.ext.commands.Range
class discord.ext.commands.Range```
A special converter that can be applied to a parameter to require a numeric or string type to fit within the range provided.
During type checking time this is equivalent to [`typing.Annotated`](https://docs.python.org/3/library/typing.html#typing.Annotated) so type checkers understand the intent of the code.
Some example ranges...
cat moment
oh ty
i need help
What is it?
how can i use a condition where i can break the loop if the message starts with a particular message only
is it possible to do so ? @naive briar
What are you even trying to do
Your bot will just get rate limited and eventually banned if you send so many messages
which library can i use to make a DJ discord bot
yes which is why i want a command to stop it
same happened to be but i got temp ban and its over now
it got to me with the purge command
i purge way to many messages some time
btw anyone know a good library to make a DJ bot
youtubedl ?
!ytdl
Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.
For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:
The following restrictions apply to your use of the Service. You are not allowed to:
1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service; (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;
3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;
9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
May be worth noting ^
lol
Music bots these days shouldn't be made
why not i want a music bot
every music bot is getting banned 🥲
It'll get sued by YouTube and deleted by Discord, but sure go ahead
It'll get sued by Spotify and deleted by Discord, but sure go ahead
;-;
well rip my time spent on making the logo for the bot
Or just don't do it, the command is pointless spam
isnt there any way to make a music bot without it getting banned ?
Don't use a music provider service, and have the rights on the music
So you'd have to store the mp3 files (without downloading from YouTube, Spotify, etc.), and have the rights on the music
So it's not even worth it
whats the point if u cant download it from yt or spotify 🥲
damn
so music bots are a no go
yepa
but what about hyra and chip ?
Lucky, but their time will come sooner or later
shucks
As far as i know hydra got flagged once before too
Not as popular as e.g. Rythm, so probably didn't catch YouTube's attention
Yeah so if you want to make a music bot just keep it to your server
den making a personal bot wont be a problem ?
i see
No it won't, unless YouTube realizes it at some point with logs or whatever
That doesn't excuse ToS breaching
You just won't get caught that's about it
I never said it wasn't against ToS
so its illegal but they wont care ?
But yeah just don't do it

They care, you're just one random across all other randoms doing it
💀
And if they catch you, unlucky
what r the consequences ?
Copyright stuff
Depends
Court will eventually tell you
That will happen
As said, depends
hmm
U might even get an ip ban
;-;
Rythm had to cease their actions within a short timespan, if they didn't then it probably goes higher e.g. you get sued and asked to go in court, then yeah you'll probably have to pay compensations
YouTube doesn't care if you delete your bot or not, they want you to stop your actions
If they can find another provider that allows it to stream their music, then probably 
soundcloud ?
;-;
To be honest, I still don't get why people would want to listen to music in Discord
Isn't SoundCloud api closed?
ive got no idea
ToS disallows it as well
Any music provider with common sense disallows it
sum countries dont have access to spotify
like ours we only recently got access to it
what if they pay to buy their service ?
As a discord activity yeah
Still no
but yea who needs music bot when they got activities
You will need written permissions for streaming music
damn
well
ig no music bot for us den
XD
how can i remove the umm.
the brackets from the message ?
use random.choice
like i said use random.choice
but i have used it ?
no you did not
!e ```py
import random
data = [1, 2, 3]
print(random.choices(data))
print(random.choice(data))
@slate swan :white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | [3]
002 | 1
👍
show how smile_names is defined
Did you save the changes? 
yes, i have autosave enabled
how do i do that ;-;
print(...) ?
print smile names ?
yes
is there a error in this code:
channel = bot.get_channel(int(CHANNEL_ID))
i dont know you tell us
!d discord.ext.commands.Bot.get_channel
get_channel(id, /)```
Returns a channel or thread with the given ID.
Changed in version 2.0: `id` parameter is now positional-only.
it can return None if thats what you mean
prefered syntax would be channel = .get_channel(...) or await .fetch_channel(...) this way you make sure you receive the channel object
ook ty
oh wait im dumb
🙂
IT WORKED
HOW
@slate swan could you please explain how it worked ?
printing it before embedding it worked
how tho
because you didn't save
it proved you didn't
;-;
wat
im confusion
OH
CUZ THE BOT WAS RUNNING
to run the print statement i had to run it again
i see
imagine not having hot reload 
what is a hot reload ?
!d discord.commands.Bot.reload_extension
No documentation found for the requested symbol.
!d discord.ext.commands.Bot.reload_extension
await reload_extension(name, *, package=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Atomically reloads an extension.
This replaces the extension with the same extension, only refreshed. This is equivalent to a [`unload_extension()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.unload_extension) followed by a [`load_extension()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.load_extension) except done in an atomic way. That is, if an operation fails mid-reload then the bot will roll-back to the prior working state.
There ^
It’s a method. You call it.
Wherever you want.
it prolly goes at the end of a function ?
If you want.
can i dm ?
No.
🥲
why do people want to randomly dm others, it's acting so weird
noo cuz i dont wanna make a fool outta myself
🥲
i trierd using the menthod from earlier ? but it didnt work for me or rather im not sure how to use it
🥲
What on earth are you even doing
discord.py ig
py-cord sounds nice but discord.py is a lil easier to understand ?
meh its whatever
lol
I think py-cord is an active discord.py fork so pretty much the same thing but idk why I even use it
Py-cord is a trash can of a fork
^
ELABORATE
Their implementations are shit
for example
General code design, their implementation of slash commands, context menus etc make no sense
the slash commands are so easy to use what are you talking about
implementation != usage
mah bad
And that’s the whole problem. Pycord focused on making it as easy as possible for users to port to slash commands
Instead of actually formulating an implementation that makes sense
import discord
bot = discord.Bot()
we need to limit the guilds for testing purposes
so other users wouldn't see the command that we're testing
@bot.command(description="Sends the bot's latency.") # this decorator makes a slash command
async def ping(ctx): # a slash command will be created with the name "ping"
await ctx.respond(f"Pong! Latency is {bot.latency}")
bot.run("TOKEN")
Like, what is this
Why is there a separate Bot object for slash commands. Slash commands don’t receive context, so no clue why they’re using it
no way that's how theyve implemented it bro...
how does discord.py do it? I'm curious
no wonder I heard so much stuff about pycord being shit
First example on their page. Such a stupid implementation
It makes literally no sense why they would do that
i lost it when I saw context
A command tree which you sync, and different classes for Interactions and such
how is it better? again im just curious
because it makes more sense
that doesn't explain it to me
because you're more familiar with discord.py (probably) and im more familiar with pycord
nah I dont use discordpy yet it makes more sense than what example penguin sent
ah okk thanks for explaining
what library do you use?
disnake?
Is there something objectively bad in pycord's slash command implementation though
A command tree allows for better control with syncing and managing slash commands. Slash commands never receive context so it makes no sense for them to have it. Furthermore, having the exact same decorators, and using the same class just confuses the end user
Okay so for discord dev portal, if you change the profile of the bot, does it actually update or do you have to make a new bot?
it updates
yeah it does
how long does it take
not very long
like an ETA
its instant im pretty sure
its never worked for me
I'd say max 1 minute
try restarting discord
did you update bots pfp or applications pfp?
well im asking for a friend, but when ive done it, i think it was icon
not app icon
well it is pretty much instant
@quick gust mind giving me a sales pitch to convert to disnakeism? everyone seems to hate pycord
pycord is just more famous somehow
It's probably because of advertisement
and honestly just switch to dpy
I'm still using disnake because im too lazy to switch
yeah that indian youtuber
isn't dpy discontinued?
oh you might be slightly outdated
are they continuing it
Since March 2022, yes
bros behind 😭
lmao yeah im slightly outdated
yeah just slightlyy outdated
SLIGHTLY
I just make bots and py-cord works perfectly for me there's no reason to switch libraries so I havent been keeping up
sory python pepol
Nah there are still many believers of discontinuity of dpy
yeah idk why lol
After all, it's your choice
that was YEARS ago 😭
tbh hikari looks noice
Their docs confused me
💀
yeah true but once you start using it, it's fine
Every time I need to find something, I have to guess which super class have it
They could definitely remake the docs though
I guess it's familiarity thing
Though I'm used to reading horrible documentations like Apple and Windows documentations
what is the best way to handle multiples tasks in a discord bot so it don't disrupts the tasks of the other users?
!d discord.ext.tasks.loop
@discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True, name=None)```
A decorator that schedules a task in the background for you with optional reconnect logic. The decorator returns a [`Loop`](https://discordpy.readthedocs.io/en/latest/ext/tasks/index.html#discord.ext.tasks.Loop).
this you mean?
i have a chat bot and i want to give access to it to other people, it generates response and send, but just to be on safe side i don't want it to brick when multiple people are trying to generate a message with it
more like a gpt bot but instead of openai it is a local llm
what will be the way to go with it? Add a user queue so they do it one at a time?
@discord.ext.commands.max_concurrency(number, per=discord.ext.commands.BucketType.default, *, wait=False)```
A decorator that adds a maximum concurrency to a [`Command`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Command) or its subclasses.
This enables you to only allow a certain number of command invocations at the same time, for example if a command takes too long or if only one user can use it at a time. This differs from a cooldown in that there is no set waiting period or token bucket – only a set number of people can run the command.
New in version 1.3.
i have found only about queue on discord music bots, is there any good resources to look into on how to implement it
There are some built-in queue implementations, but the best fit for your case is probably asyncio.Queue
!d asyncio.Queue
class asyncio.Queue(maxsize=0)```
A first in, first out (FIFO) queue.
If *maxsize* is less than or equal to zero, the queue size is infinite. If it is an integer greater than `0`, then `await put()` blocks when the queue reaches *maxsize* until an item is removed by [`get()`](https://docs.python.org/3/library/asyncio-queue.html#asyncio.Queue.get).
Unlike the standard library threading [`queue`](https://docs.python.org/3/library/queue.html#module-queue), the size of the queue is always known and can be returned by calling the [`qsize()`](https://docs.python.org/3/library/asyncio-queue.html#asyncio.Queue.qsize) method.
Changed in version 3.10: Removed the *loop* parameter.
This class is [not thread safe](https://docs.python.org/3/library/asyncio-dev.html#asyncio-multithreading).
You can have the command put the request into the queue and have a task to process the request
this won't mess with the interactions / slash commands right?
like users will be able to keep sending the commands and it will just put it in queue when one is done it moves to the next persons request
Nope
Yes. Or do you want to limit how many times a user can request?
:3
as long as it is in queue its all good

i am gonna check it out and see if i can implement it
You can’t directly. I just send a button that when clicked sends the modal
does discord.py offer a way to run synchronous code without blocking it's main event loop excluding threads? if not, what's the solution for doing it manually using asyncio? if that's not possible either, what's the best practice for spawning threads under an async event loop
Asyncio's loop objects have a run_in_executor method for this
The executors can be process pool executors or threadpoolexecutors
so i must spawn either a process or thread for this? :/
if its a short-lived task, await loop.run_in_executor(None, callback, ...) or await asyncio.to_thread(callback, ...) is fine, but for longer-lived workloads i would suggest creating the thread/process manually so you have more control over it's lifetime
alrighty, thanks!
[2023-10-15 13:30:58] [WARNING ] discord.http: We are being rate limited. PUT https://discord.com/api/v10/applications/987664938627653673/commands responded with 429. Retrying in 26.35 seconds.
Anyone know what this mean?
Have you tried reading it?
rate limited, but what it means after that
What does it mean after what
idk
What
This is the question you asked. How do you not know what the question you asked means
PUT discord.com/api/v10/applications/{id}/commands is the endpoint for overwriting your current global commands, so the error means discord doesn't want you to sync your commands so quickly
i've tried adding it but there still seems to be some issue with it, it will not take into the request of second users response in and will show it as failed
Hello
hi
Do someone know how i can make my bot send a webhook when someone use a command ?
MemberJoinMonitoring:
creation_time All commands related to the Creation time trigger.
No Category:
help Shows this message
Type $help command for more info on a command.
You can also type $help category for more info on a category.
!d discord.TextChannel.create_webhook
await create_webhook(*, name, avatar=None, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Creates a webhook for this channel.
You must have [`manage_webhooks`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_webhooks) to do this.
Changed in version 1.1: Added the `reason` keyword-only parameter.
!d discord.ext.commands.Context.channel
Returns the channel associated with this context’s command. Shorthand for Message.channel.
Is there any way to ban users marked with Unusual DM Activity (the new Automod feature)?
!d discord.Member
class discord.Member```
Represents a Discord member to a [`Guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild).
This implements a lot of the functionality of [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User).
x == y Checks if two members are equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User) instances too.
x != y Checks if two members are not equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User) instances too.
hash(x) Returns the member’s hash.
str(x) Returns the member’s handle (e.g. `name` or `name#discriminator`).
Is it even available to the public API?
I don't know
https://discord.com/developers/docs/resources/user#user-object-user-flags
If it's supported, it's not documented
I'd say it's not supported though
Especially recently, Discord doesn't have the best track record with that type of stuff
How did you implement it?
does .get_guild() not work anymore?
!d discord.Client.get_guild
get_guild(id, /)```
Returns a guild with the given ID.
Changed in version 2.0: `id` parameter is now positional-only.
It does
Right, im using it but my guild returns NoneType every time i reference it
Can you tell where you are using? Like in an event or command?
I defined the guild globally, and i am referncing it the line directly below defining it
guild = bot.get_guild(MY ID IS HERE)
STAFF = get(guild.roles, name="TSK STAFF")```
So it isn't inside an event or command?
No.
In that case the problem might be because it gets called even before your bot cache is ready
Cant u just use py guild = ctx.guild.id Staff = guild.get_role()
I was thinking that, should i wait()?
It's not a command
Oh alr
Cant use commands.Context outside a function
Alr
I don't think that will solve it u can try it
What do you recommend?
What r u tryna do?
I'd say just recall the guild where you need it
Yes, but im trying to grab this role beforehand of the function call
where it will be used
Oh
Let me change up my code a bit
Try getting the role inside the function
@patent lark 
I did this, still returns NoneType
And yeah i grabbed the role inside the function
Still returned NoneType
Hmm can you show the function
Sure.
Wrong chat 😭
@bot.listen("on_message")
async def on_message(message): # Called when a chat is sent
if message.author.bot:
return
STAFF = get(guild.roles, name="TSK STAFF")
if STAFF in message.author.roles:
return
if banned_msgs in message.content.lower():
await message.delete()
await message.channel.send("Message Moderated.")
Guild is defined at the top of my code. Returning NoneType
Just to be sure the role returns none or the guild?
Fetch the guild inside the on message too
Alright
Cuz the problem remains same the get_guild gets called before the on_ready if it's outside
Which results in the guild being none
That fixed my problem.
Thank you, I figured if i just made the guild global i would be able to reference it in another scope
You need to wait for bot to have loaded cache inorder to use get
thanks
Yo @turbid condor
Im also having another issue
I have a list of strings, and when this list of strings is referenced i get:
TypeError: 'in <string>' requires string as left operand, not bool
Not quite understanding it.
!e True in ""
@shrewd apex :x: Your 3.12 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "/home/main.py", line 1, in <module>
003 | True in ""
004 | TypeError: 'in <string>' requires string as left operand, not bool
ah i fixed it
@bot.event
async def on_ready():
print(f'Logged in as {bot.user.name}')
try:
synced = await bot.tree.sync()
print(f"Synced {synced} commands.")
except Exception as e:
print(e)
# Start the queue manager as a background task
asyncio.create_task(queue_manager())
async def queue_manager():
while True:
# Wait for a task in the queue
interaction, input = await response_generation_queue.get()
await process_response_generation(interaction, input)
@bot.tree.command(name="generate")
async def generate(interaction: discord.Interaction, input: str):
if not interaction.response.is_done():
await interaction.response.defer()
user_data = {
'interaction': interaction,
'input': input}
if not response_generation_queue.empty():
await response_generation_queue.put(user_data)
await interaction.followup.send(f"You're placed in queue. Current position: {response_generation_queue.qsize()}.")
return
asyncio.create_task(process_response_generation)
What went wrong? 
it will create the response for user 1 but as soon as the user 2 interacts with it, it will say interaction failed after 2 sec
and then a full error log of the interaction.defer()
Did you get any tracebacks?
File "/usr/local/lib/python3.10/dist-packages/discord/app_commands/commands.py", line 828, in _do_call
return await self._callback(interaction, **params) # type: ignore
File "/workspace/bot.py", line 64, in convert
await interaction.response.defer()
File "/usr/local/lib/python3.10/dist-packages/discord/interactions.py", line 661, in defer
await adapter.create_interaction_response(
File "/usr/local/lib/python3.10/dist-packages/discord/webhook/async_.py", line 219, in request
raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/discord/app_commands/tree.py", line 1248, in _call
await command._invoke_with_namespace(interaction, namespace)
File "/usr/local/lib/python3.10/dist-packages/discord/app_commands/commands.py", line 853, in _invoke_with_namespace
return await self._do_call(interaction, transformed_values)
File "/usr/local/lib/python3.10/dist-packages/discord/app_commands/commands.py", line 846, in _do_call
raise CommandInvokeError(self, e) from e
discord.app_commands.errors.CommandInvokeError: Command 'generate' raised an exception: NotFound: 404 Not Found (error code: 10062): Unknown interaction
Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/discord/app_commands/commands.py", line 828, in _do_call
return await self._callback(interaction, **params) # type: ignore
File "/workspace/bot.py", line 64, in generate
await interaction.response.defer()
File "/usr/local/lib/python3.10/dist-packages/discord/interactions.py", line 661, in defer
await adapter.create_interaction_response(
File "/usr/local/lib/python3.10/dist-packages/discord/webhook/async_.py", line 219, in request
raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/discord/app_commands/tree.py", line 1248, in _call
await command._invoke_with_namespace(interaction, namespace)
File "/usr/local/lib/python3.10/dist-packages/discord/app_commands/commands.py", line 853, in _invoke_with_namespace
return await self._do_call(interaction, transformed_values)
File "/usr/local/lib/python3.10/dist-packages/discord/app_commands/commands.py", line 846, in _do_call
raise CommandInvokeError(self, e) from e
discord.app_commands.errors.CommandInvokeError: Command 'generate' raised an exception: NotFound: 404 Not Found (error code: 10062): Unknown interaction
That's very weird
Does the process_response_generation have long blocking code (synchronous)?
it takes user response and then send it to LLM which then generates response and respond back nothing much
i think it impacts the interaction in a way that unless the GPU gets free it won't move to the next one right
what library are you using to interact with the llm
Guys is there a hot reloader for discord.py?
no
u have to manually reload u can use reload_extension along with watchfiles
disnake has one inbuilt
!pypi cogwatch
Automatic hot-reloading for your discord.py (or other supported libaries) command files.
What if I use auto-save with my IDE, would that just crash the bot?
Hello, what should I do if the library is not installed? discord-components. Help pls
discord-components in not suppoerted any more i think
I have an error in the bot, here is the code itself. He doesn't see the discord components and says to install them.Here is the code itself
import discord
from discord.ext import commands
from discord_components import DiscordComponents, Button
intents = discord.Intents.default()
intents.typing = False
intents.presences = False
bot = commands.Bot(command_prefix='!', intents=intents)
DiscordComponents(bot)
tickets = {}
@bot.event
async def on_ready():
print(f'Logged in as {bot.user.name}')
@bot.command()
async def ticket(ctx):
await ctx.send("Нажмите кнопку, чтобы открыть тикет.",
components=[Button(style=1, label="Открыть тикет")])
@bot.event
async def on_button_click(interaction):
if interaction.component.label == "Открыть тикет":
guild = interaction.guild
user = interaction.user
channel = await guild.create_text_channel(name=f"ticket-{user.name}",
category=guild.categories[0])
await channel.set_permissions(user, read_messages=True, send_messages=True)
tickets[channel.id] = user.id
await interaction.respond(content="Ваш тикет был создан!",
ephemeral=True)
elif interaction.component.label == "Закрыть тикет":
channel_id = interaction.channel.id
user_id = tickets.get(channel_id)
if user_id:
user = await bot.fetch_user(user_id)
await interaction.respond(content=f"Тикет закрыт пользователем {user.name}!",
ephemeral=True)
else:
await interaction.respond(content="Тикет не найден!",
ephemeral=True)
await interaction.channel.delete()
bot.run('YOUR_BOT_TOKEN')
is this discord.py?
Yes
then you can use discord.py to create buttons
If you wish to use Buttons (and Selects/Dropdowns), please view the documentation for discord.ui here:
https://discordpy.readthedocs.io/en/latest/interactions/api.html#bot-ui-kit
You can also view examples in the repo: https://github.com/Rapptz/discord.py/tree/master/examples/views
Can you correct the code, or rather remove what is not needed? And make sure there are no mistakes
no
Okay, thank you for your help
yes that was the issue its resolved now thanks for the help
It can now handle multiple interactions at once but for some reason it does not send them a followup message of that they are in the queue
await response_generation_queue.put(user_data)
await interaction.followup.send(f"You're placed in queue. Current position: {response_generation_queue.qsize()}.")
return```
Why are you checking if the queue isn't empty before putting the request, by the way? 
is it not suppose to be like that
How did you put the first request if the queue would be empty then?
check this
do correct me if im wrong would appreciate the help
can someone help me with my pip installation its saying this
from discord_slash import SlashCommand
ModuleNotFoundError: No module named 'discord_slash'
i alr have everything install idk why im gettting this


