#discord-bots
1 messages · Page 702 of 1
inline=false
wdym
i have that
no should i?
if u want them all to be like second pic u should?
You should have inline=True
i thought it was only for the discord.Embed part
😭
add_field(*, name, value, inline=True)¶
If you want them all to line up
Yeah
ty
np doood
inline should be False if you want them to look like the second picture
show more of your code
!d time.time ?
time.time() → float```
Return the time in seconds since the [epoch](https://docs.python.org/3/library/time.html#epoch) as a floating point number. The specific date of the epoch and the handling of [leap seconds](https://en.wikipedia.org/wiki/Leap_second) is platform dependent. On Windows and most Unix systems, the epoch is January 1, 1970, 00:00:00 (UTC) and leap seconds are not counted towards the time in seconds since the epoch. This is commonly referred to as [Unix time](https://en.wikipedia.org/wiki/Unix_time). To find out what the epoch is on a given platform, look at `gmtime(0)`.
Note that even though the time is always returned as a floating point number, not all systems provide time with a better precision than 1 second. While this function normally returns non-decreasing values, it can return a lower value than a previous call if the system clock has been set back between the two calls.
!d datetime.datetime.now
classmethod datetime.now(tz=None)```
Return the current local date and time.
If optional argument *tz* is `None` or not specified, this is like [`today()`](https://docs.python.org/3/library/datetime.html#datetime.datetime.today "datetime.datetime.today"), but, if possible, supplies more precision than can be gotten from going through a [`time.time()`](https://docs.python.org/3/library/time.html#time.time "time.time") timestamp (for example, this may be possible on platforms supplying the C `gettimeofday()` function).
If *tz* is not `None`, it must be an instance of a [`tzinfo`](https://docs.python.org/3/library/datetime.html#datetime.tzinfo "datetime.tzinfo") subclass, and the current date and time are converted to *tz*’s time zone.
This function is preferred over [`today()`](https://docs.python.org/3/library/datetime.html#datetime.datetime.today "datetime.datetime.today") and [`utcnow()`](https://docs.python.org/3/library/datetime.html#datetime.datetime.utcnow "datetime.datetime.utcnow").
Hi myxi
Hey guys, im having an issue posting a time to a channel
@tasks.loop(minutes=1)
async def my_background_task():
format = '%Y-%m-%d %I:%M %p'
now_utc = datetime.now(timezone('US/Eastern'))
channel = client.get_channel(919746368027918357)
await channel.send((now_utc.strftime(format)))
any idea why
!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.
@tasks.loop(minutes=1)
async def my_background_task():
format = '%Y-%m-%d %I:%M %p'
now_utc = datetime.now(timezone('US/Eastern'))
channel = client.get_channel(919746368027918357)
await channel.send((now_utc.strftime(format)))
how to limit my discord bot commands to a moderator role ?
!d discord.ext.commands.has_role
@discord.ext.commands.has_role(item)```
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 invoking the command has the role specified via the name or ID specified.
If a string is specified, you must give the exact name of the role, including caps and spelling.
If an integer is specified, you must give the exact snowflake ID of the role.
If the message is invoked in a private message context then the check will return `False`.
This check raises one of two special exceptions, [`MissingRole`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingRole "discord.ext.commands.MissingRole") if the user is missing a role, or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") if it is used in a private message. Both inherit from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
Changed in version 1.1: Raise [`MissingRole`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingRole "discord.ext.commands.MissingRole") or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") instead of generic [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure")
Or you could do a check by permissions
!d discord.ext.commands.has_any_role
@discord.ext.commands.has_any_role(*items)```
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 invoking the command has **any** of the roles specified. This means that if they have one out of the three roles specified, then this check will return True.
Similar to [`has_role()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.has_role "discord.ext.commands.has_role"), the names or IDs passed in must be exact.
This check raises one of two special exceptions, [`MissingAnyRole`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingAnyRole "discord.ext.commands.MissingAnyRole") if the user is missing all roles, or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") if it is used in a private message. Both inherit from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
Changed in version 1.1: Raise [`MissingAnyRole`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingAnyRole "discord.ext.commands.MissingAnyRole") or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") instead of generic [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure")
You can use this, for multiple roles
When I try to kick someone it says MissingPermissions even though I have written @commands.has_permissions(kick_members=True)
does the bot have permission to kick the members?
yep
@manic wing have you got it?
no
channel = message.channel
number = 1
await channel.send("Guess a number from 0 to 20")
def check(m):
return m.author == message.author and m.channel == channel
wait = await client.wait_for("message", check=check)
if wait == str(number):
await message.channel.send("Right!")
else:
await message.channel.send("Wrong. Try again!")```
Does anybody hot to fix this
Even if the user's response is correct (1) the bot says what it's wrong
Did you print() wait?
No, but i can try
I suggest doing that.
Ok hold a sec
It doesn't print
where do i have to call the print in the program?
Well where did you put it?
yes
Well it has to print atleast None then
Well how is client defined?
sorry wrong server
discord.Client()
You got intents on?
I'm not that good at english what do you mean
.
!intents
Using intents in discord.py
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default, discord.py has all intents enabled, except for the Members and Presences intents, which are needed for events such as on_member and to get members' statuses.
To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.
Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:
from discord import Intents
from discord.ext import commands
intents = Intents.default()
intents.members = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.
@bot.command(name='giveaway')
@commands.has_any_role("ᴀᴅᴍɪɴ 🛡️","ᴄᴏ ᴏᴡɴᴇʀ 🛡️","ᴏᴡɴᴇʀ 👑")
async def gstart(ctx, time=None , *, price=None):
if time == None:
return await ctx.send("Wpisz czas!")
if price == None:
return await ctx.send("Wpisz nagrode!")
await ctx.message.delete()
time_convert = {"s": 1, "m": 60, "h": 3600, "d": 86400}
gtime = int(time[0]) * time_convert[time[-1]]
rozdanie = discord.Embed(title=":giveaway: **Giveaway!** :giveaway:", description=f"⭐ __**Do wygrania**__ ⭐: **{price}**\n⏲️ Kończy się za ⏲️: **{time}**", color=0x42c2f5)
gmsg = await ctx.send(embed=rozdanie)
await ctx.send(ctx.message.guild.default_role)
await gmsg.add_reaction("🎉")
await asyncio.sleep(gtime)
nowy_gmsg = await ctx.channel.fetch_message(gmsg.id)
users = await nowy_gmsg.reactions[0].users().flatten()
users.pop(users.index(bot.user))
zwyciezca = random.choice(users)
await ctx.send(f"🎊 Gratulacje {zwyciezca.mention}! Aby zgłosić się po nagrodę, skontaktuj się z administracją na ticket'cie! 🎊")
``` How can I add to this code to update the time every 30 minutes?
just use discord timestamps
u have idea how?
How do I make it so when the bot gets mentioned alone it sends this message but when the bot gets mentioned with help or something it doesn’t send it? https://mystb.in/EffortsEnoughPrevent.python
check for msg content id equal to ur bots mention form
Uhh
@boreal ravine should look like this
!d discord.TextChannel.get_message
No documentation found for the requested symbol.
what the fuck
u have idea how?
I’m a bit confused on what you mean by that
@outer violet check the message content for this
by making it? it needs an epoch time code <t:119191>
Like this? if self.client.user.mentioned_in(@golden geyser):
Is there a method in dpy to look for messages without reactions in certain channel
Oh
Yes
Lmfao 😭
Can you send a doc link or implementation of it?
how this clean syntax lookin
basically:
- used impractical groups just for a command
- used
bot.wait_forfor the reaction
if I do that in on message event won't it effect the performance?
No
you talking to me or? nvm
What a great help this guy is.
bro don't use bot.wait_for to check messages oh fu-
bot.wait_for has to be awaited i think
No. Your bot is always scanning for shit using on_message.
!d discord.ext.commands.Bot.wait_for
wait_for(event, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits for a WebSocket event to be dispatched.
This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.
The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.
In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.
This function returns the **first event that meets the requirements**...
If you're using commands.Bot atleast.
Technically yes
i once got rate limited by the discord api, now i make changes to my bot but don't load them that fast
I’ll inv your bot
why
I’ll also give it 5 stars
how to get a bot to detect a word
What a simp
Why tf is the bot offline
I simp for bots ok
Nah you simp for devs
like in a sentence
Bro I don’t love humans
just make a listen()
Check a msgs content
I love bots
Devs*
I love your bot. Does that mean I love you?
!ot
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
im confused
What are you confused about
this
I can’t display the code since I’m on a phone lmao 😂
check the message content
!d discord.Message.content
The actual contents of the message.
hello how i make my bot do a command in custom channel
do a command? wym
A command only in a channel?
yes
Pretty ez
Check the id of the channel
I have a question
Send it
I think so
Alr
Mm hm
Ofc its their so yes
Would it sense for profanities even if it’s a emoji?
Since spoiler uses |
why cant you
No it doesn’t
message.content returns the raw message content lol
Oh
Why wouldn't you
Yes
Alr
sure
What
You know what I’ll find out myself
Okay
In a msg it probably looks like:
Msg || lol || :kek:
No it wouldn’t look like that
How would it look like then
Not like that
Then what would it look like
it would
Is that really your explanation
My bad but how would it look like kayle?
what do you mean by what it would look like lol
“It wouldn’t look like that”
“Then what would it look like”
“not that”
“Then what”
Does a msg look like this to the bot?
Since you said it takes raw msg content
*ahem* he was pointing to your explanation to me
🚶
yes it would
I told you
i to coding so idk what that is😅
It escapes mark down.
No it wouldn’t
a msg.content for spoiler looks like ||test||
Yeah ik
So ||hi|| would look like ||hi|| to the bot
ah ok 😅
it looks like what the message looked like
Also, thanks for your question. I earned 30 rep from that
if "letter" in message.content:
....
you can use regex to
I alrd forgot what the question was 😅
Huh
you mean **hi**
Yeah I fixed it
Nvm
if that was a question, yes it would
So how would it look like tyler is saying what i said and kayle is saying it doesn't
Can a bot use different commands for different prefixes
Im having a stroke
you got answer for it? (I made a decorator myself)
#discord-bots message same thing #discord-bots message
Idek what’s going on anymore. Are you asking how bots see message content.
I asked it already lmao 😂😂
Ok
Like many of them?
Naw I sent the link
But you asked, and I said no
Yes
just pass in a list to the command_prefix kwarg
Alr
ah, decorator is best choice so far imo
You don’t understand
check for the prefix then? whats hard lol
CodLab 🧪
Bots don’t see markdown. They literally see what was typed in.
Cyberweapon asked it so I asked on stack
Isn’t that the raw content
Wdym by "raw content"
Cool
Hi
sweet
Yeah my fault
it will be \😄 for smile face
Bro🕴️
Mentions are seen as @sage otter
Breh I thought it was a question
Everything is just barebones
Basically
Thank you tyler and kayle
ok
but
?
So that’s why the thxheist commands in dank memer are so weird
Can you give me the example of a bot's code that detects a certain word, like "dog" for instance
if “dog” in message.content
@tawdry perch just add a check to see if the prefix is equal to something else
def my_check():
def do_check(ctx):
return ctx.prefix == "+"
return commands.check(do_check)
@my_check
@bot.command()
...
No
Sure
@bot.listen()
async def on_message(message):
if "dog" in message.content:
await message.channel.send("bark")
its possible
Cool
No it's not
Wiser has said no to me like five times with no explanation i dont see if hes helping or not
Yeah me neither
Seems like hes trolling
why “no” lmao
Yeah
@crude crater
Right there
no is a good word but only if its justified
Caeden is the expert he’ll explain
It is justified
Yeah but he never justifies it
thank you
But you never provided context
Yw
Exactly
You’re just saying “no”
Yes I did
Where
No I'm not
I do not recall you explaining anything
This guy has to be shitposting right now.
Ok
The sentence starts with "No"
Fax
No
No
Let’s ignore him
Can you stop please?
No
No
Anyways someone ask a goddamn question
Yup

Before I do something I’ll regret

Stop spamming emojis
!ot
No
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
!ot-names || they changed the name of the command
Off-topic channels
There are three off-topic channels:
• #ot0-psvm’s-eternal-disapproval
• #ot1-perplexing-regexing
• #ot2-never-nester’s-nightmare
The channel names change every night at midnight UTC and are often fun meta references to jokes or conversations that happened on the server.
See our off-topic etiquette page for more guidance on how the channels should be used.
I should read docs on how to use regex and i should go learn sql because i havent
I should learn js
You havent even learn pythons syntax lmfao
I did not say that, however if you want me to ping the mods then ok
Says the guy who can’t use PEP8
7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.
what even is going on here
Cant be talking
Uhhh…hard to explain
Bro
Ask a goddamn question before I do something I’ll regret
You cant even follow pep 484

You are eating dinner
No
!rule 7
7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.
You are are going to eat breakfast later
But i want my bot to kick them
make sure it doesnt respond to itself
Can it not do that?
Wdym?
you should add the if statement that checks if the message user is the bot itself
if the bot sends dog, it would respond to itself
No
Ok well that suck
bare on_message events would
S
No
not commands
Ah i see
I made a decorator for it alrd
Thx korta
He’s joking
np
Never knew that lol
discord.on_message(message)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") is created and sent.
This requires [`Intents.messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.messages "discord.Intents.messages") to be enabled.
Warning
Your bot’s own messages and private messages are sent through this event. This can lead cases of ‘recursion’ depending on how your bot was programmed. If you want the bot to not reply to itself, consider checking the user IDs. Note that [`Bot`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot") does not have this problem.
Guess im blind
see, the bot can respond to its own message
I dont even think hes a dev
yeah
Alr
I'm being dead serious
did you never know that
Ok
Ok
Then why aren’t you dead
Bro
💀
Ok
You cant even make a cog
Learn common sense
Or buttons
I can
I made buttons
Well….yeah…
Because you dont know them
You followed a YT tutorial
Its disnake not pycord
Learn buttons its not that hard
😳
I don’t like buttons 😭
Just check the examples in disnakes git
Ok mr smartypants
Imagine average button hater
I didn’t see the use in buttons
I do
Buttons > reactions
Why should we let the user decide what to do, when we can do things for them
🕴️
It’s called communism
Your excuses not to learn buttons are huge
We serve the people, not ourselves (well, occasionally)
169 more to go
Lol
they are easy
I have a question
Hes scared of them for a reason
Yeah. Once my finger was stuck in a button
Were in a elevator
!ot
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
is discussion of selbotting allowed
no
Not at all
what is it
How was discord.py created? Did he use a web scraper or something
discord has an api and all discord.py does is interact with said api
Ok
web scraping lmfao what
you should look at the source code
Will do
all it does is use aiohttp/websockets
Dekriel did you thought dpy was an api💀
Does that mean I can create my own discord py
Naw
Yes
Andy is actually making an api wrapper for the discord api
Bro🕴️
Well how do i know that?
there is actually a good wrapper by someone i know made which is wip https://github.com/neocord-lib/neocord
i was writing a fucking paragraph
Look at the previous comments
Let Caeden speak
I love it when he goes god mode
Hes always making huge paragraphs like andy for a reason
They would give you a whole page of info if you wanted
reddit has a json endpoint
nah kayle wrote misinformation and then edited it
It does?
I have to read some documentation on what are exactly endpoints web sockets and others
Yes ive used it before
Also if I made an API for self bots what would happen
totally forgot I edited it
Fbi would come to your house
Ok
- discord.py kinda already did that
- nothing would happen
Bruh
It isnt that serious
im learning c++ for one reason and one reason only; you can compile it to an exe without windows pissing itself
All it does is break their terms
Good reason
Nothing else
i prefer typescript
Woohoo, that’s my Caeden
I wanna learn js but im going to learn sql first and master it and then ill go to js
learning sql 🤸♀️
How do I fix this error?
embed = discord.Embed(colour=0xd7832b,timestamp=ctx.message.created_at)
AttributeError: 'NoneType' object has no attribute 'created_at'
python objects can change at any time but in static languages you must explicitly define the type lol
However instead of using JS I can just access their API, but that doesn’t react with anything really
Pretty easy
message wasnt created yet
more so deleted
use discord.utils lol
Utild💀
!d discord.utils.utcnow
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.
or use datetime.datetime's version if you aren't using 2.0
im making the worlds best help command, wish me luck
Alr
I need some help with how my bot pulls and sends info from a json file in help-pineapple
so like this?
discord.utils.utcnow.created_at
its a method, call it
wdym
you call it using a parenthesis
<@&831776746206265384>
<@&831776746206265384>
how do i make a discord bot ping a role cause &@910691879354523718 doesnt work
where has auto mode gone wtf
!ban 909842478293733377 racism
:x: User is already permanently banned (#57593).
its <@& >
you did <&@ >
oh
I installed a discord.py fork, how do I uninstall it
It deleted discord.py and replaced it with itself
This is the cmd to install it
pip install -U git+<link>
pip uninstall module
Just pip uninstall the package
ping bot and respond prefix discord.py any hands?
That doesn't work
Whats the issue?
ERROR: You must give at least one requirement to uninstall (see "pip help uninstall")
I wrote pip uninstall <github_link_here>
@commands.command(
aliases=['h', 'commands', 'cmd', 'command', '?', 'helpme', 'helpcommand', 'cmds']
)
async def help(self, ctx:Context, command=None) -> None:
if not command:
embed = await self.main_help(ctx)
return await ctx.send(embed=embed)
cmd = self.bot.get_command(command)
if cmd:
embed = await self.specific_command(cmd)
return await ctx.send(embed=embed)
cog = self.bot.get_cog(command.capitalize())
if cog:
embed = await self.specific_cog(cog, ctx)
return await ctx.send(embed=embed)
embed = await self.no_command(ctx)
return await ctx.send(embed=embed)
whats this
async def no_command(self, ctx:commands.Context) -> disnake.Embed:
message = ctx.message.content.replace(f"{ctx.prefix}{ctx.invoked_with} ", "").strip()
commands = [f"- `{k.name}`" for k in self.bot.commands if k.name.startswith(message[0]) and not k.hidden]
embed = disnake.Embed(
description="**Did you mean:**\n" + '\n'.join(commands)
).set_author(
name=f"{message} is not a command!",
icon_url=ctx.author.avatar.url,
)
return embed
sexy code
!d discord.ext.commands.Bot.mentioned_in
What is it
its in message class @final iron
is it possible to create custom commands in dpy?
?
where you can make your own commands for each server?
lost
easy to do
well im new to dpy
Never seen something more beautiful
looks efficient but why not use difflib?
?
as in, easy to lose a link
is it possible to create custom commands in dpy?
!d difflib.get_close_matches
i dont want that
you can add a check to your commands
is slash commands possible in dpy?
@bot.command()
async def do(ctx):
if ctx.guild.id == an_int:
...
why give me this error?
wrong token
I even changed my token
wrong token then
I even changed my bot
uh
Ignoring exception in command join:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "main.py", line 77, in join
channel = ctx.message.author.voice.voice_channel
AttributeError: 'VoiceState' object has no attribute 'voice_channel'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'VoiceState' object has no attribute 'voice_channel'
it's voice.channel
also
ctx.message.author can be shortened to ctx.author
the same problem
not true mate
read what I type
ok
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x000001FB92A04EE0>
Traceback (most recent call last):
File "C:\Users\DR_Nitrogen\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 116, in __del__
self.close()
File "C:\Users\DR_Nitrogen\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 108, in close
self._loop.call_soon(self._call_connection_lost, None)
File "C:\Users\DR_Nitrogen\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 746, in call_soon
self._check_closed()
File "C:\Users\DR_Nitrogen\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 510, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed```
whyyyyyyyyy
does this have any effect on your bot?
how to define bot in bot.listen
full error pls
Why would you do that
And I don't really think that's possible as to have a bot.listen() you need a bot instance in the first place
but how do I define bot
in @bot.listen()
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.
that's right?
Didn't you want a commands.Bot() inside your @bot.listen()?
Yeah that's the older way to do things
If you're going to make commands I strongly recommend you use commands.Bot
Yeah
@mental viper
commands.Bot subclasses discord.Client so it does everything discord.Client can and more
the api is a bit confusing
Eh
l see
yeah, commands.Bot is amazing
so I add bot = commands.Bot()?
Don’t forget all the kwargs and stuff
bot = commands.Bot(command_prefix=..., help_command=... Intents=...)
command_prefix and intents are the most important
bot won't really function without those
bot = commands.Bot(command_prefix="whatever you want it to be")
command_prefix is a kwarg
pass in your command prefix there
You shouldn't change_presence in on_ready
put it before your @bot.event
Heck you shouldn't do anything except printing in on_ready

I am confused about discord.py should I use that library to create discord bot or not ?
probably, though there are others out there
But I heard it's shutting down so I am concerned about using it
I would say discord.py is the best for python as it's had the most time to mature and get as good as it can get, if you want to make it in different languages there are most likely libraries there as well
it already shut down, it doesn't really affect smaller bots though
If you need to implement slash commands, you can easily do so yourself with the base discord.py library without any forks
Personally I prefer this over the forks as I don't really trust them as they're not as mature as the discord.py library, but if you want to use the forks you are more than welcome to do so
if i have a variable called player1 which has a discord name like TawdryDragon#2484 how would I add a role to someone with just that variable
It would be preferable the variable had an ID
but if there's absolutely no possible way to store the ID, then you can use utils.get()
well can u gib me an example?
Of using an ID or with the name?
would it be like player1 = utils.get(id)
If you had the ID it would be
player1 = guild.get_member(id)
ok and then how do i get the id of player1 with player1 being TawdryDragon#2484
Well how did you get the name in the first place
I mean how did you set player1 to TawdryDragon#2484
Through a command?
interaction.user = player1
it is what i got from someone pressing a button
with nextcord
interaction.user is a discord.User object, not a name
you most likely did something like so:
player1 = interaction.user.name
@nextcord.ui.button(label='Join', style=nextcord.ButtonStyle.primary)
async def who_plays_game_button1(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
userid.append(interaction.user)
for index in userid:
print (index)
self.value = 1
self.stop()```
I see
you should probably append interaction.user.id instead
considering the name of the variable is userid
oh nextcord
Also it's probably printing TawdryDragon#2484 instead of the object itself because discord.User has a __repr__ dunder
Your userid is actually a list of user objects
has literally everything the exact same but it is updated
as far as i know
I prefer disnake
can anyone help me create a bot?
no.
!e
class MyClass:
def __repr__(self):
return "It prints whatever I return here instead of the actual object"
print(MyClass())
@sick birch :white_check_mark: Your eval job has completed with return code 0.
It prints whatever I return here instead of the actual object
!e
class MyClass:
pass
print(MyClass())
@sick birch :white_check_mark: Your eval job has completed with return code 0.
<__main__.MyClass object at 0x7fc44fe31120>
It just prints the memory location of the object
@sick birch now i have the id what do i do now
guild.get_member(...).add_role(...)
how do i get guild
Didnt i made you switch to disnake
uhh..
I did
Ikr
pretty cool
how do i get the guid from a user id
you don’t
Hey @manic wing!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
-_
how do i get the guild so that i can get this
Pep 8 is screaming
import disnake, json, asyncio, traceback
anyone know where i can get the guild
if you have access to ctx you can use ctx.guild
You can also get a guild by ID using bot.get_guild(...)
*creaming
what is in the parenthases
Its not creaming its screaming
The ID
😉
nah man pep-8 is horny for me
😳
Nah its avoiding you mf💀
😂
which id lmao
The ID of the guild
Pep8 like:

how do i get that
i changed that
import disnake,
The typehints too
import disnake, json
It hurts
ok fine ill change that
Do it or else
and ill make an __init__.py to import * from emojis
Why are all your add_fields like that to
Def does not look good code wise kek
looks more like javascript than anything
tysm
cus its fucking sexy
subjective
I think hes delusional
nah he just likes his help command
!pep8 here caeden
PEP 8 is the official style guide for Python. It includes comprehensive guidelines for code formatting, variable naming, and making your code easy to read. Professional Python developers are usually required to follow the guidelines, and will often use code-linters like flake8 to verify that the code they're writing complies with the style guide.
More information:
• PEP 8 document
• Our PEP 8 song! :notes:
Typehinting for the second photo is wrong command should be command: Optional[str] and the return statement is disnake.Message as you are returning send
a nice looking embed can make anyone happy
I 100% believe if you were to install a type checker 90% of your code would be red
Correct
lmaoo
You did not💀
The code is just as important as the end result
If your 3.9+ or something you can also do command: str | None
Whats a good type checker for vsc?
Can mean a few things:
- Bot is not in the guild
- Guild is not in the cache
- You gave the ID as a string (must be an integer)
Pyright
Alright thx
Its just my vsc screams when i downloaded it
Are you sure the bot is in the guild?
It just says to turn off pylance and it screams in pain
.bm
i've been getting tired of dynamically typed languages these days lmao
main reason i've been using typescript
Idrk
Idek what you mean by a type checker
Is PyLance some type of linter or something?
It just checks your code
andy
find a way to dis my main.py
"""
The MIT License (MIT)
Copyright (c) 2020-present CaedenPH
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMxITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
"""
from core import JesterBot
if __name__ == "__main__":
JesterBot().run()
See here, I typehinted code as an int when really it should be str
Ohh
Yeah pylance does it lol
how do i add to cache
fetch it
You don't need to add a license to your code, just put it in a LICENSE file inside of your repo and that covers all your code under the same license unless stated otherwise
how
bot.fetch_guild(...)
it looks good 😎
Its just a waste of lines
Andy always finds something to dis
me with 9 gigs left of my drive
Each line should matter when you code lol
andys going to turn into fucking tesco - every little helps
Me with 1.3tb🕴️
Rich people
My current code does so much but uses 120 gbs!!! But my friend has made code that does the same thing but is 10 gbs
Can you see how that would matter lol
I wish
With their 20,000 tb hdds
main reason i dual boot linux and windows so i need to partition my drive into 2 parts
Is parentheses the id
my code is 32mb 
though i'm planning on getting a tb ssd for christmas lmao
dual boot 😬
mans gotta play his games
It's an example
My code only reaches 4kb😭
Just check proton db
awk
yeah windows just runs them better tbh, just a lot of little tiny annoyances
I still havent broken 500lines in a project 😔
bro im lucky to reach over 30 mb
i really wish i didn't have to use their bloatware trashy os but i'm left with no choice haha
i usually have under 1gb left, unless i go through my whole ass drive
I havent even reached a mb💀
bruh 💀
clear your temp files or smth
you could also delete/move the biggest files on your desktop
and move your downloads
that works for me
Ik lol
My whole wrapper is only 6.55mb
9.4 for me
I need a sata cable to add 3tbs to my desktop and ill have 4.5tb finally 🕴️ 🚶
50-100 actually
Can i just set the guild to bot.fetch_guild()
you need an ID and await it
i have like, 3.5 tb, all of my shit goes to my c drive tho
damn bro what you need that much for
Most of my projects are 400lines still havent broken 500lines
the rest are filled with other shit
Stuff😉 😏
ahh yes
His terabytes of homework ofc
Im jk idk i just like having allot of space
sure buddy
Claustrophobic
Homework file has already hit 10gbs💀

@sick birch so this?
my most complex program was like 50 lines and it was a bot info checker
global makes me cry
probably less
What is global for never used it
like 30-40
What do you think it does?
Makes a var global idk
im still a stinky programmer ngl, i dont know most of this shit
i mainly just use stacks or github and ctrl c/v
👌
lmao
🚶
So was i right🚶
if that doesn't work then the bot isn't in the guild
you might wanna store it in a variable though
i was thinking about making a discord bot that sets someones nick to a stupid name if it starts with a !
!e ```py
foo = 0
def bar() -> None:
global foo
foo += 1
print(foo)
bar()
print(foo)
@pliant gulch :white_check_mark: Your eval job has completed with return code 0.
001 | 0
002 | 1
globals
You also have keywords like nonlocal
why must you hurt me in this way
Useful some times
i was told globals are bad and you should stay away from them
Ah i see
Same to me
!e ```py
def wrapper(func: callable) -> None:
def inner():
nonlocal func
func = lambda: True
inner()
return func
func = wrapper(print)
print(func)
Idk this was really a bad example but I use nonlocal sometimes
Correct 99.99% of the time
@pliant gulch :white_check_mark: Your eval job has completed with return code 0.
<function wrapper.<locals>.inner.<locals>.<lambda> at 0x7fb200218ca0>
They tangle everything up into an absolute mess. Values are being changed and accessed from god knows where, making it very hard to follow the code and try debug it
Ah i see
Yes globals are bad mostly, python is a multi paradigm language, so you have OOP and stuff, much better to create a class instance variable and mutate that from within methods
So guild = await bot.fetch_guild(id)
Easier to track which is one of the problems of global as well
You could use mutable data types as an alternative to globals, like dictionary
Classes are basically just dictionaries
right
Real pimped out dictionaries
yeah
does anyone know why this does not work in giving me a role
Your inside of an if statement that checks if index == open then you add the roles in a nested if statement that checks if the same index is somehow 0 now
🤔
Lmao
@pliant gulch so i fixed index==open to multiplayer_spots==open and now there is this error:
TypeError: list indices must be integers or slices, not str
What do i fix
Anyone know what i then do
anyone know what is wrong with the line i am on
this is the creation of the list
index would be each element in the list (which is a string)
That's why you are getting a TypeError
@mellow gulch
Oki
If you trying to actually check the element's index, then it might be good idea to use enumerate
Is it possible to get the cooldown of a command? Like this?
yes it iz
How do I do it
error handler
@client.command(pass_context = True)
async def getalt(ctx):
msg = ["gabrielwarren2000@gmail.com:Cyber123", "leandroriveros123@gmail.com:culillo123", "albesi8@msn.com:Albakortoci1", "dryden6@yah...
nope.
why not?
Eh?
because there's a command for cooldowns
@outer violet
asyncio.sleep wont do anything
shit
Not what I asked :/
sorry
@bot.event
async def on_command_error(ctx, error):
if isinstance(error, commands.CommandOnCooldown):
await ctx.send('This command is on a %.2fs cooldown' % error.retry_after)
something like this
Still not that
Hi
just add it into your embed lmao
hai! :D
you can make a variable
How do I set the bot's Icon status so like Idle and DND and all that.
I have a feeling this question gets asked a lot so sorry, but is there any clear front-runner for the successor to discord.py yet?
@outer violet explain a lil idk what to recommend while you're not explaining lmao
and use it in your embed
he's trying to find command cooldown iirc
yes but for what
Like so I’m making a help command and for the on_command_help and I want to display the number of the cooldown in the embed like this
oh
Ig add the coopdown manually
Not sure
you should make variable with the time amount to wait and add it into a new embed field ig
bruh I just gave you the solution?
Just why
idk
@bot.event
async def on_command_error(ctx, error):
if isinstance(error, commands.CommandOnCooldown):
await ctx.send('This command is on a %.2fs cooldown' % error.retry_after)
das what im thinking lmao
Shes subclassing help command
who
Yes 💀
lmao

:yea:
Guessed correctly
they're making a custom help cmd or what
Lol
hmm
Eh?
brb
#help-lollipop anyone know
how do i make a command that will have text and an embed as well
like i know how to make a command with an embed but i want to also add normal text along with the embed
just send the text and the embed
await ctx.send("msg",embed=myembed)
Is there a way to code an event that gives the first 50 members a specific role?
ah ty
yw
how to convert minutes to unix timestamp (for timestamp)
what is the variable for tag for example : ernest#0001 no mention just the username and the tag ?
you mean the .name attr?
await ctx.send(ctx.author.name)
this?
wdym
!d discord.utils.format_dt if you wanna use unix timestamp use this
discord.utils.format_dt(dt, /, style=None)```
A helper function to format a [`datetime.datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "(in Python v3.9)") for presentation within Discord.
This allows for a locale-independent way of presenting data using Discord specific Markdown...
copy his id and paste it like that <@the_id>
i mean in python
timestamp like your thing will be done in insert timestamp
it is in python 🙂
!d discord.Member just ctx.author/member will do, it'll return hello#1234
class discord.Member```
Represents a Discord member to a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").
This implements a lot of the functionality of [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User").
x == y Checks if two members are equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User") instances too.
x != y Checks if two members are not equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User") instances too.
hash(x) Returns the member’s hash.
str(x) Returns the member’s name with the discriminator.
scroll up @shrewd inlet
like
^
i think it will send it
no
wouldn’t it be
that'll return hello, not hello#1234
^^^
{member.name}{member.discriminator}
:0
ctx.author does it
alr
yh
cast it to string, ctx.author alone will return Member object
how do you string something
str()
@bot.command()
async def on_member_join(member):
guild = bot.get_guild(917821802351308910)
channel = guild.get_channel(917826956295303219)
embed = discord.Embed(title="**{member.name}{member.discriminator}** has joined the server.",color=0x2f3136)
await channel.send("{member.mention} <@&917950907445039154>",embed=embed)
does that work?
why both member.name and member.discriminator
i want it to be like ernest#0001
@bot.command()
async def on_member_join(member):
guild = bot.get_guild(917821802351308910)
channel = guild.get_channel(917826956295303219)
embed = discord.Embed(title="**str(member)** has joined the server.",color=0x2f3136)
await channel.send("{member.mention} <@&917950907445039154>",embed=embed)
didnt f string it btw
so that?
oh ya
nope
{str(member)}
have to use it in a bracket
@bot.command()
async def on_member_join(member):
guild = bot.get_guild(917821802351308910)
channel = guild.get_channel(917826956295303219)
embed = discord.Embed(title="**{str(member)}** has joined the server.",color=0x2f3136)
await channel.send("f{member.mention} <@&917950907445039154>",embed=embed)
so that
Creating a Python string with your variables using the + operator can be difficult to write and read. F-strings (format-strings) make it easy to insert values into a string. If you put an f in front of the first quote, you can then put Python expressions between curly braces in the string.
>>> snake = "pythons"
>>> number = 21
>>> f"There are {number * 2} {snake} on the plane."
"There are 42 pythons on the plane."
Note that even when you include an expression that isn't a string, like number * 2, Python will convert it to a string for you.
use the f
@bot.command()
async def on_member_join(member):
guild = bot.get_guild(917821802351308910)
channel = guild.get_channel(917826956295303219)
embed = discord.Embed(title=f"**{str(member)}** has joined the server.",color=0x2f3136)
await channel.send(f"{member.mention} <@&917950907445039154>",embed=embed)
you forgot a f string in the title kwarg