#discord-bots
1 messages · Page 837 of 1
That's odd, add_signal_handler should work fine for linux
I was expecting windows or something
Since you sublcasses the client already, you could just overwrite the run method bound to the class, and just call self.loop.stop() after calling the super classes run method
That would probably fix the error, or in this case handle closing the client correctly
Ok I will try
Thanks for your help anyways
Where do I place the command self.loop.stop() ?
You would overwrite the run method, call super().run(...) ... being whatever args you were gonna give to bot.run, You'd wrap super().run(...) in a try-except with RuntimeError then call self.loop.stop() if caught
You may then call self.loop.close() afterwards, which discord.py was originally attempting to do
I have this error now :
NameError: name 'self' is not defined```
You have to create the method bound to the subclassed client class
Pass self to the arguments as the first arg
self should be the first parameter of instance methods
class methods take cls and static methods don’t need any params
okay
If not, can you fix the code? I admit I'm a little confused especially since I don't speak English fluently so it's hard to understand what you're saying.
we won’t spoon feed, but we will help you
okay
Failed to load the developer.py cog. Exception: Extension 'cogs.developer' raised an error: AttributeError: module 'utils' has no attribute 'CustomContext'
from contextlib import redirect_stdout
from typing import List, Optional
import discord, json, utils, traceback, textwrap, io
from discord.ext import commands
from discord import Embed
my imports and stuff
had nothing to do with imports
idk i have confused my self
well
it says your utils module
So I assume you are trying to use a name from there that doesn’t exist
as well
'cogs.misc' raised an error: AttributeError: module 'discord' has no attribute 'ui'
i am learning cogs
Are you using dpy 1.7.x ? Or
!pip discord-ui
forks like disnake don’t require you to install extra shit for things like interaction. I would migrate over as it isn’t a big code change
whats a short way 2 search for a command
wdym
like u can search for a command name'
in discord?
in vsc
CTRL+F and search for the function?
thanks
damn
In Pycharm there's something called structure showing you all the classes and functions separately
pycharm kek
yea these are just all my errors i got 2 fix
[-] Failed to load the developer.py cog. Exception: Extension 'cogs.developer' raised an error: AttributeError: module 'utils' has no attribute 'CustomContext'
[-] Failed to load the misc.py cog. Exception: Extension 'cogs.misc' raised an error: AttributeError: module 'discord' has no attribute 'ui'
[-] Failed to load the moderation.py cog. Exception: Extension 'cogs.moderation' raised an error: AttributeError: module 'utils' has no attribute 'CustomContext'
[-] Failed to load the reminder.py cog. Exception: Extension 'cogs.reminder' raised an error: AttributeError: module 'utils' has no attribute 'CustomBot'
@slim ibex can u add me
- make a
CustomContextclass? - use discord.py 2.0 to access the
uifolder/features - 1
- make a
CustomBotclass?
I smell copied code 👀
do you have any problem with pycharm
How to avoid InteractionResponded error, but still be available to edit the interaction
use interaction.defer then interaction.followup
perhaps
I do 👀
Traceback (most recent call last):
File "/pufferpanel/.local/lib/python3.10/site-packages/disnake/client.py", line 693, in connect
self.ws = await asyncio.wait_for(coro, timeout=60.0)
File "/usr/local/lib/python3.10/asyncio/tasks.py", line 445, in wait_for
return fut.result()
File "/pufferpanel/.local/lib/python3.10/site-packages/disnake/gateway.py", line 428, in from_client
gateway = gateway or await client.http.get_gateway()
File "/pufferpanel/.local/lib/python3.10/site-packages/disnake/http.py", line 2391, in get_gateway
data = await self.request(Route("GET", "/gateway"))
File "/pufferpanel/.local/lib/python3.10/site-packages/disnake/http.py", line 343, in request
async with self.__session.request(method, url, **kwargs) as response:
File "/pufferpanel/.local/lib/python3.10/site-packages/aiohttp/client.py", line 1138, in __aenter__
self._resp = await self._coro
File "/pufferpanel/.local/lib/python3.10/site-packages/aiohttp/client.py", line 559, in _request
await resp.start(conn)
File "/pufferpanel/.local/lib/python3.10/site-packages/aiohttp/client_reqrep.py", line 898, in start
message, payload = await protocol.read() # type: ignore[union-attr]
File "/pufferpanel/.local/lib/python3.10/site-packages/aiohttp/streams.py", line 616, in read
await self._waiter
aiohttp.client_exceptions.ClientOSError: [Errno 104] Connection reset by peer
@pliant gulch do u know why this error is there?
How to get started with this bot in python ,any online material anyone could suggest
In order to work with the library and the Discord API in general, we must first create a Discord Bot account.
Creating a Bot account is a pretty straightforward process.
ah so interaction.followup.edit_message?
!unban
Prematurely end the active ban infraction for the user.
no like where it says that lucases unban command is bad
so you prefer a text editor with syntax highlight over a full fledged IDE designed for Python development ?
We don't do that here
Yes 
oh i though there was
i can just steal the one from here
Haha
The server has kicked you out seems like
I prefer a bloat-free IDE that I get to pick and choose what I use
Randomly?
Also I don't want to be forced to use a venv

¯_(ツ)_/¯
Facts. I don't use venv's lmao
Imagine me smh over a ModuleNotFoundError lol
Ah well... Weird
can a command be triggered by a slash or it's prefix at the same time? (disnake)
Venvs are good though, I use them all the time I just don’t want to be forced to use pycharms
I don't use those ngl
That was one of my first errors
since pycharm automatically starts a project in a venv & I was installing globally
no let's say i have a command called "ping" & the bot's prefix is !
can ping be triggered by using a slash command (/ping) and using the normal prefix (!ping) ?
Sure
Haha I know that feeling
you just need an alias for one of the ping commands, since else the functions will be shadowing
Should I use interaction defer before or after respondid the message
pov you want to import modules you don't have installed

Lmaoo
@maiden fable
legend
also if you really have a problem with this you can make that the venv inherits the modules from your other projects but well 
before
ur right i used my mates code for template
Uhh I will stick to VSC, thanks
i am trying 2 learn cogs
U didn't copy it correctly
i can see
Pycharm, the IDE that does 20 other things you don’t need
pass the requirements.txt I'd say
await send_message(content=None, *, embed=..., embeds=..., view=..., tts=False, ephemeral=False)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Responds to this interaction by sending a message.
But i want to edit the message
Which message lol
Firstly it's inside a dropdown menu
then after selecting something it will add another view with buttonis
Then remove the defer and just do interaction.response.send_message and then use interaction.response.edit_original_message
I think that was the thing I was searching for
whats best way 2 learn cogs
!d discord.ext.commands.Cog
class discord.ext.commands.Cog(*args, **kwargs)```
The base class that all cogs must inherit from.
A cog is a collection of commands, listeners, and optional state to help group commands together. More information on them can be found on the [Cogs](https://discordpy.readthedocs.io/en/master/ext/commands/cogs.html#ext-commands-cogs) page.
When inheriting from this class, the options shown in [`CogMeta`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CogMeta "discord.ext.commands.CogMeta") are equally valid here.
And If I want to respond with nothing (to avoid the Interaction Failed) then I just respond with defer right?
or is there another way
uh, maybe you should stick first to learn classes in general
How are there multiple views on one message?
yo anyone know how I would check an account age?
like compared it e.g. if account age < 3 months then:
ok imma make a new bot so in a few hours i might need help
It is just 1 view
U can add multiple components in the same view
!d disnake.Member.created_at
property created_at```
Equivalent to [`User.created_at`](https://docs.disnake.dev/en/latest/api.html#disnake.User.created_at "disnake.User.created_at")
i got it
anyone know how to like get the account age from the creation date?
it seems really complex but if anyone got a good idea lmk
Wait what
account age from creation date?
Ah u mean the time how old the account is?
Well, there was a function like that in the datetime lib
https://www.geeksforgeeks.org/comparing-dates-python/
this may help ig
A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.
how to do cooldown messages?
@client.command()
async def test(ctx):
await ctx.send('click here for roles')
await message.add_reaction(':white_check_mark:')
why is the reaction not on the message
where did you initialize message?
what does that mean
message = value
uh
message = await ctx.send('click here for roles')
you need to define variable as that ctx.send and it will be a message object that u then can use with .add_reaction() on
i see
await message.add_reaction(':white_check_mark:') message does not have anything
did you change the code?
i just did lemme see
uh still no reaction i put in message =
@client.command()
async def test(ctx):
message = await ctx.send('click here for roles')
await message.add_reaction(':white_check_mark:')
which is?
\✅
@client.command()
async def test(ctx):
message = await ctx.send('click here for roles')
await message.add_reaction('✅')
@naive spokehint ow to get unicodes of emijis in discord type :emojiname: but put \ infront of the emoji and post it
k
or i can just copy the emoji
if you copy ✅ it will not be unicode it will copy : white_check_mark :
but if u put \ infront of emoji it will post a unicode one
ah yea
for messages as posted by a user? then you will need to track them and put em with time and if like X messages in Y time: put timeout / ignore messages for a cooldown, this would be best done in a database
ok
but if you want cooldown for commands there are @decorations @command.cooldown()
thx
Need a idea
ok how do i make the bot reconize a reaction and the user who did it and send a message
use User.created_at and convert it to a timestamp() "unix timestamp" and post in discord "<t:"+str(THE_TIME_STAMP)+":R>"this will automaticly display like 1 year 2 month 3 days etc, or if just 2 days ago
I have a !prvc create command which creates a channel and add author id to a list i want to check if the channel is deleted the user id is removed suggest something
Datamanagment smh
@commands.Cog.listener()
async def on_raw_reaction_add(self, payload):
print(payload)
if payload.message_id == 12346578969:
``` just a short example
or you can use wait_for()
um
!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...
how do i convert it?
whats a cog
member.created_at.timestamp?
logs = some of database
for items in logs
If payload.guild.id == logs
await ctx.send(guild somehow)
payload.guild.send()
.channel*
cog is a file that contains a class for commands and tasks or listeners
https://discordpy.readthedocs.io/en/stable/ext/commands/api.html?highlight=wait_for#cogs
Nvmd
Cogs are for seprating commands like different file for moderation.py main.py utility.py
If im not wrong
wich makes it easier to edit and manage ur bot, and also disable/activiate diffrent commands
<built-in method timestamp of datetime.datetime object at 0x00000265EC2985A0>:R is what I get
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\phoen\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\client.py", line 515, in _run_event
await coro(*args, **kwargs)
File "c:\Users\phoen\OneDrive\Desktop\nox-bot\main.py", line 123, in on_command_error
raise(error)
File "C:\Users\phoen\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\bot_base.py", line 561, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\phoen\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\core.py", line 930, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\phoen\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\core.py", line 185, in wrapped
raise CommandInvokeError(exc) from exc
disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: Embed.__init__() got an unexpected keyword argument 'name'
Whyyyyyyyy
Cogs are a very important part of discord.py which allow you to organise your commands into groups - not to be confused with actual command groups, which will be explained later in the tutorial.
Code
@bot.command(name='snipe')
async def snipe(ctx):
channel = ctx.channel
try: #This piece of code is run if the bot finds anything in the dictionary
channel_name = channel.name
em = disnake.Embed(name=f"Last deleted message in #{channel_name}",
description=snipe_message_content[channel.id])
em.set_footer(
text=f"This message was sent by {snipe_message_author[channel.id]}"
)
await ctx.send(embed=em)
except KeyError: #This piece of code is run if the bot doesn't find anything in the dictionary
await ctx.send(
f"There are no recently deleted messages in #{channel.name}")```
that is a datetime object you need it to print only the string it contains
@bot.event
async def on_message_delete(message):
snipe_message_author[message.channel.id] = message.author
snipe_message_content[message.channel.id] = message.content
await asyncio.sleep(60)
del snipe_message_author[message.channel.id]
del snipe_message_content[message.channel.id]```
member.created_at.timestamp thats what Im printing
There is no name kwarg
!d discord.Embed
class discord.Embed(*, colour=Embed.Empty, color=Embed.Empty, title=Embed.Empty, type='rich', url=Embed.Empty, description=Embed.Empty, timestamp=None)```
Represents a Discord embed.
len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.
bool(b) Returns whether the embed has any data set.
New in version 2.0.
Certain properties return an `EmbedProxy`, a type that acts similar to a regular [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") except using dotted access, e.g. `embed.author.icon_url`. If the attribute is invalid or empty, then a special sentinel value is returned, [`Embed.Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty").
For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") for you.
kwarg
ouch
try member.created_at.timestamp()
t:1609864241.184:R
I was using old discord version
No decimals
<t:1609864241:R>
<t:1609864241:R>
yeah remove decimals
<t:1609864241184:R>
You can use Math.trunc
how do I remove decimals 😦
<t:9462829>
Is:
<t:8462829>
u can use round(thetimestamp)
Math.trunc()
!d round
round(number[, ndigits])```
Return *number* rounded to *ndigits* precision after the decimal point. If *ndigits* is omitted or is `None`, it returns the nearest integer to its input.
For the built-in types supporting [`round()`](https://docs.python.org/3/library/functions.html#round "round"), values are rounded to the closest multiple of 10 to the power minus *ndigits*; if two multiples are equally close, rounding is done toward the even choice (so, for example, both `round(0.5)` and `round(-0.5)` are `0`, and `round(1.5)` is `2`). Any integer value is valid for *ndigits* (positive, zero, or negative). The return value is an integer if *ndigits* is omitted or `None`. Otherwise, the return value has the same type as *number*.
For a general Python object `number`, `round` delegates to `number.__round__`.
Math.trunc(datetime())
F
?
round(datetime()) 😛
!e
print(round(1609864241.184))
@final iron :white_check_mark: Your eval job has completed with return code 0.
1609864241
well with this build in converter i guess it only say a year ago
or 2 years ago etc
you will have to make your own but you can print both formats and it specifies
There are more formats
!e
import time
print(time.time())
@honest vessel :white_check_mark: Your eval job has completed with return code 0.
1645199827.5217543
<t:1645199827:R>
<t:333:f>
1645199827
thats when unixtime is started counting seconds from
how manyh seconds has been since that date n time
oof
oof k
that is a question they should use on "who wants to be a millionare" or something 😄 what date n time is unixtime 0
use datetime
and .timestamp()
and trunc it
and use
dpy has inbuilt converty ( 2.0 only )
if you use any fork its there for you already
quick question. is there a way that i can remove the cooldown py @client.command() @commands.cooldown(1,60,commands.BucketType.user) async def test(ctx, *,arg=None): if arg is None: #removes the cooldown from the command #other codes here
!d discord.utils.format_dt
discord.utils.format_dt(dt, /, style=None)```
A helper function to format a [`datetime.datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "(in Python v3.9)") for presentation within Discord.
This allows for a locale-independent way of presenting data using Discord specific Markdown...
!d discord.ext.commands.Command.reset_cooldown
reset_cooldown(ctx)```
Resets the cooldown on this command.
tnx
np
i think that resets for all users tho
!e
!eval [code]
Can also use: e
*Run Python code and get the results.
This command supports multiple lines of code, including code wrapped inside a formatted code block. Code can be re-evaluated by editing the original message within 10 seconds and clicking the reaction that subsequently appears.
We've done our best to make this sandboxed, but do let us know if you manage to find an issue with it!*
!e generator
@lavish axle :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | NameError: name 'generator' is not defined
lol?
@lavish axle :x: Your eval job has completed with return code 1.
001 | File "<string>", line 1
002 | print(""Hello world")
003 | ^^^^^^^
004 | SyntaxError: invalid syntax. Perhaps you forgot a comma?
lol
@lavish axle :white_check_mark: Your eval job has completed with return code 0.
Hello
!e i = []
@lavish axle :warning: Your eval job has completed with return code 0.
[No output]
!e
while 1:
print("LOL")
@honest vessel :x: Your eval job has completed with return code 143 (SIGTERM).
001 | LOL
002 | LOL
003 | LOL
004 | LOL
005 | LOL
006 | LOL
007 | LOL
008 | LOL
009 | LOL
010 | LOL
011 | LOL
... (truncated - too many lines)
Full output: too long to upload
xD
#bot-commands
um, @honest vessel you okay?
Seems like he is drunk
Why not? 😄
!e
for i in range:
print("LMAOOO")
@lavish axle :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | TypeError: 'type' object is not iterable
Wat
visit #bot-commands for the reason
u had space infront of ur for loop
Not yet working on it 🙂
Yea he is totally drunk rn
😦
hunter, check #bot-commands
aw, dont be sad 🫂 ilysm
What's there
anyways
Would be fun to see yr reaction to yr messages when u become sober
Anyways
!ot
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
Knew it
I'm predictable enough
And using it in your discord bot
with*
in the code
Is that a lot?
Isn't 3 tables like nothing though?
I am talking about the reads and writes lol
Oh
u can show me my messages then if they so funny 😄
Lol
bbl cigg n beer time
hello guys, how can i make
if user2 == None:
user2 = ctx.author```
If the user none the user == my bot
i try slap command with pillow
what is a good cheap VPS for simple bot? only using on 1-2 servers
i use vultr before i used digitalocean
what is better
pretty much same
@native wedgemy vultr server, top - 16:51:52 up 373 days
more than a year up n running
like why ? i dont understand
AWS is also an excellent provider though it's a bit more expensive than the others
like its the same bot multiple times, how and why
that looks not like abuse at all 😛
user2 = user2 or ctx.author. user2 will become ctx.author if user2 is None
ctx.me works
ah yeah forgot that one!
Oracle ftw
Oracle free tier users be like:
Cloudflare rest only bot

raspberrypi 😄
More expensive over time compared to renting a cheap VPS
You have to do maintenance, pay Wi-Fi bills, pay electricity bills, you also have to pay for more storage for the more users you get
cheap vps cost 5-10$
Your raspberry pi is also more likely to go offline compared to one of the VPSs backed by enterprises
i have a raspberry laying at home doing nothing atm but sucking electricity
You also don’t have any warranty for corruption etc
your ISP dosnt prob have same uptime either 😛
You also don’t have enterprise level security
👁️👁️ overall it’s better to get a VPS
I’m return you get that mega latency
That probably breaks their Wi-Fi TOS which they can then sue you for
👍 genius idea
Your ISP also might not be fine with you hosting, they can throttle your bandwidth
what are u trying to make
that depends on ISP i never had issue with hosting like IRCbots or skypebots at home
Depends on the ISP but still an issue no less
ye vps is best option for sure
I think he trying to make a slap function and if no given mention/user it gonna slap the bot itself?
And then there's my ISP which is currently giving 5000 MS in Discord VC lmao
wait what? wth
@bot.command()
async def fight(message, user: discord.Member):
global fighter
global fighter2
embed = discord.Embed(
description=f"""{message.author.mention} has challenged {user.mention} to a fight!
Do you want to accept or decline? (yes/no)
"""
)
await message.channel.send(embed=embed)
fighter = message.author
fighter2 = user
p1hp = 100
p2hp = 100
dmg = random.randint(10, 30)
def start_choice_p1(ch1):
return ch1.author == fighter2 and ch1 in ("yes", "no")
ans = await bot.wait_for("message", timeout=60.0, start_choice_p1=start_choice_p1)
if ans == "yes":
while p1hp > 0 and p2hp > 0:
embed = discord.Embed(description=f"{fighter.mention} it is your turn. What would you like to do?")
await message.channel.send(embed=embed)
async def choice_p1(p1choice2):
return message.author == fighter and p1choice2 in ("hit", "kick")
p1choice2 = await bot.wait_for("message", timeout=60.0, check=choice_p1)
async def p1move():
if p1choice2 == "hit":
embed = discord.Embed(
description=f"You have hit {fighter2.mention} for {dmg}hp! They now have {p2hp - dmg} left!"
)
await message.channel.send(embed=embed)
p2hp -= dmg
slap command. if i write me and asnyone the bot send a pic slap. if i add just 1 member the bot slap anyone with pill
@client.command()
async def slap(ctx, user: discord.Member = None,user2: discord.Member = None):
if user == None:
user = ctx.author
if user2 == None:
user2 = ctx.author
wanted = Image.open("batman.jpg")
asset = user.avatar_url_as(size = 128)
data = BytesIO(await asset.read())
pfp=Image.open(data)
pfp = pfp.resize((291,251)) #A kép mérete pxben
wanted.paste(pfp,(809,321)) #Ez itt a szélesség / magasság. A szélesség az első
wanted.save("batman1.jpg")
await ctx.send(file=discord.File("batman1.jpg"))
else:
embed = discord.Embed(
description=f"You have kicked {fighter2.mention} for {dmg}hp! They now have {p2hp - dmg} left!"
)
await message.channel.send(embed=embed)
p2hp -= dmg
embed = discord.Embed(description=f"{message.fighter2.mention} it is your turn. What would you like to do?")
await message.channel.send(embed=embed)
async def choice_p2(p2choice2):
return message.author == fighter2 and p2choice2 in ("hit", "kick")
p2choice2 = await bot.wait_for("message", timeout=60.0, check=choice_p2)
async def p2move():
if p1choice2 == "hit":
embed = discord.Embed(
description=f"You have hit {fighter.mention} for {dmg}hp! They now have {p1hp - dmg} left!"
)
await message.channel.send(embed=embed)
p2hp -= dmg
else:
embed = discord.Embed(
description=f"You have kicked {fighter.mention} for {dmg}hp! They now have {p1hp - dmg} left!"
)
await message.channel.send(embed=embed)
p2hp -= dmg
if p1hp == 0:
embed = discord.Embed(description=f"{fighter2.mention} HAS WON!")
await message.channel.send(embed=embed)
elif p2hp == 0:
embed = discord.Embed(description=f"{fighter.mention} HAS WON!")
await message.channel.send(embed=embed)
else:
embed = discord.Embed(description=f"{fighter2.mention} has cancelled the fight!")
await message.channel.send(embed=embed)
@fight.error
async def on_fight_error(message, error):
if isinstance(error, asyncio.TimeoutError):
embed = discord.Embed(description=f"Time's up, the match has been forfeited.")
await message.channel.send(embed=embed)
You mean sum ISP chokes the speed?
yea, since a few days the WiFi is fucked
Not discord? u sure its ISP choking it?
whats wrong with this
fight cmd
any errors?
use ctx.author instead of the author having to menion them selves
your posted code dosnt even have that yes/no question
it does
i sent it in 3 parts since it was big
@honest vessel
use ctx.author.avatar_url
this gets the author profile picture
then use pillow to edit it
ik but i try use my bot if the member not call 2 member to the command
member = ctx.author```
my commaand work but i dont know how to call my bot pfp if the member is 1
yap this is my code
.
ctx.me.avatar_url?
well it should work right?
its work but my problem is not this
i try it
then what is it
so u want the bots profile picture?
botavater = bot.avatar_url
ty i try it
or u can use attachments
error?
pm me @regal pulsar
ch1.content
instead of just ch1
do that in all other places like p2choice2
wherever you're checking the message's content
ah
Bot doesn't have that attribute
!paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
Paste all your code in there
bot.user.display_avatar.url```
The correct way for dpy 2.0 and main forks
Already helped them
still isnt working
I'm not clicking on a random link
Use the one that was given
oh k
Why the heck do you name context message
force of habit ;/
I don't know how to describe this code
That might cause misunderstanding
then what is it
@left crater
is it that bad :/
I mean it's not a message lol, the actual message would be message.message and that's weird af
Yes
i started like a week ago
According to PEP8 you should give variables descriptive names
hmm
Not even in python, you should name the variables normally in any languages
Sorry for bad grammar
Naming Context message, naming a Member object user etc.
whats wrong with naming a member obj as user
Yes i also use user
discord.User exists
It should be member, cause user is usually discord.User
bot is only on servers ¯\_(ツ)_/¯
member = discord.User
user = discord.Member
Or:
member = discord.Member
user = discord.User
Which one is more readable
I use user = discord.Member 😎
😎
ah
Proper variable naming matters
Ok ill change it its ez only ctrl + f2 and done
Same thing with context. As Exenifix pointed out, message.message can be really confusing and throw off the reader
ctx
import error
Code?
edited it
import os
from discord.ext import commands
import discord
bot = discord.Bot()
@bot.slash_command(
name="user",
description="Find info about tiktok user",
guild_ids=[943921571347714109]
)
async def user(
ctx,
username: Option(str, "Enter the username of the user you want to check.", required=True)
):```
huh
What library are you using?
discord doesn't have slash support
Also, requests is blocking
Use aiohttp instead
!pypi aiohttp
well apart from wrong variable names what's the actual error in my code
You never gave any errors
hmm ill try removing it
ans = await bot.wait_for("message", timeout=60.0, start_choice_p1=start_choice_p1) TypeError: Client.wait_for() got an unexpected keyword argument 'start_choice_p1'
says start_choice_p1 isnt an expected arg
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**...
ah
so ```py
ans = await bot.wait_for("message", timeout=60.0, check=start_choice_p1)
now im getting no errors but no output either
your command error handler will definitely eat up all the errors u dont handle
i removed it
hi guys how can i send my bot pfp with client.user.avatar_url
?
ctx.bot.user.avatar iirc
?
!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.
@tacit token
i try command with pillow if the user1==none the bot send the bot pfp but if the user1 == none the bot send my pfp
use the one i sent, that should work for bot's avatar/
Why would you send bot pfp
just dont question how they do it
botpfp=ctx.bot.user.avatar
if user == None:
user = botpfp
if user2 == None:
user2 = ctx.author
==
i try it and nothing
I just did
bot.user.avatar
Why ctx.bot
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'avatar'
what?
You may also try ctx.me.avatar
.url
In his code he has the asset so I suggested asset
yeah
Also why c code 😳
how can i convert ctx to SlashContext (slash command)
Oh mo I smell weird slash commands lib
Depends if he's using something else than dpy
Even dpy 2.0 ig got rid of .url
Nope
how 🙄
oh wow, wait...when did that happen?
In versions lower than 2.0 it was indeed
...user.avatar_url```
But now it is
```py
...user.avatar.url```
Wasn't that just an alias?
i don't think so
And it's better to use display_avatar because avatar for users with default profile is None
can you link me the docs for display_avatar?
!d discord.User.display_avatar
property display_avatar: discord.asset.Asset```
Returns the user’s display avatar.
For regular users this is just their default avatar or uploaded avatar.
New in version 2.0.
well, you can just add an inoffensive check if it's none
Why'd you need that
@client.command()
async def slap(ctx, user: discord.Member=None,user2: discord.Member=None):
botpfp=client.user.avatar
if user == None:
user == botpfp
if user2 == None:
user2 = ctx.author
wanted = Image.open("batman.jpg")
asset = user2.avatar_url_as(size = 128)
data = BytesIO(await asset.read())
pfp=Image.open(data)
pfp = pfp.resize((291,251)) #A kép mérete pxben
wanted.paste(pfp,(809,321))
asset = user.avatar_url_as(size = 128)
data = BytesIO(await asset.read())
pfp=Image.open(data)
pfp = pfp.resize((291,251)) #A kép mérete pxben
wanted.paste(pfp,(497,115))
wanted.save("batman1.jpg")
await ctx.send(file=discord.File("batman1.jpg"))```
When there's better option
Does context even have bot attr
!d discord.ext.commands.Context.bot
similar to dank memer slap
The bot that contains the command being executed.
dpy lib or pill or what
Dpy
1.7.3
imo i see no point into displaying a default avatar
but i understand what u say
i have this for a client.wait_for('reaction_add') check and how do i make it check also if the message is the same py def check_reaction(reaction, user): return user == ctx.author and (str(reaction.emoji) == cross or str(reaction.emoji) == check)
reaction.channel ? if thats a thing
o
its reaction.message
anybody?
Try
ctx.me.avatar_url```
ctx.author
!d discord.Member.add_roles
await add_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s.
You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the added [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
not work
!d discord.abc.Messageable.send
await send(content=None, *, tts=None, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, view=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message to the destination with the content given.
The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.
To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.
To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
class discord.File(fp, filename=None, *, spoiler=False)```
A parameter object used for [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") for sending file objects.
Note
File objects are single use and are not meant to be reused in multiple [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send")s.
await channel.send(file=discord.File('./main.py'))
what is a good resource to learn to make discord bots
Check channel's topic
A tutorial on how to use discord.py to create your own Discord bot in Python, written to fix the flaws of many other popular tutorials.
And this one is good as well
Thank you both. It looks fun to do.
Fun until you get to the real stuff
gives me something to do while outside of class to keep up on python code. Im a cybersecurity major so anything helps keep fresh

the channel isn't in any category
didnt u say it works
its not work, but i delete this project.
im new to coding and im using some code to make a discord bot but when i try to install colarama this error comes up
Isnt colorama preinstalled
And this isnt the right channel
nope
Okay python sucks
Its the ANSI color codes
no, it's just a third party module lmfao
use get member please
Welp
i agree, it does need to be a default module but it's not made by python officially.
that will trigger every time a message is sent
fetch_member isnt a thing anyways rofl
So u will need to make another check to see if the message channel has no category
Ha lol
!d discord.Guild.fetch_member uhhh
await fetch_member(member_id, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Retrieves a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") from a guild ID, and a member ID.
Note
This method is an API call. If you have [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") and member cache enabled, consider [`get_member()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.get_member "discord.Guild.get_member") instead.
💀
Wait....Good night
@slate swan
await Birthday.bot.db.execute(...)
class Birthday(commands.Cog):
def __init__(self, bot) -> None:
self.bot = bot
```AttributeError: type object 'Birthday' has no attribute 'bot'
excusez moi?
just check first if msg.channel.category is None
Where u using that tho
Also u need an instance of the Birthday class
oh well
I wanna make this efficient
but it's the worst code I've ever written
and my raspberry will NOT be able to handle the bullshit it will see here
Yea, also u can combine the first two if statements
Just do:
if msg.channel.category is None or msg.author.bot:
return
if not msg.channel.category lol
¯_(ツ)_/¯
!d discord.TextChannel.category
property category: Optional[CategoryChannel]```
The category this channel belongs to.
If there is no category then this is `None`.
Hmm
print msg.channel.category
Yes
See what its returning
The function should of been returned
No like print(msg.channel.category)
Oh yeah
Put that at the beginning of the code
Because of the exception the print statement isn't being reached
No
I mean like this: print(msg.channel.category)
hi how can I make it so that my dis bot can only read/send msgs in a certain channel?
code:
import discord
my_secret = ''
client = discord.Client()
@client.event
async def on_ready():
print("USER:{0.user}".format(client))
@client.event
async def on_message(message):
if message.author == client.user:
return
client.run(my_secret)
In a command or in an on_message event?
?
Do you want your bot to disregard messages in your command or in an on_message event
i.e
@bot.command()
async def my_command(ctx: commands.Context):
...
Or
@bot.event
async def on_message(message: discord.Message):
...
!d discord.Message.channel
The TextChannel or Thread that the message was sent from. Could be a DMChannel or GroupChannel if it’s a private message.
Code?
@commands.command()
async def kiss(ctx, *, user: discord.Member=None):
await ctx.message.delete()
if user == ctx.author:
return await ctx.send("You can't kiss yourself... Find someone to kiss *pssh what a loser*")
if not user:
return await ctx.send("You need to ping a user to kiss.")
r = requests.get("https://nekos.life/api/v2/img/kiss")
res = r.json()
em = discord.Embed(description=f"{ctx.author.mention} kissing <3 {user.mention}", color=0x89CFF0)
em.set_image(url=res['url'])
em.set_footer(
text=f"Request by {ctx.author}", icon_url=ctx.author.avatar.url)
await ctx.send(embed=em)
i am using old version of py btw
Does paginator already have a set amount of commands per page?
Which paginator...
Paginator in general
bor
I use this
Does it have a pages arg
idk
!pypi disputils
Some utilities for discord.py. Making Discord bot development easier.
No
wdym?
Are you asking for ways to improve your code?
hey are you still stuck?
send the full code if possible also send what’s happening / what’s not working i don’t see anything glaring in the code above
import discord
my_secret = ''
client = discord.Client()
@client.event
async def on_ready():
print("USER:{0.user}".format(client))
@client.event
async def on_message(message):
channel = client.get_channel()
if message.author == client.user:
return
if 'hi' in channel.message.content.lower():
await channel.send('hello')
client.run(my_secret)
hi how can i make this work?
i have it in i just deleted it
you know just in case
what output do you get when running it
also tell me what you’re indentation looks like that code example i think the tabs are wrong but idk if that’s just a copy/paste discord issue
what’s the issue?
the channel doesn't have the attribute message
I need it to detect when a user types something in a certain channel
print(str(msg))
at the top of your on_message for me
The channel is not in a category, thus, the channel.category returned as None.
can you help?
yeah i can i’m looking over your code
yeah run it and lmk what output is
oh ok 😄
also look at @dapper cobalt they might be right idk
The print cannot be below the decorator. It has to be inside the function.
What comes below the decorator is the function.

is there an event that can be triggered when someone creates an invite?
you only want it to output in one channel?
!d discord.on_invite_create
discord.on_invite_create(invite)```
Called when an [`Invite`](https://discordpy.readthedocs.io/en/master/api.html#discord.Invite "discord.Invite") is created. You must have the [`manage_channels`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to receive this.
New in version 1.3.
Note
There is a rare possibility that the [`Invite.guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Invite.guild "discord.Invite.guild") and [`Invite.channel`](https://discordpy.readthedocs.io/en/master/api.html#discord.Invite.channel "discord.Invite.channel") attributes will be of [`Object`](https://discordpy.readthedocs.io/en/master/api.html#discord.Object "discord.Object") rather than the respective models.
This requires [`Intents.invites`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.invites "discord.Intents.invites") to be enabled.
it already outputs in one channel but i need it to get input from one channel
okay i have an idea but we’re gonna have to work together on it to get it working. you have a little bit of time?
yea yea
Code?
okay tldr here’s what i’m thinking.
we create a dictionary to track whether or not the bot is allowed to listen in a channel.
you will have a command to toggle letting the bot talk in a channel (on and off)
this way you can change the channel / do a different channel / do multiple channels
Initially, you need to pass a channel ID inside get_channel. Secondly, inside the string of my_secret is your bot's token. (In case you didn't put one)
If youw ant to print the content of the message, then it's msg.content.
The msg param you passed represents a discord.Message.
!d discord.Message
class discord.Message```
Represents a message from Discord.
x == y Checks if two messages are equal.
x != y Checks if two messages are not equal.
hash(x) Returns the message’s hash.
i need it to get input from text channel
from all text channels or just the one?
just one
yeah ez. okay here’s what we’re going to do:
at the top of your file type this:
channelTracking = {}
ok
on top of the imports?
Below imports. With global variables if you have them
how to check if something matches the message.content even if it looks likesOmEtHiNg any help?
ty
!d str.lower
str.lower()```
Return a copy of the string with all the cased characters [4](https://docs.python.org/3/library/stdtypes.html#id15) converted to lowercase.
The lowercasing algorithm used is described in section 3.13 of the Unicode Standard.
i think i have global variables
ty
Yeah put the new variable there
ok
then
Code?
@bot.command()
async def workWithChannelTracker(msg):
do i have to do this?
Yeah that's the new function declaration, were gonna fill it in too
kk, now? 😄
if msg.channel not in channel tracker: #if the channel is not in our dictionary, do this
(Tab)channelTracker[msg.channel] = True
(Tab)await msg.channel.send("added to dictionary and I'm listening")
kk
Spaces over tabs
so if I ask you, homies, in a databases case, because the right channel is ded
will I get sent away?
You'd never do that to me
homies
🗿
else:
(Tab)if channelTracker[msg.channel]: #if the channel is in our dict but TRUE, we are turning it off
(Tab)(tab)channel tracker[msg.channel] = False
(tab)(tab) await msg.channel.send("no more listening here")
!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.
🥴🥴🥴🥴 my friend i’m typing it all by hand tab works easier AND it makes sure they are at least copy + pasting with modifications instead of just copy paste
ok?
bruh
You make no sense
LMAO
await db.execute(
"""
INSERT INTO users (id, birthday) VALUES ($1, $2)
ON CONFLICT (id) DO UPDATE SET birthday = $2 WHERE (id = $1);
""", message.author.id, var
)
- can I do that with $1 and $2?
asyncpg.exceptions.AmbiguousColumnError: column reference "id" is ambiguous
I will get sent away by Water_Gazes just cuz I said it
is that it? :)
How does changing `(tabs) into a tab make copy and pasting code any better
(tab)else: #ifwe are not listening here, now we are
(tab)(tab) channel tracker[msg.channel] = True
(tab)(tab) await msg.send(“listening here now”
channel tracker[msg.channel] that's no true code
slightly more work and they have to read every line
yeah i’m here helping not doing it completely for you
not quite. that’s one function. now we’re going to add a little bit into the on_message to make it work
lol
okay now in your on_message
i feel like there is a easier way to do this tbh
if await bot.process_commands(message): #this let’s you try and process the message as a command instead of a message
(tab)pass
else:
(put your entire on_message here)
I've been in here for 2 seconds and I'm already done
You make 0 sense
RIP help em then lmao this is the solution i know
Why is bot.process_commands in a if statement, do you know that this method always returns None so it is never truthy?
And even then, you only pass, this makes no sense
there isnt a process_commands method
there is tho
but it never returns a boolean
!d discord.ext.commands.Bot.process_commands
await process_commands(message)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
This function processes the commands that have been registered to the bot and other groups. Without this coroutine, none of the commands will be triggered.
By default, this coroutine is called inside the [`on_message()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_message "discord.on_message") event. If you choose to override the [`on_message()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_message "discord.on_message") event, then you should invoke this coroutine as well.
This is built using other low level tools, and is equivalent to a call to [`get_context()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.get_context "discord.ext.commands.Bot.get_context") followed by a call to [`invoke()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.invoke "discord.ext.commands.Bot.invoke").
This also checks if the message’s author is a bot and doesn’t call [`get_context()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.get_context "discord.ext.commands.Bot.get_context") or [`invoke()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.invoke "discord.ext.commands.Bot.invoke") if so.
It's bound to your bot instance
you might be able to skip the pass line BUT this is why
we either want it to process as a command OR a message
There should be no pass statement in the first place, neither an if-statement
not both
ummm
if it’s a command run it, otherwise don’t
You don't process commands 🤔 You process the message
the message will be the command
ok, im deconstructing my friend's code for his economy bot and attempting to make a bot with it and learn how it works at the same time, and it's been going really well, but i got this error when i tried to add a new section of the user's balance menu:
Does anyone feel kind of stuck with starting to code your bot?
huh
sometimes
No, the message is never a command lol
Please show me when it is a command
bruh
yes it is you we are implementing it right now
ignore them just listen to me still lol it might not be the best way but it’ll work at the end
you process the message and if it runs, it's a command
Hey @fallow mauve!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
yes exactly
but there isnt a process_command method
okay wait what can you send to me please

process_commands already does that for you kek
here's code:
https://paste.pythondiscord.com/azicipuben
without the if/else it runs as command and as message
this one does exist for sure
Do you realise that process_commands always returns None, it never passes your if statement
its yellow
But none the less, still runs as you call it
The if statement is totally useless, None is not truthy
i don’t understand make sure you spelled it right and put the message in it
that one for sure exists
it is spelled right
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In embed.fields.0.value: This field is required```
You need to use a commands.Bot instance, from the picture you sent earlier you are using discord.Client which has no commands implementation
bruh
okay add these
nvm, i fixed my problem
no it’s ez fix dw
so there is no way to do it?
You just change your client to commands.Bot and construct it with a command prefix
https://tutorial.vcokltfre.dev/tutorial/04-pong/ take a look at this
So far we've made a pretty simple bot - it only responds to !hello with a static response. Not particularly interesting, is it? Let's fix that! In this part we'll be creating a ping command that shows the bot's gateway websocket latency when you call it.
process_commands() is a method of commands.Bot, if you want to use the commands extension then you should use commands.Bot.
yeah this is ez fix dw
yeah add those to the top and resend your code
🤨
let us see where it’s at
its the same
this is good tutorial to see bot implementation and we’ll help you here too
send again you were supposed to add a bunch of stuff right?
like the new function and imports and stuff
ACTUALLY WAIT SORRY okayyy wait here
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In embed.fields.0.value: This field is required```
i think im going to give up
You need to handle the case when command.description is None, you can set a default value using or
Hi, my bot caches all users, so my bot uses 900mo of ram. I can remove the intent guilds however my bot needs it. What can I do to reduce the ram used?
!e ```py
a = None
print(a or 1)
@pliant gulch :white_check_mark: Your eval job has completed with return code 0.
1
this should be:
else:
(tab)if msg.channel in channelTracker: #if the channel exists as a value in the dict, do this
(tab)(tab)if channelTracker[msg.channel]: #if the value is TRUE, so this:
(tab)(tab)(tab) HERE is where your on_message loop goes
Yea, this works
you’re good this is the last line
ok ok
we’re right at the finish don’t give up yet
lmk if that runs, send error if it doesn’t and we’ll fix it
we’re gonna get this working rn
camelCase 🗿
!d discord.MemberCacheFlags you could probably use this to set what gets into your cache to limit it's ram usage
class discord.MemberCacheFlags(**kwargs)```
Controls the library’s cache policy when it comes to members.
This allows for finer grained control over what members are cached. Note that the bot’s own member is always cached. This class is passed to the `member_cache_flags` parameter in [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client").
Due to a quirk in how Discord works, in order to ensure proper cleanup of cache resources it is recommended to have [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") enabled. Otherwise the library cannot know when a member leaves a guild and is thus unable to cleanup after itself.
To construct an object you can pass keyword arguments denoting the flags to enable or disable.
The default value is all flags enabled.
New in version 1.5.
You pass this to your bot's constructor
HAHAHA I’M SORRY COMPLIANCE OFFICER my pycharm yells at me all the time too
i like camelCase 🥴🥴
🤨
wait is there an actual reason why?
Yes
or just pep standards?
readability. so there’s no REAL reason for me to listen to the warning?
PEP 8 is the official style guide for Python. It includes comprehensive guidelines for code formatting, variable naming, and making your code easy to read. Professional Python developers are usually required to follow the guidelines, and will often use code-linters like flake8 to verify that the code they're writing complies with the style guide.
More information:
• PEP 8 document
• Our PEP 8 song! :notes:
Readability is apparently not a valid reason now
If you're not going to follow it, at least don't pass your bad habit on to others
You're being an objectively bad guide/teacher right now
It does as expected but a little long as my bot has a few commands and the scroll goes on for a while
Is there a way to fix that
Are you saying that the embed size is not matching with the reactions?
It does but the length of the pages is a bit long
oof. idk how to teach people code in a style idk though 🥴🥴 should i just avoid helping people?
Is there a way to make more commands appear on page at once
You can just increase the amount you show in the paginator
i’m self taught no school or professional training i can sit this one out lol just trying to be helpful
If you're going to teach then bad practices, then I would suggest you avoid it until you get your act together
How would I do that
Not sure what your paginator looks like so I cannot say
thats why pep8 is a thing
Are you the one using a package for the paginator?
pep8 is a style guide which all developers should follow
Yea, conventions are important
disputils and they specify nothing about what I want to do
Imagine you have your finals week, and you have tests all day, but every test is mismatched and there are discrepancies
Pretty frustrating right?
atleast devs who work with other devs
Yeah. You would need to edit the source code
should always be followed no matter the situation
How?
By editing the files
ever heard of the python zen?
I think it's okay to not use it if nobody else even sees it
!zen
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than right now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
But if I do that, can I still see the number of users?
It should be used 100% of the time
i just use blacken tho
Depends on the codebase you are coding for, other codebases have different style guides that it expects it's contributors to use
But PEP8 is the most used convention
i would argue this too bc like if it’s my code for myself why does it matter if it’s not pep8.
i can understand teaching people proper stuff but my code can be ugly right?
Special cases aren't special enough to break the rules. not a rule but not practicing it doesnt seem correct
You can see the users that pass your cache flag set
eww this guide is wrong
No clue
tabs all the way
You can't really expect to lower cache size without lowering the amount of data
I would agree that if you're working on a team with their own special conventions you should follow it (but just for that project/team don't make it a habit)
if its not open source then yes that wouldnt matter but not following it is just making everything harder for you
so lemme do my shit for now 
Is there another way to run paginator?
so genuine question when you’re coding di you look up the guidelines to ensure you’re doing them correctly?
if by four spaces you mean 1 tab
depending on the lib there is examples in there git
like is it an active thing or you just know them at this point
no you remember them like anybody or get screamed at by pycharm or use black
I have a lot of them memorized but pycharm helps me out sometimes when I don't realize I've done something wrong
Sure, it's good practice but imagine you have a mega codebase with a pre-defined coding style that is not PEP8, you'd be in for a lot of change. This is what some enterprises have. PEP8 Is also not an absolute rule just like any other PEP that doesn't regard core additons/changes. For an example PEP484 (typehints), not everyone uses them
I also use black
why would i hit the spacebar 4 times when i could hit the tab once
Also, you cannot say the guide on the official python website is wrong
what is black? “black python” is just showing me snakes lol
four spaces is one tab
Are you using an IDE? If so, it's almost very likely your IDE changes a tab to 4 spaces
Really nice formatting tool
yes that is so, but knowing the standard style is still important as some companies do follow pep8 to ensure nobody needs to learn another code style or some go by formatters as well
yess black is great, i started using it when i learned python and now i pretty much learnt to copy its layout most of the time
Most ide's insert spaces instead of tabs. Either way, you should be doing it because it's correct
yeah its good knowing its format and fomatting your code and seeing no changes is great as well
so i have a invite event
@client.event
async def on_invite_create(invite):
print(invite, invite.guild)
how can I get the invite author? I tried invite.author but to no avail
vsc and pycharm both insert spaces instead of tabs
You'll have to figure out if your text editor/ide does it for you
it does, but why would it matter even if it didn't
Because code that uses tabs instead of spaces won't work with each other
It's either or
!d discord.Invite.inviter
The user who created the invite.
so you find other sane people that use tabs
Perhaps there are some, you can't say 100% that there isn't
But none the less, causes errors because someone isn't following the standard
Another reason why PEP8 exists, for good reason too
If you're not using spaces you're developing bad habits
Developing bad habits is a very bad thing. You don't even realize you're doing it wrong and its very hard to change
most editors do auto indents so it doesnt really matter
I already mentioned that
this
Inb4 switching IDE then commiting code with tabs instead of spaces
imagine if a company asks you to use notepad
would I add that as an arg to async def on_invite_create(invite, inviter)?
im not gonna start whacking the spacebar millions of times if i dont need to
And what happens if you're in a job interview?
isnt hard as pep8 says each level of indentation is 4 spaces or a tab that is the same as 4 spaces
Companies do reject applicants who don't follow pep8 a lot
if you dont know pep8s rules why are you in a job interview anyways?
A lot of people know about them, they just don't care
then why are you looking for a job if you cant even right code any developer can understand?
Tab users: It iS OnLy ONe ByTE, Way BeTTER tHAN SPaceS
no. invite.inviter will get you the author
im dumb af
oh I get it now
a tab isnt considered 4spaces? so its save as one byte?
Most people don't realize how much of an issue it is

