#discord-bots
1 messages · Page 706 of 1
zero is the best waifu ofc
I havent watch darling in the franxx :(
what are you waiting for?
idk, i feel like there are more funner animes
the anime isnt fun lol
more like romantic
she risked her life for her bf something a girl would never do with me😔
yeah ik, i like action romance isekai stuff
best genre 👍
you'll get one for sure
i see your a man of culture
if i keep comparing a int to a list no i wont😔
yeah now compare int to dict
waiting..
mobile isnt ez ok
will i ever get a gf?
!e
import random
a = ("yes","no")
print(random.choice(a))
@slate swan :white_check_mark: Your eval job has completed with return code 0.
no
😔
lmaoooo
😔

pain😞
will okimii ever get a gf?
!e
import random
a = ("yes","no")
print(random.choice(a))
@visual island :white_check_mark: Your eval job has completed with return code 0.
yes
see
i saw what you did
no one saw
@slate swan :white_check_mark: Your eval job has completed with return code 0.
yes

should i watch darling in the franxx?
!e
import random
a = ("yes","no")
print(random.choice(a))
@visual island :white_check_mark: Your eval job has completed with return code 0.
yes
!e ```py
import random; print(random.choices(("Yes", "No"), weights=(0, 100)))
🕴️
@pliant gulch :white_check_mark: Your eval job has completed with return code 0.
['No']
😔
she got Hiro already :pat:
im done with life😔
there are plenty of single anime girls though
whos akeno..
google it lol
yes
is discord client id a secret or can it be shraed publicly?
;)
Client ID is public
thanks
Its the same thing as your own account's ID
so it is ok to share the client id to other people?
Yes
thanks!
you watch those genres fr..
You share it in invites after all as well

i'm really new to discord bots
i watched it because of the story ok🕴️
yea "good" reason
how old are you?
old enough
!ot
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
i wish
..
alr ima watch some cocomelon
do you know how to make a bad word detection using lefi bot command framework?
can someone help me create a reputation system?
seriously
do i?
yes?
Why
oh thanks
anytime
I already tried to create but it didn't work so I deleted it and got angry today I'm trying to do it again
cool
but why do you need help?
I wanted to put it on my bot
I don't know how to handle database
learn how to use one then? you could use mongo, or an sql db
I just wanted to create a reputation system ;-;
But I don't know where I learn, I've already searched the internet
YouTube..?
Exactly I've already searched and haven't found
ok so what database do you wanna use though
Which ones are there?
you can learn sql with this
-> https://sqlbolt.com/
SQLBolt provides a set of interactive lessons and exercises to help you learn SQL
Ooo
from kayle btw
he showed me it
Then I'll learn how to create a database for my bot?
In this link
I mean sqlite3, asqlite, asqlite3, aiosqlite3, postgresql, mongodb
first youll have to learn the language of sql for a db
kayle wtf
I use replit is there any interference in this?
no json
not at all
I mean you could technically but coming from a replit db user, its incredibly slow.
and I don't think its asynchronous to be used with dpy
Basically, you set the bots interaction endpoint and it does this
i really wouldn't recommend you use replit's db
Keep in mind if you want to set the interactions endpoint you need to setup your HTTP server to validate requests from discord
you cant use local database on replit, so stuff like sqlite3 cant be used there
If your lazy you can also just use this with ngrok https://github.com/an-dyy/Lefi/blob/master/lefi/exts/interactions/app.py
But I don't recommend as it is NO where near finished
So can I use another base date outside?
Matter of fact, just scratch what I said okimii cause I'm gonna delete that file in the repo
thx
okie
and andy why did you scrolled so much🕴️ 
it's database
I'm using the translator haha
mongodb is always an option
o
Ok
postgresql..
Ty for help Sorry the inconvenience
ok
ok
wow, very socially adept
how do i make a timer untill christmas? do i use the time package?
no, use tasks.loop and look if datetime.datetime.now() is the expected time
i never heard of tasks.loop may i have a example?
thanks icy
this is basically just
@tasks.loop(seconds=5)
async def test():
pass
test.start()
``` `test` will be executed every 5 seconds
im kind of still confused tho
in?
like
im a beginner and this is my code so far.
@commands.command(aliases['tracksanta'])
async def santatracker(self, ctx, time):
tracker =
embed = discord.Embed(title="Santa Spotted!", description=f"Santa is {tracker} EST (Eastern Standerd Time) Away!")
class datetime.datetime(year, month, day, hour=0, minute=0, second=0, microsecond=0, tzinfo=None, *, fold=0)```
The *year*, *month* and *day* arguments are required. *tzinfo* may be `None`, or an instance of a [`tzinfo`](https://docs.python.org/3/library/datetime.html#datetime.tzinfo "datetime.tzinfo") subclass. The remaining arguments must be integers in the following ranges...
put the date of Christmas there
then tracker = datetime.datetime.now() - christmas_time
anytime
Won't it be
aliases = ['tracksanta']```
Yes
Hmm
@client.command(aliases=['tracksanta'])
async def santatracker(ctx, time):
tracker = datetime.datetime(year=2021, month=12, day=25, hour=5, minute=60)
embed = discord.Embed(title="Santa Spotted!", description=f"Santa is {tracker} EST (Eastern Standerd Time) Away!")
await ctx.send(embed = embed)
@visual island
is there a problem with it?
no just a mis understanding lmao
Is there a way to check if a message contains an embed
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-nh7_4wkh/dotenv/
Merry Christmas guys!!!
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-nh7_4wkh/dotenv/
@visual island i know the problem i just dont know how to solve it.
i use "python3" not "python"
You too (:
Pycharm isn't "hard", its complex
Its a very advanced IDE, and beginners stumble in it a lot
why even copying, when you can just git clone
You need to install requests with pip
Pip install it again, it always gives this error on first time use, then restart your ide
OK how do i install requests pip?
Restart VSC if u have installed the module
nope
Then install requests
Open cmd prompt and run pip install requests
If you have python added to PATH it should work
Otherwise you may add it to path manually but it is kinda difficult compared to reinstalling python with checkmark on
What library is good for fast migration to slash commands?
fixed?
Please someone? https://paste.pythondiscord.com/eraniwerog.py
nope
error when running the program, or error on the code?
program
how are you running it?
How do I timeout a button after x seconds? I have subclassed discord.ui.View
Try printing response.json()
!d discord.ui.View.timeout
Timeout from last interaction with the UI before no longer accepting input. If None then there is no timeout.
Is that right?
print(x)
Ignoring exception in command weather:
Traceback (most recent call last):
File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "c:\Users\thoma\Desktop\discord.py\python\bot.py", line 346, in weather
y = x["main"]
KeyError: 'main'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: KeyError: 'main'
You have wrong API key
It depends how does that API receive apikey
It may get it from headers or from params
Could you give me the link to API docs so I can help you a bit of more with that? @jade tartan
Nvm found them
Don't know what you mean
Could send it to me?
What is your base_url?
I would suggest to make the request like
r = requests.get(base_url, params={'appid': api_key, 'q': city_name})```
But it depends what base_url you have and does it accept params or json
You don't get the response with a key "main"
how do i make a welcome message on my bot delete after a second
send takes a delete_after kwarg
await channel.send("something" , delete_after = 10)```
ty
you response does not have main
could you explain what do you mean by check?
im sorry i forgor to delete that
for sending files you can use file ( if a single file) or files if they are many
Alright
arl find the solution
yea ikr bout that
ohh as a json file?
Yea , .json()
Converts the response to a dictionary/json
copied code
no, all of it and i see no error in your code
was unbanning username not user
nice
Command raised an exception: ServerSelectionTimeoutError: localhost:27017: [Errno 111] Connection refused, Timeout: 30s, Topology Description: <TopologyDescription id: 61c6d3224a33439c539198ad, topology_type: Single, servers: [<ServerDescription ('localhost', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('localhost:27017: [Errno 111] Connection refused')>]>
I want help in this error
how do i archive a thread (using ctx.channel)
python helpers knowing mongodb pls help
this is not the appropriate channel
whatever, the issue is related to databases
thanku
not possible
I think like some forks have it
hmm kden
!d discord.Thread.edit ig
await edit(*, name=..., archived=..., locked=..., invitable=..., slowmode_delay=..., auto_archive_duration=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the thread.
Editing the thread requires [`Permissions.manage_threads`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_threads "discord.Permissions.manage_threads"). The thread creator can also edit `name`, `archived` or `auto_archive_duration`. Note that if the thread is locked then only those with [`Permissions.manage_threads`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_threads "discord.Permissions.manage_threads") can unarchive a thread.
The thread must be unarchived to be edited.
It takes a archived kwarg
oo
Why is sub classing for custom help command better than making like a command for it
hmm
there's also a guide in there so yeah
.
can you have more than one welcome bot event?
Sure
!d discord.ext.commands.Bot.listen use this then
@listen(name=None)```
A decorator that registers another function as an external event listener. Basically this allows you to listen to multiple events from different places e.g. such as [`on_ready()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_ready "discord.on_ready")
The functions being listened to must be a [coroutine](https://docs.python.org/3/library/asyncio-task.html#coroutine "(in Python v3.9)").
Example...
the top one isn’t working
It won't work cz two functions can't have the same name
oh
where do i apply this?
Instead of event
so @bot.@listen(name=None) ?
@bot.listen("on_member_join")
async def join_one(member):
. . .
@bot.listen("on_member_join")
async def join_two(member):
. . .
ty
You won't have to hardcode everything
and you will be able to use things like ctx.send_help
for a good help command, not matter how you implement your help command, you will somehow end up with something that does the same thing as the HelpCommand class. so why not use it instead?
hi
just overrride the methods and use self.context as the "ctx" of the help command
ctx
wait......how'll this work?
Like ernst wants it to
You can do different things in different functions simpl
very reassuring
oh fine fine
how to make the bot send a message when some timeout a member?
Which Library?
wym
You don't
do you know how?
What?
What library do you use......
because discord.py is not adding anything updated on discord
It's a dead Library
py. ?
yea discord.py
hmm, i dont think you can do anything with that
what should i do
since its development's stopped
: (
don't think there's any such event for that
Disnake and pycord don't have any implementations for that
use some other lib
ok
wich do you recommend me
Disnake
. @jagged root
ok
you will have to more to any other Library in 2-3 months Anyways
move*
kk
Yea. Was a typo
Ikr
how can i move
await timeout(*, duration=..., until=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Times out the member from the guild; until then, the member will not be able to interact with the guild.
Exactly one of `duration` or `until` must be provided. To remove a timeout, set one of the parameters to `None`.
You must have the [`Permissions.moderate_members`](https://docs.disnake.dev/en/latest/api.html#disnake.Permissions.moderate_members "disnake.Permissions.moderate_members") permission to do this.
New in version 2.3.
thanks also do you know how to move of library
grammar
im not english shut up
👌
If you start using disnake (which I recommended) you have to change all discord to disnake such as imports and well everything
kk
not everything
wdym?
i never really understood why you need to do that in an import
I think it's more with to just replace discord with disnake
Do you mean why you need to remove discord impors and replace by disnake? You start using new lib and it's not useful to have discord imported if you use disnake
I didn't mean that
i already replaced discord to disnake, is it done?
I meant why you need to do disnake[shim]
Yes that's good, did you pip install disnake as well?
i did manually
It would install disnake with name of discord
If it is installed then it is
would that work with every lib/module?
No I don't think so, it's just a feature of lib afaik
o
Seems fine
Np
Is disnake and discord.py the same?
like will there be any error throughout the written discord.py code if I change it to disnake
Everything from discord.py V2 is applicable in disnake
Alright
Also what does it mean by voice support “To install the library without full voice support…”
@client.command()
@commands.has_permissions(ban_members = True)
async def timeout(ctx, member : discord.Member, *, reason = None):
await member.timeout(reason = reason)
await ctx.channel.send(f'{member.mention} has been takeing a brake by {ctx.message.author.mention} for reason of: {reason}!')
````AttributeError: 'Member' object has no attribute 'timeout'` any ideas?
You can't use discord.py for timeout
what fork are u using
It's no longer maintained which means it won't get updated
oh nvm right, there's discord.Member
I recommend to use disnake instead
ok ty
do you mean guild Ban or the timeout feature
Guild i guess
!d disnake.on_member_ban
disnake.on_member_ban(guild, user)```
Called when user gets banned from a [`Guild`](https://docs.disnake.dev/en/latest/api.html#disnake.Guild "disnake.Guild").
This requires [`Intents.bans`](https://docs.disnake.dev/en/latest/api.html#disnake.Intents.bans "disnake.Intents.bans") to be enabled.
k
@client.command()
@commands.has_permissions(manage_messages=False)
async def purge(ctx):
await ctx.send(f'No perms')
@commands.has_permissions(manage_messages=True)
async def purge(ctx,amount=1,):
await ctx.channel.purge(limit=amount+1)
You are missing Manage Messages permission(s) to run this command.
I own that server btw
The False part works
does disnake have timeout support
Yes
ok
!d disnake.Member.timeout if you were looking for docs as well
await timeout(*, duration=..., until=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Times out the member from the guild; until then, the member will not be able to interact with the guild.
Exactly one of `duration` or `until` must be provided. To remove a timeout, set one of the parameters to `None`.
You must have the [`Permissions.moderate_members`](https://docs.disnake.dev/en/latest/api.html#disnake.Permissions.moderate_members "disnake.Permissions.moderate_members") permission to do this.
New in version 2.3.
async def get_pre(bot, message) -> str:
bot.db
print(message.guild.id)
return "guild prefix"
intents = discord.Intents.all()
bot = commands.Bot(command_prefix=get_pre, case_insensitive=True, intents=intents)
bot.remove_command("help")
async def create_db_pool():
bot.db = await asyncpg.create_pool(
dsn="my cool link"
)
bot.loop.run_until_complete(create_db_pool())``` would i be able to use the bot.db in the get_pre coro , altho it wasnt defined 
I think if you move the create_db_pool before get_pre it might work
Oh wait now I know
You have bot = commands.Bot, u have defined bot after get_pre function
if you run create_db_pool() this function before the bot is started then yes
oh okay thanks
yeah , i'll try it but what i expect is, that i could use the bot attribute since its getting it from bot that is passed by default from the package
Merry Christmas y’all
!ot
mhm, ikr
hehe
bye?
hehe discord bots
oof
none
django supremacy :blobthumbsup:
anyways
nvm
Yeah I’ve been doing django as well lol
I was just gonna do OT

Flexing your nitro, huh
if someone can help
Alright
If you do manage_messages=False why can’t you just remove it?
Also
You did two has_permissions
You can just make an error handler to handle missing permissions
All you have to do is commands.has_permissions(manage_messages=True)
However if you retrieve a missing permissions error you can just make a purge.error
Or global error handler
Yeah ig lol
I’m starting to get good at asking questions
I recently received 2 upvotes in another question
And one downvote 😭
I also gained 2 rep from editing
I don't use stack overflow for asking questions
Why
This server is better place
I agree, but there are experts out there that don’t use this discord server
We are privileged to have Caeden though lol
how do i convert a str object (image) into a bytes object
a local image?
nah url
You may use request and pillow
hm
Are you taking about a user's avatar?just asking
Command raised an exception: AttributeError: 'Member' object has no attribute 'avatar_url' how?
command was working yesterday
Try avatar.url
ok
you updated to discord.py V2.0
yes
hey
can someone help with this its a tweet command in python for my discord bot
error_style is incorrect and idk what to replace with
What is error_style
You made the code, right?
You can use py member.avatar.url to get the user's avatar url ( though this works only if the user has a non default avatar ).
member.default_avatar.url``` for default avatar
Or , just use ```
member.display_avatar``` will show the user's avatar which shows up in the server , either custom , or main , or default
@hollow crown
Not the tweet one me and my friend do and he sent me the code and told me to put it in
thats why i have no clue
display_avatar only works in 2.0 btw
thank you so much man
And they are asking for the same
We neither can know what the error style is supposed to be (at least I can't). If your friend send the code they might know what that is
error_style is undefined
Show all related code
where did you get the code from?
My friend that also works on the bot
@tawdry perch
ok so
what's the problem
hm , just make an variable named error_style on the top of code after imports
If you want your error messages to be sent in discord as embeds , set it to "embeds" else set it to "console"
how about member.top_role.color what has it have changed it to
i dont know how to code the new feature " timeout "
It's still same iirc
!d disnake.Member.timeout
await timeout(*, duration=..., until=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Times out the member from the guild; until then, the member will not be able to interact with the guild.
Exactly one of `duration` or `until` must be provided. To remove a timeout, set one of the parameters to `None`.
You must have the [`Permissions.moderate_members`](https://docs.disnake.dev/en/latest/api.html#disnake.Permissions.moderate_members "disnake.Permissions.moderate_members") permission to do this.
New in version 2.3.
oh ok thanks
!d discord.Role.color
property color: discord.colour.Colour```
Returns the role color. An alias exists under `colour`.
Yea it's same
so.. get member object -> do member.timeout(duration, reason)
duration will be in seconds or it can be datetime object, reason is optional
im fairly new and have no clue how to make a variable named error_style
quite simple
ight
error_style = "embeds"
It's basic python.
ohhhh
after i do that everythings kind of fine
oh
got it
now i need help with coin flip
datetime. is a error and time
any other way?
Import datetime
thanks
Weird i get like a million error codes when i try either of those
You should actually learn python properly before making a bot
How can I write 8ball without the _ showing in the help command and command requiring the _?
Use the name kwarg of commands
@bot.command(name=" commandname")
async def command....```
oh ok thanks
Can we add a warning system in discord like telegram?
Wym
for eg lets say you used an abuse in telegram, u usually get a warning by bots, can we do the same in discord?
Warn a user for the given reason.
☺️💀💀
how do I make it so these dont show under the help list
If True, the default help command does not show this in the help output.
thanks
and is there a way to give it a category name cause the custom help command is in the main.py
no but you can just change if category == "No Category" to something
alright
How to reply to a message without it being global, so like it can only be seen by the person who used the command
ephemeral message can only be sent from interactions
oh okay
다들 메리크리스마스~~~!!!!!!
merry christmas
メリークリスマス
Error: Command raised an exception: RecursionError: maximum recursion depth exceeded while calling a Python object
Help plsss
nonononoㄴㄴㄴㄴㄴㄴㄴ
이건 아냐
@visual island
add_item()'s arg should be ui.Item instance
Is it possible to make a bot livestream something as a message? or do I need to keep editing the message, wouldn't that hit the API rate limit?
error:
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In embed.thumbnail.url: Scheme "img/error_minecraft_1.png" is not supported. Scheme must be one of ('http', 'https').
code:
emb.set_thumbnail(url = "img/error_minecraft_1.png")
``` ?
url must be a link not a file
how do I add a image from a computer to embed?
- sure
- yes, you need to edit it
- depends
!local-file
Thanks to discord.py, sending local files as embed images is simple. You have to create an instance of discord.File class:
# When you know the file exact path, you can pass it.
file = discord.File("/this/is/path/to/my/file.png", filename="file.png")
# When you have the file-like object, then you can pass this instead path.
with open("/this/is/path/to/my/file.png", "rb") as f:
file = discord.File(f)
When using the file-like object, you have to open it in rb mode. Also, in this case, passing filename to it is not necessary.
Please note that filename can't contain underscores. This is a Discord limitation.
discord.Embed instances have a set_image method which can be used to set an attachment as an image:
embed = discord.Embed()
# Set other fields
embed.set_image(url="attachment://file.png") # Filename here must be exactly same as attachment filename.
After this, you can send an embed with an attachment to Discord:
await channel.send(file=file, embed=embed)
This example uses discord.TextChannel for sending, but any instance of discord.abc.Messageable can be used for sending.
- Was not possible, I looked it up.
- Yes I can edit it
- Definitely will hit the rate limits 😦
Is there another way?
Honestly no idea, why do you wanna livestream something?
don't update it regularly
Try cacheing it and update it in every n seconds
What do you want to livestream with a text message tho
So my idea was
To use a satellite API of some sort that returns live images, and I want to make this request continuously and make a message update itself with the new image each second, for 15 seconds straight and then stop it
you cant edit attachments
are you sure?
actually, discord will convert message with url with .jpg and other image format to images if you have attach files permission. So you can (probably) save it to a url, then send it to discord, and edit the content to a new url
but the edit method has an attachments kwarg
await edit(content=..., embed=..., embeds=..., attachments=..., suppress=..., delete_after=None, allowed_mentions=..., view=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the message.
The content must be able to be transformed into a string via `str(content)`.
Changed in version 1.3: The `suppress` keyword-only parameter was added.
You can just set it to None , not add a new one
but you can edit attachments, discord introduced it couple months ago
pls show us a live example with you user account
You can now
Oh?
Dpy doesn't have a file/files kwarg for Message.edit but it does for Interaction.edit_original_message
Bro that's an interaction not a message
You can change the attachments on a Message and edit new files, just not with dpy itself
E.g. if a fork supported it you could do that
bruh u can just delete the previous and add the edited?
Yes
Starting with API v10, the attachments array must contain all attachments that should be present after edit, including retained and new attachments provided in the request body.
pycord supports it lol
v10..
thats cool
Works in v9 (editing attachments)
but eh i dont think its very useful since u can just delete the file and add the edited
oh~
I never tried it yet as I pretty much dont need it
Oh I see
yeah im a noob sorry
ok
ahem ahem
hi

ew flex twice within 5 mins
Anything else?
I broke my remind command smh, I don't even know how
Nahh, instead working on an app/website with a friend of mine
Bots are.... boring now
That... sucks
smth went badly wrong in database but nothing makes sense anymore in it
Sad
better use Java for apps though
It's a website, and am using dash for it
!pypi dash
Anyways it's OT soo, uhhh
what database are you using?
@maiden fable i dont think discdb is that efficient because you have to fetch everything (the data) and you'd have to have to message id at all times (i think, im not sure) unless you have some sort of caching system
Well get_json does returns the message content, and I ain't fetching the msg everytime
o
Also am saving the msg in self._msg
dash is the easier version of flask?
Well, u can say so ngl. But we didn't pick it cz it was easier. Before we were using flask but since we also want dropdowns and stuff in our webpage and didn't want to add any custom JS for the events like whenever someone interacted with the dropdown, we went with dash
oh I see, basically making an interactive website without using js instead from the backend. That's cool
illegal
os.getenv("LAVALINK_HOST"), 2333, os.getenv("LAVALINK_PASSWORD"),
Where can i find my LavaLink Host and Password?
what i did wrong there? help me please!
Where did you host the lavalink
Local
On your own PC?
yes
At which port did you open the firewall?
2333
And what password and username did you set in the lavalink?
And the username is ofc your localhost IP
Hmm what was the issue??
i restart my bot and it worked lol
Hmm
what i did wrong there? help me please! could someone help me please?
hey guys, does anyone know how i can make a user input using replit, so like if i made a question and there could be two answers. One could be yes and the other no. i want the bot to read it and respond either correct or not? so far the bot is able to ask a question but to respond i have to go to the replit terminal
Does this if-statement detect @everyone tag?
if message.role_mentions:
can anyone help me? i try to make a Music bot but i got a error :/
so i've got a automod thingy which adds words to a database and then checks if any message contains that word by using sets
so i'm wondering is there any way to avoid reading the database everytime someone sends a message
On bot startup, fetch from the db once and set a botvar with the result @slate swan
and what if people add new words while the bot is running
Like bot.bad_words = <fetch from DB>
how do you give a command a cooldown i forgor 💀
Either update the botvar on every command (not preferred by me) or just make a task which fetches from the DB every 5 min or smth
@commands.cooldown(1, 30, BucketType.member)```
!d discord.ext.commands.cooldown
@discord.ext.commands.cooldown(rate, per, type=discord.ext.commands.BucketType.default)```
A decorator that adds a cooldown to a [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command")
A cooldown allows a command to only be used a specific amount of times in a specific time frame. These cooldowns can be based either on a per-guild, per-channel, per-user, per-role or global basis. Denoted by the third argument of `type` which must be of enum type [`BucketType`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.BucketType "discord.ext.commands.BucketType").
If a cooldown is triggered, then [`CommandOnCooldown`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CommandOnCooldown "discord.ext.commands.CommandOnCooldown") is triggered in [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") and the local error handler.
A command can only have a single cooldown.
huh i dis/misremembered eit
so i've got the task part and its a bit hard tbh
so like in every 5 minutes i fetch all the info in the database to a dict then access each servers blacklist words by the id then covert it to a set and compare it to the message 
what does rate have to be and per
Yea... Just update the botvar
lots of work but okie
so would that allow the command to be used once every 30 seconds?
If I set the rate to 5 and per to 3, and if I send 6 messages in 3 seconds, then I get ratelimited
Yes
i have to revamp a whole file

How to detect @everyone or @here tag in bot?
bruh, it's from discord.ext import commands
can i store a list in a database as a string then return it so its becomes a list when i fetch it ?
def main(key):
try:
client.run(key)
except:
sys.exit()
api_key = StringVar()
def submit_api_key():
x = threading.Thread(target=main, args=(api_key.get(),))
x.daemon = True
x.start()
idk if this is for here, but im stuck tbf. Im trying to run a tkinter gui and discord bot together and it works perfectly fine if i enter the correct api key first time, but if i make a mistake and then type the correct one it still wont work due to "Event loop is closed". I tried fixing this by doing sys.exit() on improper token but this still doesnt seem to work so oof, any help would be greatly appreciated
i might be dumb on this problem tho
yes ive done that before you can store a string seperated by a delimiter (eg. ",") and then use split function to get the list
yh makes sense.
but what are you trying to achieve though, the thing with the method i showed is kinda stupid for the reason i did it as there was a much ebtter way
i was trying to store pokemon characters for each user whenever they gained one
yk a blacklist system that blacklist words , each guild has there own so a guild : array of blacklisted words
ah i see
the thing i would do instead of an array is that i would make a composite key of guild and blacklist word and have multiple of them, the two of the same would not exist but you would be able to remove and add new words much easier than the list thing
rlly hard to explain ill show a pic
im not the best at expalining
the user_id is not a primary key and can be repeated, having multiple pokemon names, but not two of the same rows exist
that is much much better than a long string seperated by commas imo
and you can get all the values back very easily using commands, but this is sql tho
idk if this has helped but yh
you can use AllowedMentions to prevent everyone pings
its a commands.Bot attribue
oh, thanks!
commands.Bot(... allowed_mentions = discord.AllowedMentions(everyone = False, users = True, roles = False))
np :D
Do you want to check if a message mentions everyone?
yeah, already figured out how to check it. Thanks
cool message.mention_everyone would be the easiest way to do that
nah just AllowedMentions is easier
that's not even related
cus that applies on all the bot
It's used while sending messages
it is
no
class discord.AllowedMentions(*, everyone=True, users=True, roles=True, replied_user=True)```
A class that represents what mentions are allowed in a message.
This class can be set during [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") initialisation to apply to every message sent. It can also be applied on a per message basis via [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") for more fine-grained control.
I like this
Specifies if the message mentions everyone.
Note
This does not check if the @everyone or the @here text is in the message itself. Rather this boolean indicates if either the @everyone or the @here text is in the message and it did end up mentioning.
yeah ik but i thought he was trying to prevent role mentions
That's just for the bot sir , they want to check if a message received from Gateway mentions everyone
@tasks.loop(seconds=30)
async def my_loop(self):
data = await self.bot.blacklist_db.fetch("SELECT guild_id , text FROM blacklist")
ids = [i["guild_id"] for i in data]
words = [i["text"] for i in data.split()]
print(dict(zip(ids,words)))
``` sooo confused
https://cdn.discordapp.com/attachments/696888170167664691/924341862012182528/unknown.png
What db are you using?
Seems like you're using an non-async one
can u print i for i in data pls i just wanna cehck something
Can i add special discord role to a user for only 15 minutes? Is there any flag like in message deletion?
you can use await asyncio.sleep(60*15) to sleep for 15 minutes
Nope , but you can asyncio.sleep for 15*60 seconds and remove the role
yeah
^
user=<user>
role = discord.utils.get(ctx.guild.roles, name = "role name")
await user.add_roles(role)
await asyncio.sleep(60*15)
await user.remove_roles(role)
here
hold on
oop
Thanks!
wait wa
i think for me sleep is bad idea
np
why?
cuz i use it in on_reaction_add event
Doesn't matter
it does , bot only for that reaction
🤔 wow
So even if two users react on the same time , each session would be continued seperately
oh
that's what async is....
nice
A
Is this only works for bot commands? Does it work for on_message event for example?
this basically works on all the bot, the bot will never be able to mention specific pings
aah, thanks
It works whenever your bot pings someone, be it on message or command
but if you want it locally, you can try this
ugh finally
i'm close to finish rewriting it
almost an hour
and 15 mins
A bot in an hour and 15 mins?
me who's been doing the same for a month
I have Commands object how do i get the docstring of the command ?
!d discord.ext.commands.Command.short_doc
property short_doc: str```
Gets the “short” documentation of a command.
By default, this is the [`brief`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command.brief "discord.ext.commands.Command.brief") attribute. If that lookup leads to an empty string then the first line of the [`help`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command.help "discord.ext.commands.Command.help") attribute is used instead.
Ok
command.brief can also be used tho
Or. Command.callback.__doc__
yea also what hunter said
But brief can be different , as the embed above explains
Yea
!pypi discord.py
This is the basic one, but since it's discontinued, u can use some of it's forks like disnake and pycord
which one would you recommend and what knowledge should I have beforehand?
Basic asyncio, classes and OOP
disnake imo , and for knowledge
basic concepts like variables , data types , OOP and a bit of Asyncio
And staying away from YouTube tutorials
ima have to learn some asyncio then. Whats so bad about youtube tutorials?
Sure , you won't actually have to use Asyncio in it but it's better if you know how it works
Most of Tutorials are outdated ( based on discord.py 1.7.3- , which is now out of development)
They use many had coding practices ,etc
*bad
if you go through the docs , you can understand everything they teach in a better way
Youtube tutorials teach you through a middle man
The docs come directly from contributors and or the maintainer
aha where can i find those?
aha thanks!
- functions and decorators*
Well yea. Sarthak completed the list for me (;
!d discord.on_voice_state_update ^
discord.on_voice_state_update(member, before, after)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") changes their [`VoiceState`](https://discordpy.readthedocs.io/en/master/api.html#discord.VoiceState "discord.VoiceState").
The following, but not limited to, examples illustrate when this event is called...
decorators are confusing :/
at least learn the basics of decorators since they are frequently used in dpy
tbh, I'd say just get to the intermediate point of python and then do a dc bot
Hi
Yeah i understand the simple decorators but then there are several on top of eachother it gets confusing
Unless you are working internally you won't need to know all that confusing stuff
well. In case of discord bots decorators are not too confusing
The only thing in discord.py you need to know about decorators is that
Yea
Functions, methods can be decorated by them
E.g @decorator placed over the function, method declaration
one last thing , use commands.Bot if you're making commands . Not Client. 
Wait imma send a youtube video, I never understood how decorators works until I watched this one, give me 1 min
interesting
Decorators are an advanced feature of the Python language that allow you to modify the behavior of a function or method without touching its code. This video will teach you why decorators work and how to create your own. It will also walk through a few examples to give you a better idea of where to use Python decorators.
⭐ Kite is a free AI-pow...
Here, I promise you wont regret
It's nothing advanced btw, bare basics
skip to 1:09
Decorators are very neat syntatic sugars, I'd give it 8/10 prob
Very useful in advance cases such as using decorators as markers via metaclasses and a staticmethod
Eh, depends on what you are doing
I use metaclasses, a lot
But mostly you won't need them
I mean, just why?
Metaclasses aren't even necessary?
Do u just do it, because u can? lol
https://github.com/an-dyy/Lefi/blob/master/lefi/exts/commands/core/plugin.py Take a look at this
Using this metaclass I can actually decorate methods in a useful manner
Unless otherwise I would be required to use @Class.method(...)
But here I can use a special marker, E.g @command(...)
Losing the need of access for the Class from earlier
mY gaWhd haf merhyy 👴
Are you making your own discord API wrapper?
Yes
ty
buttons most forks have them i think even dpy has them
bro that's insane, ur doing it all alone?
ouhh
yep pretty easy to learn with view
if your using disnake just subclass view and add buttons lol
I am thinking of going back to dpy
just why
Hi, is there a way to get a member object with a user's name?
I know about IDs, but I don't want to use them for some reason...
Not all alone I got some helpers
But I did do a lot of the stuff in the wrapper it's quite hard to maintain
<ctx>.<author/user>.name
can I not make my bot dump on disboard for me ?
I see, but why?
Why for what? Why did I decide to make an API wrapper or?
Yeah, what made you wanna do an API wrapper for discord?
Because I didn't like how discord.py was ending, and I didn't like all the shitty forks out there
So I took matters into my own hands
Damn, lets hope your new API wrapper succeeds 🙂
A
But I don't want to get the member who sent the message...
that's why I put /user there
i am not sure about this at all but..
discord.utils.get(client.users, name = "user")
not what he asked for
Ohk, should I just put the username in there, or the 4 digit code too?
he asked for something just like fetch_user but with username instead of id
u could try this but am not sure
Yeah, this looks more suited for what I wanna do. Thanks guys
discord utils kinda slow tho
np, again not sure so pls tell me if it works
ugh
yeah true but idk if there is any other way
?
i'm blank how to do this
!d discord.ui.Button
class discord.ui.Button(*, style=<ButtonStyle.secondary: 2>, label=None, disabled=False, custom_id=None, url=None, emoji=None, row=None)```
Represents a UI button.
New in version 2.0.
okimii — Today at 6:58 PM
yep pretty easy to learn with view
if your using disnake just subclass view and add buttons lol
!d discord.ui.View
class discord.ui.View(*, timeout=180.0)```
Represents a UI view.
This object must be inherited to create a UI within Discord.
New in version 2.0.
Check both of these
ok
and what oki said ^
you forgot the "mii"part how is my name so hard its only 6 characters long
well it's double so yes
🚶
hello oki

wait how do you add all intents in disnake
Almost forgot to tell you, it's working...
same as discord.py
oh really?
thats cool
!d discord.utils.get
discord.utils.get(iterable, **attrs)```
A helper that returns the first element in the iterable that meets all the traits passed in `attrs`. This is an alternative for [`find()`](https://discordpy.readthedocs.io/en/master/api.html#discord.utils.find "discord.utils.find").
When multiple attributes are specified, they are checked using logical AND, not logical OR. Meaning they have to meet every attribute passed in and not one of them.
To have a nested attribute search (i.e. search by `x.y`) then pass in `x__y` as the keyword argument.
If nothing is found that matches the attributes passed, then `None` is returned.
Examples
Basic usage...
oh
but when i do disnake.intents.All() its saying that use Intent not disnake.flags.intents
how to check how many servers my bot ? 😄
It's discord.Intents.all() and this disnake.Intents.all()
sm0L a
bot.guilds returns a lost of servers
You can use len()
!d disnake.Intents.all
classmethod all()```
A factory method that creates a [`Intents`](https://docs.disnake.dev/en/latest/api.html#disnake.Intents "disnake.Intents") with everything enabled.
im getting this traceback:
Traceback (most recent call last):
File "main.py", line 11, in <module>
bot = commands.Bot(command_prefix=["$", 'Diesel, ', 'Deez, ', 'Copilot, ', 'copilot, '], intents=discord.Intents.all())
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 98, in __init__
super().__init__(**options)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 1107, in __init__
super().__init__(*args, **kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 248, in __init__
self._connection = self._get_state(**options)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 265, in _get_state
return ConnectionState(dispatch=self.dispatch, handlers=self._handlers,
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/state.py", line 152, in __init__
raise TypeError('intents parameter must be Intent not %r' % type(intents))
TypeError: intents parameter must be Intent not <class 'disnake.flags.Intents'>
why isnt it catching that error ?
when i use disnake.Intents.all()
wtf is that
["$", 'Diesel, ', 'Deez, ', 'Copilot, ', 'copilot not closed here, idk whats even this '] -> , ```
wdym, i added a space there so syntax looks clean
Bro why did you use discord.Intents.all when you're using disnake
i did import disnake as discord
but it's importing it from discord anyways
That's a bad practice
💀
how
time to search replace ig
!e
import random as discord
print(discord.choice(["hey","i'm","working"]))```
Your bot is actually discord.ext.commands.Bot
ok now it's working
oh wait
i search replaced
Great
@slate swan :white_check_mark: Your eval job has completed with return code 0.
working
explain that then 
or is he importing discord aswell
he had discord imported too as his error suggests
no i did import disnake as discord and then from discord.ext import commands but now i search replaced
Yea
Your commands came from discord
now that makes sense, replit thought i was using discord
still don't blame it on replit tho
just use disnake :p, don't import it as Discord lol it's often confusing
Even for yourself
im just changing from discord.py to disnake for no reason lol
how? can u show example?
print(len(bot.guilds))
disnake is an active fork of discord.py since discord.py is no longer getting updates or maintained anymore
ehh i user pycord
I know.. but what u said made no sense
it even supports the new timeout feature
to discord.py to disnake
disnake has way too much updates for small shit ig
and that's not bad
Disnake doest that too , it's all person preferences
the vsc write to me its 0, because my bot min 5 server 😄
same as disnake lol
await timeout(*, duration=..., until=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Times out the member from the guild; until then, the member will not be able to interact with the guild.
Exactly one of `duration` or `until` must be provided. To remove a timeout, set one of the parameters to `None`.
You must have the [`Permissions.moderate_members`](https://docs.disnake.dev/en/latest/api.html#disnake.Permissions.moderate_members "disnake.Permissions.moderate_members") permission to do this.
New in version 2.3.
very lovely
If you will print that directly , that will always be 0,
Make it a part of some function or something which runs after the bot is online
😍 disnake looks awesome
reason for it being 0 is , discord.py is a cache dependent library , so until the bot is online almost every cached object is 0
wait im not that familiar with timeouts but what does until=... do
the duration already provides the time
until takes a datetime object instead of seconds
i see why they said one of duraton or until
you can only use 1 of them tho and if you put one as None it removes the timeout
i never use print in command. how can i use it? 😄
@bot.event
async def on_ready()
print("I'm in"+len(bot.guilds)+"servers")
```🏃♀️ it's googleable so I expect noone to ping me randomly Asking not to codefeed
@tacit token
Try giving the value a variable.
@bot.event
async def on_ready()
Guild_count = len(bot.guilds)
print("I'm in "+ Guild_count +" servers")```
Did you change anything in the intents?
are intents even enabled?
And yes. You didn't use the code I sent
Guild intents are enabled by default , unless they change it
oh kk
Well if that's the case.. I don't think he used the code u've sent cuz ther's nothing wrong abt it
Yea
len always gives an integer right?
Or is there a case where you have to convert it?
len is length , so it's always 0/ a positive integer
alr ty
I am following the one in dark black and idk whats wrong
It's just replit being weird
no way to fix?
Hover on it and read what It says
The indentation is different
Your indents
its probably pyflakes being slow again


that's very rare tho