#discord-bots
1 messages ยท Page 623 of 1
what discord.utils.timezone will do ?
!ot dudes and dudettes
Off-topic channels
There are three off-topic channels:
โข #ot2-never-nesterโs-nightmare
โข #ot1-perplexing-regexing
โข #ot0-psvmโs-eternal-disapproval
Their names change randomly every 24 hours, but you can always find them under the OFF-TOPIC/GENERAL category in the channel list.
Please read our off-topic etiquette before participating in conversations.
Haha np, too much going on too, just came back cause of a school project
Ah cool
Python annoying as in the bot
Havent heard that phrase in a while
discord.utils.timezone what this will do /
discord.utils.utcnow()```
A helper function to return an aware UTC datetime representing the current time.
This should be preferred to [`datetime.datetime.utcnow()`](https://docs.python.org/3/library/datetime.html#datetime.datetime.utcnow "(in Python v3.9)") since it is an aware datetime, compared to the naive datetime in the standard library.
New in version 2.0.
fact=True
Yes.
same as datetime.datetime.now(timezone=<utc>) ig
๐Why can't y'all take this to an ot channel, just why
We're not bothered
๐ข
But we really should
hunter = await ctx.send("!ot")
```
You gonna get bothered when a mod comes?
idk
they're fucking annoying man, just let them be
I'm still waiting for a question
Okay, let's try that. @novel apex here I come :D
It'll return the timezone aware object, which is now required by lib to display native time
No they ain't
What's the question?
what do they want
aah i am confused!!! this will show the time of server's region or wot ?
@manic wing were just bored and having fun when people come we answer the question so please get your facts right
To display embed time in user's local timezone (maybe)
What time do you need and for what?
I tried doing that, went halfway around the internet, found nothing, gave up, but I'll do my best
i need bot to display the users time
pyzt or pytz (whatever the name is) should work
Where? In your cmd or on frontend of discord?
try using pytz
Yes, discord.utils.utcnow() is just the shorthand for it
ah ok
Ive never used discord.utils is it just better for getting stuff like roles and channels?
discord utilities judging by the name
Yeah ik i have to check it out
Makes it easier to find things in an iterable. For example, finding an object in an iterable with a certain attribute
and a few other things i've never really used, i've only used utils.get
A utility module, my favourite... Yes most utility related modules are basically to provide..... utility functions... yes
Good to see you here and wdym be easier?
I see do you have to download it or is it with discord.py?๐ค
Making your 10 line code into 1 + easy to code and remeber
Oh wow
Basically more efficient
๐ I mean, i'd rather have a one liner than having to loop through each attribute of each object and try to match something
True true
how do for bot delete all new messages in channel?
That will cost a lot of requests for a lot of messages
If you need to delete a message instantly, use on_message
i want when someone write new message in channel bot delete message
yep i know but what write
Make a listener function for on_message event... Have u ever used listeners?
@client.event
async def on_message(message):
if message.channel.id == <id>:
await message.delete()
I think
Thats how I did it anyways, there could be a different easier better way
i wouldn't suggest using on_message for stuff like this
Is there any other way for deleting a message as it is sent in a channel?
you can use a listener
Im going to learn aiosqlite and discord utils so everybody have a good day later
Umm on_message is a listener..?
Good luck 
Thank you 
Oh you mean make it listener instead of event, yes
don't hardcode your events
In my case, I use it under a different listener lol
Whats the difference between listen and event someone saidnto me theirs no difference
an on_message overrides commands so if you don't have the process_commands none of your commands will run
it's very easy to forget and a lot of people have issues with it
I see๐ค
I had that issue, I just use await client.process_commands(message)
plus the on_message event is better suited for things such as user blacklists (people the bot won't respond to), channel blacklists (channels the bot won't respond in), checking if the message author is a bot, etc...
listen allows for two or more callbacks to be set on an event. event on the other hand overwrites the previous ones and sets the decorated callback
Ah i get it
No clue why discord.py decided to have .event instead of just listeners with an overwrite kwarg
Btw great to see you as always
You also don't have to process_commands on a listener
So I currently have something under on_message
if message.channel.id == 909685766244945921 or '@everyone' in message.content:
print('Success')
if len(message.author.roles) <= 2:
print('Check 1')
await message.author.ban(reason = 'Softbanned bozo')
await message.guild.unban(discord.Object(message.author.id))
await mc.send(f'{message.author} has been softbanned')
print('Check 2, softban successful')
elif len(message.author.roles) > 2:
await message.delete()
print('Seems good')
Is this appropriate use of on_message?
why this is showing the bot's host time
thetiming = datetime.utcnow() + dt.timedelta(seconds=int(seccs))
perfecttiming = thetiming.strftime("%I:%M %p | %d %b")
```this
when i use this in embed
it show my time
how do i make this delete after 3 seconds? await ctx.message.delete()
await ctx.message.delete(3)
oh okay
Nvm what i said i think its what roie said i think you have to do delete_after = 3
How can I make a command where only stated users (IDs) can use a command like ?announce <message>, that will pop in all Server's system channels / dm the all users about it.
You can't youll get rate limited
Oh.
How can then those scam bots do it and I can't do it in a useful non abusive way
Lol
They send it slowly ig
i tried the other way as well but it says command raised an exception: TypeError: delete() takes 1 positional argument but 2 were given
@commands.command(aliases=['poll'])
@commands.cooldown(1, 5, commands.BucketType.user)
@commands.is_owner()
async def createpoll(self, ctx, hours: int, question: str, *options):
await ctx.message.delete(3)```
My bad its ```await ctx.message.delete(delay=3)
@commands.command(aliases=['poll'])
@commands.cooldown(1, 5, commands.BucketType.user)
@commands.is_owner()```
is that actually like that
what?
the indenting
no
ah i always get confused
continues watching
Can I somehow edit the color of an existing embed in a message but keep the same content?
sure, just do something like:
embed.color = 0xFFFFFF
and resend it
after all it's just a python class
!loop

Iterating over range(len(...)) is a common approach to accessing each item in an ordered collection.
for i in range(len(my_list)):
do_something(my_list[i])
The pythonic syntax is much simpler, and is guaranteed to produce elements in the same order:
for item in my_list:
do_something(item)
Python has other solutions for cases when the index itself might be needed. To get the element at the same index from two or more lists, use zip. To get both the index and the element at that index, use enumerate.
๐ญ
lurking + coding
perfect
good evening guys do any of you know this code eg to write / twt and send the message you sent down the Twitter image date and time you sent it and above your name with the image and the tag does anyone know this code?
I think you can make use of the twitter API for that
that is, what do you mean by the Twitter application;
Perfection and why so much classes
it will be smth like discord.User, discord.Member objects later
Ah i see
But revolt.User and revolt.Member

Wut that๐ญ
another chatting app
๐ง
Revolt basically just discord but open source and more privacy focused
It's cool, the UI is basically the same though
Other then allowing themes
and pretty much free nitro
People alr made API wrappers for revolt iirc
yeah
I haven't checked out their API though, but might later
its nice to work with
HELP-
how to create gaps in range! like
print(x)
1,2,3,4,5,7,8,9
so i have to create gaps like 2,4,6,8 like this (Multiplication table )
no need of intents and all that crap
[1,2,3,4][::2]
what
!e print([1,2,3,4][::2])
@sullen shoal :white_check_mark: Your eval job has completed with return code 0.
[1, 3]
but thats output i have to do it in code itself how i can do it
do you want me to spoonfeed your entire project
How is that even related to discord bots?
idek
Might want to check #โ๏ฝhow-to-get-help
Can i as questions about my life their?
ohh I see
Yes
Good
make a for loop and then make a variable and then add the numbers into the variable and then print the variable easy
That was legit what I was thinking
Your just adding a var for each element in the list but he was asking to delete specific ints from a list
VS code? that looks strange, are you using linux?
ahhh
nah i use that crap windows and vscode
oh ๐
without theme actually
well I did not understand anything he said because I think english he was speaking not
just an extension
Its alr lmao
probably this
english weird should I speak pretend be a foreigner for the rest of the day
how can you make public variables? like a money variable for a work command
i use smth called glass
just make a variable
...
global variables bad
or use JSON
what do you mean
set them as attribute of bot or the cog instead
Anybody have a good aiosqlite tutorial i cant find one
oh yeah it's completely transparent, Vibrancy is more blurry than transparent
global variables aint good thats it, there are a lot of reasons of that
https://www.youtube.com/watch?v=h4uN2dcM6Zk whatever this is @slate swan
developer portal link- https://discord.com/developers/applications/
GitHub for code- coming soon
SQLite Brower app-
https://sqlitebrowser.org/dl/
download to the latest version of python- https://www.python.org/downloads/release/python-396/
visual studio code- https://code.visualstudio.com/download
Contact our team-
Lil ใ#6699
how can I make variables
var = value
variable = "hello"
Bro.
๐คฃ
I MEAN FOR A WORK COMMAND
._.
wdym
Nah i just want to learn the basics of aiosqlite
^
speaking of work commands I'm building a economy discord bot ๐
OFC I KNOW HOW TO MAKE VARIABLE
I understand not aiosqlite because dumb I am
I MEAN ONE FOR A WORK COMMAND
Same
Arguments?
Please use pseudo code to explain
What is this man talking about?
I understand not, okimii.
Idk
He literally asked how to make a var
English I may not speak well, but bad English I understand notter
What does he want?
๐คฃ
No not you the vdp guy๐ญ
pretending to be bad at english
Mister "he" has a name
*miss
I am talking about myself
._.
You were talking to Okimii, no?
keep that aside, whats a work command
please use pseudo to explain pls ๐
So whos gonna tell him
Like what you're trying to do
Because we understand not what your code saying is trying to
https://i.krypt0n.co.uk/24029358.png this is lovely
๐ญ
๐ welcome to the club, bud.
Anybody know my gender? ._.
I love english speaking broken
Hey. How can I make it so I can use a personal command that only choosed people (IDs) can use. For example; ?announce <text>, and it would send a message to every server the bot is in, in the system channel. Of course, with the delay like a minute, so it doesn't block the bot for multiple actions.
python
Is it that hard to know?
That is very hard and you will need a website or something
That's why I prefer to make a big server and ping people
Oh, oky
speaking of pings I get 20+ messages because I'm in some kind of weird star wars discord server I joined only because i wanted guns in the game
for x in range(2, 4 ,3):
print(x)
why its not working ๐ข
what are you on about please tell us your purpose
do you understand the docs, thats what i gotta ask before explaining
Yep.
its not working :/
Use asyncio.sleep() for delay
wow, it's not working, that tells me everything
Yes
Well just needed some checksum updates, it's fixed now
Amazing
great! ๐
I was being sarcastic tell me
no that range is not working
you may use a command check, to check if the author's id is in the array of your selected users. then, discord.ext.commands.Bot.guilds will give you the list of all the Guilds your bot is in, then just send them to the system channel
please go to python general this is discord bots
Not related to discord bots, please use a help channel in #โ๏ฝhow-to-get-help
Oh I thought you were a female judging by the pfp srry
No shes my wife
please #python-discussion
not even a python, imagine...
Its hard ok๐
I'm a species called programmers who have mental breakdowns every second
I'm a book, more precisely a winrar
? i didnt get this
Ok boomer
you're in the wrong channel
oh yes! XD
Unique speecie
Click on one of these and ask there https://i.krypt0n.co.uk/4673328b.png

Yes, please head off to #python-discussion or claim a help channel and I can help you
@slate swan to make commands use #bot-commands
why it has rice and all anmes
ye, very rare and endangr because of NoCode
To distinguish between channels
bruh it's a name, like help-1, help-2
Your like 20 go get a wife and stop being on your computer you dinosaur
๐ค
my wife is my computer
๐ญ
I have a girlfriend 
yes yes idk how my channel got switched
Marry her ;)
nocode is a bunch of people who doesn't know how to code and then codes scratcc
should I marry my computer?
My kid will be named discord.py
I will have no children
No plug your male connector to her female๐ณ
LMAO
thts much better
Because I'm a programmer they do not experience any kind of love/affection for other, err...non-programmed subjects.
For example, humans.

What even is a human?
Just plug yourself to her female connector
Hey @twilit dragon!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
๐ณ
.
wasnt expecting this from you 
https://github.com/kkrypt0nn/Python-Discord-Bot-Template/blob/f5039a35682a8d2a509939182ccf6c30714388f1/bot.py#L85-L94
!d pkgutil.iter_modules
pkgutil.iter_modules(path=None, prefix='')```
Yields [`ModuleInfo`](https://docs.python.org/3/library/pkgutil.html#pkgutil.ModuleInfo "pkgutil.ModuleInfo") for all submodules on *path*, or, if *path* is `None`, all top-level modules on `sys.path`.
*path* should be either `None` or a list of paths to look for modules in.
*prefix* is a string to output on the front of every module name on output.
Note
Only works for a [finder](https://docs.python.org/3/glossary.html#term-finder) which defines an `iter_modules()` method. This interface is non-standard, so the module also provides implementations for [`importlib.machinery.FileFinder`](https://docs.python.org/3/library/importlib.html#importlib.machinery.FileFinder "importlib.machinery.FileFinder") and [`zipimport.zipimporter`](https://docs.python.org/3/library/zipimport.html#zipimport.zipimporter "zipimport.zipimporter").
Changed in version 3.3: Updated to be based directly on [`importlib`](https://docs.python.org/3/library/importlib.html#module-importlib "importlib: The implementation of the import machinery.") rather than relying on the package internal [**PEP 302**](https://www.python.org/dev/peps/pep-0302) import emulation.
bruh
kinda bored
`import os
import discord.py
from discord.ext import commands
client = commands.AutoShardedBot(commands.when_mentioned_or('$'))
from flask import Flask
from threading import Thread
app = Flask('')
@app.route('/')
def home():
return "I'm alive"
def run():
app.run(host='0.0.0.0',port=8080)
def keep_alive():
t = Thread(target=run)
t.start()
print("bot is online")
keep_alive()
client.run("Bot token")`
nice
You sure๐
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
yeah 
And might want to remove these useless new empty lines
@slate swan stop copying me bro๐คฌ 
I got pinged 1000 times
@velvet tinsel 1001
๐ณ
damn he will pay
SHEEEEESH
And yeah, I'm not really into python anymore since a few months
Never check your DMs innit
๐ญ
what have you be coding java
Python is life๐
Na Java is useless pain
Agree
Never knew ๐ฑ
as every programmer should know
Jk
The bottom part is more useful
I don't get spammed of friend requests anymore, which is kind of nice
Ah i see
24/7
ngl that reminded me of smth else
I get random requests from people who dont talk in chat or just add me to help which i dont do dm help anymore
Oke
I never did and never will
My DMs are for more relevant stuff
Mine are personal
Yeah same basically
I have like 20 friends from which I talk to only like 5
I got like 100 which i only talk to 0๐
yikes 
Thats why you see me here๐ ๐
Its lonely outhere๐
i have it like that on my programmer alt account as well but dat acc is kinda dead now
Yeah I mean, I talk actively to 2 people. 3 others are just school mate and we share homeworks
In the end it's not about how many but how good you feel with the ones you actively talk to
I mostly talk to the real ones you know
#discord-bots turning to #life-advices 
Yeah makes sense
๐
Which i have 0 rn๐
Python is the real one tho
It will change sooner than what you can think
Idk๐คทโโ๏ธ
I mostly just stay coding all the time
Anybody know a aiosqlite tutorial pls docs arent good๐ญ
Never used it, sorry
Pog
Any db good tutorial would be good๐ญ
๐ญ
Never used any database in bots
My bots never really needed any database
๐
i dont think its any different than synchronous dbs tho
What even is a database
atleast not the syntax
Understand not I
Whatโฆisโฆa database?
I never used it before
Didnt see the purpose so I skipped it
okimii has left the chat
DownloadPython has been shot dead
๐ณ
:cri:
there are many sources to learn mongodb, sqlite3 or whatever, the async extensions of it should include what change you have to make so that it works
:kek:
At this point im not gonna even learn a db if im not gonna use it
Yes me too
Lmao
Wth 2:27 am
Ikr
what have you been doing
I need to be a contributor
hey, idk if it's a problem or a bug but the thing is
my public bot recently joined a server, and when i do the servers command it suddenly crashed saying NoneType has no attributes to name at guild.owner.name so i made an if, else statement to pass it and what i found is
the server has no name, no owners and actually no members (the member count is 0), i am not sure if that's a bug or something
yeah that's better anyways
Ayo what
ikr
because the Guild is None, which happens when the command is invoked from a DMChannel
i can't lol
dies
but i am doing for guild in client.guilds
exists
shouldn't it only show servers?
Show code pls
it should
for guild in client.guilds:
if guild is None:
text += f"Unknown Server????\n"
else:
if guild.owner is None:
text += f"{guild.name} - {len(guild.members)} - {guild.owner}\n"
else:
text += f"{guild.name} - {len(guild.members)} - {guild.owner.name}\n"
if len(text) <= 2048:
embed = Embed(title=f"Total Count: {len(client.guilds)} server(s)",
description=text,
color=random_color())
await ctx.send(embed=embed)
return
embed = Embed(title=f"Total Count: {len(client.guilds)} server(s)", color=random_color())
await ctx.send(embed=embed)
return```
ok, so it says Unknown Server????
Myxi can do this a lot faster than me so Iโll leave the final answer to him
Im going to use json as a db๐
what comes is this
Sweet a discord developer
see the None - 0 - None
Yes?
so if guild is None: is False
^^
check the type of Guild
i would have ignored it as i might have thought of it as a server and owner name but it shows 0 as member count which is weird
type(guild)
Ok myxi is going god mode here Ima sit back and watch this
Anybody has some ideas for a bot๐
i have a little doubt if its really a Guild object
Economy bot is gonna be a challenge
Same hes always going god mode
He is basically Sherlock Holmes when it comes to stuff like these
I mean i would but im just not interested idk
Oh
<class 'discord.guild.Guild'>
hmmm, looks like you have to print every attrubute of it then
dir then
I think im going to do a search bot with asyncpraw๐ค
Wait
yes use it, would be better if you filter the dunder ones
You can just do embed.add_field(), no?
See you guys have a good day
I started using that recently, got addicted
['_PREMIUM_GUILD_LIMITS', '__annotations__', '__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__slots__', '__str__', '__subclasshook__', '_add_channel', '_add_member', '_add_role', '_add_thread', '_banner', '_channels', '_clear_threads', '_create_channel', '_discovery_splash', '_filter_threads', '_from_data', '_icon', '_large', '_member_count', '_members', '_public_updates_channel_id', '_remove_channel', '_remove_member', '_remove_role', '_remove_thread', '_remove_threads_by_channel', '_resolve_channel', '_roles', '_rules_channel_id', '_splash', '_stage_instances', '_state', '_store_thread', '_sync', '_system_channel_flags', '_system_channel_id', '_threads', '_update_voice_state', '_voice_state_for', '_voice_states', 'active_threads', 'afk_channel', 'afk_timeout', 'audit_logs', 'ban', 'banner', 'bans', 'bitrate_limit', 'by_category', 'categories', 'change_voice_state', 'channels', 'chunk', 'chunked', 'create_category', 'create_category_channel', 'create_custom_emoji', 'create_integration', 'create_role', 'create_stage_channel', 'create_sticker', 'create_template', 'create_text_channel', 'create_voice_channel', 'created_at', 'default_notifications', 'default_role', 'delete', 'delete_emoji', 'delete_sticker', 'description', 'discovery_splash', 'edit', 'edit_role_positions', 'edit_widget', 'emoji_limit', 'emojis', 'estimate_pruned_members', 'explicit_content_filter', 'features', 'fetch_ban', 'fetch_channel', 'fetch_channels', 'fetch_emoji', 'fetch_emojis', 'fetch_member', 'fetch_members', 'fetch_roles', 'fetch_sticker', 'fetch_stickers', 'filesize_limit', 'get_channel', 'get_channel_or_thread', 'get_member', 'get_member_named', 'get_role', 'get_stage_instance', 'get_thread', 'icon', 'id', 'integrations', 'invites', 'kick', 'large', 'leave', 'max_members', 'max_presences', 'max_video_channel_users', 'me', 'member_count', 'members', 'mfa_level', 'name', 'nsfw_level', 'owner', 'owner_id', 'preferred_locale', 'premium_subscriber_role', 'premium_subscribers', 'premium_subscription_count', 'premium_tier', 'prune_members', 'public_updates_channel', 'query_members', 'region', 'roles', 'rules_channel', 'self_role', 'shard_id', 'splash', 'stage_channels', 'stage_instances', 'sticker_limit', 'stickers', 'system_channel', 'system_channel_flags', 'templates', 'text_channels', 'threads', 'unavailable', 'unban', 'vanity_invite', 'verification_level', 'voice_channels', 'voice_client', 'webhooks', 'widget']
Bye
Oh
feels like a ghost server, it is there but it isn't
The guild name.
it isnt optional tho
Myxi comes to his conclusion, I was about to go through a wide variety of stuff
well it returns None in the guild.name
Hmm
looks like some bug to me, which version are you using
and 0 in the len(guild.members)
Weird, in fact, very weird
the one from the GitHub
Just delete it
sorry
Delete the None server if you can
does it return the id?
i meant v2.0 pycord (forked discord.py)
i see
Ahhh
?
I have never used Pycord, Iโm a bit old fashioned
oh wait
IT DOES
912766681644941392
Try for servers in member.servers
fetch it and see if it works then
Iโm just substituting stuff
then?
Embed.add_field(member.servers)
if you fetch it, it should update the cache
Will this work Myxi?
i dont think theres any attribute named that
Or for Guild
I was just substituting a lot of stuff
alr
idk try using myxiโs idea
For member.servers I used it off bot.servers but idk if it works
Bubai, see you later
Does it work Yami?
so it showed the server name only
Laterr
Letโs see letโs see
Bye ๐
doesnt the other attributes work
Bye bye
apparently the server was an old server, when i checked the old messages i found it FUCKING SERVER XD - 5773 - Skwll
now it only shows FUCKING SERVER XD - 0- None
nope
Oh god swear words but idk why it does that
i guess the caching system of pycord is kinda fucked
Iโd prefer discord.py if I were you
the server name has always been like that
maybe they made changes to it
Maybe, maybe
i did but the slash command
i will check with them
Then use pycord ๐คทโโ๏ธ
I use it for slash and buttons
Use discord.py, but for external stuff Pycord
oh
I recommend that since pycord is pretty new and we dont understand a lot of that
won't the functions be overlapped with each other
it's like you have discord(1).py somewhere
@viral mirageso when you fetched the guild by the id, only the name attribute was working or others were working too?
pycord is just discord.py with slash command slol
yeah
Ok, but I think theyโll mess up a lot of functions on git
hello, anyone know how to DM a user? This didn't work out for me... dmUser is just a userID, pulled from a command, in string form that then gets transitioned to int. Error is:
AttributeError: 'NoneType' object has no attribute 'send'```
doesnt answer my question correctly :/
the literal discord.py documentation told me to do it this way
member: discord.Member
That should be a passing argument
yeah when i fetched the guild by it's ID, only the name worked while the other attributes didn't
Are you using an event or command?
event
I'm doing it all wrong, I know
Guys how do I make commands?
but I need to do on_message for the way I set my code up
majik
By learning discord.py
ok
Right send the full code this should be easy and straightforward pls
idk then, could be smth wrong with discord's api or pycord or maybe the server was deleted, not sure tho
@slate swan ?
I will sry
Ok
Itโs ok, take your time ๐
the bot is really poorly made since I started when I was learning how to code and just built on it, it needs refactoring
it's okay, at least we discovered some stuff about it
here's a chunk
thanks for the help 
so messy, yes, I know
Why did you not indent stuff?
๐
But thatโs not the problem
just the error I sent initially, when I try to run -dm command
how can you put a cooldown in the commands and the bot says "Hey. You need to wait <remaining cooldown time> to work again!"
don't think so
Commands.cooldown()
i haven't run into any problems that weren't just stupid code bugs before this one though, and when you dive into the later sections of this bot it gets pretty lengthy
Ok youโll need to activate it, thatโs probably why
I have paging embeds and the like
Commands.ext or discord.ext
does anyone understand discord.py quite alot
Nevermind
how would I go abt that
!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.
this?
the bot isn't actually being run off my computer, it's off another server
Yep.
Ok, get intents
@client.event
and
async def
idk what these are they r so confusing
Learn discord.py
is it just a module
read it
Here @slate swan
Remember that you also have to have it with command prefix
oh sorry
@sullen shoal HELP ME
missed that
I HAVE TO ANSWER TWO QUESTIONS AT ONCE
?
Please help VDP I have to answer a lot of questions Iโm crying
Or anyone else
ah i never used cooldowns before
could be idk
I dont want to spoonfeed
Lets pretend I have typed the other stuff for the command
now the cooldown part
@bot.command()
async def work(ctx):
discord.ext.commands.cooldown(1,300,type=<BucketType.default: 0>
I think that is correct
No
oof
Bot.commands.cooldown(etc, etc)
Wait no commands.cooldown()
Sorry I misled you there a bit
commands.cooldown(*insert code here*)
Does it work?
just applied, currently starting bot up
Ok
it has 3 parameters
rate(int) - The number of times a command can be used before triggering a cooldown.
per(float) - The amount of seconds to wait for a cooldown when itโs been triggered.
type (Union[BucketType, Callable[[Message], Any]]) โ
The type of cooldown to have. If callable, should return a key for the mapping.
yes! it worked. Tysm
You donโt really need that
!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.
Itโs ok
rate, per, type
Yeah, so 1, 300, commands.BucketType.user
Or whatever
I donโt want to spoonfeed you
Damn I need to read stuff I keep doing the same mistakes
commands.BucketType.user is what you want, fill out the rest
What is status_task that is my question
but I will put it like with the discord.ext (maybe .commands is requiered) or I will put without it? like cooldown(1, 300, commands.BucketType.user
Show me the code
Yessir
No, no
gimme a sec
now?
dont hate on me for using glitch
@kind wind
I want to put that inside a command. Why does it have the @?
Do you do change_presence?
Because you put it under bot.command and a async def innit
@slate swan Do you think you can help lmao
He is offline
Ik
Show me the code for status_task, I may be slower than the experts but Iโll try my best
Hes the one who made it ๐ฉ
Wdym has he been spoon feeding you
@bot.command()
async def work(ctx):
@cooldown.command(1, 30, commands.BucketType.user)
#Other code goes below
Like this?
No
No no no no you dont understand
@bot.command()
@commands.cooldown(1, 20, commands.BucketType.user)
Async def work(ctx):
blah blah
oh ok
He made a template on github and i used it like last summer and it was perfect i used it a few days ago and it started to work amazing again then i dont even know what i changed and it started saying that
Yes Ipayforwinrar you have relieved me of my duty
you copied and pasted it.
Right.
Bro what
It works
I will ask more help tomorrow. I am going to sleep. Byeeee
That was what I was thinking
Lemme check the log thingy
Night
There we go
lmaoo
Now put it back in
Here you never really answered me
Ok
This is empty and thereโs only me\
What
No sorry i fixed it i removed the thing that changed the status on accident while i was at school
I mean, I'm half here and half looking at a video
Ok
@slate swani fixed it lol
Glad to hear that
am i ok i see no error with this i tried to debug it with the vsc debugger and nothing wrong and it never prints done or pass sub and yes i did the reddit var:
@bot.command()
@commands.cooldown(1, 120, commands.BucketType.user)
async def search(ctx,*arg):
search = arg
print("search command has been executed")
all_subs = []
multireddit = await reddit.multireddit("setups","supercars","AnimeGirls","anime","Minecraft","apexlegends")
top = multireddit.top(limit = 500)
async for submission in top:
if not submission.is_self:
sub = submission
name = sub.title
if search in name:
all_subs.append(submission)
url = sub.url
em = disnake.Embed(title = name)
if "jpg" in url or "png" in url:
em.set_image(url = url)
await ctx.send(embed = em)
print("done")
break
else:
pass
else:
print("passed a sub")
pass
i started using the multireddit instance and everything went downhill lmao
You have a cooldown
thats for after the command is invoked it will give the cool down lmao
its a discord.py decorator for command cooldowns
Do you have PRAW?
its the same tbh just async
?
Itโs because the reddit modules are broken af and it wont work so thats why it will never work. Happened to me before, never use reddit API
You dont
Or you search it up, youre in the wrong place
I rate it 1 star
its not really broken it just doesnt work with the multireddit instance
cause i was using the single one and it worked like a charm
You download PyCharm
Then use the single one
dang ill figure something out
yeah i will
Yay there we go
btw, if "jpg" in url or "png" in url is basically, ("jpg", "png") in url
Why arenโt you sleeping
yeah ik
who me?
Yes
Hey, my webhook doesn't work for some reason.. I get this error:
TypeError: Object of type Embed is not JSON serializable
Are you nocturnal like me?
its 5pm lmao
Oh
install discord
why your file name discord.py
oh lol
๐คฆ
don't name your file discord
or anything that is same as any of your existing modules
whats forgor
Itโs forgot
i thought its smth more than just a typo
I have a problem
import friends
from friends import love
Apparently there is no module named friends, what do I do?
go to another help channel
Ok
๐
Will they help me?
download it
touch friends.py
well you should give them more information than you gave us
Like pip install friends?
should work
!pypi
K
package
!pypi friends
you never have?
Yay!!!
no
see
damn
check source code
there's nothing I can do with python
๐ฆ
other than discord bots
not even a snake game
why tho
cuz I can't
why tho
cuz I'm dumb
i see
and lazy to learn other libs
np
Also its spelled pleasure
No your status
what about it 
rip i needed to delete a whole bot with like 200lines cuz of asyncpraw wasnt working
for no reason
Anybody have any bot ideas ig?
no.
if you dont have an idea, just dont answer.
either make it work or dont have a volatile bot
ditto my friend 
-.-
<3
ok?
problems werent cuz of me everything was fine the api is just not working
no errors at all debugged it just errors i cannot handle like bad requests from the api

seems like he woke up on the wrong side of the bed
that could come across as rude
we wouldnt want that, would we?
wasnt trying too
idk seems like your kinda toxic at the start

i was just asking for ideas no need too get toxic
@Blank.command(aliases=["whois"])
async def userinfo(ctx, member: discord.Member = None):
await ctx.message.delete()
if not member:
member = ctx.message.author
roles = ([role for role in member.roles[1:]])
embed = discord.Embed(colour=discord.Colour.random(), title=f"User Info - {member}")
embed.set_thumbnail(url=member.avatar_url)
embed.add_field(name="ID:", value=member.id)
embed.add_field(name="Display Name:", value=member.display_name)
embed.add_field(name="Created Account On:", value=member.created_at.strftime("%a, %#d %B %Y, %I:%M %p UTC"))
embed.add_field(name="Joined Server On:", value=member.joined_at.strftime("%a, %#d %B %Y, %I:%M %p UTC")+"\u0020")
if roles == []:
embed.add_field(name="Roles:", value="None")
embed.add_field(name="Highest Role:", value="None")
try:
await ctx.send(embed=embed)
except Exception:
await ctx.channel.send("I don't have permission to send embeds in this channel")
else:
embed.add_field(name="Roles:", value=", ".join([role.mention for role in roles]))
embed.add_field(name="Highest Role:", value=member.top_role.mention)
try:
await ctx.send(embed=embed)
except Exception:
await ctx.channel.send("I don't have permission to send embeds in this channel")```
My whois command, how can I calculate the age of account and the age of user in server (days, months, years)
how to create a command from /disable <command>? Example: if the person types /disable shop the shop command is disabled...
set Command.enabled to False
@client.command()
async def mute(ctx, member: discord.Member, time=None, *, reason=None):
format = datetime.now(tz=pytz.timezone('America/Tijuana'))
formatted = format.strftime("%I:%M %p")
b = DT.datetime.now().timestamp()
modlogs = client.get_channel(872909569196707870)
db = await aiosqlite.connect('database.db')
cursor = await db.execute('SELECT * FROM mutes')
rows = await cursor.fetchall()
muted = discord.utils.get(ctx.guild.roles, name="Muted")
farmer = discord.utils.get(ctx.guild.roles, name="Farmers")
apprentice = discord.utils.get(ctx.guild.roles, id=907127783849861120)
if ctx.message.author.guild_permissions.administrator:
if member is None:
e = await ctx.reply('You must mention someone to mute!')
await asyncio.sleep(5)
await e.delete()
await ctx.message.delete()
return
if time is None:
a = await ctx.reply('Please state a time for a timed mute or a reason for a permanent mute!')
await asyncio.sleep(5)
await a.delete()
await ctx.message.delete()
return
if reason is None:
if time[-1] in ['s', 'm', 'h', 'd']:``` This is quite messy, but is there a way that I can somehow determine if the `s`, `m`, `h`, and `d` are touching another letter, if so it does something?
```py
if time[-1] in ['s', 'm', 'h', 'd']:``` after this line.
Can someone explain me why this doesn't work?
await ctx.channel.edit(topic="test-topic")```
I don't know if there's an error because it's in a "try"-statement. But it doesn't change it
You can print the exception
except Exception as e:
print(e)
I've tried it now. No errors. I even created a new command just to test it out and it doesn't work. Like it doesn't give me any errors but it doesn't change the Channel Topic I really don't understand
Weird,have you checked docs?
No, I just wanted to check them. But it's very strange because yesterday it worked fine?
I see thats a bit weird.
Is there a way the code is bugging or smth? Should I restart my VS?
Because it seems like a bug for me
No i think vsc has nothing related to the error.
ik this might sound dumb, but how do you delete bots message
When you send a message you can do:
await ctx.message.delete()
Youll have to await it as its a coroutine
await ctx.send("This is a bot message", delete_after=20)```
This will delete the Bot's message after 20 seconds the message has been sent
does that delete the authors message or the bots ?
Depends where you add it
oh right hehe thanks
This will work find too
Your welcome
msg = await ctx.send("This is a Bot's message")
await msg.message.delete()```
oh wait
I think you dont have to add it to a var and just do ctx.message.delete()
I think only msg.delete() right?
this worked, thankq
No youll have to add the message object
Well this deletes the command usage.
Oh yeah ctx is the context of the invoked command so you are correct,sorry for the misunderstanding.
If you dont add it it will be instant
all good
how to make it so the command can only run if te author is an admin or having permissions?
You can use the decorator
@commands.has_permissions(administrator=True)
thanks!
Your welcome!
can anyone help me? my prefix command isnt working (changes prefix) not comfortable with sending source here cuz skids are always watching, if anyones willing to take it to dms lmk
idk
Like a invite command?
can anyone help me? my prefix command isnt working (changes prefix) not comfortable with sending source here cuz skids are always watching, if anyones willing to take it to dms lmk
yeah thats the bot is in
I can try to help but Im decently new
โน๏ธ
You can make a invite and send it as a string.
Dont know if theirs a better or different to be honest.
If its a public bot i am not familiar with invites.
dm me your error.
!d discord.ext.commands.has_permissions
@discord.ext.commands.has_permissions(**perms)```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if the member has all of the permissions necessary.
Note that this check operates on the current channel permissions, not the guild wide permissions.
The permissions passed in must be exactly like the properties shown under [`discord.Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions").
This check raises a special exception, [`MissingPermissions`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingPermissions "discord.ext.commands.MissingPermissions") that is inherited from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
take a look at the documentations to see all the decorators for these kinds of things.
thanks!
help 
Na na na bro I am asking for age...
Shit
#help-lollipop message
if someone can give an answer about this
Actually you could still use those and calculate the age
You can use member.created_at to see when he made the account and member.joined_at for when he joined
same answer like before....I want to get age e.g. 3 years 2 months
You could get the time and then do math to get the age
yeah, just do datetime.datetime.now() - Member.created_at
@client.command()
async def mute(ctx, member: discord.Member, time=None, *, reason=None):
format = datetime.now(tz=pytz.timezone('America/Tijuana'))
formatted = format.strftime("%I:%M %p")
b = DT.datetime.now().timestamp()
modlogs = client.get_channel(872909569196707870)
db = await aiosqlite.connect('database.db')
cursor = await db.execute('SELECT * FROM mutes')
rows = await cursor.fetchall()
muted = discord.utils.get(ctx.guild.roles, name="Muted")
farmer = discord.utils.get(ctx.guild.roles, name="Farmers")
apprentice = discord.utils.get(ctx.guild.roles, id=907127783849861120)
if ctx.message.author.guild_permissions.administrator:
if member is None:
e = await ctx.reply('You must mention someone to mute!')
await asyncio.sleep(5)
await e.delete()
await ctx.message.delete()
return
if time is None:
a = await ctx.reply('Please state a time for a timed mute or a reason for a permanent mute!')
await asyncio.sleep(5)
await a.delete()
await ctx.message.delete()
return
if reason is None:
if time[-1] in ['s', 'm', 'h', 'd']:``` This is quite messy, but is there a way that I can somehow determine if the `s`, `m`, `h`, and `d` are touching another letter, if so it does something?
```py
if time[-1] in ['s', 'm', 'h', 'd']:``` after this line.
im having a weird issue , im making an embed ,
if i use color = 0x000000 ( black color) , the embed's color appear black
but , if i use something like color = 0x000000 or disnake.Color.red() it ignores the black color and sends the embed in red color
any idea why?
!e
print(0x000000)
@boreal ravine :white_check_mark: Your eval job has completed with return code 0.
0
Because the hex code is empty
i see , so basically its 0
yes
thanks !
mhm i just removed the or and got it to work
@boreal ravine :white_check_mark: Your eval job has completed with return code 0.
red
Does anyone know how to delete an interaction response after a button is pressed?
you mean the original message?
no the one where is says dismiss this message
cause I have another button selection in the response and I want it to close after you've clicked the button in it
I can't find any api doc on the discord py interactions
Nope
you need to click it yourself
this?
Or you could just not respond, but I doubt thats what you want
no delete_after either?
no, an ephemeral message isn't a message object, it's controlled by discord
you can use delete_after if its not an invisible response
as kayle just said^
ik that
that sucks though
then the other option, when I click one of the buttons how do i get it to stop loading and say the interaction failed without responding
is there like an interaction.completed() or something
TypeError: Invalid permission(s): manage_server
from discord.ext import commands
@commands.has_permissions(manage_server=True)
Anyone know why?
its manage_guild
my fault
how do I get the interaction button to stop loading and say it failed after I pressed it
it get's the button press fine but thinks it never finished
while True:
interaction = await self.bot.wait_for("button_click")
if interaction.component.custom_id == 'team_add':
await ctx.channel.send('Send player info')
Why the while loop?
true
hi guys! for some reason when i run my bot, the tasks.py gets run twice and shows 2 reminders like this
https://github.com/TechnoFrost27/chad-the-discord-bot/blob/main/cogs/tasks.py
this is the code for the same
also for some reason, after a while the status stops updating
make sure there arent 2 instances of the bot running.
i did
the while loop doesn't change anything though it still will respond to clicking the button fine but it keeps loading and says interaction failed
everything else works one time.... all commands
but tasks.py works like this only ๐ฆ
sometimes it works 2 times, sometimes once sometimes 4 times
also why does the status of bot stop updating after a while?
can i make my bot repeat a message but in embed?
for example, if i do !announce hey
it responds with hey in an embed
yes
thats simple.
Use a positional argument
I'm a little lost, i can do normal response but dont know how to put it in an embed
just put an argument and put that as the title or smth
how about this:
Well you do a embed kwarg and then you add the arg where ever you want it to be in
@bot.command() <- command decorator
async def repeat(ctx, *, message): <- function definition with parameters
embed = discord.Embed(description = message) <- embed object
await ctx.send(embed = embed) <- sending the embed```
Snow pro
nah
btw, you dont need to add spaces to separate kwargs if you follow the pep8 styleguide
func(hello="world", oof="roblox")```
yeah just subtract current time with that time
whats object?
discord.Embed is an object
Im sorry im trying to understand everything i do, sorry for bugging
!d discord.Embed
class discord.Embed(*, colour=Embed.Empty, color=Embed.Empty, title=Embed.Empty, type='rich', url=Embed.Empty, description=Embed.Empty, timestamp=None)```
Represents a Discord embed.
len(x) Returns the total size of the embed. Useful for checking if itโs within the 6000 character limit.
bool(b) Returns whether the embed has any data set.
New in version 2.0.
Certain properties return an `EmbedProxy`, a type that acts similar to a regular [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") except using dotted access, e.g. `embed.author.icon_url`. If the attribute is invalid or empty, then a special sentinel value is returned, [`Embed.Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty").
For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") for you.
ahh ok
Pep 8 also says to specify each param on a different line iirc
!d object
class object```
Return a new featureless object. [`object`](https://docs.python.org/3/library/functions.html#object "object") is a base for all classes. It has methods that are common to all instances of Python classes. This function does not accept any arguments.
Note
[`object`](https://docs.python.org/3/library/functions.html#object "object") does *not* have a [`__dict__`](https://docs.python.org/3/library/stdtypes.html#object.__dict__ "object.__dict__"), so you canโt assign arbitrary attributes to an instance of the [`object`](https://docs.python.org/3/library/functions.html#object "object") class.
if the line crosses 80 chars then yes
perfect, understood
Thought so
thank u so much!
๐
help pls
Ratelimit maybe
you can only change a bots status every few minutes
Try turning on logging
I don't think so, since changing status is done via the websocket and the ws doesn't get ratelimited easily iirc
async def t(ctx):
^
SyntaxError: invalid syntax```
Does anyone know why? Is there a limit to how many commands you can have?
Nope
Probably got raised cause of something else, show the code above that function
@client.command()
@commands.has_permissions(manage_messages=True)
async def t(ctx):
await ctx.send(f'{ctx.author.mention} Hey!')
thats literally it
show your code above that
wait
there's like 500 lines
!e
def b(arg):
print(arg)
b(1)


