#discord-bots
1 messages Β· Page 834 of 1
im extremeley sorry and will not request more assistance
And it's still the same error?
oh yeah
Can we see the new check?
I'm assuming you removed the ids in devList?
else return false by the way
and you can send a message along with that
Checks need to return a boolean
Won't falsy values work 
hypothetically speaking, if it says the async under join command is unexpected indent, what would one do
alright for a test, try this:
async def dev_check(ctx):
if ctx.message.author.id == YOUR_ID_HERE:
return True
else:
return False
see if that passes
You dont even need the else just fix the indentation for return False
Helps us narrow down the issue
This is how the class should look like ```py
class Music(commands.Cog):
def init(self, bot):
self.bot = bot
@commands.command()
async def join(self, CTX):
...
CTX should be lower case
My phone makes it uppercase
'commands is undefined'
im trying to print client.guilds and i keep getting an empty list
intents = discord.Intents(messages=True, guilds=True)
intents.members = True
client = discord.Client()
bot_prefix = "."
client = commands.Bot(command_prefix=bot_prefix, intents=intents)
client.remove_command("help") #removes default help command```
when i do import chalk, it says its not accsessed
so do i need to install an external package or
Client
It means, its not used in your code yet
Plus, see the channel name
?
its for the runtime bot command
discord.Client is the old method of creating bot constructors, use the Bot class from discord extension
You can make commands and stuff
!d discord.ext.commands.Bot
class discord.ext.commands.Bot(command_prefix, help_command=<default-help-command>, description=None, **options)```
Represents a discord bot.
This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") you can do with this bot.
This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality to manage commands.
print("DONE LOADING!\n")
num1 = 0
num2 = 0
num3 = 0
num4 = 0
while True:
num1 = num1+1
if num1 == 60:
num1 = 0
num2 = num2+1
if num2 == 60:
num2 = 0
num3 = num3+1
if num3 == 24:
num3 = 0
num4 = num4+1
time.sleep(1)
@bot.command(pass_context=True)
async def runtime(ctx):
await bot.say("Running for {}d {}h {}m {}s".format(num4, num3, num2, num1))
this is what google tells me after a long time searching
oh wow thas a lot bigger than i was expecting
Rip
code block moment:
num1 = 0
num2 = 0
num3 = 0
num4 = 0
while True:
num1 = num1+1
if num1 == 60:
num1 = 0
num2 = num2+1
if num2 == 60:
num2 = 0
num3 = num3+1
if num3 == 24:
num3 = 0
num4 = num4+1
time.sleep(1)
@bot.command(pass_context=True)
async def runtime(ctx):
await bot.say("Running for {}d {}h {}m {}s".format(num4, num3, num2, num1))```
please dont use this
oh my god
format
rip google search
not only will it rate limit the shit outta your bot
but it will also be inaccurate asf
def __init__(bot):
@commands.command(name="uptime")
async def uptime (self,ctx):
current_time = time.time()
difference = int(round(current_time - start_time))
text = str(datetime.timedelta(seconds=difference))
await ctx.send("Current uptime: " + text)```
use something like that
i also have this but it doesnt recognize the command uptime
then remove it from a cog
sooooooooo change it
You're not being helpful whatsoever
well i thought
this command seemed to not be in a cog so why not just replace the code for it
async def runtime(ctx):
now = datetime.utcnow()
elapsed = now - starttime
seconds = elapsed.seconds
minutes, seconds = divmod(seconds, 60)
hours, minutes = divmod(minutes, 60)
await bot.say("Running for {}d {}h {}m {}s".format(elapsed.days, hours, minutes, seconds))
starttime = datetime.utcnow()```
would this one be better or no
client.guilds still gives me an empty list
gotta fix some of the indentation...
ive been browsing google for an answer tbh
anyone know why?
try and see if it works (also use f strings instead of .format)
Your bot isnt in any server
Traceback (most recent call last):
File "/home/pi/Downloads/riot bot 5, no way this works.py", line 124, in <module>
starttime = datetime.utcnow()
AttributeError: module 'datetime' has no attribute 'utcnow'
the code its talking about is starttime = datetime.utcnow()
this is not working
!d datetime.datetime.utcnow
classmethod datetime.utcnow()```
Return the current UTC date and time, with [`tzinfo`](https://docs.python.org/3/library/datetime.html#datetime.datetime.tzinfo "datetime.datetime.tzinfo") `None`.
This is like [`now()`](https://docs.python.org/3/library/datetime.html#datetime.datetime.now "datetime.datetime.now"), but returns the current UTC date and time, as a naive [`datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "datetime.datetime") object. An aware current UTC datetime can be obtained by calling `datetime.now(timezone.utc)`. See also [`now()`](https://docs.python.org/3/library/datetime.html#datetime.datetime.now "datetime.datetime.now").
Warning
Because naive `datetime` objects are treated by many `datetime` methods as local times, it is preferred to use aware datetimes to represent times in UTC. As such, the recommended way to create an object representing the current time in UTC is by calling `datetime.now(timezone.utc)`.
Oh isnβt utc a time zone
!d discord.Member.send
await send(content=None, *, tts=None, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, view=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message to the destination with the content given.
The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.
To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.
To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
or am I just thinking of something else
and put this in a try and except statement to prevent errors from being invoked incase the users dms are turned off
Yeah
ook
So replace starttime line with datetime.now(timezone.utc)?
try: member.send("Hunter uwu")
except discord.Forbidden: pass```
Did you import datetime or from datetime import datetime?
that is very cursed
First
It doesnt have the intents then
Then you have to use datetime.datetime.utcnow()
alr
No?
Whats funny
it contains ||uwu|| thus making it cursed
!ot
Off-topic channel: #ot2-never-nesterβs-nightmare
Please read our off-topic etiquette before participating in conversations.
File "/usr/local/lib/python3.7/dist-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/usr/local/lib/python3.7/dist-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/usr/local/lib/python3.7/dist-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: module 'datetime' has no attribute 'utcnow'```
async def runtime(ctx):
now = datetime.utcnow()
elapsed = now - datetime
seconds = elapsed.seconds
minutes, seconds = divmod(seconds, 60)
hours, minutes = divmod(minutes, 60)
await bot.say("Running for {}d {}h {}m {}s".format(elapsed.days, hours, minutes, seconds))
datetime.datetime.utcnow()```
datetime.datetime.utcnow()
Bruv, you're still doing datetime.utcnow()
did i put it in the wrong place
Yes, read the error
i need stronger glasses holy shit
You have to replace the method in the line the error mentions
File "/usr/local/lib/python3.7/dist-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/usr/local/lib/python3.7/dist-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/usr/local/lib/python3.7/dist-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: unsupported operand type(s) for -: 'datetime.datetime' and 'module'```
elapsed = now - datetime
???
You can't just subtract times like that i don't think, need to use timedelta
What are you trying to do with this code, exactly?
runtime >.<
the easiest way would be to store the UNIX seconds at startup, and get the UNIX seconds when the command is run, and subtract those 2 (they will be regular integers)
^
how uh, how would i do that
You can save the start time in the bot's cache, like bot.start_time = datetime.datetime.now.to_timestamp() <- this is an example
That's why I said it's an example - don't really remember all mehtods
then when you run the command, datetime.datetime.now().timestamp() - start_time
so would I swap the code im using right now for that or
arent you able too just save it as a global variable in the on ready function... i feel like that would be easier
yes, you would
No, on_ready can get called multiple times and won't be accurate
ah
not to mention global variables are just ugh
- saving it in the bot's cache means that you can access it in cogs
says start_time is not defined
No, that was psuedocode
You'll have to change it and adapt it to work with your own code
So what would be start time
The timestamp at startup
datetime.datetime.now().timestamp() when the bot starts would return that time
When someone runs the command subtract the startup timestamp from the current timestamp
Since the startup time happened in the past, it will be a smaller number
so the command would just be
async def runtime(ctx):
now = datetime.utcnow()
elapsed = now - datetime
seconds = elapsed.seconds
minutes, seconds = divmod(seconds, 60)
hours, minutes = divmod(minutes, 60)
await bot.say("Running for {}d {}h {}m {}s".format(elapsed.days, hours, minutes, seconds))
datetime.datetime.utcnow()```
oop
website
yeah don't do that
no need for pass_context. outdated long ago.
that code is heavily oudated
damn
Where even did you get bot.say()?
what would you recoment
is this against tos if not can someone help me code a bot like this
recommend
very old
docs, github examples, asking for help here
A tutorial on how to use discord.py to create your own Discord bot in Python, written to fix the flaws of many other popular tutorials.
and that
unfortunately most if not all of discord.py tutorials these days are not ideal
That's probably the most reliable source for beginners to work with
theres nothing on runtime or uptime 
Is that like twitter or?
No, it'll only teach you the basics and you'll have to implement the commands yourself
Do they have an API? Not familiar with tiktok so i wouldn't know
you should be familiar with how a bot actually works, first.
yes they have an api.
iβm not sure doing this is against their tos though. Im going to have to read
Just use discord formatting. <t:184688397293>
Or relative time
That's not python I don't think
this is not python
^
I donβt know if they used official api because does anyone know if tiktok api allows you to view when someone created their account?
w h a t
What is it then?
You'd need to check their documentation
okay.
You can do that later. For now, try implementing what we discussed earlier
Those end statements are familiar, can't think of it though
Perhaps
doesnt dyno have a runtime command
this is lua
oops :p
specifically lua with the roblox API
yes, it's pretty easy to implement
Should only be 2 or 3 lines of code in total
Ok thank you
does dyno have something on github
No
No
Said again it's pretty easy and you can do it if you put some thought and documentation-searching into it
All of the big bots aren't open source
Even if its open source it uses javascript
Tbh using discord formatting is just easier
The Eris library.
You don't have to deal with formatting at all
You just throw in the timestamp
<t:81828282>
Becomes:
<t:81828282>
<t:81828282:R> relative
Open source bot's readme be like
πΏ
so ive installed youtube_dl but it says its not resolved, does that have anything to do with the music bot cease and desist
!ytdl
Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.
For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:
The following restrictions apply to your use of the Service. You are not allowed to:
1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service; (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;
3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTubeβs robots.txt file; (b) with YouTubeβs prior written permission; or (c) as permitted by applicable law;
9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
what are the cons of having several bot.listen()?
I've been thinking about making a dashboard for my bot and have hard about flask, dijango and quart, which of these do ppl recommend. I'm making the bot itself in hikari which includes a rest API so should I just use that instead?
It completely depends on the amount of users your bot is serving, how many servers it's in and the type of listeners
just one
Just one server, you mean?
yeah
"ideally"?
it's basically one bot with many stuff included like it's a utility bot, suggestion bot, modmail
Depends on the number of users in that server, and the listener being used
what kind of cons?
For example, if it's a server with 10k members and you're checking for each member updating their profile - that's a lot of information for the bot to process
performance issues? don't worry about it, any performance hit is negligible
yeah i'll just combine two listeners into one then
Well yeah, but the question is pretty open-ended in terms of what machine they're running the bot on and what their bot's purpose is
So I wouldn't just tell them to not worry about it /shrug
can you elaborate?
π³ Got components back into my wrapper
combining event listeners is a pretty unsubstantial optimization. the main reason for binding several listeners to a single event is just to organize code better, combining them makes little to no sense
also I was talking about 3 of them; I assume it doesn't have a considerable impact right?
Yea, using listeners would barely impact any resources, if anything it would only just use a bit of memory since it stores in-memory
3 @bot.listen for on_message ( i have other listeners too)
unless you have a shit ton of listeners (like a shit ton) or you power your deployed app with a potato, you are fine
That shoudln't affect performance, defo
that is perfectly fine, hell, even 20 is fine
^
just don't worry about these minor things.
π
yeah, just 5 listeners so with the one I want to make for on_message, 6
real optimization happens when you start reducing time wasted on io or something
Why do you even have the need for so many listeners for MESSAGE_CREATE?
in my bot i have like 5
Is it to split up the code into chunks or
Yea that makes sense, readability is good to keep
besides, each handler performs its own thing, i don't need to jumble everything into one function
i mean right now I have two on_message, these two are for modmail, one is on_dm_message and one is on_modmail_channel_message
and I want to make one more for if a role x is pinged in a message, the bot invokes a command
just don't waste your time worrying about it, go build some stuff πͺ
haha thanks for the responses
i mean it should be pretty simple
Yea, just need a persistent storage, do some flow control, listen to message create
also, what's logger for exactly?
like error messages?
Sure, it could be error messages
ah so it's essentially print(error) in that context?
Im trying to make a warn command in txt files (ik i should use a database, but im just doing it for fun)
I have done warn command, warnings command (which shows number of warns)
But I need help in making a clrwarns (clears the number of warns) command
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
@pliant gulch im looking through the discord api itself rn and i've got a few questions about it and slash commands and registering commands and your solution for dealing with them
What are the questions exactly
Sure, but it's more abstracted in a way to give helpful messages
is it against tos here to pay people to code things for you, because I may not know how to code, but I got money.
You can also point it to 'print' the output to files if you don't want console msgs right? Or am I mixing that up with something different
Yep you can set a file handler
#rules 9 should answer that π
!rule 9
oh ight
- you would have to register the commands through the HTTP POST request first right?
- what you register is essentially just they keyword trigger for the command and descriptions of the command right?
- the interaction the application/bot receives when someone uses a slash command would be the new thing you would have to pull all the information from? such as instead of pulling a message context(ctx) and using that in the command code it would be from the interaction it receives?
Nope haven't seen you at all
ah, you don't remember me from our work on https://guide.disnake.dev ?
Not really
:(
Though if you did contribute, ty for your help
yes, yes, yes
π
- Yes. 2. Setting the command and its metadata. 3. You get the INTERACTION_CREATE payload with interaction data from the command
doooooppppeee. i think i get how you might have done yours then. kinda. how often do you do your post? every time you launch the bot or do you do it through a different file/system
i've only fiddled around with interaction commands, but the time i did, i had a script set up that i could run
basically i would load all commands, filter the ones that supported interactions, and then send post requests with a payload containing the command's data.
In the POC slash commands I had in my wrapper, I would register them before connecting to the gateway
the commands stay once you create them, you don't need to keep creating them
this script sent a PATCH request (unless i told it to post)
Im trying to make a warn command in txt files (ik i should use a database, but im just doing it for fun)
I have done warn command, warnings command (which shows number of warns)
But I need help in making a clrwarns (clears the number of warns) command
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Basically requesting those first, then getting the gateway URL then sending IDENTIFY
Hey could I send you a DM about GitHub thats unrelated to python? Just tried and it failed
You should claim a help channel, Iβm gonna go to sleep soon
so this is my code, the bold part is the main focus.
async def on_message_delete(message):
embed=discord.Embed(description=f"")```**embed.set_author(name=message.author, icon_url=message.author.avatar_url)**```channel=bot.get_channel(943385924052602880)
await channel.send(embed=embed)```
how can i make it so that it also shows the member's id like this?
embed.set_author(name=message.author + β(" + message.author.id")", ...)```would also work right? I mean it looks horrible but at least to my mind it should work
that would cause syntax errors
besides, f string is just better in every way
at least in this scenario
Oh my bad, on mobile so I couldn't test it (ignoring @unkempt canyon eval command BC I have never once got it to work)
Oh yeah I don't dispute that
so i got a 201 response when sending a post for registering commands. should the commands at least be registered and visible in the "/" list now?
i mean just check for yourself?
i tried and they arent listed but idk if its cause i had something set wrong
i think this is enough information for it to exist and doesnt have any optional features
like it works i just dont know if there is more feedback after registering a command
wdym "more feedback"?
a 201 status is plenty of info
you can just send a GET to that same url if you want to view your application commands
that's a global command, discord needs an hour to register it
can anyone help me I get the application did not respond sometimes using pycord slash commands I have defer in my code
await ctx.defer()
the 201 is enough to know its registered but its more for the developing of the command itself. i usually like to test the command in discord itself partway through developing it to make sure its doing or pulling what it needs but its hard when the slash doesnt actually show up
wasnt sure if this was the case but in the docs it says it will force a check if the command is used before the hour
don't make it a global command then
god i hate slash commands
Integrate your service with Discord β whether it's a bot or a game or whatever your wildest imagination can come up with.
fair enough, ill wait the hour while reading up a bit more and if that doesnt work i will. it would still have the issue of not picking up if its not in the list though... ill do some more reading about it
no, it shouldn't take an hour
it's just slow to update
just have it bound to your testing guilds
it updates instantly
can you show the traceback?
Ignoring exception in command <discord.commands.SlashCommand name=currentstocks>:
Traceback (most recent call last):
File "/home/container/.local/lib/python3.10/site-packages/discord/commands/core.py", line 110, in wrapped
ret = await coro(arg)
File "/home/container/.local/lib/python3.10/site-packages/discord/commands/core.py", line 766, in _invoke
await self.callback(ctx, **kwargs)
File "/home/container/247-casino-bot.py", line 325, in currentstocks
await ctx.defer()
File "/home/container/.local/lib/python3.10/site-packages/discord/interactions.py", line 471, in defer
await adapter.create_interaction_response(
File "/home/container/.local/lib/python3.10/site-packages/discord/webhook/async_.py", line 192, in request
raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/container/.local/lib/python3.10/site-packages/discord/bot.py", line 520, in process_application_commands
await ctx.command.invoke(ctx)
File "/home/container/.local/lib/python3.10/site-packages/discord/commands/core.py", line 306, in invoke
await injected(ctx)
File "/home/container/.local/lib/python3.10/site-packages/discord/commands/core.py", line 116, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.commands.errors.ApplicationCommandInvokeError: Application Command raised an exception: NotFound: 404 Not Found (error code: 10062): Unknown interaction```
i see
can anyone help me I get the application did not respond sometimes using pycord slash commands I have defer in my code
"application did not respond"?
yeah that's generally not helpful when debugging.
did you already respond to the interaction before calling defer()?
how would I duplicate a role?
!d discord.Guild.create_role
await create_role(*, name=..., permissions=..., color=..., colour=..., hoist=..., mentionable=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Creates a [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role") for the guild.
All fields are optional.
You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to do this.
Changed in version 1.6: Can now pass `int` to `colour` keyword-only parameter.
you would want to acquire the Role object using guild.get_role(id) and then pass name=role.name, permissions=role.permissions, colour=role.colour, ... and so on
its actually quite scary what a bot can do
this is dumb
wdym tim
discord should've made it raise Forbidden
..why?
role.permissions won't apply to per channel overrides right?
no
how would I get that?
because, a bot shouldn't be able to give other roles admin
or at least that's what i think
then don't give the bot permissions to do that lol
only the owner should be able to do that
ig i didn't account for that, mb. you would want to iterate through guild.channels and use channel.edit(permissions=channel.permissions_for(role))
you can't give a bot administrator privileges and then say that it shouldn't be an administrator
yeah that's kinda irrelevant here I was just saying
that's not how Discord's permissions api works
how does this apply for a new role?
did you mean set_permissions?
!d discord.TextChannel.set_permissions
await set_permissions(target, *, overwrite=see - below, reason=None, **permissions)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sets the channel specific permission overwrites for a target in the channel.
The `target` parameter should either be a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") or a [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role") that belongs to guild.
The `overwrite` parameter, if given, must either be `None` or [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/master/api.html#discord.PermissionOverwrite "discord.PermissionOverwrite"). For convenience, you can pass in keyword arguments denoting [`Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions") attributes. If this is done, then you cannot mix the keyword arguments with the `overwrite` parameter.
If the `overwrite` parameter is `None`, then the permission overwrites are deleted.
You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this...
(this is for me)
await set_permissions(target, *, overwrite=see - below, reason=None, **permissions)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sets the channel specific permission overwrites for a target in the channel.
The `target` parameter should either be a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") or a [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role") that belongs to guild.
The `overwrite` parameter, if given, must either be `None` or [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/master/api.html#discord.PermissionOverwrite "discord.PermissionOverwrite"). For convenience, you can pass in keyword arguments denoting [`Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions") attributes. If this is done, then you cannot mix the keyword arguments with the `overwrite` parameter.
If the `overwrite` parameter is `None`, then the permission overwrites are deleted.
You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this...
Tim, get rest
try to comply by this if you're targeting all channels in a guild
i think all the children are the same tho
Lol I haven't gone to sleep yet and it's 7:05am,
but why
@slate swan figured out my issue, bot didnt have perms to add commands
Ooof lol
yeah...
!ot beat my 5 day record
Off-topic channel: #ot2-never-nesterβs-nightmare
Please read our off-topic etiquette before participating in conversations.
I once went 3 days a few years ago
true
What topic? lol
Lmfao
π
import pycord as uwu
from pycord.ext import commands as uwu_c
no_uwu_prefix="!"
uwu_prefix=uwu_c.when_mentioned_or(no_uwu_prefix)
uwu_intents = uwu.Intents.all()
uwu_bot_r = uwu_c.Bot
uwu_help_cmd = True
uwu_bot = uwu_bot_r(command_prefix=uwu_prefix, intents=uwu_intents, help_command=uwu_help_cmd)
uwu_command = uwu_bot.command
uwu_event = uwu_bot.event
uwu_on_ready_message = "uwu"
@uwu_command(name="uwu")
async def uwu_cmd_one(uwuness):
await uwuness.send("Hunter uwu")
@uwu_event
async def on_ready()
print(uwu_on_ready_message)```
@maiden fable
How is my naming convention?
Tf is line 7
and line 8
Which ones?
pep8 nightmare
help_command takes a HelpCommand instance, or None
Won't be a bool
Lmfao
But it looks so uwu
Sure
wasted
And why is it pycord
π«
Because its so uwu
No that library takes the discord namespace lol.
Stop hating pycord, its our uwu wrapper
@slate swan to fix the error in your code press Ctr + A and then press backspace
anyone got any idea why on pycord even if you have await ctx.defer() sometimes it just like to say application did not respond, run same command again boom it works just fine
ctrl + q
Not uwu
I am on phone lmao
does anyone know how'd id add like a command disabler
What's ctx there?
wdym
You would be using a database
!d discord.ext.commands.Bot.remove_command maybe
remove_command(name)```
Remove a [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") from the internal list of commands.
This could also be used as a way to remove aliases.
Type of ctx
but what about enabling it back π€
Store which commands are enabled/disabled somewhere
idk it's just this await ctx.defer()
is it fine if i store it in a json or
what , if you don't know what is it why you use it
Would that be guild specific tho
because its supposed to fix the issue with the application
not responding
but it doesnt
Your Library user above ^^^
Probably not the best choice
defer means you don't want the interaction to be responded or responded later, show code?
Ofc no, apply brain
Lmao, fine, I'll !d pycord
isnt defer supposed to give the bot extra time to send the message instead of failing to send?
Any errors?
And follow Pep8
It all comes down to their use case
Fun fact, @unkempt canyon does not have pycord.
Traceback (most recent call last):
File "/home/container/.local/lib/python3.10/site-packages/discord/bot.py", line 520, in process_application_commands
await ctx.command.invoke(ctx)
File "/home/container/.local/lib/python3.10/site-packages/discord/commands/core.py", line 306, in invoke
await injected(ctx)
File "/home/container/.local/lib/python3.10/site-packages/discord/commands/core.py", line 116, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.commands.errors.ApplicationCommandInvokeError: Application Command raised an exception: NotFound: 404 Not Found (error code: 10062): Unknown interaction```
!d disnake.CommandInteraction.response.defer
im using pycord
It's happening because you defer the response
Nvm
That's Disnake inclusive
π³that's why it's the best fork.
What the heck
so if I remove the defer it'll work correctly?
Lmao
Stop developing the bot
never used that library so no idea, send the link to pycord docs I'll check it
How fast is ur wifi?
google it
its on a host, n ot hosting it locally
Okay
that's what defer is for
Its always not about the wifi
yeah see that's supposed to fix my issue, but it doesnt
i mean i thought that's what defer is for
cause as soon as like 3 seconds hit, application did not respond sometimes
Same I nver actually checked the docs for it lol
ik but its the only db thing i can use
then just respond with a message and edit it later
When I was on mobile hotspot it took ages to deliver message
Like to load it on my screen
yeah I heard that solution too, :/ hopefully I dont have to do that, that would be so obnoxious
Lmao
str.get() is not a thing btw (your name)
Why cant u use dbs?
idk mongo, sql and all that other db stuff
Then learn em 
They are rly easy to learn
indeed
Nah
i agree
Do you want to explode?
Haters will hate
π₯Ά
I don't hate lol ,I just meant different situations prefer different db
i will internally combust the second i even consider using json as a means of storing non configuration stuff
Dw, they trollin
json is so easy and easier syntax than sql or mongo, local json file dbs are cute
LMFAOOO
i alr got this:
def ifdisabled(ctx: commands.Context):
if data.get(ctx.command.name) is False:
return True
else:
return False
π€£ π€£
You rly judge good tools for each use case based on how cute it looks π
π π π
Rofl
yaml db even cuter
sadly it doesnt really disable the command
Hb u use csv for db
and corrupt.
Or a .txt file
Txt db better >>>>>>
Laughs in binary
pickle best

Off-topic channel: #ot2-never-nesterβs-nightmare
Please read our off-topic etiquette before participating in conversations.
guys stop talking about dbs else just go to #databases
#ot2-never-nesterβs-nightmare senctum sempra
but this sadly doesn't really prevent the command from running
No one's helping you now
Is the command disabled?
π
Should raise an CheckFailure if it's disabled
Whats data.get
i just did"
with open("disabled.json", "r") as f:
data = json.load(f)
π
Kek, see #databases
do data[command_name]
i heard data.get() is better
Can u show the json file
There is no isdisabled command
wdym, isdisabled is the func which i put in @commands.check
Ohhhh
wait
Itβ s a decorator??
!d disnake.ext.commands.check
@disnake.ext.commands.check(predicate)```
A decorator that adds a check to the [`Command`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.Command "disnake.ext.commands.Command") or its subclasses. These checks could be accessed via [`Command.checks`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.Command.checks "disnake.ext.commands.Command.checks").
These checks should be predicates that take in a single parameter taking a [`Context`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.Context "disnake.ext.commands.Context"). If the check returns a `False`-like value then during invocation a [`CheckFailure`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.CheckFailure "disnake.ext.commands.CheckFailure") exception is raised and sent to the [`on_command_error()`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.disnake.ext.commands.on_command_error "disnake.disnake.ext.commands.on_command_error") event.
If an exception should be thrown in the predicate then it should be a subclass of [`CommandError`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.CommandError "disnake.ext.commands.CommandError"). Any exception not subclassed from it will be propagated while those subclassed will be sent to [`on_command_error()`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.disnake.ext.commands.on_command_error "disnake.disnake.ext.commands.on_command_error").
yup
you decorate a command function declaration with it
it should be an asynchronous function too ig
How can I get the website with tutorial on how to create a python bot
no, it's not required.
are you familiar with python?
It has to be done like this ```py
def is_me():
def predicate(ctx):
return ctx.message.author.id == 85309593344815104
return commands.check(predicate)
@bot.command()
@is_me()
async def only_me(ctx):
await ctx.send('Only you!')
Yep
fahck alr
Type discord.py docs in ur browser
Ok thanks
def is_me(ctx):
return ctx.message.author.id == 85309593344815104
@bot.command()
@commands.check(is_me)
async def only_me(ctx):
await ctx.send('Only you!')
this is equivalent.
But u can do it w/o commands.checkβ¦
?
Nicer
https://discordpy.readthedocs.io/en/stable/ this right?
It becomes Itβ s own decorator
Yes
Ok thx
either work
wait do you even test what you sent
It has to be done like this
not really, which was my point
Yes you just do commands.check in different place
nvm
Itβ s in the docs
I took the example from there
?
https://discord.com/developers/applications put the description
Integrate your service with Discord β whether it's a bot or a game or whatever your wildest imagination can come up with.
i got werror
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/disnake/ext/commands/common_bot_base.py", line 418, in _load_from_module_spec
raise errors.ExtensionFailed(key, e) from e
disnake.ext.commands.errors.ExtensionFailed: Extension 'utility' raised an error: TypeError: ifdisabled() takes 0 positional arguments but 1 was given
Code
def ifdisabled():
def predicate(ctx: commands.Context):
return data.get(ctx.command.name) is False
return commands.check(predicate)
and
@commands.command(aliases=["ping"])
@commands.has_role("staff")
@commands.guild_only()
@ifdisabled
async def latency(self, ctx):
await ctx.send(
f"Pong! (Heartbeat: {self.bot.latency * 1000 / 4:0.0f}ms Ping: {self.bot.latency * 1000:.0f}ms)"
)
oh yes and this is a cog btw
you have to call it
fguck your rigtht
not sure why, kinda dumb
.........rip typo
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
i wanted to propose a pr to make decorators more fool proof (i'm not calling you a fool, you know what i mean (: ) but i was advised to not
Ok thanks
also Client class needed .listen() (not sure why commands extension has it, doesn't make any sense)
Uh I'm actually new to python
And?
Czzz the event deco is used to edit the behavior of the provided event. Suppose u use the event deco with on_message, then u need to do bot.process_commands since event modified the default behavior of the event, but it doesn't happen with listen since it adds a new event listener, not edit an existing one
!ot
Off-topic channel: #ot2-never-nesterβs-nightmare
Please read our off-topic etiquette before participating in conversations.
More of, #python-discussion
what?
Just told u the difference between event and listen deco
no like it would actually be handy to be able to register multiple handlers for a single event
without using Bot
Ah that way
lmao i know the difference
did you try setting bot.help_command = None before loading the Cog?
ok so i have my json in data/disabled.json but i kept getting Command raised an exception: FileNotFoundError: [Errno 2] No such file or directory: 'data'
so i just put it in where my cogs (and main file) is and i still get the same error
using bot.load_extension() isn't representative of the actual file path, don't try to replicate it with open().
you talking to me?
no i literally didnt do that this is what i did to load the cogs
def loadShit():
extensions = ["utility", "fun"]
for i in extensions:
bot.load_extension(i)
loadShit()
no i mean the file paths don't work like how what you pass to load_extension()
are you sure the cog is being loaded?
just pass help_command=None to the Bot constructor
it should work
what?
how is it an issue with your terminal
that's not the full traceback
ok
thats legit a bad way to do it
according to you
it's just a help command, there's no strict convention
why ya'll arguing
overwrites = {
ctx.guild.default_role: discord.PermissionOverwrite(connect=False),
ctx.author: discord.PermissionOverwrite(manage_channels=True, connect=True),
}
fine?
Rofl yes
ok..
how do i mention a text channel?
!d discord.TextChannel.mention
property mention: str```
The string that allows you to mention the channel.
how to stop my for loops
break
how can i do this? i imported datetime but please dont send any links, just help me out through here.
embed.footer.text is what you're looking for
from datetime import date
today = date.today()
print("Today's date:", today)
!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.
pass a datetime object into the timestamp kwarg
im trying to mkae a simple bot what responds but it dowesnt
'''import discord
import os
my_secret = os.environ['token']
client = discord.Client()
@client.event
async def on_ready():
print("We have logged in as {0.user}".format(client))
@client.event
async def on_messages(message):
if message.content.startswith("$hello"):
await message.channel.send("hello")
print(12)
client.run(my_secret)'''
Is their any error
no
i suggest adding a prefix
!d discord.ext.commands.Bot i suggest using this
class discord.ext.commands.Bot(command_prefix, help_command=<default-help-command>, description=None, **options)```
Represents a discord bot.
This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") you can do with this bot.
This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality to manage commands.
instead of discord.Client() since on_message handling for commands is bad
wait i found and error
client = commands.Bot (command_prefix="$") instead of client = discord.Client()
and also os.getenv()
commands.Bot bro
thanks
and name it bot since it's a bot not client (good practices)
and instead of
await message.channel.send("hello")```do ```@client.command()
async def hello (ctx):
await ctx.send("hello")```
ok
yes?
Go ahead
but hhow to set command
wdym
but whats the commnad like hello or wat
hello
how to change it
where it says async def hello (ctx): change 'hello' to something else
context
thanks
Hey does anyone know how to make something like this elif isinstance(error, commands.MissingRequiredArgument): specific to a command? e.g. it detects the command and sends a message based on that
isinstance is used for errors
error: commads not defiend
So you want to detect when a command is used and do something ?
commands not commads
Also send the full code
show me ur codes
sus bot? seriously?
LMAO
or not they did a env
im going to intergrate my among us ai detection
yeah so like if my error is in !cban, its ewrror handling is different for when its !help (even if they have the same error like missing argument)
U need to do from discord.ext import commands
bc u didnt add client = commands.Bot (command_prefix="$") to the top of ur full code
thanks
hello, u dont have to spam, if someone doesnt answer you, then they don't know.
Oh uh i'd do a
@client.command()
async def etc.
try:
the command code
except commands.MissingRequiredArgument):
specific handling here
uh what
ah
I tried this but it doesn't catch my errir
put the try before the async
i messed up
I dont think that will work
how to make command with input like *boo @ loke
Thats more a API bug then ig
huh ?
how to mkae command with imput like bot has *ban {user} how to get {user}
async def ban(ctx, user):
huh weird
thanks
@commands.Cog.listener()
async def on_command_error (self, ctx, error):
if isinstance(error, commands.MissingPermissions):
await ctx.channel.purge(limit=1)
em = discord.Embed(title="Cosmic Overground", description="Sorry, you don't have permission to run that command.", color=0x00a8ff)
await ctx.send(embed=em)
elif isinstance(error, commands.MissingRequiredArgument):
await ctx.channel.purge(limit=1)
em = discord.Embed(title="Cosmic Overground", description="You need to enter all the required arguments!", color=0x00a8ff)
await ctx.send(embed=em)
else:
raise error```
that catches it but like not what i want
try:
for i in range (0, len(Json_Items)):
for x in Json_Items[i]:
if int(x) == int(member.id):
id = member.id
name = member.name
staff = Json_Items[i][x]['Staff']
await ctx.channel.purge(limit=1)
scammer = getJSON("./Cosmic overground/scammer.json")
scammer_dict2 ={
id: {
"Discord_Name": name,
"User IGN": ign,
"Payment Method": payment_methods,
"Payment Address": payment_address,
"Proof": args,
"Reason": reason,
"Staff": staff,
"Scammer": True,
}}
scammer.append(scammer_dict2)
json.dump(scammer, open("./Cosmic overground/scammer.json", "w"), indent=1)
break
except commands.MissingRequiredArgument:
await ctx.channel.purge(limit=1)
em = discord.Embed(title="Cosmic Overground Secruity", description="You need to enter all the required arguments! ``!cban <user id> <reason> <proof>``", color=0x00a8ff)
await ctx.send(embed=em)```
that doesn't catch it
Nope
embed.set_footer(text="")
your embed.timestamp = datetime.datetime.utcnow()
embed=discord.Embed(description=f"message deleted in: <#{943385924052602880}>\ncontent: {message.content}", colour=0x2F3136, timestamp = datetime.datetime.utcnow)
AttributeError: type object 'datetime.datetime' has no attribute 'datetime'```
where?
at the end of βutcβ
File "main.py", line 34, in on_message_delete
embed=discord.Embed(description=f"message deleted in: <#{943385924052602880}>\ncontent: {message.content}", colour=0x2F3136, timestamp = datetime.datetime.utcnow**)**
AttributeError: type object 'datetime.datetime' has no attribute 'datetime'
wait
they forgot two brackets
im confused, who am i@helping
SyntaxError: 'await' outside function what does this mean
show code
send your code
show code
lmao
you must be awaiting outside an async function
π
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.
Indentation
Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.
Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.
Example
def foo():
bar = 'baz' # indented one level
if bar == 'baz':
print('ham') # indented two levels
return bar # indented one level
The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.
Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines
More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation
try to learn basic python before digging into apis
embed.set_author(name=f'{message.author} ({message.author.id})', icon_url=message.author.avatar_url)
^
SyntaxError: invalid syntax```
Do any of you know how to do slash commands with disnake? If so, do you know how to make it so only the user who issued the slash command see the response from the bot? Could you send me a documentation link or give me an example? Thanks so much! (Feel free to ping me if you decide to reply by the way)
ephemeral=True in InteractionResponse.send_message should do it
aah thank you
Yeah I just found it in the documentation. Thanks again for the help!
I didn't know what the word was called π
you defined bio somewhere else in the global scope
So last time I made this command py deletion_list = [] @bot.command() async def deleteadd(ctx, user: discord.User): deletion_list.append(user.id) await ctx.send("Done.") @bot.listen() async def on_message(msg): if msg.author.id in deletion_list: await msg.delete() How can I make it so that the deletes only happens in the server where the command is executed?
You don't need to await list.append, and are you sure you don't want the deletion_list data to be persistent?
cause bio is inside the if-statement, if the if-statement isn't executed, then bio is undefined
yes, it can be managed with small usage
But you'll need to readd the ids everytime you run the script
ik they will be wiped after a restart which is not an issue for me
If that's intended design, then ok. You can use a dictionary and store a list per guild to solve your issue
I'd use a set instead of a list though
Html
Which listener gets triggered when somebody boosts the server?
mhmm, any tips on doing that?
you can use on_member_update since they will get the nitro booster role while doing so
Learn dict
Hello guys .How can I get notified when my bot joins a new server ? Like : Everytime the bot joins a new server, it should send a message to my personal server that it has joined a server
@client.event
async def on_guild_join(id):
channelid = client.get_channel(942304159674282034)
await channelid.send("hello")```
I already tried the above code but I'm getting the following error :
```File "main.py", line 20, in on_guild_join
await channelID.send("Joined a server")
AttributeError: 'NoneType' object has no attribute 'send'```
o
np
There's also the possibility of using on_message
anyone please ?
Can bot see how many times user has boosted the serveR?
!d discord.on_guild_join
discord.on_guild_join(guild)```
Called when a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild") is either created by the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") or when the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") joins a guild.
This requires [`Intents.guilds`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.guilds "discord.Intents.guilds") to be enabled.
wait they edited
are you sure that id is valid?
Not when the user boosts the guild when he is already a booster
He can search for message type in on message
Hey wise Hun....ter? Can a bot see how many times has a user boosted the server?
I want to send the msg into my personal server... not the server which the bot has joined
yup
what intents do you have?
Indeed
embed.set_author(name=f'{message.author} ({message.author.id})', icon_url=message.author.avatar_url)
^
SyntaxError: invalid syntax``````py
@bot.listen()
async def on_message_delete(message):
embed=discord.Embed(description=f"message deleted in: <#{943385924052602880}>\ncontent: {message.content}", colour=0x2F3136, timestamp = datetime.datetime.utcnow()
embed.set_author(name=f'{message.author} ({message.author.id})', icon_url=message.author.avatar_url)
channel=bot.get_channel(943385924052602880)
await channel.send(embed=embed)```
wth is this now :/
discord.Embed missing )
so it's ()) ?
U need a description for the slash commands
I have them in all
Yes
Disnake Version?
lemme see
Descriptions for the options* it seems
which options smh
Update Disnake
Wait that's also compulsory?
embed=discord.Embed(description=f"message deleted in: <#{943385924052602880}>\ncontent: {message.content}", colour=0x2F3136, timestamp = datetime.datetime.utcnow())
AttributeError: type object 'datetime.datetime' has no attribute 'datetime'```
since when are option descriptions mandatory π€
Pretty sure yeah
I see, lemme try
Ikr
Either way you'd need an update
you probably did from datetime import datetime
the version is 2.3.0 btw @maiden fable
you are doing
from datetime import datetime
Well the latest is 2.4.0
just do datetime.utcnow()
what do i do instead
^
yeah it updated
so no imports?
no, just do that, nothing else
tysm
Works now?
Also, you need a description for kwargs
"What options smh"
- Ashley, 2022
shiki birthday today @hoary cargo
Blessed day
πΌ

happy birthday Ares π₯³
embed=discord.Embed(description=f"message deleted in: <#{943385924052602880}>\ncontent: {message.content}", colour=0x2F3136, timestamp = datetime.datetime.utcnow())
AttributeError: type object 'datetime.datetime' has no attribute 'datetime'```
just do datetime.utcnow()
Replace this in the line that the error indicates. That's all
it's not my birthday but my character profile pic, but still thanks
oh
Happy. Birthday. Ares.
I am homo for shiki.
@bot.listen()
async def on_message_delete(message):
datetime.utcnow()
embed=discord.Embed(description=f"message deleted in: <#{943385924052602880}>\ncontent: {message.content}", colour=0x2F3136, timestamp = datetime.datetime.utcnow())
embed.set_author(name=f'{message.author} ({message.author.id})', icon_url=message.author.avatar_url)
channel=bot.get_channel(943385924052602880)
await channel.send(embed=embed)`````` File "main.py", line 35, in on_message_delete
embed=discord.Embed(description=f"message deleted in: <#{943385924052602880}>\ncontent: {message.content}", colour=0x2F3136, timestamp = datetime.datetime.utcnow())
AttributeError: type object 'datetime.datetime' has no attribute 'datetime'```
You seem to have imported from datetime import datetime instead of import datetime
@bot.listen()
async def on_message_delete(message):
embed=discord.Embed(description=f"message deleted in: <#{943385924052602880}>\ncontent: {message.content}", colour=0x2F3136, timestamp = datetime.utcnow())
embed.set_author(name=f'{message.author} ({message.author.id})', icon_url=message.author.avatar_url)
channel=bot.get_channel(943385924052602880)
await channel.send(embed=embed)
andy
can i not convert a datetime.datetime object to a specific timezone without another module?
The due date is nearing π
hunter
welp, I'm not gonna get it done by then
Go burn midnight lamps
I did add buttons, interactions and action rows yesterday though
do you have taxes due andy
Sorry, I don't work with times much tbh
I prefer working with epoch time tbh
Never heard someone actually say that
Wym
Oh, yea I totally prefer calculating the date & time using epoch milis
Indeed
That was sarcasm
;-; why bully
Because why would you use epoch milis over datetime when trying to get the date & time
Okay lemme rephrase my statement: "I don't work with dates and times much"
well, that is because andy is very smart in the aspect of developing. so when andy explains something to someone who doesnt have the same knowledge, it may be looked at as confusing because andy is explaining something with the assumption it can be understood as simply as he/she understands the topic. so yeah it creates confusion. thats why you ask more and more. the more you ask the more you know. dont walk away misunderstanding the topic because one explanation didnt give you the knowledge needed. im sure andy would have been willing to break down the explanation.
OMG hi Andy!
Don't tell me u expect me to read all that...
you won't regret it
Oh yea I totally didn't
im sure Andy would have been willing to break down the explanation tho.
import disnake
from disnake.ext import commands
class Timeout(commands.Cog):
"""Mutes/timeouts a user."""
def __init__(self, bot: commands.Bot):
self.bot = bot
@commands.slash_command()
async def timeout(self, inter, user: disnake.Member, until = int, reason = None):
"""Mutes/timeouts a member for up to 28 days in the future."""
await timeout(duration=until, member=user, reason=reason)
def setup(bot):
bot.add_cog(Timeout(bot))
Slash doesn't register, any idea why?
Discord *feature
I defined a test guild in main.py
import disnake
from disnake.ext import commands
import os
from dotenv import load_dotenv
load_dotenv()
token = os.environ["token"]
bot = commands.Bot(test_guilds=[938194100639895713])
bot.load_extensions("commands")
@bot.event
async def on_ready():
print(f"{bot.user} is loading into developer mode...")
bot.run(token)
have you invited the bozo with application command set
Why using user instead of member, also it should me member.timeout
why so confused 
Ignore me nvm
member.timeout doesn't work
Still isn't registering the command in the test guild
are you sure the cog is loaded
I used bot.load_extensions("commands") to load the whole commands foldee
And it's loading my ping command
From the same folder
so are you saying that you have a cog for each command? please say no
Lmao
yes I do because organisation :)

I don't really develop bots anymore, so no comments. Everyone got their own opinions
hunter annoyed :)
inter.author, if u want the member object of the person who invoked the command
Haven't used pycord, but I heard Disnake is good
lol
Every fork is good, depends on the person which one he/she wants to choose
U do know that this isn't the correct channel for memes, right?
it isnt a meme-
this is the visual explanation of pycord's uwuness
Β―_(γ)_/Β―
dpy is worse.
inter isn't defined
not really, pycord is
Use ctx.author
I do
Pycord is so bad
I looked at their repo
They have basically no examples for new things
Okay I smell a controversy starting, so I will just keep shut
What about Nextcord?
noticed I am the root every time
its good
I ain't targetting u by any means. Just clearing my stand
lol ikr
Nextcord has done well, they're a stable fork
.....?
Ah
Well then u gotta store the ticket channel ID somewhere, mapped to the ID of the person who opened it
https://github.com/Hunter2807/disnake is the best fork :pepe_blush:
Wait what, I never knew I had a fork of that lmao
rofl
In short, u need a db
..
?
every bot needs a db at some point 
Not my bot hehe. I use txt files π
not really, depends if your bot store data
Indeed
once you want to implement anything specific, having a place to store your stuff is very useful
@maiden fable why is there a lowercase true and camelCase in your pfp smh
because it's js
Smh LEAVE it
It's like a mixture of python and js
j* 
It's been discussed like a thousand times already
yeah half js*
hunter high?

!ot
Off-topic channel: #ot2-never-nesterβs-nightmare
Please read our off-topic etiquette before participating in conversations.
Wow
lol
!ot
404 Not Found
lol

Cooldown is a bit too much tbh
uwu, we have hunter
Smh this isn't the correct channel Ash
Alright, this is getting a little out of hand
lol
Common in here
this is quite normal atm, still no serious fights
Good thing tbh. I'm either involved in those arguments, or I'm the one who starts them
#discord-bots in a nutshell
same

i wish the badges for devs would be back
at least idk like if your bot > x servers you get the badge
They ain't coming back
who's gonna start
Damn that's sad
My bot got verified last year haha
Just a day or two before their Christmas Holidays started
great Christmas present
mine still is in the same amount of servers it was in 2 months ago lmao
Happened with me too
Me πΏ
We don't celebrate it here, but yea
π
wait you don't get Christmas presents?
o
Well, u can use that, but i meant a proper SQL db
πΏ
It's still in only 123 servers even when my friend's bot which got verified like 2 weeks before mine is in like 400 or smth servers already
if you ever apply for intents, uh, expect an answer after few months 
one of my friends bot apparantly blew up on topgg and is in 300 servers now
I already got message intents (since it's a chatbot) and members intent (I don't even use it now, had requested it for seeing the guild.member_count only π€£)
i applied for member intents on February and got an answer in fucking September 
Damn tf
dang
i just needed it to set up an easy welcome message stuff for my server, but imagine over half year, in that time i just made a custom bot just for my server and solved the problem
but at least they enabled the intent after over half year
Lmao
dyno and mee6 supremacy is over, their moderation stuff are pretty easy to replicate
Mhm
Have you seen mee6s dashboard? It's insane
Indeed
i'm talking strictly about their moderation part, ofc, it's nice to have all those features on a dashboard but it's not really hard to add those features on your bot if it's just for your server
hi, I know that discord.py is not the best library and dpy is not getting updated anymore but what is new to disnake. like is there some major features that Im missing by staying with dpy?
ye you could say so
like application commands, interactions
i would just use a fork or something like hikari/pincer
im trying to make command like boo {user} but i get to have id how can i get id by usernam
You dont need ID, just do user.mention
!d discord.Member.mention

