#discord-bots
1 messages · Page 877 of 1
but they only exist in the cogs? and i removed them by doing bot.remove_command('rules') bot.remove_command('rule') bot.remove_command('rule_add') bot.remove_command('rule_remove') bot.remove_command('rule_replace') the last few restarts
this is what happens when i run a command in the cog without removing the commands and adding the cog first - Ignoring exception in command rules: Traceback (most recent call last): File "C:\Users\shake\AppData\Local\Programs\Python\Python310\Lib\site-packages\disnake\ext\commands\bot_base.py", line 570, in invoke await ctx.command.invoke(ctx) File "C:\Users\shake\AppData\Local\Programs\Python\Python310\Lib\site-packages\disnake\ext\commands\core.py", line 912, in invoke await self.prepare(ctx) File "C:\Users\shake\AppData\Local\Programs\Python\Python310\Lib\site-packages\disnake\ext\commands\core.py", line 846, in prepare await self._parse_arguments(ctx) File "C:\Users\shake\AppData\Local\Programs\Python\Python310\Lib\site-packages\disnake\ext\commands\core.py", line 752, in _parse_arguments transformed = await self.transform(ctx, param) File "C:\Users\shake\AppData\Local\Programs\Python\Python310\Lib\site-packages\disnake\ext\commands\core.py", line 578, in transform raise MissingRequiredArgument(param) disnake.ext.commands.errors.MissingRequiredArgument: ctx is a required argument that is missing.
slash commands are apart of application commands
specifically the API calls them CHAT_INPUT
add context
alr lemme try
try mentioning self 
@client.command()
async def casinoh(ctx, reason=None, member: discord.Member=None):
member = member or ctx.author
if reason is None:
await ctx.reply("❌ אתה חייב להכניס סיבה!")
await ctx.send("<@&948997997860126740>")
embed = discord.Embed(
color = discord.Color.green(),
description = f"המשתמש {member.mention} צריך עזרה בקזינו!\n`סיבה:` {reason}",
)
embed.set_author(name="Casino Help", icon_url="https://media.discordapp.net/attachments/889822776024768573/949006996714168340/Comp_1_1.gif")
await ctx.send(embed=embed)
No error but why I send the message without a reason it not only send the error message which says you have to put a reason it actually sends both of the messages.
greek?
you have to return the function
async def uwu():
if ...:
return ...
return await ?
you only use return await if are calling a coroutine in the return statement, no?
why the if statement to check if the reason is None just set a default value
they did?
its already defauled to None
yes the method will return a coroutine
that check is not needed, and tbh i would put member arg before reason
guys read again
what do you mean by that?
Okimii meant defaulting it to the thing they were setting it to in the if statement
With your current setup you won't be able to have multi word reasons due to parsing ambiguities
thank you water_gazes
oh ok
I'm gonna dip
y
cya guys
k pce
cause there are no more questions- 🚶♂️
bye bye
robin needs to stop flexing his reaction permissions, not cool 😢
fr
checking for it's type is better than checking for it's value
It's actually faster to check for None than to check for a truthy value
Because that would mean checking over multiple things
idk because is compares the id and == compares the value not is better as its short and None returns False
Also it's just good practice to compare the pointers when dealing with None
that is a good reason
to specify the value or id
tell em andy

also maybe because ```py
x = []
if not x:
print(x) # prints the list
if x is None:
print("it's none") # wont print
print(x or "It's none")
yea
!e print(bool([]))
@manic wing :white_check_mark: Your eval job has completed with return code 0.
False
falsey value
you said it prints the list but it wont
@slate swan :white_check_mark: Your eval job has completed with return code 0.
[]
whelp

well arent they both true?🗿
@slate swan :white_check_mark: Your eval job has completed with return code 0.
001 | its 0
002 | False

0 returns? False interesting
if bool(y)
!e print(bool(0))
forgot true true 
@pliant gulch :white_check_mark: Your eval job has completed with return code 0.
0
0 = false
anything above 1 = true
i forgot 0 is false and true is 1
never came in mind 
@slate swan :white_check_mark: Your eval job has completed with return code 0.
False False False False False False False True
@slate swan :white_check_mark: Your eval job has completed with return code 0.
hi
guess its True get it
Well there is no reason why ... shouldn't be truthy
ellipsis is true?
It's an object, you wouldn't want your classes to randomly become not truthy
ellipsis is ...?
yes? did you not know that 
i called them 3 periods
ok
i know about ellipsis because of typehints
i called them dot dot dots
I know about ellipsis because I google shit
i probably did but ellipsis sounds stupid
things have changed since 1987
🗿
I'm not older than 35
unlike you guys that learnt it, there was no CS/programming type subject in 5th grade
asian schools are depressing 
Ellipsis is basic english bro, it has nothing to do with programming
ok English teacher
English isn't even my mother tounge lol
same
Me neither
we have an excuse
we scared the person away
🗿

Why i get an error but its working if i use py after.activity.type ?
What error?
ActivityType never mind
activity_type = after.activity.type
AttributeError: 'NoneType' object has no attribute 'type'
Probably because the user stopped doing something, e.g stopped playing a game or listening to spotify
Use a typeguard to make sure that doesn't happen
whats a typeguard?
Yes the error comes when that happen but how can i stop that error
If statement i believe
if after.activity is not None:
print(after.activity.type)
i think that's a typescript term but it still applies
Oh i see
smh
One of the things I like about it, after.activity would be typehint to an activity or none so if you try to access .type it would say "hey this could be none, so you can't do that"
Mh the dont stop the error
How can I make a mute cmd for example and for the reason I can type with spaces....
How can i put a custom emoji to the discord bot status? i tryna put the ukraine flag
multiple status
@boreal ravine ?
including support for ukraine + none of ur business
🇺🇦 
wait
ah sorry
well it's still impossible
multiple status? impossible?
yeah, bots can only have bios/activities
@client.command()
async def ch(ctx, reason=None, member: discord.Member=None):
member = member or ctx.author
if reason is None:
return await ctx.reply("❌ אתה חייב להכניס סיבה!")
await ctx.send("<@&948997997860126740>")
embed = discord.Embed(
color = discord.Color.green(),
description = f"המשתמש {member.mention} צריך עזרה בקזינו!\n`סיבה:` {reason}",
)
embed.set_author(name="Casino Help", icon_url="https://media.discordapp.net/attachments/889822776024768573/949006996714168340/Comp_1_1.gif")
await ctx.send(embed=embed)
I have this working but when I type: .ch dshb dshgds d with spaces it doesn't work
i meant activity
oh
ig you can copy paste the id to the playing status
activity == status in normal terms
i tried.. it will just say the emoji name+id
like <
id...
🇺🇦?
wtf
yes that's the name of the flag
you can't use custom emojis in activities
not custom
you said "id"?
\🇺🇦
like the format <lol:10228292>
ye u can't do that
mhm
no sadly u can't... the only way to see it is by phone
when i use "ua" copy paste emoji
ye need it in the status
copy paste this 🇺🇦
yeah
sadly
just google it
i can see it from phone tho
You can use \ for raw text
i tried .. still ua
you mean format? and it returns ua in this situation
i think everyone can choose what to do with they own bot 🙂
guys lets not judge others by their beliefs 
i mean u said it shouldnt be political
ye but i can do whatever i want with it
ty for ur approval 🙄
Does it matter?
no clue
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
Bro you have said this 3 times just let the convo finish takes like one minute
ugh but the rules
No
he's saying facts lol

Too bad
struggling to forgive you

.sqlite3 better
Why is the file not being created by git?
tell me whats better about it then
how do I install this?
what do you want cogs to be
that looks like a folder
nothing
?
just preference
self roles.
ok
even the sqlite browser makes a db file
doesn't really matter
yes, there is practically no difference
yup
you can name it anything as long as it isn't valid language 

People flexing their nitro 😔

It has this when hovered over.
Import "cogs.utils" could not be resolvedPylancereportMissingImports
resolve it
just be nice in a server and someone will eventually gift you nitro 🤷

How?
by creating a folder named cogs
well i dont know what you're trying to do soo
got it free
That’s gonna be hard
say you're a girl
Import cogs.utils.
you cant give me no info and expect me to resolve it for you
Can anyone help me with my command error handler? It doesnt send a message
Yessir
then be toxic 
I gave you everything. It's self explanitory.
just be nice in a server and someone will eventually gift you nitro 🤷
Contradictory statement innit
async def on_command_error(ctx,error):
if isinstance(error,commands.MissingPermissions):
await ctx.send("You cannot do that!")
await ctx.message.delete()``` It doesnt send nor delete the message.
Because you sent it and then instantly deleted it, no?
dekriel stop making a fuss noone is taking pitty on you at all
that might mean that the error is not an instance of MissingPermissions
I was just saying chill 😳
I made it to a role then i didnt give it to me and it still doesnt send
Still doesnt work.
did you use asyncio.sleep?
I'll gift you nitro if you promise to stop enforcing pep8 to everyone like a person that just found it and wants to be cool 
I haven’t enforced pep8 in ages 💀
🤨
Its just weird, Is there a special version of python i need to use?
well
yes
above python v3.6
I tried 3.7, does the same thing.
how do i get the total length of message in a channel?
python 2
Python 0 😩
!d discord.Message.content returns a string
The actual contents of the message.
Use len() on the content
Is that even a thing lmao
bro what
sorry, i mean the total length of messages in a channel

like, all of the messages sent in the channel
What
?
messages don't have lengths
how many messages were sent in a channel
he means the len of msg objects
!d discord.TextChannel.history
async for ... in history(*, limit=100, before=None, after=None, around=None, oldest_first=None)```
Returns an [`AsyncIterator`](https://discordpy.readthedocs.io/en/master/api.html#discord.AsyncIterator "discord.AsyncIterator") that enables receiving the destination’s message history.
You must have [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permissions to use this.
Examples
Usage...
Okimii you’re weird 
Tons of api calls*
then what does he mean

Still doesn't send on the command, Would someone be able to hop in a call with me and see what the issue is?
he means get how many msgs were sent in a channel
Why hop on a call? Also, are you sure it’s a MissingPermissions error?
so like channel_list = list(ctx.channel.history) len(channel_list)
Yes.
Did you wait before deleting the message?
how do i create a bot instance?
Talking is more easier than using your hand to messages
bot = discord.ext.commands.Bot(*args)
Oh, well I guess so
oh did it change?
!d discord.ext.commands.Bot
class discord.ext.commands.Bot(command_prefix, help_command=<default-help-command>, description=None, **options)```
Represents a discord bot.
This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") you can do with this bot.
This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality to manage commands.
im used to discord.commands()
I dont have that role. And i ping myself.
Not that I know of
no
Did you wait before deleting the message?
i don't want to use an async iterator
var = Class
it's an async for loop
i just want to total number of messages
why not
I took the ctx.message.delete() out
because i need to just return the number of messages in a channel
that's impossible to do without making tons of API calls unless you logged messages or something
alr
just use delete_after
Oh, so it didn’t send?
imma figure it out
Not at all.
can i do it without making a class?
what instance are you getting then
Maybe try something like @command_name.error or just add some print statements
you don’t need to make a class?
I did. Still nothing.
It’s already made for you 
@slate swan you’re the expert here 
you need a class instance to use its methods many times so you dont have to make a bot instance each time
Its just making me mad cause i cant figure out the issue
@velvet tinsel i dont know whats happening
import commands
🤦♂️
Danny didn't import the folder in the init file
ay, leave em alone
from discord.ext import commands
ok Joe
yes
what would a purgeban command do?
can the bot check if a change is being made to this?
probably yes
Purge users messages + ban them
oh....
ban lots of members?
is this a reference
i don't know
I think
it could be this
I think it was something called "guild locale" through
!src purgeban
Same as ban, but also cleans all their messages from the last hour.
aha
found it
typically method/property names are pretty straight forward
!d disnake.Guild.unban
await unban(user, *, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Unbans a user from the guild.
The user must meet the [`abc.Snowflake`](https://docs.disnake.dev/en/latest/api.html#disnake.abc.Snowflake "disnake.abc.Snowflake") abc.
You must have [`ban_members`](https://docs.disnake.dev/en/latest/api.html#disnake.Permissions.ban_members "disnake.Permissions.ban_members") permission to do this.
is user in this case a user object or id?
class disnake.Object(id)```
Represents a generic Discord object.
The purpose of this class is to allow you to create ‘miniature’ versions of data classes if you want to pass in just an ID. Most functions that take in a specific data class with an ID can also take in this class as a substitute instead. Note that even though this is the case, not all objects (if any) actually inherit from this class.
There are also some cases where some websocket events are received in [strange order](https://github.com/Rapptz/discord.py/issues/21) and when such events happened you would receive this class rather than the actual data class. These cases are extremely rare.
x == y Checks if two objects are equal.
x != y Checks if two objects are not equal.
hash(x) Returns the object’s hash.
got it
ok
as it says
The user must meet the abc.Snowflake abc.
member 
whats snowflake
a frozen form of rain that precipitates from the atmosphere

haha, very funny, but actually, what's abc.Snowflake
!d disnake.abc.Snowflake
class disnake.abc.Snowflake```
An ABC that details the common operations on a Discord model.
Almost all [Discord models](https://docs.disnake.dev/en/latest/api.html#discord-api-models) meet this abstract base class.
If you want to create a snowflake on your own, consider using [`Object`](https://docs.disnake.dev/en/latest/api.html#disnake.Object "disnake.Object").
thanks
lmfao, accurate description
its just a unique object that has one attribute; id
each snowflake is different, foreshadowing irl snowflakes
ez 9 at gsce english
discord ids
thankscaeden
whats wrong here?
read the error
i did but i dont get it
you are calling a set object
where?
_ = set()
_() #error
i have no idea, look for it in your code lol
uwu()
you have called the uwu 👀
no
ok kayle
im not calling it anywhere, i dont even have sets
show code
📸 kayle I screenshotted that
wait don't
async def trade(ctx, price: float, buy: bool = True):
calc = Calculator(price=price, buy=buy)
tps = calc.get_tps()
sls = calc.get_sls()
side = 'Long' if buy else 'Short'
tp_list = list()
sl_list = list()
for tp in tps:
percentage = tp['percentage']
tp_ = tp['tp']
difference = tp['difference']
item = f'+{percentage:.2f}%'.ljust(7) + f' | {tp_:,.2f} | {difference}'
tp_list.append(item)
for sl in sls:
percentage = sl['percentage']
sl_ = sl['sl']
difference = sl['difference']
item = f'-{percentage:.2f}%'.ljust(7) + f' | {sl_:,.2f} | {difference}'
sl_list.append(item)
msg = Embed(title='Trade',
description='---Info---\n\n'
f'Price: {price}\n'
f'Side: {side}\n'
'\n\n'
'---TP Table---\n\n'
f'{tp_list}\n\n'
'---SL Table---\n\n'
f'')```
show full error
full error pls
File "C:\Users\vilko\OneDrive\Desktop\Bitcoin\main.py", line 55, in <module>
async def trade(ctx, price: float, buy: bool = True):
TypeError: 'set' object is not callable
damn bro 😠
its command
not commands
oh thanks
.
...
bot.commands returns a set not a wrapper
im done
you guys are too slow
same
good night
I'm gonna do chemistry homework
GN
so i moved a few commands to a cog, when i ran a ban command it banned the user twice?
are you running multiple instances?
nope
do i have to remove the command and add the cog for it to work?
because originally the command wasn't in a cog
w h a t
I moved the command to a cog?
and?
formatted the style for a cog
changed @bot.command to @commands.command defined self first in the params and such
and bot.add_cog(ban_cog(bot))
yes i name my cogs generic names
typically cogs have multiple commands...so it would be like Moderation
but anyway, continue
thats in the setup func correct?
bot.run loops everything inside of it ... nothing outside of it gets called
just put it after you define bot
bot = commands.whatever_the_fuck_Bot_is()
# commands and cogs here
bot.add_cog(ban_cog(bot))
bot.run(TOKEN)```
so any clue as to what might be happening?
can I see any code?
yup
class ban_cog(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.command(aliases=('ban_user', 'ban_member'))
@commands.has_permissions(ban_members=True)
async def ban(self, ctx, member: discord.Member, *, reason='None'):
await member.ban(reason=reason)
await ctx.send(f'''**{ctx.message.author.mention}** banned **{member.mention}**:
**{reason}**.''')
try:
await member.send(f'''{member.mention} you were banned from **{ctx.guild}** by **{ctx.author}**:
**{reason}**''')
except (discord.HTTPException, discord.errors.HTTPException, discord.ext.commands.errors.CommandInvokeError,
commands.CommandInvokeError, commands.CommandError, AttributeError, discord.Forbidden):
print(f'Cannot direct message {str(member)}.')```
full code
like, ALL of it?
how do i send multiple embeds in 1 msg
sure
!d discord.TextChannel.send || embeds kwarg
await send(content=None, *, tts=None, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, view=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message to the destination with the content given.
The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.
To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.
To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: send() got an unexpected keyword argument 'embeds'
w h a t
da fuq
discord version + code?
i just installed discord.py today
info_emb = Embed(title='Info',
description=f'Price: {price:,}')
tp_emb = Embed(title='TP Table',
description=f'{tp_list}')
sl_emb = Embed(title='SL Table',
description=f'{sl_list}')
await ctx.send(embeds=[info_emb, tp_emb, sl_emb])```
did you do from discord import Embed?
yes
show the full command
@bot.command()
async def trade(ctx, price, buy: bool = True):
price = float(price.replace(',', ''))
calc = Calculator(price=price, buy=buy)
tps = calc.get_tps()
sls = calc.get_sls()
side = 'Long' if buy else 'Short'
tp_list = list()
sl_list = list()
for tp in tps:
percentage = tp['percentage']
tp_ = tp['tp']
difference = tp['difference']
item = f'+{percentage:.2f}%'.ljust(7) + f' | {tp_:,.2f} | {difference}'
tp_list.append(item)
for sl in sls:
percentage = sl['percentage']
sl_ = sl['sl']
difference = sl['difference']
item = f'-{percentage:.2f}%'.ljust(7) + f' | {sl_:,.2f} | {difference}'
sl_list.append(item)
tp_list = '\n'.join(tp_list)
sl_list = '\n'.join(sl_list)
info_emb = Embed(title='Info',
description=f'Price: {price:,}')
tp_emb = Embed(title='TP Table',
description=f'{tp_list}')
sl_emb = Embed(title='SL Table',
description=f'{sl_list}')
await ctx.send(embeds=[info_emb, tp_emb, sl_emb])```
we dont need to see the full command
why would one do that
what discord.py version are you on
idk, i asked because they didn't do discord.Embed
i downloaded it today, so i guess the latest
i daresay, it's as bad as doing from discord import *
yes...but it's strange
no its not, in the slightest
oh god no
you 'daresay' out your ass
?
theres nothing wrong with doing from discord import Embed
whelp you're fucked ¯_(ツ)_/¯
hey run this import os os.system('py -m pip install discord --upgrade')
I know, but if you're using other stuff (like discord.Color) it's just better to not do from discord import Embed and instead do import discord
can anyone help me?
ran it and still the same thing
try refreshing ide
what python version u using
idk
oh dear Caedens typing a lot of stuff
3.9.7
wtf
this is cursed
switch to disnake.
py -m pip install disnake
it might fix it
!star-imports || or you just do from discord import Color, Embed ... you guys talk about pep-8 to act fancy but all you're doing is talking out your ass. there is nothing wrong with doing from x import y
a) y may be used many times so would be more code efficient to import it at the start
b) its all about personal preference so there technically is no right or wrong answer except in the terms of efficiency, speed and practice
c) sometimes you might want to import a lot of things from discord which there is no problem with doing so
you guys literally do from discord.ext import commands but then say its 'just as bad as using a wildcard import' - you guys dont even know the problems of a wildcard import so im putting this here so you guys can actually get some knowledge about what exactly is wrong with wildcard imports and how that does not compare in the slightest with from x import y
Star / Wildcard imports
Wildcard imports are import statements in the form from <module_name> import *. What imports like these do is that they import everything [1] from the module into the current module's namespace [2]. This allows you to use names defined in the imported module without prefixing the module's name.
Example:
>>> from math import *
>>> sin(pi / 2)
1.0
This is discouraged, for various reasons:
Example:
>>> from custom_sin import sin
>>> from math import *
>>> sin(pi / 2) # uses sin from math rather than your custom sin
• Potential namespace collision. Names defined from a previous import might get shadowed by a wildcard import.
• Causes ambiguity. From the example, it is unclear which sin function is actually being used. From the Zen of Python [3]: Explicit is better than implicit.
• Makes import order significant, which they shouldn't. Certain IDE's sort import functionality may end up breaking code due to namespace collision.
How should you import?
• Import the module under the module's namespace (Only import the name of the module, and names defined in the module can be used by prefixing the module's name)
>>> import math
>>> math.sin(math.pi / 2)
• Explicitly import certain names from the module
>>> from math import sin, pi
>>> sin(pi / 2)
Conclusion: Namespaces are one honking great idea -- let's do more of those! [3]
[1] If the module defines the variable __all__, the names defined in __all__ will get imported by the wildcard import, otherwise all the names in the module get imported (except for names with a leading underscore)
[2] Namespaces and scopes
[3] Zen of Python
like a different lib?
yes
can you show the full traceback? theres probably some whackass shit interfering
i dont want to
but even in docs there's no embeds, only embed
if they dont want to switch, dont force them to.
embeds=None
maybe embed is a kwarg?
as i said, it varies on your discord.py version
do you even know what a kwarg is?
okay caeden
keyworded arguments, like (name='hrlo77', online=True)
huh, why did i suggest that?
okay, so why did you say 'maybe embed is a kwarg'? literally related to absolutely nothin
i got nothing man, I'm dead
@quaint epoch what time is it there?
5 pm
oh okay nevermind
don't use disnake
okay
use dyesnake, 20% better because it uses green dye
already migrated
!pip dyesnake

it's a joke
nevermind
2 bot instances
⭕o do you want to know why that is?
wrong
why say wrong and answer the question
it is because you have await bot.process_commands(…) in an on_message but cogs already handle that for you because they are listeners not events
most likely
i think he knows the difference between events and commands
what?
your logic is out the window

gOd aT PrOgRAmInG bTw

🗿
it always happens
@slate swan @manic wing you guys should coc tbh
clash of code
!ot
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
not whatever you're thinking of
🗿
also I think okimii plays clash of clans
as if that would be a fair competition
no
ok
why wouldn't it be though
why

oh yeah lol
i play clash royale
i think okimii can answer that one for you
@slate swan answer
dumb game
cause im better

as if
Can we keep it on topic?
okimii even kayle is better than you
it's true though

poor you 😔
Moderator ping time 🗿

nooo-- I never did anything wrong
talk in akeno (aka tweeter) server
fact
Yo quit arguing
we arent
we aren't
famous last words
yes
indeed one of us will get banned
.topic
i am a python skid
i use replit and I copy lucas's code 
lucas is trash
probably a paginator with the help of @fast vortex 
fcc is better
guys, i fixed that problem with embeds. i had to download the experimental 2.00 version of d.py
always the same question
suggest a topic
no

[link text here](url here)
Ever heard of f-strings?
no
!f-strings
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.
should I know now
It's pretty simple
hey how can i create an event that can be triggered on only one specific server?
Display information and a GitHub link to the source code of a command, tag, or cog.
It was simple before I knew to do it
Which event?
f"Go to GitHub"
on_member_update
You can get the guild object with:
!d discord.Member.guild
The guild that the member belongs to.
The guild’s ID.
Then compare the id's
this was right though, damnit pep8
@purge.command()
@commands.has_permissions(manage_messages = True)
@commands.bot_has_permissions(manage_messages = True)
@commands.cooldown(rate=1, per=20, type=commands.BucketType.member)
async def image(self, ctx):
def is_attachment(m):
return m.attachments
await ctx.message.delete()
em = discord.Embed(title=' Purge Successful!', description=f'Successfully purged! (Can take a few seconds)', color=discord.Color.from_rgb(black1, black2, black3))
await ctx.channel.send(embed=em, delete_after=15)
await ctx.channel.purge(limit=200, check=is_attachment)
``` why is this def not working?
won't delete the attachments tbh
what do you need help within that?
Code/error?
what's this checking?
@client.command(aliases=['si'])
async def serverinfo(ctx):
name = str(ctx.guild.name)
description = str(ctx.guild.description)
guild22_owner = str(ctx.guild.owner)
own4er = discord.Guild.owner
id = str(ctx.guild.id)
region = str(ctx.guild.region)
mc = str(ctx.guild.member_count)
text = len(ctx.guild.text_channels)
voice = len(ctx.guild.voice_channels)
cat = len(ctx.guild.categories)
channels = text + voice
rolet = len(ctx.guild.roles)
guild_owner = client.get_user(int(ctx.guild.owner))
bots = [bot.mention for bot in ctx.guild.members if bot.bot]
embed = discord.Embed(title=f"{name}",description=f'\n**owner**\n{guild_owner}\n\n**created**\n\n\n**members**\n``{mc}``', color=0xFFFFFF)
embed.add_field(name="server boost", value=f" ``{str(ctx.guild.premium_subscription_count)}``", inline=True)
embed.add_field(name="id", value=f"``{id}``", inline=True)
embed.set_footer(text=f"{ctx.author}")
embed.timestamp = datetime.datetime.utcnow()
await ctx.message.reply(embed=embed,mention_author=False)
me?
No
😳
says none for owner
lmfao dont worry im gonna delete some im js seeing what i wanna add
ctx.message.reply ??
it works yes
can't he just use ctx.reply ?
he can
bru
ty but any help
!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.
i have them all?
you have members?
yes
even in the dev portal
yes
Is the owner's account terminated?
It would throw an error if it wasn't
Do you have guild intents?

Just spit balling
ya i do
^^
str() works fine
are you sure you wanted to name the variable own4er
ye but is not needed
ye
oh lol
like ctx.guild.owner gets name and discrim
ik
im using it and it works perfectly fine
it returns a member obj
That returns a member object. Using str()on it returns the name and discrim
ye but in his code
guild_owner = client.get_user(int(ctx.guild.owner))
WHAT THE FUCK
own4er = discord.Guild.owner

I had to join
Why is he getting the owner anyway
i just saw that there are like 3 defines for it 😭
@slate swan
Why are you getting the owner?
no don't do that .. look
discord/member.py lines 300 to 301
def __str__(self) -> str:
return str(self._user)```
i deleted
It shows it in the docs...
!d discord.Member
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.
tysm.
👍
just trying to show src bro
🗿
1 tip: don't variable everything
make everything a one liner
i do that for before / after shit
still getting NONE
huh
it keeps saying none
send code
one liner bot?!?!??
oki
send it again @slate swan
show your bot constructor if it doesnt show up the owner isnt cached

😂
@client.command(aliases=['si'])
async def serverinfo(ctx):
name = str(ctx.guild.name)
description = str(ctx.guild.description)
guild_owner = ctx.guild.owner
id = str(ctx.guild.id)
region = str(ctx.guild.region)
mc = str(ctx.guild.member_count)
embed = discord.Embed(title=f"{name}",description=f'\n**owner**\n{guild_owner}\n\n**created**\n\n\n**members**\n``{mc}``', color=0xFFFFFF)
embed.add_field(name="server boost", value=f" ``{str(ctx.guild.premium_subscription_count)}``", inline=True)
embed.add_field(name="id", value=f"``{id}``", inline=True)
embed.set_footer(text=f"{ctx.author}")
embed.timestamp = datetime.datetime.utcnow()
await ctx.message.reply(embed=embed,mention_author=False)
I still don't understand these anime emojis
wtf
dont bind a var with a built in
ok
it shouldn't get it None
pretty sure that shouldn't be None
can u invite me to ur server rq? @slate swan
hehe ignored

stop zerotwo

Why are you using str() on everything?
im not even sure why he makes the guild name a str if it already returns a str
!d discord.Guild.description
The guild’s description.
The guild name.
water_gazes bro
pretty sure he doesn't have the intents enabled
dpy has an embed url kwarg
Python bot literally makes fun of it
by using the normal python urls
What?
!d discord.Embed.url
The URL of the embed. This can be set during initialisation.
You can’t do that with titles tho
it's for the titles
dunno, I just learned it
Obviously. I was telling water that
Yes you can
no
You literally can’t but ok
what can't you do with titles
discord doesnt format hyperlinks on a title
Hyperlink them without the Embed.url
HUH
without Embed.url
Look up documentation for Python symbols.
Channel.permissions_for(Member | Role)
You asking for that?
Oh
Just look at discord.Permissions
!d discord.Permissions
class discord.Permissions(permissions=0, **kwargs)```
Wraps up the Discord permission value.
The properties provided are two way. You can set and retrieve individual bits using the properties as if they were regular bools. This allows you to edit permissions.
Changed in version 1.3: You can now use keyword arguments to initialize [`Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions") similar to [`update()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.update "discord.Permissions.update").
I'm still looking at it and I can't find the embed
can i keep track of how many times a command has been run by the same user?
in a file or something?
database
with disnake
still database
hmm ok, will look into it, thanks
👍
I think the Python bot bamboozled us
I think it gave use the wrong command
!d discord.Guild.create_text_channel
await create_text_channel(name, *, reason=None, category=None, position=..., topic=..., slowmode_delay=..., nsfw=..., overwrites=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Creates a [`TextChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.TextChannel "discord.TextChannel") for the guild.
Note that you need the [`manage_channels`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to create the channel.
The `overwrites` parameter can be used to create a ‘secret’ channel upon creation. This parameter expects a [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") of overwrites with the target (either a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") or a [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")) as the key and a [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/master/api.html#discord.PermissionOverwrite "discord.PermissionOverwrite") as the value.
Note
Creating a channel of a specified position will not update the position of other channels to follow suit. A follow-up call to [`edit()`](https://discordpy.readthedocs.io/en/master/api.html#discord.TextChannel.edit "discord.TextChannel.edit") will be required to update the position of the channel in the channel list...
bot/exts/info/doc/_cog.py lines 307 to 311
embed = discord.Embed(
title=discord.utils.escape_markdown(symbol_name),
url=f"{doc_item.url}#{doc_item.symbol_id}",
description=await self.get_symbol_markdown(doc_item)
)```
!d discord.utils.escape_markdown
discord.utils.escape_markdown(text, *, as_needed=False, ignore_links=True)```
A helper function that escapes Discord’s markdown.
await create_role(*, name=..., permissions=..., color=..., colour=..., hoist=..., mentionable=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Creates a [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role") for the guild.
All fields are optional.
You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to do this.
Changed in version 1.6: Can now pass `int` to `colour` keyword-only parameter.
how can i make it so that when someone presses a button it creates a dm with them?
await send(content=None, *, tts=None, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, view=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message to the destination with the content given.
The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.
To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.
To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
no because after that i want it to ask a question and they are supposed to respond
what stops you from sending him a message again
and using bot.wait_for
but if you'd like
almost
!d discord.Member.create_dm
await create_dm()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Creates a [`DMChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.DMChannel "discord.DMChannel") with this user.
This should be rarely called, as this is done transparently for most people.
how do i use bot in buttons
interaction is as ctx
do i need to pass it in the init method
Code is attached but ow would I fix this json error?
like self.bot = bot?
!json
When using JSON, you might run into the following error:
JSONDecodeError: Expecting value: line 1 column 1 (char 0)
This error could have appeared because you just created the JSON file and there is nothing in it at the moment.
Whilst having empty data is no problem, the file itself may never be completely empty.
You most likely wanted to structure your JSON as a dictionary. To do this, edit your empty JSON file so that it instead contains {}.
Different data types are also supported. If you wish to read more on these, please refer to this article.
Make sure the json is not empty
Also when comparing ids you must make sure they are integers, as in JSON you have to store them as strings iirc
It's not.
Wait....
When I made the Reaction roles I forgot to add the json file. Maybe that has to do something with it.
@pliant gulch What would I put in the JSON file when empty?
{}
My plan didn't work
I don't know how to use a db file to store it.
Learn how to
#databases has some resources in the pins
do you know how to make a on_member_join and gives people a role?
Probably
Yes or no, because this ain't working.
Perhaps
Not yet.
give us a traceback and full error.
how you're doing it is so wrong
wait
i dont think that permission exists?
unless Mute Members is a custom permission you made.
Hm
well try changing it to "manage_members"
a:
In order to give a role, it's 'discord.utils.get(member.guild.roles, id="roleid")
hm strange.
wait
OHH
maybe try manage_messages?
since it's for muting, right?
ah
well im not sure then honestly.
@peak loom
Yeah I fixed it.
File "C:\Users\nikit\PycharmProjects\discord.py\discord\ext\commands\bot.py", line 994, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\nikit\PycharmProjects\discord.py\discord\ext\commands\core.py", line 894, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\nikit\PycharmProjects\discord.py\discord\ext\commands\core.py", line 176, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: send() got an unexpected keyword argument 'view'``` my button commands were working fine but now it is saying this for some reason
What dpy version are you using?
Depends. If the member the command is being run on is the owner or has higher role than the bot, then it will simply error since it can't really do much.
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.
can someone help #help-cherries
Can anyone help me out
how do i get a list of member's name in discord server ?
i want to make my bot's status a task loop where every 30 seconds it says
Watching insert name here
!d discord.Guild.members
property members: List[discord.member.Member]```
A list of members that belong to this guild.
property name```
Equivalent to [`User.name`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.name "discord.User.name")
Do u have any components lib like discord_components or smth?
Yeah why?
pip uninstall <lib>
Cool!
don't
Why tho
it'll rate limit his bot
I mean, the presence is changed via the websocket, not HTTP
should change it to a minute instead
yeah the gateway handles it i was told by andy
since its not like a command to the gateway its 2/1 iirc
probably wrong lol
And the ratelimit is like 120/60s for the gateway
https://discord.com/developers/docs/topics/gateway#update-presence
In case you think am wrong
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
1/30s probably won't break the gateway limit
Although it isn't recommend by discord staff either way a it uses bandwith still
1/30?
The gateway limit is 120/60s bruv
Ah wait nvm, I get what u mean
Ywa
from discord_slash import SlashCommand, SlashContext
from discord_slash.utils.manage_commands import create_option
Are this imports are right?
My cog command wont even work, why?
?
or use slash_util
Class names should be written in PascalCase
yeah you right but when I use it

token = 'token_here'
client = discord.Client()
client = commands.Bot(command_prefix=";", intents=discord.Intents.all())
slash = SlashCommand(client, sync_commands=True)
whats that? I thought this would work tbh
Slash = SlashCommand
Turns red
it should be ‘’bot.add_cog(basic(bot))
it does just look at his name
just ignore him
since you defined bot in the async def, it requires that as the add_cog method.
if you have nothing to actually help with, dont respond.
This is helpful.
ohhhhhhhhhhhhhhhhhhhhhhh
he did with pep8
Class naming convention
that didnt work
help on this
wait, it’s self.bot. not self.client.
show screenshot
in the init.
client can work but only if you define in the params of init
im using client for decorators and stuff, so I thought to use client
bot.add_cog not client.add_cog
commands.Cog
i already told them that.
well its not working
Oh sorry didn’t see
@frozen patio do this as well
capitalize the first letter of cog when you did you class
import slash_util
nope
it ain't the token
didnt work either
well it is
why are you making two client variables? and did you import SlashCommand?
then i dont know, because thats all the issues with tje cog.
this is a problem with how you’re prob loading the cog
i showed how im loading it in both screenshots
how should I put the variables? and what do you mean by SlashCommand
yes
idk ngl
from slash_util import SlashCommand
like that?
then what should I do?
OH WAIT
i think i fixed it
the file wasnt in a folder
alr how would I go through the most recent msgs of a channel using the channel name im using nextcord
If you have the name you can use utils.get/utils.find to get the TextChannel object ```py
channel = discord.utils.find(lambda channel: channel.name == 'lobby', guild.text_channels)
!d discord.TextChannel.history you can then use this method to get the most recent messages in a channel
async for ... in history(*, limit=100, before=None, after=None, around=None, oldest_first=None)```
Returns an [`AsyncIterator`](https://discordpy.readthedocs.io/en/master/api.html#discord.AsyncIterator "discord.AsyncIterator") that enables receiving the destination’s message history.
You must have [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permissions to use this.
Examples
Usage...
I mean have you imported SlashCommand from somewhere?














