await callback(interaction)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
The callback associated with this UI item.
This can be overridden by subclasses.
#discord-bots
1 messages Β· Page 1025 of 1
!d discord.ui.Button.disabled
property disabled```
Whether the button is disabled or not.
Thx also do you know a in depth guide for buttons in general
refer to these:
https://github.com/Rapptz/discord.py/tree/master/examples/views
use an unix timestamp
how can i get a direct link to a command that has just been sent?
wdym by direct link? the message which invoked the command?
so i type $ban, in my audit longs it sends a link which i can tap to take me to that particular command
ctx.message.jump_url will get you the link of the command message
ok ty
!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 "(in Python v3.10)") for presentation within Discord.
This allows for a locale-independent way of presenting data using Discord specific Markdown...
i want to make a quiz with discord-ext-forms and idk how it should check answers
I want it to check them so it can say something like this: You have answered 3 out of 5 right
Or check if 2 out of 5 are right say: You are ...
In the screenshot is my current code
Nice quiz bro
as when using the send two messages command. the first message is to the chat where the command was written, and the second message is to a specific chat. That is , how to send a message to a specific chat ??
@brave forge so u basically want to know how to send a message to x channel?
yes
Get the channel, using channel = bot.get_channel(id)
i was gonna say that and explain it smh
It's just that the way I do it doesn't work for me
Mb xd
returns an error
also, don't spoonfeed
Kk
I was trying to find the docs but I have like no clue how to use the bot
What error
just do something like, on message if message author id == bla bla, then do this bla bla
from discord.utils import get
I have
Maybe I'll show you the code myself ?
hint:
user: disnake.Member=None
Also iirc you can't have a digit starting the function name
having issues with my loop command and dont know what to do
any1 can help ?
@commands.command
async def loop(self, ctx):
if not ctx.voice_state.is_playing:
return await ctx.send('Nothing being played at the moment.')
ctx.voice_state.loop = not ctx.voice_state.loop
await ctx.message.add_reaction('β
')
it's a syntax error, and i litterally told u to look at it
Can you give an error or something?
How to say if message not "yes":? Till now it just sends it after the command has been finished! Even tho the answer was "yes"
Why does it say commands.get_channel
off topic, use .lower() so it doesn't matter abt the capitalasation, so u don't have to do stuff like Yes yES etc
^
i found ban-unban but i can't find kick event
I have already understood everything. thanks
how is it off topic? I just asked my question
But thanks i will try it
doesn't help with the x problem rather helps improve the code
I don't think you understood what rip meant
@dire folio to delete a message with a reaction when clicking on the reaction, you need to write "await self.bot.message.delete()" ??
Ye
to delete the message itself (I'm guessing you mean the invoking message), ctx.message.delete. However to remove reactions (guessing you also mean the invoking message), do ctx.message.clear_reactions() if you want to remove all reactions, or clear_reaction(emoji) to remove a specific emoji reaction
@fading marlin and where should I enter "ctx.message.clear_reactions()" ??
whenever you want the reactions to be cleared
@fading marlin after pressing and when the pressing has worked and what is put on it, the reaction is removed
i use replit for my bot and want "all red stuff in console to be dumped in a .txt file"
anyone got a block of help?
add the method after your if check then
if by 'red stuff' you mean errors; make an error handler, and whenever an error pops up, format it using something like traceback.format_exception and write to the file
errors and warnings and all
i am trying to get it right since past day now, nothing seemed to work right
there is a delete_after kwarg to send() which deletes the message after a specific time
then I'd suggest taking a look into the logging library
there's not much there
!d logging
Source code: Lib/logging/__init__.py...
Similar names: arcade.logging, discordpy.logging, flask.logging, disnake.logging, pytest.logging, rich.label.logging, rich.doc.logging, aiohttp.logging, nextcord.logging
@tiny ibex
I don't need it to be deleted after a certain time. The question is not how to delete a message after a certain time. And how to delete a message after clicking on the reaction
error and warning args arent logging them
just wait for the reaction then fetch the message object and delete it I guess....
...
well, I'm asking how
can I see your code please?
above is my code
the full code
with the definition of ctx
Moreover pass a message object to it
I don't know. I was once told to make reactions like this, and I do them like this, although it turns out with mistakes, but still@tiny ibex
Answered
@tiny ibex
just answer the question I asked. I already know that the code is bad!!
@tiny ibexCommand raised an exception: AttributeError: 'function' object has no attribute 'clear_reaction'
ERROR
It already can't
wdym it cant
It can't give money to bots
user is not defined π
yea but i am trying to do that
change the variable names BRUHH
but u still can give money to bots
rep = await ctx.send(embed=embed)
Huh?
if member.bot:
Looks like you are trying to call .clear_reaction on a ctx.send() function. Do you mean to clear the reaction on the embed object itself instead?
What exactly is member?
A discord guild member
@tiny ibex @fading marlin don't reply to my messages for help anymore. I just might as well not have asked
yes
In that case the check is pretty much overcomplicated
!d discord.Member.guild
The guild that the member belongs to.
You can simply do
if member.bot:
# Member is bot
It's undefined, hence their error
i didn't see that
Not needed to define, just use member
Then I think you would do this with:
if str(reaction.emoji) in ":white_check_mark:":
embed = discord.Embed(description= f'ΠΠ°ΡΠ΅ΠΉ ΠΆΠ°Π»ΠΎΠ±ΠΎΠΉ Π·Π°Π½ΡΠ»ΡΡ {user}', colour=0xF1C40F)
embed.clear_reaction(":white_check_mark:")
But I'm not super knowledgeable about d.py
ok cool thanks
That wouldn't really work
You need to define a message variable when you send the embed, then use on that variable the function
You canβt remove a reaction from an embed
Only messages
i thought i need to do member == member.bot π
m = await ctx.send(embed=...)
m.clear_reaction(...)
makes no sense TBH.......
that would mean member == True/member==False
Very cool, TIL
In that case, what would Toxic Penguin need to change for their code to work?
Or you need to get_message/fetch_message if you have its ID/channel ID and save that in a variable, and use that variable to clear the reaction
@velvet compass Command raised an exception: AttributeError: 'Embed' object has no attribute 'clear_reaction'
tbh yes
So they have a function rep and a variable rep and the error was function has no attribute so maybe rename the rep variable
Yeah, apparently you cannot clear a reaction from an embed, only messages
Use on your msg variable that you have already defined
message.embeds
what does that have to do with anything
@velvet compass I don't understand. Why was only one out of 3 people adequate ?? Well, that is, he didn't tell me about the code
We are all volunteers, I was also wrong Β―_(γ)_/Β―
await for sure on the last line
Then I recommend to join their server and ask in their development channel :)
!d discord.Message.clear_reaction
await clear_reaction(emoji)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Clears a specific reaction from the message.
The emoji may be a unicode emoji or a custom guild [`Emoji`](https://discordpy.readthedocs.io/en/master/api.html#discord.Emoji "discord.Emoji").
You need the [`manage_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission to use this...
hi Eito now Eito
reaction.users is a list so reverse the list
explain a lil bit.. pls Nakime
I think it's users
Backwards such as?
!d discord.Reaction
class discord.Reaction```
Represents a reaction to a message.
Depending on the way this object was created, some of the attributes can
have a value of `None`...
reaction.users().flatten() is a list
u mean countdown before the giveaway ends?
that backward counting?
Simply use await asyncio.sleep(seconds) to wait until the end of the giveaway, then you can draw a winner based on the link above
oh
owo
Problem is when bot goes offline
no it's for the part where bot will pick the winner after the time has passed
but without this problem it would work
just ending the sleep() 10 seconds before then sending a message every second or editing
alright
+1
@slate swan use his suggestion
If you want to explain an overkill method to newcomers, feel free to do so. I'd also explain clusters, scalability and more while you are at it π
use @heady sluice 's suggestion that he suggested above
sorry for ping btw lmao ||in case u mind ||
atleast somebody pings me
π π
π€¨
... my bro has struggles.. π©
π then.. use button instead of reaction?
makes things harder
but wait.. can we use button insetad of reaction?
you can't just count the reactions at the end
π€ i see..
yes but make something that waits for button presses
oh yeah.. there is timeout shit
everyone is bro.. or.. what should i say? π
#discord-bots message this is for u
just use a unix timestamp which updates itself with change in time automatically.
I'm frightened by the name of the guy that was typing
stop
please
see this thing? the highlighted time..?
its a timestamp, which updates itself with time.
animated? π
@slate swanhow do I remove a reaction after it has worked ??
there should be reaction_remove or remove_reaction shit.. idr exactly.. look docs
Hi i'm using requests.get to send a reques to my API in my discord bot and my bot sometimes freezes does anybody know why?
use aiohttp
Yes, because it's blocking your bot
using requests in async flow... results in blocking
!d aiohttp.ClientSession
Could you please give me an example
class aiohttp.ClientSession(base_url=None, *, connector=None, cookies=None, headers=None, skip_auto_headers=None, auth=None, json_serialize=json.dumps, ...)```
The class for creating client sessions and making requests.
1 minute
if you're familiar with requests.. aiohttp would be easy too
^ +1
I am already aware of the team itself, but I do not know where to put this shit I have a constant error
how would i make it just send a request without getting the response
And here is an explanation on why your bot freezes https://discordpy.readthedocs.io/en/stable/faq.html#what-does-blocking-mean
as its a API, i don't need a response.
Again, see above
see their docs
it's the best
async with aiohttp.ClientSession() as session:
session.get('http://aws.random.cat/meow')
could i just do this?
await session.get
it's a message object method i suppose
Okay so if i add this it should just work right?
yep.
Alright thank you so much
i can send more than 1 request?
use a task to update that message after every minute then..
u can use it just like u use requests..
Alright thanks
!d discord.ext.tasks.loop
discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True)```
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/master/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
oh, thats a disnake thing
i said that it's prolly a message object method
!d discord.Message.remove_reaction @brave forge
await remove_reaction(emoji, member)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Remove a reaction by the member from the message.
The emoji may be a unicode emoji or a custom guild [`Emoji`](https://discordpy.readthedocs.io/en/master/api.html#discord.Emoji "discord.Emoji")...
!d discord.Message.clear_reaction u can use this too @brave forge depending on your use
await clear_reaction(emoji)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Clears a specific reaction from the message.
The emoji may be a unicode emoji or a custom guild [`Emoji`](https://discordpy.readthedocs.io/en/master/api.html#discord.Emoji "discord.Emoji").
You need the [`manage_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission to use this...
there is also clear_reactions
hm ```py
from discord.ext import tasks
@tasks.loop(minutes=1)
async def my_task():
channel = bot.get_channel(...)
message = await channel.fetch_message(...)
embed = message.embeds[0]
do stuff to update time by 1 minute in the embed
await message.edit(embed=embed)
this is the best i can provide. and its a bit spoonfeed-ish already so dont expect more
π man u were literally writing the code?
im bored, so yea
ah.. well fine
it works same for all
pycord is just a bad forked version of discord.py
so it stays the same.
...
the urge of including bad
@slate swandocumentation in discord.py it is written disgustingly, it is impossible for a beginner to understand it!!!!!!!
i'm getting a error at async with aiohttp....
π alright sir.. i get your point.. just try to become familiar with OOP in case u r not.. otherwise.. you'll get its grip someday
this must be used inside an async function
Oh alright.
The person who made it has said discord.py is not meant for beginners
i made a custom paginator, just to realise that hikari-lightbulb already provides you an inbuilt one
+1 ^
discord bots itself are intermediate level stuff imo
π
@slate swanmost likely I will throw a brick into the head of the one who wrote such documentation. It would be better to take an example from the discord documentation.js it's perfect, you can use it to write a bot without knowing the language itself
write the bot without knowing the language itself
lmao bro.. that's not how u r suppose to go uk
π okay calm down
first of all, noone forced you to use discord.py
if you really find djs so comfortable why not use it?
+1 ^ lmao
what part of the docs do you dislike?
if the documentation is normal and there is a video on YouTube with examples, then you can
he doesn't like the docs..
they dont spoonfeed
its just classes/methods and attributes, no code to copy and use
Oh I meant βwhyβ
ooo.. i see :>
because I don't know JS. And I learned Python, so I'm trying to do everything on it
ahem.. ig the "level" of normal depends on the "level" of the lib/framework :")
but readthedocs makes the docs automatically with just the source code.....
doesn't it
yeye
i'm getting RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Yes but humans write the doc strings
ok lemme put it straight, the docs are designed keeping in mind that you are aware how classes and methods work in python. and yeah its hard to understand but it ain't that shitty that you wack about it
well it's not sending a request i want it to
no :c
yes
await session.get
well
thats what i'm doing
but the deeper I dive into disocrd.py the greater the desire to throw it. But I'm stubborn and I want to understand him.
the source code includes the function descriptions which humans write
that's what readthedocs uses
you just dont need to write the html scripts, docs is something you need to do yourself
Sphinx uses but yes
I remember being told to write bots you need to know the language. But with discord.ru it doesn't work like discord.ru is like a separate language created by a sick bastard
^^ this is how it works
could you PLEASE stop using this kind of language whenever you just write a message here
like why would you call the creator a sick bastard
why are we talking about discord.ru?
just because he did something
or is that even a thing...
discord.ruby probably
It's because of the translator
i can assume a ruby api wrapper but ruby uses rb extension
yeah google translate aswell
there are more pythonic terms than english terms there
@slate swanhe sometimes replaces py with ru
so translating it would just be bad for you.
russian google translate wants discord.py for itself
lmao wtf is going on lol
honestly, discord.py docs are on of the easiest and clearest docs i've used.
^ and penguin, english is not my first language either
Yeah I really like the theme they use too
i can just say.. they seemed easy to me since i got grip of OOP
@slate swan you have no idea how infuriating the creator of python is to me as the creator of the product
I started programming with Java so oop was a piece of cake
otherwise i used to write bot.py all commands in the same file .. when i ws a beginner lmfao
thats exactly the point, you wont understand a shit unless you know OOP
yep yep
and thanks to discord.py who "forced" me to learn OOP... i wanted to use cogs so desperately lmfaooo
make ur own programming language using 0s and 1s
π you wont blame it then.
all fun and games until your stick of ram goes boom
enters a user with 512mb ram
16gb of ram
.... don't talk to me anymore shuu

πΆββοΈ
what os do you even use.
how would i do if category.id
in case that was not a joke
π ||it is a joke lmao||
i mean, i have seen people doing that so yeah
he probably can only use only 16mb of ram because of windowsπΏ
ooo yeah my first pc ws 512mb one :>
only then will the whole planet be bombed by this language. Because it will be in Russian
and many os like ubuntu have only 1gb minimum ram reqs
if Category.id == 970833097249652737: dont seem to recgonise cateorie id
The category channel ID.
should work...
i only used it once.. in school.. when i was in 5th or something ig
first language with keywords in russian lol
nope
how's Category defined
.
does it not work like channel.id?
what's Category? π
@slate swan I am 100% sure that most of this server will not be able to learn it. Since I noticed that for an American to learn Russian is just something impossible
yk the thing that seperates channels
Category = what
i didnt define it
π
property category```
The category this channel belongs to.
If there is no category then this is `None`.
hear me out so channel.id works so why doesn't category.id work
so you wanna check if <i dont know what it is>'s ID is 970833097249652737, fair.
if category.id == 3428934582
well you didnt define category, how is you code supposed to know what you're talking about
π my bro meh literally...
so it does not work like channel id
u must have defined channel somewhere @slate swan
i'm able to feel u π
we want full code
we love code
speak in your name
i need to do bot.get
ahem nvm
How to display a list of servers on which a people is an administrator, as in JuniperBot or MEE6
is this a selfbot
!d discord.Member.guild_permissions
property guild_permissions```
Returns the memberβs guild permissions.
This only takes into consideration the guild permissions
and not most of the implied permissions or any of the
channel permission overwrites. For 100% accurate permission
calculation, please use [`abc.GuildChannel.permissions_for()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.GuildChannel.permissions_for "discord.abc.GuildChannel.permissions_for")...
Returns True if a user is an administrator. This role overrides all other permissions.
This also bypasses all channel-specific overrides.
i dont think so
ok cuz I don't think I ever saw anything like this
as they said, they are making a dashboard ( they said that without saying that )
so that's why
hey, please do not use ableist terms
cuz if you do bot.get_category or anything like that that actually exists, it's always gonna be that id
im saying it about myself though???
Steak bot changed names
its bot.get_channel
category
mhm
!d discord.Client.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.
and it makes sense to get a category with get_channel in the perspective of dpy because ....
that doesn't make it better, you're still using it as a pejorative
I learned a word
what my code is doing is if channel has same name in categorie it wont create
because, it returns any abc.GuildChannel which can be any of these
in terms of discord API, they are
when you realise DMs are channel too
makes more sense
and dms calls in dms are yet another channel
that doesn't make sense
who tf calls a bot
i take it back
mah fault. wrong information
right it's not there
what happens if I call my bot
does it get some sh from the api
it will ask you to send a friend request first
as it does for a normal user, with privacy settings turned on
does my bot get a request from the api for that
or like an event
anything I could handle
nope~
what's the point
u simply cant make a call
π
that button is just useless
u_simply_cant_make_a_call()
how do I call my assistant then
cuz in 20 minutes my breadboard will appear in front of my door in the night and I'm gonna implement voice receiving in my new API wrapper I'll make and I'll buy lights my breadboard will be able to use, also I'm gonna connect it to the TV so when I call my bot and tell it to turn off my lights and TV my raspberry's gonna trigger and explode the house using the breadboard
but I need friend requests
discord hurry
just do the same in a VoiceChannel
how lame can you be
π€‘ is that even practical?
yes
How to display a list of servers on which a people is an administrator, as in JuniperBot or MEE6
.
@bot.command(name='allmsg')
async def msg(ctx, num = None):
# below is a debug output to show when command is recieved.
print('Running Search')
if num == None:
num = 10
# fallback settings incase commanding user dosen't specify a number of messages'
print(Fore.CYAN + '[DEBUG]' + Fore.YELLOW + 'Num Fallback Active')
else:
print(num)
# debug output to show if custom number of messages is used
print(Fore.CYAN + '[DEBUG]' + Fore.YELLOW + f'Custom Message Number Active {num}' + Fore.WHITE)
msgs = [message async for message in ctx.channel.history(limit=num)]
# ^ messages is now a list of Messages
# below line runs checks for each message as described / laid out beloq
for msg in msgs:
# below print statment is for debugging.
print(Fore.CYAN + '[MSG CONTENT]-' + Fore.YELLOW + msg.content + Fore.WHITE)
#checks if message had any reactions
if msg.reactions:
# scans message for specific reactions
for reaction in msg.reactions:
if reaction.emoji == 'β
':
print(Fore.green + '[β] Checkmark Detected')
# message sent is for debuging
await ctx.send(f'checkmark detected! it is in {msg.id}', delete_after=5)
#it then adds the reaction to the message with a checkmark reaction
await msg.add_reaction('<furheart:802746458088013864>')
# We break since we already found the check, heading to next message
break
Waiting For Commands
Running Search
11
[DEBUG]Custom Message Number Active 11
Ignoring exception in command allmsg:
Traceback (most recent call last):
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/disnake/ext/commands/core.py", line 169, in wrapped
ret = await coro(*args, **kwargs)
File "<string>", line 62, in msg
File "<string>", line 62, in <listcomp>
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/disnake/iterators.py", line 123, in __anext__
return await self.next()
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/disnake/iterators.py", line 329, in next
await self.fill_messages()
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/disnake/iterators.py", line 351, in fill_messages
if self._get_retrieve():
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/disnake/iterators.py", line 338, in _get_retrieve
if l is None or l > 100:
TypeError: '>' not supported between instances of 'str' and 'int'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/disnake/ext/commands/bot_base.py", line 570, in invoke
await ctx.command.invoke(ctx)
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/disnake/ext/commands/core.py", line 920, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/disnake/ext/commands/core.py", line 178, in wrapped
raise CommandInvokeError(exc) from exc
disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: '>' not supported between instances of 'str' and 'int'
Like the fallback number works but when I use a custom number it breaks
how do i print my dpy version in repl
can someone give me an template of a simple bot that contains multiple / commands?
I could make one with a cog but not rn.
go to the github page of the library you want to use and you'll find many of them in the "Used by" page
I wish I knew what was throwing this error and how to fix it :/
if l is None or l > 100 l is a string here
Did that if statment break the code?
@slate swan :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | TypeError: '>' not supported between instances of 'int' and 'str'
this is what you did ^
Ok
Still throwing it
typehint num to int ```py
async def msg(ctx, num: int = None):
it is hard, russian is a complicated language but dont underestimate someone for where they live or come from
Ah that helped
Now lol the color text is cutting off in the terminal
Why are you actually manually doing logs
Why donβt you look into the logging module or something
umm... idk. i just do it that way for some reason
Equally as good and doesnβt require effort likes yours does
How can I internally respond to a view so that I don't get an error after clicking a response and getting a message back?
I made a bot and I want to be able to use commands without people knowing I used the commands, how can I make it so I can run commands from the terminal instead of typing them out ?
No
clean background tylerπ³
u talking to me
yes
r u sure
Yes
Are you using slash cmds?
you cant with dpy, you would need to send the payloads yourself or just do it in private channels
no
Then you can use the DM.
If you use slash commands you can use ephemeral.
Dm commandsπ³
k
it needs a space
No space
Space
Hello
I'm kinda stuck here
I wanted to create a bot which could be able to run a battle pass inside it. Like, the entire bot is a battle pass that updates every single month (but that info isn't usefull). What I really wanna know is: How can I create a bot? :D
i'd suggest looking up some tutorial on youtube
eh, tutorials are iffy
Thank you very much. You too @inland bane; But you guys have any more advices?
Thank you π
import discord
client = discord.Client()
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('$hello'):
await message.channel.send('Hello!')
client.run('your token here')```
very basic bot, taken from docs
that is the base bot yea
I think I'm gonna spend my free time reading docs :D
have u worked with python before?
I understand 50%? Maybe 30%
But I can learn it
i did add a space lmfao still doesnt
I am trying to make a discord webhook with python using disccord_webhooks and I cant seem to find a way around rate limiting. The switch that is recommended will delay a few second, however it send in multiple messages
show the string
Hello okimii 
Is there a way to get the permission the user is missing from an error?
webhooks dont have ratelimits iirc?
hey
Of course, do you have a global error handler?
if isinstance(error, commands.MissingPermissions):
await ctx.reply("bla bla")
should be like this if i remember right
Didn't talk in a long time, how have you been?
!d discord.ext.commands.MissingPermissions.missing_permissions
The required permissions that are missing.
ive been better, wbu
Hm, well there are multiple ways to do it, but for example here's what I'm using:
In my global error handler I'm just passing through the Missing Permissions
if isinstance("error, Commands.MissingPermissions") :
pass
Then I'm just specifying the error in the command:
@command.error
async def command_error(ctx, error):
if isinstance(error, commands.MissingPermissions):
await ctx.reply(f"`{error} `\n\nLooks like youre missing some permissions.")
There are probably much better ways to do it, but just as example thats what I use.
I already got it
Actually, I'm doing pretty good, besides that I'm currently Migrating from d.py to disnake which is harder then I thought
If I'm not wrong they're asynchronus now, which means you need to await them
Error?
Nope disnake is simple tbh
Disnake is
simple β¨
!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.
disnake is a fork of discord.py
Ye we know
so theyre very similar
https://paste.pythondiscord.com/ohirutofer
Does anyone know how to create a cooldown when selecting the menu?
Or simple limiting how many channels can be made through the menu?
Code in link π
but its simple doe
atleast the slash commands and app commands
on dpy u need to use tree somethjng like that
Idk prolly
Yep
i mean when i did it was quite easy
Well, I'm not saying that it is hard, but the docs are quite, uh let's say atleast I don't really understand some stuff
what dont you understand?
For example, I tried to check the user in an interaction, well the docs said "await interaction_check(interaction)" that was literally it I didn't even know interaction.author is an alias for interaction.user like bruh
i mean it can be quite confusing but its really not disnakes fault tbh
its just some stuff is a bit confusing if you dont check source which that is what i do when im confused
You could say I'm stupid, and yes I'm sometimes, but compared to the d.py docs I personally think they're a lot more clearer & easier to understand
yeah I found out about that pretty late lol
im not saying youre stupid nor do i think so. the docs are mostly the same its just some coroutines are very similar in naming or its ways of doing things but it can all really be solved by just reading its source which is the easiest way for me
Yes, I know you didn't say I'm stupid, but if you would see me sometimes, my brain just dies sometimes lets say it like that
Yeah, well checking the source helps me pretty much, but for some reason I just figured it out & I never got told about it lol
I'm having issues with the code below. If someone can help.
https://paste.pythondiscord.com/ohirutofer
Does anyone know how to create a cooldown when selecting the menu?
Or simply limiting how many channels can be made through the menu?
Looking for the menu to be on cooldown per option, not the command to bring up the menu.
Were all humans, we all have our moments including me, you should check all my old messages it makes me look very bad and like a beginner but we all make mistakes which we learn from. Thats great!
Love how you guys handled a potentially tense situation π
I learned from the best didnt i
If you don't want one user to create multiple channels, couldn't you just check if the user already opened one? Maybe storing the ID & Channel ID in a json?
!d discord.ui.Button.disabled
property disabled```
Whether the button is disabled or not.
Couldn't have said it better, as long as we do improve ourself we can be happy that we made mistakes 
That's something I've yet to try. I'm not sure how to go about that at all, actually π
i alr looked there and still dont understand how to make it disabled after click or a certain amount of time
just remember the more mistakes you make the more you learn!
Hm, do you know how jsons works?
I've never actually stored data before, the only parts of a JSON I understand is being able to use an API to get data from one.
So, not too much
you shouldnt really store data in it
For a short period of time it would be okay Ig
but yes most apis use json to format there payloads with
short period by?
I'd be down to learn how to use an SQL but it's just one of those things where I'd like to get all the other fundamentals down first before diving into that.
JSON doesn't "work", it's just a format
And not to shoot you down but storing it in a JSON is probably not the best idea
i would recommend you learn sql it gives you so much options between SQL based databases e.g postgresql and sqlite and its a good skill which can be used in any project in the future
Damn, everytime I'm here I learn something new
I understand you find JSON daunting, and SQL even more so, but I promise with a little time and effort you'll get it
Do you think it would be a good/bad idea to try to learn while still learning Python?
reason why im always hereπ³
I don't know how deep it goes, I don't wanna be stuck looking into it forever lol
nah its quite easy as its mainly just easy queries
Yeah well, not to mention that I made a whole economy System with a JSON as database I actually don't think JSON is that bad, atleast everything worked alright for me most of the time
Yup. it's just a set of specifications on how you should format it. I can very well put JSON-like data inside a regular .txt file and call it a day
I see
It seems like that, but it's highly inefficient (you won't be able to tell with a bot that doesn't get all that much traffic), and it's also prone to data loss
Count yourself lucky you had no issues with it
Okay, I'll go try that. Any recommendations on which database(s) I should start with?
Am probs still a beginner at coding in Python, don't want anything insane to go into.
Don't get me wrong, I'm a massive fan of JSON
sqlite is by far the easiest. Postgres if you want more reliability, security, robustness, and speed
Hm, well I never had data loss yet, my bot is in exactly 100 servers atm & the economy category gets daily used, and believe it or not it really does work fine. But it seems like I should consider switching to SQL
how advanced would a giveaway cmd with buttons be
yeah i love it as well only when its used correctly ofc
thats allot of strain ngl
Are these similar? As in, I could start with sqlite and move down the list?
@olive osprey reason why you should switch^
and better management
The primary reason that it's slow and inefficient because if you want to add even a single key/value pair, you have to delete the entire file, and rewrite it with all your new data. You don't notice this since json does this in the backend for you. The larger your JSON file is, the longer it's going to take to delete and re-write everything
Any tutorials you can suggest on it?
Yup. They more or less use the same query format, tables, columns, etc
As long as you're not jumping from, say, a relational to NoSQL database
SQLBolt provides a set of interactive lessons and exercises to help you learn SQL
typed it myselfπ³
i still remember the domain
Oh damn, that's good to know, yeah I will probably consider switching to SQL
I'll probably stick with what you recommended.
Should I just pull up a YT video on it or do you know another place I can probably learn from it better?
hi okimii
hey
If you want a JS dev's opinion, I prefer not to mess with the Python connectors and write an API middleman using Prisma that sits in between the bot and the database
SQL isn't an online database or?
nah that's a tutorial lol
Yeah I didnβt understand anything of that
sql is a structured query language
Yes, but SQL doesn't store it's data online or?
Structured Query Language
oh
its a language for queries it depends on what database
forgot what i just said
remember sqlite is a database based on SQL
That was my question, ok now in the right format:
SQLite doesn't store the data online, right?
Alright, so it gets stored in a local file?
if you're going to use sqlite then use aiosqlite
No. Stores it in a regular .db file
aiosqlite is the asynchronous version of sqlite
or a .sqlite file!
SQL server, MySQL, Postgres, can store it "online" in the sense that it has a URL, username & password you have to connect to
But it "stores" it on the hard disk of the local machine
Alright, alright, thank you guys. I will look into it tomorrow. Thanks for the expl
:shipit:
unrequired args with views?
what my message is messed up oh god
the what?
examples?
explanation
I think my discord just died
explarabbit?
It's alright, one of those days
Thanks for the explanations, yes lmao
Friday's a long way off guys, keep at the grind
when is friday for you
friday is wednesday for you?
that is correct
what
what
friday is tomorrow for my timezone

what timezone is 2 days ahead
scroll down my discord died
why are you learning about sql at 3 am in the morning
Why not
its Wednesday here and i have tomorrow and friday free so ill work on my gateway implementation π
seems like your shit is messed up
it appears as if so
Somewhere in the past
Also look into SQLAlchemy because once you start writing queries you'll think "surely there's gotta be a better way to do this" and I 100% agree with you
time travelers for sure
Make it good
you're asking a guy with 0 situational awareness
What is SQLAlchemy now lol
It's an ORM. It's an abstraction layer on top of SQL. Long story short, you don't have to write SQL queries
finish your modelsπΏ
hope you ain't been taken by the aliens yet
a what
a ORM
what
I've been working on my own gateway implementation as well π³ I think it's pretty good so far
I have a Gateway Interface -> Gateway State then the rest of the events will be based of state as well
ive rewrited my implementation 5 times already because its not good enough and its making me wanna yeet my computer
Prisma is one example I use frequently in Typescript, for example, to add a row to a table, you can do this:
await prisma.peoples.create({
first_name: "John",
last_name: "Doe",
age: 42
});
Which, under the hood, gets translated to:
INSERT INTO peoples VALUES ("John", "Doe", 42);

Gateway Interface acts only as the attributes holder, then in the gateway state it handles everything from close codes to the pacemaker
Thanks for the explanation, I really appreciate it, but I think its too late
i almost thought this was typescript
go to sleep trust me its better
Yup. Just something to keep it in mind
Yeah when I actually get tired
It can be. It should be. One of the best features of Prisma is its type-safety (which is non-existent in Javascript)
no go to sleep. when i program tired its just something else once i compared an int to a list and didnt knew what was happeningπ
I will most likely forget it tomorrow anyways, my brain is bad in keeping such stuff. If I got questions I will just ask in #databases 
Reminds me of:
@bot.command()
async def test(ctx, user = discord.Member)
and it took me pretty much about 30min to find the mistake
π
Hey, atleast I figured it out lmao
yep
Anyways, I will probably go brush my teeth and head to bed afterwards. Thanks for the "Introduction" to SQL, have a nice day/night my fellow friends
Took me a minute to figure out what's wrong there
lmao
You too!
Goodnight much love
it took me a solid 5 secondsπ
def foo(bar: str, baz: list[str] = []) -> None:
baz.append(bar); return baz
foo("qux")
foo("quux")
``` can you see what's wrong here
How can I delete all messages from a specific user?
Got me once before when working with components kek
I did everything for the normal message delete and the view, but forgot to add the part to remove messages from the mentioned user
nevermind
!d discord.TextChannel.purge
await purge(*, limit=100, check=..., before=None, after=None, around=None, oldest_first=False, bulk=True, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Purges a list of messages that meet the criteria given by the predicate
`check`. If a `check` is not provided then all messages are deleted
without discrimination...
nothing
if you're using >= 3.10
dont see anything wrong only that youre using a semi colonπΏ
It's a common gotcha, python evaluated the default mutable argument only ONCE, so it brings the state over to the next call
!e ```py
def foo(bar: str, baz: list[str] = []) -> list[str]:
baz.append(bar); return baz
foo("qux")
print(foo("quux"))
the list?
@pliant gulch :white_check_mark: Your eval job has completed with return code 0.
['qux', 'quux']
it's a common gotcha
Most people end up expirencing this at some point without knowing
iirc this happens because the argument gets set in the function signature?
ive kinda heard about a problem of this, of setting e.g a list as the default value
why is the return type none when it's returning a list
Oopsie
Well, this is with all default arguments
lmao was that the mistake?
Python will only evaluate them once
once after its first call?
It should be evaluating it when the function is defined
ah so what i said is correct?
Not sure 100% of how it works so I can't say
well ive heard that python evaluates a functions arguments first so maybe thats related to it idk
!e print(1, print(2))
@slate swan :white_check_mark: Your eval job has completed with return code 0.
001 | 2
002 | 1 None
learned it from this example
check=lambda message: message.author == ctx.author how would i also check for the channel
im back
error here
help
huh its working all of sudden @slate swan @heady sluice
after i change the bot.change_status thing its working
btw new problem
check=lambda message: message.author == ctx.author and message.channel == ctx.channel
why is it taking username instead of userid
@bot.event
async def on_message(message) :
if message.channel.id == 970895283250675813 :
data = message.content.split(" ")
user = re.sub("\D", "", data[4])
hehehe = str(bot.get_user(user) or await bot.fetch_user(user))
db[hehehe + 'cooked_pogchop'] += 50
db[hehehe + 'voteCount'] += 1
should be 757508305256972338cooked_pogchop instead of HydroRICO1209#8868cooked_pogchop
Is there any way to get around the issue of purge counting messages that are filtered?
?
check=lambda message: (ignore_pinned and message.pinned) or (member is not None and message.author == member)
This counts messages that are filtered out to the total deleted message count
It's a pain
(member is not None and message.author == member) what is this
is there a way to delay an on_message event such as, if message x is sent: do this, but only once every say 1 minute
such as commands.cooldown but on an event / listener
message.author == member then enough edi la
if message.author == member then member != None because message.author != None
Or the lambda can not work at all when there's no member specified
replit ?
Okay, so now that it isn't a mess
there is no response in Button()
Is there any way to fix this counting messages that aren't deleted because of the check?
check=lambda message: message.author is member and (ignore_pinned and not message.pinned)
π
i.e. when I do clear 3 @Elephant_1214#3698 rn, it'll check the three most recent messages and count them against the count of messages that are getting deleted even if they aren't from me
Are you using the button decorator @discord.ui.button?
Aka Views
Interaction and button positions got swapped
Ye
Ye ig
(self, button, interaction) is now (self, interaction, button)
wo
@pulsar bay
bruh moment
In the functions with the button decorators
@bot.event
async def on_message(message) :
if message.channel.id == 970895283250675813 :
data = message.content.split(" ")
user = re.sub("\D", "", data[4])
hehehe = str(bot.get_user(user) or await bot.fetch_user(user))
db[hehehe + 'cooked_pogchop'] += 50
db[hehehe + 'voteCount'] += 1
```should be `757508305256972338cooked_pogchop` instead of `HydroRICO1209#8868cooked_pogchop`
hehehe.id
ok

can la
Ye
kekw
Does a bot being dragged and dropped into another voice channel trigger an event listenable via dpy?
Looks like it must be this
Ye
you're gonna have to iterate through the history for that
Does anyone know of a somewhat easy project to try once you learn some sqlite - Something for a Discord bot.
right, but it'll work
economy?
I shall try 
Yeah, that was fun to make, Cameron
Can also help engrain SQLite into your memory lol
and I recommend to make helper functions instead of righting sql straight to your command functions
I will attempt, it's my first day learning it.
Wanted to see if I can put it into something possibly.
hm, interesting
good luck with it!
!d discord .json
leveling system is pretty good as well
Got it, thank you.
I heard you should use a db over json for most things.
What would a json actually be used for that's good with discord bots?
json is not a db
don't let anyone tell you differently
it should never be used as a database as there's a lot of underlying problems with it.
I know, I'm asking what a json would be used for though
Like a config file
I worded that wrong lol
but even that I would use something like yaml for configs
just a lot cleaner and takes a way a lot of the extra syntax json requires
: (
as soon as you receive any sort of significant traffic it will break so no you can't use it
..
if it's for a discord bot use aiosqlite
Got it π
it's the asynchronous version of it so it's just sqlite
Do you have a decent understanding of asyncio @alpine pewter ?
but async
if not I would recommend you at least learn the basics so you don't run into a lot of common issues as all python discord libraries are async
I'd say I have a very basic understanding of most things. I was just told to always use a database, so, I was wondering what a json would be used for on Discord.
I'm currently just learned basic aiosqlite and was wondering projects to attempt with it
projects that are asynchronous and needs a database
also damn 10$-15$/month for a discord bot

As a configuration file
idk what i am doing worng ```py
Ignoring exception in command 'giveaway_start2':
Traceback (most recent call last):
File "C:\Users\culan\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\commands.py", line 639, in _do_call
return await self._callback(self.binding, interaction, **params) # type: ignore
File "C:\Users\culan\OneDrive\Desktop\3.0.0 echo\cogs\giveaway.py", line 126, in giveaway_start
c_id = int(answers[0][2:-1])
IndexError: list index out of range
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\culan\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\tree.py", line 1094, in call
await command._invoke_with_namespace(interaction, namespace)
File "C:\Users\culan\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\commands.py", line 665, in _invoke_with_namespace
return await self._do_call(interaction, transformed_values)
File "C:\Users\culan\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\commands.py", line 658, in _do_call
raise CommandInvokeError(self, e) from e
discord.app_commands.errors.CommandInvokeError: Command 'giveaway_start2' raised an exception: IndexError: list index out of range```
i did idk what is out of range
ur list is not long enough
!e print([1, 2][3])
@boreal ravine :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | IndexError: list index out of range

so this? (answers[0][2:-1])
Ye
so i need to change the 2?
can u print answers?
[]
yeah it's empty
import discord
client = discord.Client()
can anyone explain to me more about this client thing?
I read the docs but it's still quite unclear
yeah it's a class
wdym by the answer here?
this class represents our connection to the Discord's api right
what does this mean
i keep getting rate limited does anyone know why
Are you using replit?
that's why
can i use the same crappy method of hosting on visual studio too?
or how does that work
well why does it happen to replit tho
replit uses shared IPs so if someone gets banned on a repl everyone on that IP gets banned too
π
anyway how would i host it otherwise
Self host/Buy a VPS
self host meaning leave pc on? (prob not) but ill do vps i just dont know what that means
not just a PC but yeah
wdym
virtual private server
how much would that be
and im guessing thats the best i could get
Digitalocean droplets go for super cheap
Even cheaper if you're a student
is it ez to set up
Hosting a discord bot?
Literally takes like 20 seconds to setup if you've got it down
im a noob tho and i only used replit so far
is there a yt tutorial anywhere
For setting up a vps?
idk my bot is hosted via replit and i need smth better so im just wondering
It depends on how your bot is set up
wdym
For example, my bot is all on github, so for me it's basically just cloning the repo, installing my requirements.txt, tweaking my settings and running the file
Consider a VPS like a 'second' computer, so it's pretty easy to set it up - just do everything you did on your computer to start your bot, on the VPS
Jeez
well i use replit so
im guessing its different
I must say I'm probably biased since I've never used replit
how replit hosting works is u type ur code in the replit then you get a web server like uptimerobot to ping it every 5 mins so it doesnt shut off
so i kinda wanna learn how to import that code into visual studio or whatever and go from there hosting
what does discord.Client.user represent
A User version of your bot
This is going to sound absurd, but I have to check
Do you have python installed?
You sure you donβt mean heroku?
ah ok
u wanna make ur bot 247 isit
i can help
thanks
prob not
if its smth i have to manually install
on my computer
It's likely the first step
def start_loop(self):
await self.api.start_loop()
print("Post Count")
async def setup(bot):
cog = DiscordListsPost(bot)
await bot.add_cog(cog)
await cog.start_loop()``` ```py
Traceback (most recent call last):
File "C:\Users\culan\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 912, in _load_from_module_spec
spec.loader.exec_module(lib) # type: ignore
File "<frozen importlib._bootstrap_external>", line 846, in exec_module
File "<frozen importlib._bootstrap_external>", line 983, in get_code
File "<frozen importlib._bootstrap_external>", line 913, in source_to_code
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "C:\Users\culan\OneDrive\Desktop\3.0.0 echo\cogs\api.py", line 26
await self.api.start_loop()
^
SyntaxError: 'await' outside async function
Extension 'cogs.api' raised an error: SyntaxError: 'await' outside async function (api.py, line 26)``` I seem to still be having an issue with my API can someone help me please
yeah
As the error says, start_loop needs to be async
y bad
Extension 'cogs.api' raised an error: AttributeError: loop attribute cannot be accessed in non-async contexts. Consider using either an asynchronous main function and passing it to asyncio.run or using asynchronous initialisation hooks such as Client.setup_hook```I must have accidentally taken that out last night sorry but this is the one I've really been
I've really been trying to figure out
you think i should just pay for replit hacker?
:/
no
import discord
client = discord.Client()
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('$hello'):
await message.channel.send('Hello!')
client.run('your token here')
On different VPS services
people still use client instead of bot?
if i were to buy replit hacker would it randomly restart still and go down
so it means this will ignore whatever the bot sends right
An author is a member
is there smth wrong with that
Iirc
its not wrong but its weird
bot is much more better
.
I never actually got using Bot instead of Client
I've never really ran into anything I'd need Bot for
hm
u will, someday :D
Unless you're doing some cache level shenanigans
cache level
i don't use dpy anylonger so
This just shows how bad the tutorial is.
LOL
can you answer me?
the bot,yes
thanks
this is the best among the worst
Another point is the use of making 'commands' with on_message
not true
just wondering
And a third would be the non use of f-strings
no idea
wait but it's literally the doc
you can configure it to not restart
lol just modify it urself
how
π³
so doc's examples are bad?
you'll see that option after you get hacker plqn
its not bad but it can be better