#discord-bots
1 messages Β· Page 708 of 1
you have an example??
I don't get it pls help
@heavy folio yo can u add me
why
send it here
trying to make this autotyper send messages slower
What does this have to do with discord bots?
Since im going in to this blind I might be wrong but if you want a delay you can use asyncio.sleep
!d asyncio.sleep
coroutine asyncio.sleep(delay, result=None)```
Block for *delay* seconds.
If *result* is provided, it is returned to the caller when the coroutine completes.
`sleep()` always suspends the current task, allowing other tasks to run.
Setting the delay to 0 provides an optimized path to allow other tasks to run. This can be used by long-running functions to avoid blocking the event loop for the full duration of the function call.
Deprecated since version 3.8, removed in version 3.10: The `loop` parameter. This function has been implicitly getting the current running loop since 3.7. See [Whatβs New in 3.10βs Removed section](https://docs.python.org/3/whatsnew/3.10.html#whatsnew310-removed) for more information.
Example of coroutine displaying the current date every second for 5 seconds:
@final iron can u add me plz
No
Implement asyncio.sleep in to the appropriate places so the bot doesn't send the messages instantly
where do i put that?
Again I don't know your desired results but in-between each message send
6 seconds
Hmm?

hey guys i have a question
ctx.author
does this check the Context class and uses the author attr it has (if it does) but how is it ctx and not ctx().author if your using the class and one of its attrs kinda confusing and would love for someone to tell me how it works exactly and how a coro is made if someone knows is it an async function? that when used it needs to be awaited?
!d discord.ext.commands.Context
class discord.ext.commands.Context(*, message, bot, view, args=..., kwargs=..., prefix=None, command=None, invoked_with=None, invoked_parents=..., invoked_subcommand=None, ...)```
Represents the context in which a command is being invoked under.
This class contains a lot of meta data to help you understand more about the invocation context. This class is not created manually and is instead passed around to commands as the first parameter.
This class implements the [`Messageable`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable "discord.abc.Messageable") ABC.
Cz ctx is an instance of the Context class
author is a property here
im not very familiar with property can you explain?
Property means self.author = message.author
ah ic
It's just somehow similar to how you use self.bot= bot in init while making cogs
discord.py makes an instance of the Context class and then passes it to the ctx param when invoking the command
but isnt message a class?
Nope, it's the message instance from the on_message event
explain lol
That's the event discord.py uses for commands
explain πΆ
It checks if the message starts from the command prefix. If yes, then it just splits the message by spaces and then uses bot.get_command() where the command name will be the first word (excluding the cmd prefix) and then does something like
cmd_name = message.content.split()]0].remove_prefix(self.command_prefix)
cmd = bot.get_command(cmd_name)
ctx = Context(message, self, ...)
await cmd.invoke(ctx, ...)
This is just a very rough explanation, since there are more things going on under the hood than just this
it's just like the command handler sends the first argument as a commands.Context object to the command callbacks
You might have seen many people typehint the CTX to commands.Context
ic
!d inspect is the module dpy uses to get access to the underlying function (source code of the command)
Source code: Lib/inspect.py
The inspect module provides several useful functions to help get information about live objects such as modules, classes, methods, functions, tracebacks, frame objects, and code objects. For example, it can help you examine the contents of a class, retrieve the source code of a method, extract and format the argument list for a function, or get all the information you need to display a detailed traceback.
There are four main kinds of services provided by this module: type checking, getting source code, inspecting classes and functions, and examining the interpreter stack.
That's basically it , ctx is just context in short
as for the property/attribute thing , they are functions which dont need to be called
btw guys im asking these types of questions because i want to make a praw api wrapper but first i want to learn how attrs work deeply
yeah ik
!e ```py
class my_class:
@property
def name ():
return 1
print(my_class.name)```
@slate swan :white_check_mark: Your eval job has completed with return code 0.
<property object at 0x7f895c30bbf0>
U didn't make the instance
Ow yeah
But that's roughly the same as self.name = 1
!e
class my_class:
@property
def name (self):
return 1
print(my_class().name)β
@maiden fable :white_check_mark: Your eval job has completed with return code 0.
1
There (:
i see
can you guys explain setters and getters and deleters if you guys dont mind? and whats a meta class and how a coro is made 
Best of luck with it 
thx
Coro are just async functions
ah makes sense
metaclass are just class inherited from type
whats that
class Meta(type): ...
metaclass are usually used for the class's magic methods such as __new__ or __iter__
dont know about them lol
still dont kinda get it
And as the name suggests , getter gets you a value inside the class , setter is used to defined a value for the class
can you send an example?
for example I have a class which I want it to be iterable, instances magic method can be done by doing
class ClassName:
def __iter__(self):
...
and this can be iterated by for i in ClassName():. But the question is, how to iterate the class and not the instance. The answer is metaclass
class Iterable(type):
def __iter__(self):
...
class ClassName(metaclass=Iterable):
...
```now we can iterate it with `for i in ClassName:`
class MyClass:
def __init__(self)
self.name = "a class"
def getter_func(self):
return self.name
#as you can see it's just returned a pre defined value
def setter_fun(self):
self.is_cool = False
return
# and here in the setter function I just added .is_cool set to False i.e. settings a new property```
snake casing in a class name? ouch
ah i see
forgot a :
probably okimii meant the @property.getter and @property.setter function
Yea in the init sorry, In in phone
nah i just ment the general meaning
ah
since property has setters and getters right?
Can't the class name be?
not necessary
wdym?
how would i use this?
And what did i do?
snake casing
wow
this_is_snake_casing. ThisIsPascalCasing
No
No
It's pascal
Oh that was for the old message , sorry
I didn't check what message you replied to v
its fine
oops forgot to eval it
!e
class Foo:
def __init__(self):
self.value = 1
@property
def prop(self):
return self.value
@prop.setter
def prop(self, val):
self.value = val
f = Foo()
print(f.prop)
f.prop = 2
print(f.prop)
..
lmao
the first def is a bit too forward
@visual island :white_check_mark: Your eval job has completed with return code 0.
001 | 1
002 | 2
typing on phone is hard
yes
ah i see
Is the attribute just completely removed? Or just set to None
btw whats a api endpoint just how its said an end point for users to use?
removed
how can I wait for a certain amount of players to join a vc in a certain amount of time?
!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**...
yes but whats the event
!d discord.on_voice_state_update
discord.on_voice_state_update(member, before, after)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") changes their [`VoiceState`](https://discordpy.readthedocs.io/en/master/api.html#discord.VoiceState "discord.VoiceState").
The following, but not limited to, examples illustrate when this event is called...
on_voice_state_update
!e
class Foo:
def __init__(self):
self.value = 1
@property
def prop(self):
return self.value
@prop.setter
def prop(self, val):
self.value = val
@prop.deleter
def prop(self):
print(3)
f = Foo()
print(f.prop)
f.prop = 2
print(f.prop)
del f.prop
print(f.prop)
oh shoot, so u can actually do wait_for(on_voice_state_update, timeout = 60*30)
@visual island :white_check_mark: Your eval job has completed with return code 0.
001 | 1
002 | 2
003 | 3
004 | 2
It doesn't take a val in delete iirc
you can not actually delete it
although it's weird not deleting the attr in the deleter
how would i change something in a class? a subclass right
you could do Class.func = my_func if it isn't subclassed, or if it is, just override it
doesnt a subclass make a new class that inherits everything?
A one sided channel for communication to the API
ah i see
Pretty sure I explained it as well when you asked in the Lefi discord
your explanations are just confusing sometimes okπΆ
π
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.
even if i ask andy hes still gives smort explanations so he mostly just gives up lol
π¬
thats why you need to give responses other than "explain?" "can you give an example?". because thats not really enough, tell them what you need explained. tell them what you understand and where your confusion gets started and for what reasons it may be confusing you.
Snow, there's a thing known as pronouns 
im unaware of andys pronouns, nor is it my business
andy would probably have a seizure if i didπ
How get count members, on the all servers
?
len(bot.users)
no. its all about learning, you just gotta be more willing to ask. dont feel like an idiot because a question you have may be simple to someone else but not you. asking goes a long way, explaining your confusion helps more than "explain?".
Or Iterate thru all guilds and and use guild.member_count if you don't have member intents
ill try my best
:)
thanks for the advice btw
no problem.
now i will try to fork asyncpraw thank you guys :DD
goodluck!
thanks mostly trying to push myself 
wtf.
what's wrong with it? ( Also I don't understand what's written there)
you did it in a loop?
most likely
bot.users gives a list of all users your bot can see , using len gives the number of elements in the list
Why a loop?
oh
stop
sorry, sorry, im sorry
How to get the server count?
bot.guilds and len
subclass == inherit
ik
Personally, I find "extending a class" easier to understand subclassing but yes, inherit also works
Though I'm pretty sure java uses extends keyword to make a "subclass" and I started off with java so there's that haha
thats kinda cool
Starting off with java? I digress
kinda impressive
Eh that's just what they teach in school, hated it personally but I'm better off now lmao
what did they teach you?
Im wondering if I need to put the arguments of the event before the await like I did
try:
member, before, after = await client.wait_for('voice_state_update', timeout=60.0, check=check)
except asyncio.TimeoutError:
im gonna get a course of technology idk what it teaches but i hope its software related and not hardware like what a usb is because i know about it already,would love to learn java if they show it
yes
but using 1 variable is also fine, will return tuple
yeah alright cheers
how to make my message count command count messages for each server, not all at once cuz i wonna to have it like when i type +messages on the server it count form only this when i use this on the other server it count from other server only?
!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.
@client.event
async def on_message(ctx):
author = str(ctx.author)
if author in messageCount:
messageCount[author] += 1
else:
messageCount[author] = 1
await client.process_commands(ctx)
@client.command()
async def messages(ctx: commands.Context, *, user: discord.User=None):
"""To see how many messages are being sent by the user"""
user = user or ctx.author
msg = messageCount.get(str(user))
if msg:
await ctx.send(f"{user} sent about {msg} in total")
else:
await ctx.send(f"{user} didn't sent any message yet")``` here is code
for my command
And it doesn't work?
it works but i count messages from all server in once
.
is my question
make another dict inside the dict for each guild
ok but how i can make it?
{"guild":
{
"member": "number",
"member 2": "number"
},
"guild 2":
{
"member": "number",
"member 2": "number"
}
}
```the dict format would be something like this
i came here to see what creative ideas you guys are doing for discord bots
yea?
ok
so how i can make it in other way?
ok
sql is a language dbs use like sqlite and postgresql
aiosqlite3
||hi||
Sqlite has like 4 async modules lol
hello! do you need help with your discord bot or anything?
only 2 i know is asqlite and aiosqlite
asqlite3 and aiosqlite3 exist too
whats the difference between sqlite and sqlite3
Sqlite does not exist , sqlite3 does.
in raw python
ah its a term
explain
!e import sqlite
@slate swan :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | ModuleNotFoundError: No module named 'sqlite'
we do a little bit of asking
if your named mini is their big
πΆ
jk ima be srs
lol
lobby_channel = await guild.create_voice_channel(f"Team 1 - #{game_id - 1}",
overwrites=overwrites,
category=bot.get_channel(917647089016635392),
user_limit=6)
def check(member):
return member.id in games[game_id - 1]
try:
member, before, after = await bot.wait_for('voice_state_update', timeout=300.00, check=check)
except asyncio.TimeoutError:
await ctx.channel.send('Game Cancelled')
else:
if len(lobby_channel.members) == 6:
Hi guys, this is a complete shitshow, but I'm trying to wait for a certain channel to reach 6 members in 5 minutes, and if not, game is cancelled
this is inside a command
i'd only need examples for a concept of implementation, i can explain my problem in the most misunderstandable way possible though π
in vscode i pip installed disnake and pip uninstalled discord.py, but vscode saying disnake undefined, why?
did you install disnake after launching vscode?
π€ vscode was open before i installed disnake
i restarted vscode and still saying it's undefined
hmm
actually no it's just saying module import can't be resolved π
fuck
i am about to throw up rn
will it fix your problem?
so dont do it
alr
but why tf is it saying import "disnake" could not be resolved
oh yeah and i run my file and it said modulenotfound disnake doesn't exist
happens just restart your vsc or reinstall disnake without a file open
or use cmd if your on windows
why in vscode, use terminal
how else would you think id pip install without a terminal im obv not using pycharm π
I'm talking about command prompt... U just said u installed disnake in vscode right?
ok wtf is this now ssl error:
raise ClientConnectorCertificateError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host discord.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)')]
oh wait i get why it's happening
bad Wi-Fi moment
i dont think there is anything worse than an ssl error
i tore out some hair over the last one
now i look like iβm balding
why does that happen and what is it?
its an SSL error
whats that πΆ
ssl certificates are (despite the errors) amazingly awesome things that allow for the private encrypted transfer of data - ssl certificates verify the data from each end. theyβre awesome but cancer to deal with
^^ ssl fix
ah i see thank you
not always
nvm it was a network issue
^
and turns out the interpreter i had was 3.10.0 and i installed 3.10.0
now it works :]
that barely scrapes the surface of ssl errors
class disnake.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.10)") 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://docs.disnake.dev/en/latest/api.html#disnake.Embed.Empty "disnake.Embed.Empty").
For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") for you.
what does the type=... arg even do lmfao
!source
it is not
It can do the same for nextcord too
hm
!d disnake.Embed
class disnake.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.10)") 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://docs.disnake.dev/en/latest/api.html#disnake.Embed.Empty "disnake.Embed.Empty").
For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") for you.
!d nextcord.Embed
class nextcord.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.10)") 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://nextcord.readthedocs.io/en/latest/api.html#nextcord.Embed.Empty "nextcord.Embed.Empty").
For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") for you.
fuck
yeah bit of an overreaction from me 
How do I move a textchannel to another category?
@client.event
async def on_member_join(member):
embed = discord.Embed(title='Welcome', color = discord.Color.purple())
embed.description = f'Welcome {member.user} to {member.guild}'
channel = client.get_channel(924522866890911774)
await channel.send(embed=embed)
No error message and isn't working
do you have intents?
why doesn't this command work, apparently on the await ctx.send(embed=embed) syntax error comes:
@bot.command()
@commands.guild_only()
@commands.cooldown(1, 60, BucketType.user)
async def topic(ctx: commands.Context):
topics = [
"What do you want to do but can't?",
"What do you do when you are bored",
"If the world in Minecraft was infinite, how does the sun and moon revolve around it?",
"What is the best way to get a job?",
"What are you thinking about?",
"What is your favorite food?",
"What is your favorite color?",
"What is your favorite animal?",
"What is your favorite sport?",
"What is your favorite movie?",
](
embed = disnake.Embed(
title=f"Topic: {random.choice(topics)}",
description="Do `>topic` or `i!topic` for more topics!",
# set the color to blurple using hexadecimal codes
color=0x7194FF
)
await ctx.send(embed=embed)
and purple isnt a color afaik
say aye if you see shit wrong with this
hello can i ask something
ye what
Does anyone know good hosting services for discord bots?
wait the parantesis shouldnt be there
huh nice bracket catc
i want to like this
yes all
show
whys the ( there @shadow wraith
but how to do it?
have no idea how that happened
lol
show what?
make a new line \n
code
I did
Does anyone know any good hosting services for discord bots?
show the code
I did
digital ocean is good
of your intents
where to put the line?
after the colon
intents = discord.Intents().all()
client = commands.Bot(command_prefix=',', intents=intents)
anyone has any idea why a cog loads twice? the way i load cogs: ```py
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
extension = filename[:-3]
try:
self.load_extension(f'cogs.{extension}')
logging.info(f"Successfully loaded extension '{extension}'")
except Exception as e:
exception = f"{type(e).name}: '{e}'"
print("---------------------")
logging.warning(f"Failed to load extension '{extension}'\n-- {exception}")
terminal output:```py
INFO:root:Successfully loaded extension 'utilities'
---------------------
WARNING:root:Failed to load extension 'utilities'
-- ExtensionAlreadyLoaded: 'Extension 'cogs.utilities' is already loaded.'
!e
print("hello\nworld")
@slate swan :white_check_mark: Your eval job has completed with return code 0.
001 | hello
002 | world
bro?
!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.
example
I sent my intents
thank you
nice
and you forgot intents.members = True
^
anytime
i hope you have a good day today
ah my bad,i assume you enabled it in the portal correct?
yes
you to :D
weird i dont remember purple() being a color at all
would this do?
category = ctx.guild.get_channel(867025452513230849)
await ticket_channel.move(category=category)
!d discord.TextChannel.move
await move(**kwargs)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
A rich interface to help move a channel relative to other channels.
If exact position movement is required, `edit` should be used instead.
You must have the [`manage_channels`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to do this.
Note
Voice channels will always be sorted below text channels. This is a Discord limitation...
hmm
ye should work
its there
yeah how do I get a category
yeah i just noticed got confused with the colors of buttons
can't seem to find any method
is embed.description even possible?
bru
indents
thats 5 spaces
also im pretty sure that'd return an error
thats 4
yeah, it should be random.choice(topics)
is your bot var really called aπ΄οΈ
yes topic is a function
wuts that
How to mention role in this code ?
!d discord.ext.commands.group
!d discord.ext.commands.Group
class discord.ext.commands.Group(*args, **kwargs)```
A class that implements a grouping protocol for commands to be executed as subcommands.
This class is a subclass of [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") and thus all options valid in [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") are valid in here as well.
i seeπ΄οΈ
!d discord.Role.mention
property mention: str```
Returns a string that allows you to mention a role.
guild.get_role(id)
okimii i finally know something you dont
Β―\_(γ)_/Β―
Why not just <@&id> when they just want to mention it , instead of getting the role object first
should i defer my views everytime i make one?
how to remove timed out from a user?
what lib are you using?
lmao
Could you explain more briefly?
discord's new feature - giving timed out to a user
it cannot be removed by d.py ?
uh
you can edit the internals though to get timeouts
how ?
It's been unmaintained for a long time
?tag timeout in dpy in the dpy server
ok
it depends. If you're going to have longer reply time, then yes, else no
thanks
disnake has timeouts ;D
!d disnake.Member.timeout
await timeout(*, duration=..., until=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Times out the member from the guild; until then, the member will not be able to interact with the guild.
Exactly one of `duration` or `until` must be provided. To remove a timeout, set one of the parameters to `None`.
You must have the [`Permissions.moderate_members`](https://docs.disnake.dev/en/latest/api.html#disnake.Permissions.moderate_members "disnake.Permissions.moderate_members") permission to do this.
New in version 2.3.
well , if you want your bot to be updated with latest discord elements
You use forks
else , you're cool with discord.py
disnake made my aiohttp api command thing much more faster
dpy already has the new stuff being made by the dpy people lol
disnake has unnecessary but life-changing-and-bet-you-did-not-know-it-was preferences added
like for example, tired of specifying seconds. until=... fucking takes a datetime obj
Sad?
!d nextcord.Member.timeout
property timeout: Optional[datetime.datetime]```
A datetime object that represents the time in which the member will be able to interact again.
Note
This is `None` if the user has no timeout.
New in version 2.0.
pycord still has the folder name as discord lmfao
Oh pycord doesn't exist in the bot
Wow
is there a disnake support server
Lmfao very epic
For disnake it's a method to timeout a member
For nextcord it just checks member's timeout
can someone show me how to make a slash command in disnake (like a concept of implementation or example)
hey can anyone tell me where can i host single server bot for free?
railway
or heroku is good
nani?
your pc.
:^)
what's the check for guild owner again
lol
is_guild_owner()?
def is_guild_owner():
def predicate(ctx):
return ctx.guild is not None and ctx.guild.owner_id == ctx.author.id
return commands.check(predicate)
@bot.command()
@commands.check_any(commands.is_owner(), is_guild_owner())
async def only_for_owners(ctx):
await ctx.send('Hello mister owner!')```
mm dont spoonfeed
π i was asking bout using the commands decorator
i didnt ask you to give me the code
hm
just check for the guilds owner id
and there's no check in discord.py for that
kden a custom check is it
yes
he meant the is_guild_owner function
i was asking if there's a built in function
lol but he got what he want
i don't think
this
Yeah that works for his purpose
The check is doing same
but its more easier to do
Yea ofcourse
the check will anyways just raise a CheckFailure
if it's not a guild/bot owner
which can be handled
and i will saying making a custom check is better practice
because it can be used with multiple commands at once
it indeed is
hi guys. i wanna ask how to make this 2 commands in one. i mean 2 in 1. as you can see, the word (C) is diffrent
str.lower() method
where to put?
after the content attribute https://docs.python.org/3/library/stdtypes.html#str.lower
if message.content.startswith("Covid stats"):
await message.channel.send("> Daily covid cases\nhttps://www.worldometers.info/coronavirus/")
what
and if you wanna make commands, use ext.commands, don't use on_message events
ouhhhh
okok
you mean dont use message.content and switch to ext.commands ?
No..?
that's the opposite lmao
why me getting this when making disnake slash command :[
click the link
i did
read it then?
use the or operator
i won't tell you about it since python knowledge is required and recommended to those who want to use discord API's for python (not saying discord.py since there are multiple forks of it and they are somewhat better)
I have an instance of say discord.Emoji with name x.
And I am assigning it to y like
y = x
value of x will be changed in the future (after this assignment) but y should not be changed and stay as it was. How can i go about this?
async def clear(ctx, amount=11):
if (not ctx.author.guild_permissions.manage_messages):
embed = discord.Embed(description = 'staff command only', color=0xC8E9E9)
await ctx.send(embed=embed)
return
amount = amount+1
if amount > 101:
embed = discord.Embed(description = 'Can not delete more than 100 messages', color=0xC8E9E9)
await ctx.send(embed=embed)
else:
await ctx.channel.purge(Limit=amount)
embed = discord.Embed(description = 'Cleared Messages', color=0xC8E9E9)
await ctx.send(embed=embed)``` no errors bot dosent respond. .ping works
confused
limit=amount*
L will be small
If I do that multiple times when other tasks are still going, how can I cancel specific tasks?
store that in a var i think
wait you can run a task once only
there can be one instance of task running i think
!d discord.ext.tasks.Loop.cancel
cancel()```
Cancels the internal task, if it is running.
ty works now
yeah but can I start multiple task loops?
damn ok ty
when using nextcord do i unistall discord?
or will that fucks shit up
ok so i unistall discord py and my commands and shit will still work correct?
change the namespace from discord to nextcord
import nextcord
from nextcord.ext import commands
Yes
basic example
oh got it
do i unistall both?
uninstall both discord.py and discord
or just discord.py
So, nextcord now has slash commands
Lol
oh got it
in your terminal pip uninstall <package-name>
Don't use the module named discord
Use discord.py
!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.
every time i unistall next cord my shit goes like that
go to command palette an dselect python: select interpreter
and change it to your highest version (install the version too)
then go to terminal and do pip install sqlalchemy and pip install mongoengine
HUH
ok
thank you
did it
i just uninstalled everything then downloaded latest version again
Suppose I have this code :
@bot.command()
@commands.has_permissions(manage_emojis=True)
async def delete(ctx, emoji: discord.Emoji):
await emoji.delete()
Does emoji here apply to only the emojis that is in the guild that the command was used or does it apply to all the guilds that bot is in?
Because I think I found quite a security vulnerability here :
Suppose someone with malicious intent decides to delete emotes in a legitimate guild then they could set up a new guild with manage_emoji permission for themselves, invite the bot to the new guild and use the the delete command with the emojis from the legitimate guild. Since bot checks for the permission in current guild which evaluates to true would the bot delete the emoji from the legitimate guild assuming it has "manage emojis" permission?
I am, hbu
This is pretty interesting 
!d discord.Emoji
class discord.Emoji```
Represents a custom emoji.
Depending on the way this object was created, some of the attributes can have a value of `None`...
U cant delete emojis from other guilds
anyone know why this is happening
discord.Emoji has an delete method.
trying to make a lottery bot
Enclose within square brackets for comprehension
It's for , not fro
And that too ^
But you will probably get HttpException
!e print(",".join(str(I) for I in [1,2,3]))
@slate swan :white_check_mark: Your eval job has completed with return code 0.
1,2,3
Not important
ah spelling for right might help thanks!
for not fro
so im tryna import schedule but it doesnt work
Did u install it?
i did pip install schedule but its not a thing ig
It's for any emoji the bot can see , you can use py if emoji in ctx.guild.emojis: to check if it's in the same server
im tryna do schedule.every(5).seconds.do(job)
Do you have docs for the library
Did you restart your code editor?
Emoji.delete() probably deletes emoji from current guild, so if you try to delete emoji that is not in that guild it will just raise an exception
Is it another library u installed?
Try to hover over it and see what it says
Or if ur in pycharm use alt+enter
is pycharm better?
This actually works 
Does it delete an emoji from another guild??
download it first
But the bot has to be in that guild ight?
Yes.
you can if the bot has perms and its in the other guild
Else it'll obviously raise an discord.Forbidden exception
Yea I just figured
Ig u have to check if emoji is from current guild manually
Damn, that is an interesting issue. It has an easy solution tho
i tried doing pip isntall libary controller but its not a command
then i closed and re opened still not fixed
It can delete it from other guilds too...
isntall?
install*
Is there a way to use colorful code on pillow module python?
Doing emoji.guild_id == ctx.guild.id fix this issue 
Yea, I didnt know that b4
Wrong ping ig
try py -3 -m pip install module
Yes, sry
No worries
py -3 ? Is that a thing?
Isnt it python3 -m etc.
Yep
I have no clue, stole it from a tag
but python3.10 -m pip install ... works for me
still not working for importing library controller
Yea , python(version) -m pip install should work
pip install schedule
nvm its cuz i spelt it wrong
LMAO
Lol
i tend to do that
What does the schedule library do?
I once spelled βpermissionβ wrong
I think u can run tasks periodically with it
Similar to discord.exc.tasks
Iβ m guessing
π€·πΌββοΈ
!PyPi schedule
βFor humansβ
I once forgot that aliases was a list
what?
nothing.
Lmao, same
lmaoooo
It was alias=ββ for me π
Me too xD
And I always used to forget the ctx parameter
Oh I never forgot that
Ok, once maybe.
I was new to classes and used ClassName.function instead of self.function for calling them
Though they were in the same class
still not working
so weird.
what's lottery?
lottery command
like lottery
I mean
Is it a folder you created , or some Library smthin
Lottery folder is in the same directory as bot?
If yes , use from .lottery.controll....
yes
relative imports in vsc are weird
with on_voice_state_update
if before channel is none, is after channel the first vc they join
how do i make a event thats when someone send a random message the bot add automatically a reaction
and it's a .listen() if you want all your other code to work
because it doesnt work that way either
@slate swan since u r using a DEBUG environmental variable, I am still sure u r using functions and classes from that file in your main code. So, if the debug variable is false, then it would result in an undefined error, no? I don't know whats your approach here so I can't really help u much
yea that was confusing for me so i got rid of it but im sticking with gamble
class Gamble(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.command(brief="Gives a random number between 1 and 100")
async def roll(self, ctx):
n = random.randrange(1, 101)
await ctx.send(n)
@commands.command(brief="Random number between 1 and 6")
async def dice(self, ctx):
n = random.randrange(1, 6)
await ctx.send(n)
@commands.command(brief="Either Heads or Tails")
async def coin(self, ctx):
n = random.randint(0, 1)
await ctx.send("Heads" if n == 1 else "Tails")
def setup(bot):
bot.add_cog(Gamble(bot))
is like this but when i do the command
dont mind the coinflip one
you didn't load the extension
Yea
kayle
hi dekrile
dekrile?
Wait u r kayle?!? Didn't even recognize u. Thought u were a random lol
dekriel* phone keyboard is really small
yes
Ik i am (;
Andy by the way. Can I ask what client modifier you use for this codeblock design?
await message.author(embed=discord.Embed(title=f"you've sent a blacklisted word in {message.guild.name}",description=f"Word : {set(blacklisted_text & set(content))}"))
```  why is this giving me an error
File "c:\Users\rrfda\OneDrive\Desktop\sublime pg version\commands\snipe.py", line 172, in on_message
await message.author(embed=discord.Embed(title="you've sent"))
TypeError: 'Member' object is not callable```
ok
its abc.messagesendable
with on_voice_state_update
if before channel is none, is after channel the first vc they join
Messageable*
Yups
hi
how to make the bot write "25" instead "(25,)"?
gg, tysm
hello! :]
you can do tuplename[0] or "".join([str(i) for i in tuplename])
Also, How do I get emoji limits for gifs emote and static emotes separately? Docs only show one attribute for discord.Guild for getting limits and that being discord.Guild.emoji_limit ?
!d discord.Guild.emoji_limit
property emoji_limit: int```
The maximum number of emoji slots this guild has.
Well emoji limits are static unless boosted
You could work it out with the server boost integer
!d discord.Guild.premium_tier
The premium tier for this guild. Corresponds to βNitro Serverβ in the official UI. The number goes from 0 to 3 inclusive.
what does this means?
Command raised an exception: TypeError: 'NoneType' object is not subscriptable
and the code is:
def check_coin(user):
user = str(user)
cur.execute("SELECT COIN from users_data where NAME = ?", (user,))
conn.commit()
co = cur.fetchone()
coin = co[0]
return coin
None of this code is related to discord.pyβ¦
And format your code
k, this is the full one
@bot.command()
async def profile(ctx):
name = ctx.author.id
coin = database.check_coin(str(name))
# level = database.check_level(str(name))
name = ctx.author.name
p = discord.Embed(title="",description="",color=ctx.author.color)
p.set_author(name=ctx.author.name + "'s profile",
icon_url=ctx.author.avatar_url)
p.set_thumbnail(url=ctx.author.avatar_url)
p.add_field(name="Progress", value="Coin: " + str(coin) + "\n Level: ",
inline=False)
await ctx.channel.send(embed=p)
def check_coin(user):
user = str(user)
cur.execute("SELECT COIN from users_data where NAME = ?", (user,))
conn.commit()
co = cur.fetchone()
coin = co[0]
return coin
Ignoring exception in on_command_error
Traceback (most recent call last):
File "C:\Users\thosiba\Downloads\d-bots\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Users\thosiba\PycharmProjects\main.py\main.py", line 36, in profile
coin = database.check_coin(str(name))
File "C:\Users\thosiba\PycharmProjects\main.py\database.py", line 26, in check_coin
coin = co[0]
TypeError: 'NoneType' object is not subscriptable
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\thosiba\Downloads\d-bots\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "C:\Users\thosiba\PycharmProjects\main.py\main.py", line 21, in on_command_error
raise error
File "C:\Users\thosiba\Downloads\d-bots\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\thosiba\Downloads\d-bots\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\thosiba\Downloads\d-bots\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'NoneType' object is not subscriptable
and it return "25" as "(25,)"
then its empty, and returns None
cursor.fetchone() method returns a single record or None if no more rows are available.
hmm, lemme try once again
k it works, thanjs
?
What does it mean too many request what i did?
do you mean ratelimited?
yea
well maybe someone is sharing the same ip as you and is sending to many requests limiting you
Happened to me
what should i do
ight..
i would recommend using vsc or any other editor or you can just wait
k
tbh idk
unlucky π
Is it thought the terminal
ye
probably after he starts his bot he gets ratelimited
Then itβs discord
yes

and discord blocks it
oof
heyy
is this somehting to do with cache?
hm
for some reason when i use discord.Intents.all(), it works as it should but when i use ```py
intents = discord.Intents(
guilds=True,
members=True,
bans=True,
emojis=True,
messages=True,
reactions=True
)
presences
intents
intents
oh right
dev portal
nah have them enabled but didnt define it
o
o.o
presences = True when?
presences
you will be
@slate swan What i did was forking the repl and using the new one and worked what do you think
I just think that , replit sucks
i think you should use vscπ΄οΈ
xd
no offense 
pycharm π‘
24/7
ew
but ineed to pay?
Noβ¦
you..
nah its free
oh
could you send the link please
πΆ
Nvm use repl.it
once ready , use some host or heroku to keep it online but not replit
if you can spend money on replit why not just get a vps
idk
...
by "some host" I mean any host , not somehost hosting service just to avoid confusions
digital ocean has 5bucks for the lowest plan which is good for a mid level bot
ight
yeah
me who litterally have no money at all
same 
i got 5 bucks in my pocket is that a flex?
of course
but just wanna know if im allowed to fork repls when im banned
broke mfs smh
ikr
ratelimited*
yes
I got no Moni to spend on my projects πββοΈ
always got the drip
am i
but you got moni for other stuff
Is there anyway I can set a default color for all of my bot's embeds?
whoa sarthak_ and okimii here and icy
hi
More like I don't keep money with myself and my parents won't allow me to spend it just for the sake of a discord bot which actually noone gonna use
imagine almost forgetting me π
use a bot var? idk that's the only way i can think of
no no, just not seeing ur message ;-; sorry
;)
how old are you?
11-
oh π
reports
β¦
17
no sarthak
Mhm, sounds good. I was thinking if there is a way to initialize it in my main.py and have all my embeds be with that color.
.
so in mainpy bot.color = 0xffffff in your whatever cog```py
embed.color = self.bot.color
cant even buy a snicker from a store
just guessing how old is he
i already have my own credit card
You pinged the wrong person.
Yeah, does that work? let me try.
not sure i'll test it
it will
autoscroll suk
Oh I mean, I'd have to do embed.color = self.bot.color every time I create an embed.
i have 800βΉ equivalent to 10$ in my pocket rn but sadly I don't have a bank account
xD
yeah ofc else how would the program know what color it should be
that sucks 
Thought I could initialize it by setting a default color somewhere but it seems that the API doesn't provide anything like that.
Ikr , I could be freelancing discord bots if I had one :)
no one answer me in database lemao
but you can create your custom Embed class with self.color to your wish
Your against discord tos 
||you can just ask here if it's discord.py related and I'm in the chats||
you would probably be in debt if you had a credit card

waht
Your 11β¦
Yeah I might eventually do that.
how to check is "something" in the column "name" in "table_name"?
that's a guess how old is sarthak_ :l not my actual age
guess mine
< 7
29 single ||lol||
π
he did notπ
so old π
2 letters
GG
@visual island another way to do it is to just create self.embed = embed(color = embedColor)
then only change the description and title of the embed through the code, this way it will keep the same color in all of them.
no no, < 5

Oh ok
mf you could be my older brotherπ
gni gni gni gni
but with that you cant construct it everytime, what you can do is just self.title = "title" and stuff
im a girl btw
only thing i know about sql is almsot nothing just
SELECT colum,colum2 FROM table;
π
you can be my grandma
girl on discord = fat old guy irl
Yes, true.
what, I've seen at least one SQL tutorial and I know more than you π€
smort

i gaved up ok
inner left right joins were to confusing smhπ€
like, I know the basics of SELECT, WHERE
at least u understand 1 code
i almost not understand anything "E"
yeah thats the hardest part
got demotivated now im trying to make a fork for asyncpraw 
almost forgor to ask, when did u change ur pfp
maybe 3 days ago
ok
lol
SELECT table.col FROM table WHERE INNER JOIN table2 ON table.id = table2.id but its fun
cavedude
whoa sarthak making a novel in #databases
share the repo to me π
uh what
you can say that but i got demotivated lol i will jump back to it when i feel like it
you wanna embarrass meπ
Ill probably do some pointless commit
havent even started its my first time im just trying to push myself
did you not use db on your bot?
ill start with auth in like 8 more hours
whats auth
no .-.
And that's why I don't have a bank account
imagine that im a kawaii girl
ganbatte yo, okimmi-san π
english isnt my main language either i have an excuse 
o
hentai
im in debt toπ
@mods
jk

pain
psst
imagine watching them
imagine 
thats why i live in the street
anyways im innocence, idk anything about those things
we all know thats cap
no cap, really..
u don't do it when you live with a 10yo brother
k
how do i check for a cogs name? ```py
for cog in bot.cogs:
cog = bot.get_cog(cog)
if cog.qualified_name == 'Jishaku':
pass
why change nickname lol
mhmm sureπ΄οΈ
wdym
what does cog.qualified_name returns?
theres locks for a reason smh i only watch those types of anime cause of the story its good trustπΆ
the cogs name
no, i mean is it Jishaku or..
u r kayle right E
kayle += mark
no
btw @slate swan, do you know kylee?
kayle >= mark
for cog in bot.cogs: if cog.qualified_name == βnameβ?
@tender wave
you
Bot.cogs usually returns a string this is what I used https://github.com/sarthak-py/kakashi/blob/main/kakashi/cogs/helpcmd.py#L13-L20
no and im glad i dont
kakashi/cogs/helpcmd.py lines 13 to 20
categories = self.context.bot.cogs
embed = Embed(
color = await EmbedColor.color_for(self.context.guild),
timestamp=datetime.now()
)
for cog in categories:
cog : Cog = self.context.bot.get_cog(cog)
if cog.qualified_name in ['HelpCog','Jishaku' , 'botbase']: continue```
Jishaku
Moderation
Errors
Events
Starboard
Image
Owner
Tags
Information
General
Bot
NSFW
Helpful
Levels
Utilities
shhh
im a normal american π
hmm
perfect timing to advertize ur bot, nice
average one toπ
sure


