#discord-bots
1 messages · Page 974 of 1
i agree
ty
.
whats the update_json function
actually, I could just make a commandtree and assign it to client
And you don’t need either to make slash commands 😳
stop
You can do it all from requests without any library abstraction
slash commands are cool
andy go work on rin
No
requests is blocking
Request as in RESTful requests
nullptr = andy?
I never said aiohttp nor requests etc
mmhmm
😔 urllib requests !
Commits in rewrite branch was just my late April fools

you got the error?
and what about revolt?
Dropped
andy is this the correct way
i dont see an issue there , do you have a error handler?
is this really what I wanna do
No clue I haven’t used this nor read documentation
so basically you do nothing now
No I have a secret project
this is enough info

or I subclass CommandTree with the right error handling function, make an instance of it, then assign it to a discord.Client instance because I don't need bot anymore since I have a CommandTree instance already

Use hikari and be cool
~~Use hikari and ~~be cool
use hikari and be cool
i mean, you dont need to waste your time reading docs and experimenting stuff with that 😔
Use hikari~~ and be cool~~
mention about the codebase
hikari is much better typed
and makes sense
apart from that, it allows you to use the rest freely, and the http/rest client is documented as well Client.http never mentioned coughs
I'm happy to hear that
show me a bot you wrote in hikari now
I bet it's wonderful
it's nice
bump 👉👈
!d disnake.Member.add_roles
await add_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Gives the member a number of [`Role`](https://docs.disnake.dev/en/latest/api.html#disnake.Role "disnake.Role")s.
You must have [`manage_roles`](https://docs.disnake.dev/en/latest/api.html#disnake.Permissions.manage_roles "disnake.Permissions.manage_roles") permission to use this, and the added [`Role`](https://docs.disnake.dev/en/latest/api.html#disnake.Role "disnake.Role")s must appear lower in the list of roles than the highest role of the member.
How does discord work out API limits
Is it an average of minutes or each minute etc.
not until you ask a question
i wanted to script a lil spammer fore anoying my friends but idk why its not working thats the video i used https://youtu.be/LMb5kfJAzws
Yo hows it going this is how to code a discord spammer tool in python, super easy and you can totally spam anything with it. be safe!
Understand that this is for entertainment purposes only! :)
NEW DISCORD: https://discord.gg/E8JJ8tjYfS
Be wary its still being set up. no judgy judgy.
-------------------------------------------------------...
im really bad at this sorry
why we making spammers? Can't you make something productive?
cause its a small thing and things that are productive are mostly bigger i guess
Discord API has a global rate limit which by default is 50 requests/second (This number can be raised if your bot is big enough). It also have an endpoint specific ratelimit which mostly isn't documented.
TOS police is not happy
😦
The per guild limit is 5 per second right?
It's dynamic
if u could help me i would try to do somthing prodoctive
Wait, do u know bout the endpoint?
So if I wanted to code the bot to prevent rate limit it would have to cool down if it exceeds 50 in a second
@dull terrace he ratelimits are dynamic
Or 3000 in a minute
They change with each request u make
Prevent API calls
does some one have time and could help me ?
My bot edits messages quite a lot for each user
I mean, you could ask here
You really can't check on what number of requests your bot is on
Is it a good idea to trigger a cool down if my bot reaches 50 message edits per second though
Or 50 button uses
i wanted to code a spammer but it always tells me for i in range ("0 repeats") is not closed and idk why
i am tbh bad at this
they use buckets for each endpoint which the ratelimits are dynamic
range accepts an integer data type
I notice things like owobot has a cool down, there must be some logic to that
!e
for i in range(5):
print("uwu")```
Setting the atomic keyword to False allows you to add multiple roles in one request. Otherwise, you will make more than 1 request depending on how many roles you're going to add.
@slate swan :white_check_mark: Your eval job has completed with return code 0.
001 | uwu
002 | uwu
003 | uwu
004 | uwu
005 | uwu
what does that mean
ohhh thanks
well
can i add u when i have more questions that i can finde u and dont need to spamm here if no its also okay sorry
Thanks. Is there any reason to set atomic to False?
I mean, I dont accept random friend requests nor am I online as much, so I might not be the good option here
aight but still thanks
its alright
can i send in the code here i am making ?
the spammer cause there are more things not working 😂
!paste
Pasting large amounts of code
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 floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
^^
Does disnake handle rate limits for me? 
No
i put it in there
Ok
i'll go fail biology now, bai bai
good don't waste your time on biology, programming has a better future
tell that to my parents and then tell me
Howdy, I was wondering how I could change the discord name of my bot to display its prefix, is there a way to not use ctx? and could I put that on my on_ready function?
fun fuct: i didn't waste my time on Italian literatures and i've ended school with a score of 95/100
that's pretty based
thats.....not a discord bot?
the link of my shame
yes is just a spammer
sorry my englisch is bad
well

i hated my italian teacher too
she was a lot like to a thresh TV celebrity, and i hate thresh TV too lol
sorry
I keep finding way to create command but that's not what I want to do so does anyone know?
you could set the activity in the bot constructor or use update_presence
how so


!d discord.Client.change_presence
await change_presence(*, activity=None, status=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Changes the client’s presence.
Example
```py
game = discord.Game("with the API")
await client.change_presence(status=discord.Status.idle, activity=game)
``` Changed in version 2.0: Removed the `afk` keyword-only parameter...
ha thank you
^^
but that changes its activity status not server nickname
Maybe I could use this command I already made:
async def get_prefix(bot, message):
prefixes = fetch('prefixes')
config = fetch('config')
default_prefix = config["prefix"]
guild = message.guild
if guild:
return prefixes[f'{guild.id}']
else:
return default_prefix
``` The problem is that it requires a message so not really possible
property display_name```
Returns the user’s display name.
For regular users this is just their username, but if they have a guild specific nickname then that is returned instead.
user = ctx.guild.me
user.edit(nickname=new nickname)
I saw this, but it uses ctx
You can't change the nickname of an user neither the display name in a server
im high
yeah but the only user I want to change the nickname is the bot
it's only that, in order to show the prefix in the nickname for each server
!d discord.Guild.get_member
get_member(user_id, /)```
Returns a member with the given ID.
Changed in version 2.0: `user_id` parameter is now positional-only.
this is a stupid thing btw, when_mentioned_or exists
like those two
ahem what does Guild.me return?
Yeah i never used that in this way lol
they don't do it by default probably the owner of that server changed them name manually
!d discord.Guild.me idk
property me```
Similar to [`Client.user`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client.user "discord.Client.user") except an instance of [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member"). This is essentially used to get the member version of yourself.
^^
uhm
it returns the bot's.....
wdym Ashley?
Well btw let's return to what you want to do
ye
it'll return a Member object of the bot in that case
probably it will be mostly impossible to do it in real time
Do you have a different prefix for ever guild?
because you'll need a task loop
so you could loop through all guilds on startup and see if the nickname already contains the prefix, if not change it
then every time someone changes a guilds prefix, you also update the nickname
doing on startup will not make any sense, he needs a loop task
why so?
iterating through every guild and checking its prefix then changing its username and re-iterate every 30 mins uwu
mmh
because if the bot will be added in another server his display_name will not change in the server where it is added
or set nickname on guild_join, when prefix change command is ran add a line of code to update the bot nickname
this will be the best way
naisu
"he"
yes he lol
bad choice
No it
Hey it's an english issue to have three third person, in italian it/he/she are the same thing 
why?
if your bot joins a server, you most probably have a default prefix set to new servers, hence not making your nickname eligible for if in a change in the prefix
lol exactly
but if he has a change_prefix command he can change the name in that command
? I have a default prefix, on join the nickname is by default with the default prefix, when change prefix is ran it updates the nickname
right

you could do that
yay
this is useless and when_mentioned_or is better~
?
just make slash commands
LOOOOOT Better
???
nothing lmao, you continue
And say that i've saw a lot of stupid ideas in this channel
Hey Kayya
my favorite pokemon is Darkrai your crying bayleef doesn't make me sad
rude

Hola
here is command, here is the error,
and yes, i am an admin the server
any clue?
i tried to mute myself in a vc, while in it
the bot hasnt got the mute_members permission or lacks behind in the role/permission hierarchy
nope, it has a higher role than me
for discord, you have the same role level from yourself
admin too
have you got members turned on here
yes
still you are the owner of the server
and discord doesn't let mute or ban users with the same role level
im not
!paste
Pasting large amounts of code
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 floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
hm ic
#bot-commands
Bro you can't mute someone who has your same role level, that's all.
Im tryna convert requests into aiohttp for an ip lookup command, however when I run the command I get discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body In message_reference: Unknown message
the bottom admin role is mine, the top is the bot role
and the bot doesn't have the admin role
sorry
why do you want someone's ip, huh?
even myself?
is it possible to mute a server owner?
nope
to check the hosting?
oh lol
and i own a network
You do know that there are many bots that have IP Lookup commands, right?
so its useful
@blissful sparrow u need to use an API
I do use an api
interesting 
ip api
Then what is the issue
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In message_reference: Unknown message
idk, who even uses discord's bots anyways in the end
Yes
import socket
ip = socket.gethostbyname(socket.gethostname())
print(ip)```
this is returned, it works when I used requests
so im assuming i put either too many awaits
or something else entirely
You referred a message that was deleted
Most likely
okay but NOW, i tried to mute a random member, with no perms, still the same error
and the member is lower than me in roles and perms
?
Is it lower in roles with bot
yes
It depends on the hierarchy
it has admin
If there is a role above the persons role that has disabled send messages, they won’t be able too
it can ban the same member, but can't mute them
geocoder library exists
😔
if thats the case then I defos put an await in the wrong place
import geocoder
_ip = geocoder.ip('IP ADDRESS')
print(_ip)
If the error was cause of awaits it would be a different error
Whats that idk
!e
from asyncio import run
async def main():
await print("yes")
run(main())
@vale wing :x: Your eval job has completed with return code 1.
001 | yes
002 | Traceback (most recent call last):
003 | File "<string>", line 5, in <module>
004 | File "/usr/local/lib/python3.10/asyncio/runners.py", line 44, in run
005 | return loop.run_until_complete(main)
006 | File "/usr/local/lib/python3.10/asyncio/base_events.py", line 641, in run_until_complete
007 | return future.result()
008 | File "<string>", line 3, in main
009 | TypeError: object NoneType can't be used in 'await' expression
lmao
or py import hitman hitman.pay_visit(ip=ip)
awaiting a print 😔
@blissful sparrow see it is TypeError
*None cause print returns nothing
ik
Everything is already parsed etc im not rewriting it
https://caught-lackin-in-8k-by-cyberghost.cf/k2RrqZw4
thats my server btw
@blissful sparrow just try to make the deletion delay lower
how do you get the city
IP APIs give that...

lol gl ssh aint even 22
😳
i know it's a joke but mods will 😡
I know 🤷♂️ I really meant something else
like what?
and legit every port is almost whitelsited
how do i dm a server member with just an ID?
cant explain
await member.send('thing')
You mean every port is open?
or await user.create_dm()
No need
no, I have to open ports on tempest firewall
That is an unnecessary API call
they all closed by default
Tried dat.
lol = await user.create_dm()
AttributeError: 'NoneType' object has no attribute 'create_dm'```
user = client.get_user(payload.user_id)
welp you have the wrong object
Yea
user = client.get_user(payload.user_id)```
is client a discord.client or bot?
bot
!d disnake.ext.commands.Bot.get_user
get_user(id, /)```
Returns a user with the given ID.
still thinking about rate limits
libraries handle rate limits for you right? so i should just make a cooldown that prevents one individual using a too large share of resources?
@slate swan, is this code in a on_raw_reaction event?
what?
how you gonna implement a cooldown, its nearly complicated
alr
How do you know?
payload.user_id
user = await client.fetch_user(payload.user_id)
await user.send('thing')```
class cooldown:
async def check(interaction):
guild_id, send = interaction.guild_id, interaction.send
if guild_id in guild_cooldown:
if guild_cooldown[guild_id]:
return True
guild_cooldown[guild_id] = True
guild_cd = random.uniform(0, round(len(guild_cooldown) / 50, 1)) + 3
message = f"{cooldown_msg}\nPlease wait {guild_cd} seconds."
await send(message, delete_after=guild_cd)
first_call = False
prints(guild_id, message)
else:
guild_cooldown[guild_id] = False
guild_cd, discord_cooldown = 0.2, round((len(guild_cooldown)) / 50, 1)
if discord_cooldown > guild_cd:
guild_cd = discord_cooldown
first_call = True
asyncio.get_event_loop().create_task(
cooldown.wait(first_call, guild_cd, guild_id)
)
return False
async def wait(first_call, guild_cd, guild_id):
await asyncio.sleep(guild_cd)
if first_call and not guild_cooldown[guild_id]:
del guild_cooldown[guild_id]
elif not first_call:
del guild_cooldown[guild_id]
prints(guild_id, "cooldown expired " + str(guild_cd))```
this is how it's currently implimented
prevents more than 5 requests per second per guild and 50 across discord
Hell
TypeError: fetch_user() got an unexpected keyword argument 'id'```
yeah check the updated code
Ohhh.
It's positional
get didn't work
It works, thank you.
user = get_user or fetch_user
await getch_user(user_id, *, strict=False)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Tries to get the user from the cache. If fails, it tries to fetch the user from the API.
there
He using disnake?
What's wrong with my current code?
Same
!d discord.ext.commands.Bot.getch_user
I am?
oh
Lol
are you?
@dull terrace you could just make a dict like {guild_id: datetime}
Isn't DPY discord.py?
Yea
who wants to use 50 list comps and lambdas to solve this problem?
I am on discord.py.
this is pretty old code from when i first started on the bot
This is a discord bot channel in a python server.
yes
user = await client.fetch_user(payload.user_id)```
worked
You mean the thing I suggested is old or your current implementation is
!d disnake.Guild.getch_member
await getch_member(member_id, *, strict=False)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Tries to get a member from the cache with the given ID. If fails, it fetches the member from the API and caches it.
If you want to make a bulk get-or-fetch call, use [`get_or_fetch_members()`](https://docs.disnake.dev/en/latest/api.html#disnake.Guild.get_or_fetch_members "disnake.Guild.get_or_fetch_members").
oh this exists too
current implimentation, i was still using strings for datetime back then 
oh god
i think the best way is per person if they're mashing buttons and then just consider what to do if i do end up getting time outs by discord when it happens
Discord has protection from rapid buttons clicking on client side
so basically don't bother adding anything?
Hello there it's me again hehe, I was wondering if with @commands.cooldown(rate=1, per=30, type=commands.BucketType.user) there was a way to send in the chat that the cooldown has been reached ?
Just members clicking buttons can't cause your bot to get ratelimited but your bot responding can
technically someone could try to hack around the client side and get the bot timed out if they're malicious right?
By client side I mean discord app
I saw online that python @command_name.error async def command_name_error(ctx, error): if isinstance(error, commands.CommandOnCooldown): em = discord.Embed(title=f"Slow it down bro!",description=f"Try again in {error.retry_after:.2f}s.", color=color_code_here) await ctx.send(embed=em) would be a way but I'm not sure where to add this line of code exactly
You meant that as well?
you mean the discord api or the actual app
The decorator you mentioned is for commands only
because if it's the app then it's definitely open to malicious people
so after my commands.command() and async def command_name(...) I can put this ? with the corresponding command name?
You can do the cooldown ofc
That’s when your wrappers ratelimit system will become your fallback
So basically
@commands.command(...)
@commands.cooldown(...)
async def command(...)```
but if it ratelimits based on total usage rather than individuals then a person could crash the app for everyone else right
That's called decorating
yes yes
And you can add as many decorators as you'd like to but I think they execute from top to bottom
Theoretically yes, but again ratelimits are based on buckets
And the global ratelimit is 50/1s
And to the lower decorator the result of upper one is parsed
and would there be a decorators to send the cooldown message like You're trying that too fast try again in x second?
or
should I create the async def
and then call the decorator from that command ?!
is that it ?!
hmm, still have no idea the best way to approach this 
If the command is decorated with cooldown and the cooldown for the function is hit, it raises CommandOnCooldown exception
And even the possibility of someone modding the client to get rid of the client sided ratelimit is NICHE at best. Not to mention it won’t be easy to bypass it for the gateway
And you can handle it in your global error handler
maybe just guild limits if their use gets insanely high like 25 per second
I’m sure discord has made it so it won’t send to the gateway
This overall is a non-problem
so just stop wasting my time on it
I am not sure where exactly the button blocking for client happens
why does owobot and others even have cool downs then?
It happens when you spam the button for a few seconds
It is either the API request decline or client side blocking
I didn't mean that
Oh
or do they use cooldowns due to responding to message content
Larger bots will get a higher ratelimit threshold per request as well
Afaik verified bots' limits are higher by like a lot
oh really?
Lemme check the dev portal rq
has anyone got a really dumbed down way to convert normal commands in to / commands?
Also not to mention the ratelimit bucket system just makes it harder to exceed your request limits
I cant get my head around it
Still want to keep the regular prefixed cmds as well though
What coding softwares are recommended for discord bots? Or is there anyway you can get the discord package on visual studio code?
hmm i might be overestimating how fast people will click, a quick test shows that i'm around 1 click per second or a little faster while i know exactly what thing i want to do next
I spent 4 hours on a bot on replit got rate limited
replit uses shared ips doesn't it?

Depends what lib you use
I think so
dpy 2
Local IDE
ive not used any other fork
Pycharm, vsc, etc.
I use vsc
yes they do
same
Sorry can't help with migrating to slash commands with dpy
Cause I hate their implementation
@carmine pasture try launching the terminal inside the app and running pip install discord.py
shame discord-slash not compatible with dpy 2
Disnake has much better slash commands implementation
didn't they drop support for discord-slash recently
i switched over to disnake and so far it's been very good
Same here
Doesn't work. Error message pops up
d.py has something like that
discord-slash would give me rate limit errors when i started my bot a bunch
I cant understand for the life of me how to implement them into cogs
Install python interpreter from official site and during installation put on "Add Python to PATH" checkmark
Also install python extension for VSC
discord.py 2.0a slash command info and examples. GitHub Gist: instantly share code, notes, and snippets.
Lemme see
pip : The term 'pip' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of
the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
- pip install d.py
-
+ CategoryInfo : ObjectNotFound: (pip:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
thats the error message btw
Yes command not found
Do the steps I said
alr lemme try that
in dpy 2.0 you can use the app_commands.command() decorator in your cog and it gets added like regular commands
python -m pip
``` maybe
the amount of times i've forgotten to check add python to path when installing on aws 
tryna implement as hybrid though
@boreal ravine Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.
thats the error message
so prefix works and slash
also i alr have the vsc python extension installed
im reading the example gist
okay so in order to add a cooldown message if you're on cooldown i've added this line of code but the message is sent 4 times everytime for some reason and I don't understand if it's because the round function tries to round the number too many time:
@commands.Cog.listener()
async def on_command_error(self, ctx, error):
if isinstance(error, commands.CommandOnCooldown):
await ctx.send(f"{round(error.retry_after)} seconds left")```
Have you installed the interpreter yet
both decorators work in your cog, the gist is just a bit out of date (inheriting from app_commands.Group is optional)
I gotta delete it and install again as I have it installed ages ago but lemme check if u selected it correctly
Ok
so for example for my ban command, would I just do ?
@app_commands.command(name='ban', description='Ban a user')
@commands.command(aliases=['beam'])
@commands.check_any(
commands.is_owner(),
commands.has_permissions(ban_members=True)
)
async def ban(self, ctx, member: discord.Member, *, reason=None):
if reason==None:
reason=" No reason provided"
embed = discord.Embed(title=' Successfully Banned!', description=f'{member.name}#{member.discriminator} has been Banned. Reason: `{reason}`.', color=0xff0000)
embed.set_thumbnail(url=member.avatar)
embed.set_footer(text="Requested by: {}".format(ctx.author.display_name), icon_url=ctx.author.avatar)
await ctx.send(embed=embed)
await ctx.guild.ban(member)
if member ==None:
embed = discord.Embed(title=' Error banning member!', description='Please provide a valid @mention/ID!', color=0xff0000)
embed.set_footer(text="Requested by: {}".format(ctx.author.display_name), icon_url=ctx.author.avatar)
await ctx.reply(embed=embed)
ignore the indent after app commands
its vsc being annoying
oh no you cant combine both decorators, but you can write two functions and then a shared method they call
Can I ask a discord.py related question here?
yes
Okey
what if we said no 
so My discord bot goes offline randomly even tho the machine is online
how big is the bot
cos my friend has a verified bot and it was a sharding issue
hmm
I searched on google but it didn't help
async def remove(ctx, channel: discord.TextChannel):
if ctx.author.guild_permissions.manage_channels:
await channel.delete()
this command doesn't work when i try it
File "C:\Users\\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\core.py", line 169, in wrapped
ret = await coro(*args, **kwargs)
File "c:\Users\\Desktop\Programming\PyScrap\cogs\core_cog.py", line 115, in start
await ctx.channel.send(view=view_level, embed=embed)
File "C:\Users\\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\abc.py", line 1504, in send
data = await state.http.send_message(
File "C:\Users\\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\http.py", line 420, in request
raise HTTPException(response, data)
disnake.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In components.0.components.0.options.2: The specified option value is already used
anyone know the issue
wait I think I found the issue
embed = disnake.Embed(
title="Welcome!",
description="""
Time To Begin Your Python Journey!
How much experience do you have with python?
""",
color=ORANGE,
)
select_level = Select(
placeholder="",
options=[
SelectOption(label="No knowledge of python at all", value="noob", emoji="😶"),
SelectOption(label="Slight experience with python", value="beginner", emoji="😮"),
SelectOption(label="I know basic python", value="beginner", emoji="😎"),
],
)
view_level = View()
view_level.add_item(select_level)
await ctx.channel.send(view=view_level, embed=embed)
the code
What are you hosting it on, mate?
read channel topic
Sorry :(_ _
@commands.command()
@commands.has_permissions(manage_channels=True)
async def remove(ctx, channel: discord.TextChannel):
await channel.delete()
It's a channel topic, continue
A jetson Nano
tf is that
why?
im just running my test bot off my laptop 
It is not test
no venv or anything
get a 3 euro server from 100up
help someone ;/
disnake.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In components.0.components.0.options.2: The specified option value is already used
Yep, get a PebbleHost Minecraft Server, 3$, Quick Support and Strong Servers
it still doesn't work
it does nothing at all when i run it
No work involved
how to make cogs after update in v2 ?
do you have channel delete perms
just a reminder in a cog you need self
it has
Sorry?
woah ton of messages
I wanted to do a project than buy it for 3$, If I sold my solution it wud be like 7000$
Hello hello, I have a small issue with a command to display the cooldown it might have, everytime, the bot sends the message several time and I have no idea why it does that, here is the problematic code:
@commands.Cog.listener()
async def on_command_error(self, ctx, error):
if isinstance(error, commands.CommandOnCooldown):
retry = error.retry_after
remaining_time = str(datetime.timedelta(seconds=int(retry)))
embed = discord.Embed(title=":clock1: Slow Down!!", description=f'{ctx.author.mention}, you can use this command again in ' + str(remaining_time), color=0xE74C3C)
await ctx.send(embed=embed)```
Can Anyone help Me With Just filling up some data into a bots code which i find Difficult cauze i am no bot developer. Any help is much appriciated!
how so?
depends how u want to store it, whether its via db file or json
@commands.command()
@commands.has_permissions(manage_channels=True)
async def channel(ctx: commands.Context, channel: disnake.TextChannel):
await ctx.channel.send(f"Deleting {channel}!")
await channel.delete()
uhh one sec
forgot to await it
https://github.com/Midorina/Shinobu
this is the bots code repository
with which i need help!
@jovial pilot
Extremely Sry For bothering Yall !
np
@commands.command()
@commands.has_permissions(manage_channels=True)
async def channel(self, ctx: commands.Context, channel: disnake.TextChannel):
await ctx.channel.send(f"Deleting {channel}!")
await channel.delete()
what would the command be here
!channel channel-name
if its not in a cog then @commands.command() does nothing
yes it does
still having trouble with that, idk why it sends the message multiple times
you just have to add the command manually then
its via sql db
@commands.command()
@commands.has_permissions(manage_channels=True)
async def channel(ctx: commands.Context, channel: disnake.TextChannel):
await ctx.channel.send(f"Deleting {channel}!")
await channel.delete()
bot.add_command(channel)
I use json atm so I can't help with that
like so
@vagrant brook
sqlite or an sql server?
ohk
ik but why even bother doing that
yeah ik
just saying you can 🤷♂️
can someone help me with my problem :/
i thought that was arl
embed = disnake.Embed(
title="Welcome!",
description="""
Time To Begin Your Python Journey!
How much experience do you have with python?
""",
color=ORANGE,
)
select_level = Select(
placeholder="Choose your skill level",
options=[
SelectOption(label="No knowledge of python at all", value="noob", emoji="😶"),
SelectOption(label="Slight experience with python", value="beginner", emoji="😮"),
SelectOption(label="I know basic python", value="beginner", emoji="😎"),
],
)
view_level = View()
view_level.add_item(select_level)
await ctx.channel.send(view=view_level, embed=embed)
File "C:\Users\\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\core.py", line 169, in wrapped
ret = await coro(*args, **kwargs)
File "c:\Users\\Desktop\Programming\PyScrap\cogs\core_cog.py", line 115, in start
await ctx.channel.send(view=view_level, embed=embed)
File "C:\Users\\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\abc.py", line 1504, in send
data = await state.http.send_message(
File "C:\Users\\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\http.py", line 420, in request
raise HTTPException(response, data)
disnake.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In components.0.components.0.options.2: The specified option value is already used
arl?
I don't understand the indentation haha
the error is quite easy to read, look at your 3rd's option value
discord go brr
oh
🤦♂️
i forgot that i copy pasted the option
first time using select menus ;/
a classic
here it says channel is undefined
would anyone know ?
then define the channel?
can someone explain the sub command like wtf is that
or not
Advanced Racist Leg, nah im just joking arl is @vast gale
in / commands
i'm not
lol
then
@commands.command()
@commands.has_permissions(manage_channels=True)
async def channel(ctx: commands.Context, channel: discord.TextChannel):
await ctx.channel.send(f"Deleting {channel}!")
await channel.delete()
client.add_command(channel)
just paste this in
oh wait im using disnake one sec
lmao
there
that's what I thought haha
🤦♂️
can someone give me an example of how to implement prefixes and slash commands using this snippet
@commands.command(aliases=['beam'])
@commands.check_any(
commands.is_owner(),
commands.has_permissions(ban_members=True)
)
async def ban(self, ctx, member: discord.Member, *, reason=None):
if reason==None:
reason=" No reason provided"
embed = discord.Embed(title=' Successfully Banned!', description=f'{member.name}#{member.discriminator} has been Banned. Reason: `{reason}`.', color=0xff0000)
embed.set_thumbnail(url=member.avatar)
embed.set_footer(text="Requested by: {}".format(ctx.author.display_name), icon_url=ctx.author.avatar)
await ctx.send(embed=embed)
await ctx.guild.ban(member)
if member ==None:
embed = discord.Embed(title=' Error banning member!', description='Please provide a valid @mention/ID!', color=0xff0000)
embed.set_footer(text="Requested by: {}".format(ctx.author.display_name), icon_url=ctx.author.avatar)
await ctx.reply(embed=embed)
Hello hello, I have a small issue with a command to display the cooldown it might have, everytime, the bot sends the message several time (4 times in a row) and I have no idea why it does that, here is the problematic code:
@commands.Cog.listener()
async def on_command_error(self, ctx, error):
if isinstance(error, commands.CommandOnCooldown):
retry = error.retry_after
remaining_time = str(datetime.timedelta(seconds=int(retry)))
embed = discord.Embed(title=":clock1: Slow Down!!", description=f'{ctx.author.mention}, you can use this command again in ' + str(remaining_time), color=0xE74C3C)
await ctx.send(embed=embed)```
maybe it has to do with the fact that in my cog 4 commands uses a cooldown
is it possible to restrict certain drop downs to certain perms?
but it doesn't make sense because another cog has 3 commands and has the same issue
idk what that means mate
Lets say I have a help command that uses drop downs
For the admin commands I want the drop down to be restricted to admins only
what is drop downs
I'm currently using this for a random code generator:
.join(random.SystemRandom().choice(string.ascii_uppercase + string.digits) for i in range(N))```
However, i get this error:
```TypeError: 'str' object cannot be interpreted as an integer```
I'm not sure how to fix it, have i got to replace `i`?
fixed it ^^
anyone would have any idea ?
hmm weird
for some reason the function is being called 4 times
can u show me the command due to which it is happening?
all of them
they all have @commands.cooldown(rate=1, per=60, type=commands.BucketType.user)
Weirdddddd
Hm that shouldn't really be an issue
Pycord, a maintained fork of discord.py, is a python wrapper for the Discord API - pycord/slash_basic.py at master · Pycord-Development/pycord
yeah of course
what events do u have?
@bot.slash_command(title="Hello!", description="Hi!")
async def hello_cmd(inter: Interaction):
await inter.send("Hello there!")
I think this is right
events ?
I do not make slash much
huh wait
Ok so i wanna make a command that when used with a word or phrase after it will put the word or phrase into a json file, and then another that will remove a specific word or phrase from in the json file, can someone explain this to me?
I have on_ready, on_guild_join and on_guild_remove
Only?
ye
please tell me what i have to put in it i fork a code
He is on dpy
mmh ?
Not u, Zaidorox
ha oke
Hmm, you need disnake or nextcord
please some one tell me
Has the problem been there since the start?
I just added the command to display the cooldown
Show
so since I added it yes
hello there i just need to use data from a json file but python cant seem to access it though the file exists, any clue why?
No like, the command code
not to mention i print the path and it seems to be correct as i included the os.path.exists verify method to ensure the path exists
ho
can u print os.listdir()
@commands.command()
@commands.cooldown(rate=1, per=30, type=commands.BucketType.user)
async def ocrandom(self, ctx):
""" Gives the description of a random OC"""
id = str(ctx.guild.id)
file_name = random.choice(os.listdir(f'database\{id}'))
Content = fetch(f'database\{id}\{file_name[:-5]}')
user = await self.bot.fetch_user(int(file_name[:-5]))
Key = random.choice(list(Content))
character = Content[Key]
age = character['age']
gender = character['gender']
hex = character['hex']
Url = character['picture']
desc = character['description']
universe = character['universe']
embed = discord.Embed(title=Key, color=int(hex,0), description=desc)
embed.set_thumbnail(url=Url)
embed.add_field(name="Age", value=age)
embed.add_field(name="Gender", value=gender)
embed.add_field(name="Universe", value=universe)
embed.add_field(name="Creator", value=user)
await ctx.send(embed=embed)```
???
Can't just pass in user in the async def
Go to the dev portal and enable intents
Did you enable the application_commands scope when you invited the bot?
Show me your code
it prints out the directories above because im not working in the same directory but i've fixed this using this method and when i print it, it returns the correct directory of the file: half_path_name = python if os.path.exists(str(Path(__file__).parent.resolve()) + "/config.json"):
Ah cool
I think you need to do
from disnake.ext import commands
Here is the code that's sending me an error when i try to open using the "with open" methodpython print(str(Path(__file__).parent.resolve()) + "/config.json") if os.path.exists(str(Path(__file__).parent.resolve()) + "/config.json"): with open("./config.json") as file: config_data = json.load(file) else: config_template = {"discord_token": ""} with open(str(Path(__file__).parent.resolve()) + "/config.json", "w+") as file: json.dump(config_template, file)
And you need to put the commands.Bot above the 2 intent lines
Error?
Which ide u use??
mmmh
FileNotFoundError: [Errno 2] No such file or directory: './config.json'
Just move the 2 intent lines below the client = commands.Bot line
no just that one but idk how to fix it tho
Code please?
Go down
@rustic sky what is it printing?
The intents
??
the print statement is just the path of config.json but a little modified so i can access the config.json no matter which dir im in
Like this
But it isn't working, soooo
i just dont know why it doesnt recognize the ./config.json statement
No I use discord white cause ye keeps me awake
Tf
is message_content an intent?
Waaa
!d disnake.Intents.message_content
Whether messages will have access to message content.
This applies to the following fields on Message instances...
(:
how to fix that ? (V2)
why should he define his intents after the bot? This way he can't pass it to the bots constructor like disnake.Bot(intents=intents)
await it
I do not use disnake 👀
same for discord.py or the forks
that was already good, you still need to pass intents=intents to the Bot constructor
Oh yeah, you do need to add that 😐
@maiden fable thanks for your help man i finally found what caused the error
What? (I didn't really help tho haha)
disnake.Bot(..., intents=intents, ...)
One thing tho, you don´t even need message_content for slash commands
How do you guys type code like that on discord
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
Alr
idk i just appreciate the time you spent
What caused the error tho
BTW thanks a lot I got it fixed now
then change bot to client
👍
i copied the ./config.json statement from a video but it worked in the video because it was in the cwd (which is not my case) so i just used the same method to open the file as for the others and it managed to locate and it worked
pretty disappointing
yeah you called it client by doing client = ...
You need to import interaction
Hello, does anyone know how I can hide cogs from my bot's help page?
like this ?
Ah cool
i think for disnake its disnake.ApplicationCommandInteraction
@slate swan wanna hear a fact?
Anyone please?
Yes?
Make custom help command
.
A custom help command gives you a lot of control and customization, so look into that as CyberGhost suggested
Hmm, actually I was hoping for a solution that would work with the default help command, anyways, I guess it's time to switch over. Thanks.
Hello hello, I have a small issue with a command to display the cooldown it might have, everytime, the bot sends the message several time (4 times in a row) and I have no idea why it does that, here is the problematic code:
@commands.Cog.listener()
async def on_command_error(self, ctx, error):
if isinstance(error, commands.CommandOnCooldown):
retry = error.retry_after
remaining_time = str(datetime.timedelta(seconds=int(retry)))
embed = discord.Embed(title=":clock1: Slow Down!!", description=f'{ctx.author.mention}, you can use this command again in ' + str(remaining_time), color=0xE74C3C)
await ctx.send(embed=embed)``` **Please could anyone help, I seriously don't understand what's happening** 
class MyCog(Cog, command_attrs={"hidden": True}):
...
..
The default help command can also be customized by subclassing
the sun is gonna explode somewhere around the year 275000 

I see, I don't exactly know what subclassing is (sorry, a little new to python here). But I'll look into it, once again thanks 🙃
make classes within classes
I'm seriously considering opening a help request in a help channel at that point because it's been lile the 5 times I ask and no-one seems to understand the problem 🥺
Adding emoji to ur msg is more attractive
possibly multiple instances of your bot sre running
no because that issues happens only with that cooldown message sending methods
thats why shutdown command pog
the other commands work just fine
Thanks, I'll try this out
Ive tried to subclass the drop down menus in the help cog but it cant find what select and selectview are
https://paste.pythondiscord.com/vawaqibitu
self.Select
the class is inside a class so you have to use self to access it
It works, tysm
ah I see, so why does it not work when I do it here:
@commands.command()
async def help(ctx):
await ctx.send("Help Menu!",view=self.SelectView())
Sorry to bother you @sick birch but you were here a moment ago and you seem knowledgable, so would you have an issue of why this thing makes my bot send the same message 4 times in a row
here is an example
can you add a return statement below the send method
do u have 4 instances of the bot running?
no just one lol
what doesn't work?
inside or outisde the indentation block of if?
inside
it says self not defined
https://caught-lackin-in-8k-by-cyberghost.cf/NtAA80tc
nope doesn't work
add self in the commsnds parameters
how about you move the classes outside the cog
I was thinking I should do that tbh
no otherwise I think it would make every commands run 4 times
hm idk then
hmm yea, i didnt notice the first command you ran
truly odd
you could try asking in the d.py server, there are lots of knowledgable helpers there
yea
Defer it ig
thats discord.py's discord server
Because I still have the same issue for hours and I have 0 idea why

lemme see if I can help
🥺
try
return await ctx.send(embed=embed)```
~~even though I know it wont be much difference~~
or simply reset your bot's token
welp nope nothing
you think that might be the issue ?
it's weird that it does that only for this cogs listener and not the commands
Am I able to host my bot with a domain that I own?
@lofty pecan did u post the code for the cooldown command (which caused the issue?)
yes
Might have missed that
that litteraly what I sent lol
this is exactly that
ye
idk i just better not come here, I'm like half alive today
@lofty pecan can u try printing it?
Does it print 4 times?
It should print 4 times but eh
lmao
it send 4 times
And how many times does it respond to a command?
Like when u invoke a command, how many times does it send the message
reseting the token did nothing
yo can someone make me a code that when a user joins, it changes their username automatically -(pls send code in dms, i'll reward you)
127 lines for that cog
Hm, is the code too big to share?
Well rn I am just shooting arrows in the dark, cannot really do anything without seeing all the code
lmao
Lol
I'm telling you, the code works fine, adding this command of cooldown to display how much time there is left is the problem
!d discord.on_member_join
discord.on_member_join(member)``````py
discord.on_member_remove(member)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") join or leaves a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").
This requires [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") to be enabled.
I didn't have that problem before
@bot.event
async def on_member_join(mem):
await mem.edit(nick="Welcome bro")
so i am trying to host my bot on railway and the logs are as follows:
What is yr dpy version
@maiden fabledms
@slate swan
How do I do this?
==========================
Using Buildpacks!
==========================
full: Pulling from paketobuildpacks/builder
Digest: sha256:bf3ca4acadd5449311e9d5cddda8a2e951f10198c180fc05004fd8c3d1c461f5
Status: Image is up to date for paketobuildpacks/builder:full
full-cnb: Pulling from paketobuildpacks/run
Digest: sha256:037e1acf18b5e2cb41cf8f9f9b6c8637b718f4a6ff823a22cde641a332d01505
Status: Image is up to date for paketobuildpacks/run:full-cnb
===> ANALYZING
Previous image with name "us-west1-docker.pkg.dev/railway-infra/railway-docker-users/project/05fb51cc-0cc0-4a6a-813e-5f648118482c/service/83f555fc-993a-4e81-b289-61fd7131198e:540b789e-ffea-4876-b1c4-2a5681e73330" not found
===> DETECTING
3 of 7 buildpacks participating
paketo-buildpacks/ca-certificates 3.2.0
paketo-buildpacks/cpython 0.9.3
paketo-buildpacks/python-start 0.9.0
===> RESTORING
===> BUILDING
Paketo CA Certificates Buildpack 3.2.0
https://github.com/paketo-buildpacks/ca-certificates
Launch Helper: Contributing to layer
Creating /layers/paketo-buildpacks_ca-certificates/helper/exec.d/ca-certificates-helper
Paketo CPython Buildpack 0.9.3
Resolving CPython version
Candidate version sources (in priority order):
<unknown> -> ""
Selected CPython version (using <unknown>): 3.9.12
Executing build process
Installing CPython 3.9.12
Completed in 2.804s
Configuring environment
PYTHONPATH -> "/layers/paketo-buildpacks_cpython/cpython"
pip show discord.py
Paketo Python Start Buildpack 0.9.0
Assigning launch process
web: python
===> EXPORTING
Adding layer 'paketo-buildpacks/ca-certificates:helper'
Adding layer 'paketo-buildpacks/cpython:cpython'
Adding layer 'launch.sbom'
Adding 1/1 app layer(s)
Adding layer 'launcher'
Adding layer 'config'
Adding layer 'process-types'
Adding label 'io.buildpacks.lifecycle.metadata'
Adding label 'io.buildpacks.build.metadata'
Adding label 'io.buildpacks.project.metadata'
Setting default process type 'web'
Saving us-west1-docker.pkg.dev/railway-infra/railway-docker-users/project/05fb51cc-0cc0-4a6a-813e-5f648118482c/service/83f555fc-993a-4e81-b289-61fd7131198e:540b789e-ffea-4876-b1c4-2a5681e73330...
*** Images (8d7d3f983c5d):
us-west1-docker.pkg.dev/railway-infra/railway-docker-users/project/05fb51cc-0cc0-4a6a-813e-5f648118482c/service/83f555fc-993a-4e81-b289-61fd7131198e:540b789e-ffea-4876-b1c4-2a5681e73330
Successfully built image 'us-west1-docker.pkg.dev/railway-infra/railway-docker-users/project/05fb51cc-0cc0-4a6a-813e-5f648118482c/service/83f555fc-993a-4e81-b289-61fd7131198e:540b789e-ffea-4876-b1c4-2a5681e73330'
The push refers to repository [us-west1-docker.pkg.dev/railway-infra/railway-docker-users/project/05fb51cc-0cc0-4a6a-813e-5f648118482c/service/83f555fc-993a-4e81-b289-61fd7131198e]
Preparing 83d85471d9f8
Preparing 4bcf52917c7c
Preparing 195ce6778985
Preparing 71f46b69cb09
Preparing c99d6be99282
Preparing b4a080c9e328
Preparing a53ff049d96e
Preparing 5a904fb774ec
Preparing 2b55f3c2f32a
Preparing 2f2856c4c220
Preparing 95c443da13bf
Waiting b4a080c9e328
Waiting 5a904fb774ec
Waiting a53ff049d96e
Waiting 2b55f3c2f32a
Waiting 2f2856c4c220
Waiting 95c443da13bf
Pushing [> ] 1.024kB/79.73kB 71f46b69cb09
Pushing [==================================================>] 85.5kB 71f46b69cb09
Layer already exists c99d6be99282
Layer already exists 4bcf52917c7c
Layer already exists 83d85471d9f8
Layer already exists 195ce6778985
Layer already exists b4a080c9e328
Layer already exists a53ff049d96e
Layer already exists 2b55f3c2f32a
Layer already exists 5a904fb774ec
Layer already exists 2f2856c4c220
Layer already exists 95c443da13bf
Pushed 71f46b69cb09
540b789e-ffea-4876-b1c4-2a5681e73330: digest: sha256:4716f9b41812ba4baaa74d4206ef9b6da996baedf4710f2cd37f187371ae9a5d size: 2622
why
sad
I need to open anaconda wait
!paste
Pasting large amounts of code
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 floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
hi
lol i forgot
@slate swan help @slate swan add code to his bot hosted on replit
why me
version 1.7.3 @maiden fable
Because I am going to sleep
jus an auto username when someone joins the server lol
just dont.
weird, should've worked then
yeah
what
hey guys i am hosting my bot on railway and it stays like this and my bot doesnt turn on
i have homework
I already have a headache stop messing around
👀
There @slate swan
and i have homework
I am at my wits end for yr issue @lofty pecan, sorry
lol
(:
pls?
it sends the embed many times?
4 times
someone pls?
exactly 4 times
do you have many instances running of your bot?
no
damn
one on my laptop
If you shut down your bot, how many times does it send (0 right)?

pls?
can't help ya mate sorry
I also thought he had multiple instances, but there is only one response to commands
yeah
👍🏼
@lofty pecan do you have this cooldown code for multiple commands?
yes
its probably that
Let me guess, 4 commands? 😅
each cogs, I just thought maybe that would be the issue
auto username?
Oh wait 😐
@lofty pecan how many commands have a cooldown?
that's the thing
The event listener you register is global, it applies to all commands once the cog is loaded
any command thats on cooldown will trigger the error handler
so, 4 commands in this cogs, BUT in another cog only 3 have a cooldown and the cooldown error embed is triggered 4 times as well
show ss
How many cogs do you have?
Ngl they should allow threads here
4 have the cooldown thingy 
We are discussing it in internal channels
@lofty pecan can u add the command name to the cooldown embed to see for which command its being called?
Yes, you should only have one
ctx.command.name
Huh? They're all the same
Wym
^
There are 4 error handlers, one for each cog, yet they apply to the whole bot. What happens, is that they all get triggered because each error hanlder (as I said) applies globally
Remove 3 of them, you should only have one.
Ah, so he has different eh's for each cog?
one is enough for all the cogs ?
Who would have known 😔
on_command_error is a global error handler for all commands
Yes @lofty pecan
ho really ?!
Yep, that's how error handlers work. I recommend placing it somewhere else though
all commands that are registered can trigger it.
!d discord.discord.ext.commands.on_command_error
discord.ext.commands.on_command_error(ctx, error)```
An error handler that is called when an error is raised inside a command either through user input error, check failure, or an error in your own code.
A default one is provided ([`Bot.on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.on_command_error "discord.ext.commands.Bot.on_command_error")).
Mentlegen, your solution was a success
Thanks a lot, I hesitated at first to put it there but yeah that's actually what I should have done
how do i add another argument to a callback func
thanks a lot @minor totem !
with select menus (disnake.py)
async def callback(interaction: disnake.Interaction, total):
total += 1
dict[select.values[0]] += 1
dict_profile = dict[select.values[0]]
embed = disnake.Embed(title=question, color=ORANGE)
for ch in choices:
embed.add_field(name=f"{ch}: ", value=f"{(dict_profile * 100) // len(choices)}%", inline=False)
await msg.edit(embed=embed)
select.callback = callback
view = View()
view.add_item(select)
msg = await ctx.channel.send(embed=embed, view=view)
can it?
Why do you want to do that?
im trying to make a poll command with select menus
just pass the argument to the View and then pass it to the menu
Right, but what do you want that argument to be?
basically i need the total number of times options have been selected





