#discord-bots
1 messages · Page 848 of 1
in the random.choice part
I did a major over haul on my main file and restarted the server witch means I have to start my bots once more now my bots don't run at all they only load events.py apparently because it prints in console doesn't reply to commands at all no error In console
Well no since it has to be it's own thing, the
async with aiofiles.open(...) as f:
...
hm?
Do you think that goes before or after random.choice()?
how could i fix this
before
alright
a s y n c i o
Put the c in front of the I
AND TIMEOUT not tiemout
@commands.command(...)
async def myCommand(...):
async with aiofiles.open(...) as f :
...
...
i’m using bot.command, and i’ve never seen “myCommand”
oh wait THATS JUST A PLACEHOLDER
No, that's just pseudo-code
😂
Yep, only meant to nudge you in the right direction
Yep but consider using is not instead of !=
ok :V
thank you!
that's work! tyy
i might just be really dumb 😭
maybe the indentation is wrong?
uh yeah, you are missing () in the event decorator, and (): in your function
It is wrong yes
OH YEAH
aiofiles.open() takes 2 arguments: the path of the file & the mode r for reading, w for writing
so what do i put?
async with aiofiles.open('/path/to/file', mode='r') as f:
contents = await f.read()
aiofiles.open("path/to/file", mode). w if you wanna write or r if u wanna read
there are others too i forgot
ohhh
speed
hmmm
i n d e n t
!indents
Indentation
Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.
Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.
Example
def foo():
bar = 'baz' # indented one level
if bar == 'baz':
print('ham') # indented two levels
return bar # indented one level
The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.
Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines
More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation
well duh but i’ve been doing that and it keeps saying that
ty
just gibe some space :l
you need to indent everything after your function properly
embed.set_image() and send() are not indented
what did I say?
oh wait send isn’t indented
fixed it but now i’m getting that error
i also imported aiofiles because i also got an error, but fixed it afterwards
Anyone knows pufferpannel?
not an error
oh ya yellow means not used
what do i put in the random.choice section?
you also dont copy paste what robin gave, you need to actually give it a valid file path
a list
contents will be the contents of the file, manipulate it and get it into a list of URLs depending on how your txt file is laid out
alright
the txt file has each media link per line
Then split by newlines
"file contents".split("\n")
> list of strings, each item is one line
alright
hey im using pycord how do I check if the user id is of a bot and if so return ?
if user.id == CLIENT.user.bot:
if user.bot:
you can use the bot property on the Member/User object
async def foo(ctx, member: pycord.Member):
bot = False
if member.bot: bot=True
@slate swan Hey, it’s discord mod from the English server, I don’t meme nearly as much outside of there
waittt, whattt, I havent seen you there for even once, glad you recognized me xD
oh wait
the name xD
I thought you were an actual mod
lol sorry
Just asking again, anyone here has any knowledge of using puffer pannel for a dpy bot?
never heard of that
wait, thatsa software, how can you dpy it
its like how you "dpy it" for pterodactyl
nevermind, I'm not too good at third party softwares with dpy
good luck though
Ask your question
How do i put the discord bot template in the panel?
I downloaded one from github but dont know how to put it to puffer panel
That's not for templates
This seems like a relatively common task.. https://pufferd.pufferpanel.com/docs/creating-pufferd-templates
The first section. You just need to place your template’s json into that directory
Anything on my issue?
ask?
I did a while qgo
mention me with the message
I did a major over haul on my main file and restarted the server witch means I have to start my bots once more now my bots don't run at all they only load events.py apparently because it prints in console doesn't reply to commands at all no error In console
what do you mean by "bots"
I run my beta bot and my reg bot
And I changed it from this
To this
Don't mind that I was just getting thr code I don't code there
Please help I don't get what broke the entire bot to not receive commands
DO NOT RUN MORE THAN ONE BOT IN ONE SINGLE CODE
I don't lol
Just in the same folder 📂 with 2 different start files and cogs folders
I wont help anyways
since okimii is here
Dude they don't link
Huh?
Don’t know what’s wrong with that 🤷♂️
its not a good practice
Can you show us the beta_cogs that you plan to load
I have heard that before
Ummm you mean like the files or the code?
Files sure code no
It’s not a practice to begin with.. running multiple bots in one program is completely fine, if that’s what you want to do 🤷♂️
what if one of them gets ratelimited? all the bots will die down
No
yes
Just run them in different asyncio tasks
How else would you run multiple bots at once
the discord api ratelimits ips
🤷♂️
Same thing as running two bots independently then
lol
Then you can glob that cogs module for your cogs and load them, in your main file
Really? I’m fairly certain IP addresses are a cloudflare limitation
Think the discord rate limits are per bot token
Or user token
Just checked docs
Repl.it runs a ton of containers under the same IP
How do a command /say in bot?
a slashcommand that echos?
Mmm yes
just make a slash command with a kwarg
Example: /say (message) = bot:(message)
Well yeah, and so what?
Which library are you using
?
I’m not denying that ip rate limits exist, I’m saying that they’re on cloudflare
They can't because of hosting services
Not the actual discord api
ok? ik that lol
Which, on repl.it, 10k requests per 10 minutes is nothing considering the amount of selfbot spammers and discord bot devs on there
Don’t think you read my message fully #discord-bots message
just put a parameter in your function and use the Context.send method with content as the paremeter
Thanks
I deliberately made it harder to understand idk how you figured that out lol
For some reason, my bot isnt working. In the console I'm getting an error message saying "Access denied | discord.com used Cloudflare to restrict access" and "The owner of this website (discord.com) has banned you temporarily from accessing this website." I tried regenerating my bot token and rerunning but the same thign keeps coming

You are ip banned
You need to wait a bit, or use a proxy
Bruh how the hell you get banned
i have no idea, my bot was working perfectly until today
2 questions:
- how long is "a bit"
- proxy meaning vpn?
10 minutes from when the rate limit was first applied, but that would be a waste of time if you’re using something like repl.it
You are better off using a proxy, or a vps to host, somewhere that you have your own ip
are u using replit?
yeah
@acoustic sleet
go to shell and try kill 1 if it dosent work then you have to wait
Unfortunately repl.it doesn’t give you your own ip so you have to share with spammers
o so its not my actual ip that got banned but rather the replit ip cuz spammers
Yeah, because replit uses shared IPs. So if someone else gets API banned from discord, it's likely you will aswell.
thx
yea
its wokring!! tysm
welcome
Maybe the rate limit expired 
what did kill 1 do tho?
it takes hours for that to happen
it closes the connection to all replit servers i think
i didnt dive that deep into the command
It says 10 minutes in the docs
oh ok
so basically removed my connection to that ip and connected me to another one
its been going on for a couple hours
Maybe you’re lucky 🤷♂️
but for me when mine was temp banned from the api for too many requests it took a ton of hours
i just came online a few mins ago and noticed
one time my friends were spamming the commands on my bot and i got temp banned from the api
i just runned this command and it solved everything
o lol
Or maybe it just spins up the container on a new node, not sure, either way it’s good it’s working now
Lol
yea probably
I’m relearning python after a longtime and just discovered discord.py is dead, what are the alternatives?
Pycord is by far the most popular
discord.py is dead? its what im using to code my bot
disnake, nextcord, edpy
Alright thx
It’s dead, but it works, and will work for a while for small bots
It’s no longer receiving updates, itll eventually stop working but for now you can use it
oh ok
I didn't know that. Thanks, I'll switch my bot to one of the alternatives
Are they forks on the GitHub or entirely new libraries?
All 4 or just pycord?
All of them are forks, pycord is a drop in replacement
Ah ok, thanks
Last I checked nextcord doesn’t support slash commands without some other crappy third-party interactions module.. couldn’t work with that ever
I don’t have any previous code written nor do I remember anything other than bot.run(“token”) but I’ll prolly just go with pycord if it’s basically the same
I'm just testing a command that sends 20 msgs per second. Can this go on for a few mins without getting rate limited? I looked up the discord.py rate limit and that's 50 msgs per second
That sounds horrible, I don’t plan to use slash commands unless they end up being super useful or smthn but I’d rather have the option available lmao
That is globally, so as long as you’re doing all this sending in multiple channels you are fine
But keep in mind it’s actually for every api request. So changing someone’s roles, or nickname would be rate limited and slow
If you do end up hitting that limit
i use nextcord though
since it is available
pycord is still in development
Oh yeah, how are you enjoying that discord-interactions crap?
really well
I swear, the dev had like 3 different websites all with zero docs
there are nextcord docs
Or confusing ones at best
Yeah, nextcord itself is good, just that interactions module I dislike
oh ok
Btw since these things are so new, is it possible to find good tutorials and how to use them properly?
you can use discord.py tutorials but for nexdtcord only features there arent tutorials other than from a channel named glowstik
I think I’ll prolly use pycord tbh, but if I do I’ll try and remember the name lmao
Pycord has a little examples folder in their repo
Otherwise, it’s the same as discord.py
Alright awesome
its sending and deleting messages with a 0.05 second break in a single channel
Even keeps the package name the same it’s just import discord
Glad I can use old tutorials then lmao
Oh good, that was like the one thing that i remembered lmao
Oh, I see
oh so im doing import discord does that mean im automatically using pycord?
ah
Yeah wouldn’t you need to like actually install it to import the libraries lmao
pycord has the same namespace as dpy in the memory, but are completelt different libs
u need to uninstall discord.py and then install pycord using packager
otherwise replit will import discord.py
oh
how do i uninstall it? do i have to go to the folder or can i just use a command in terminal
pip uninstall <package_name>
you can do what @placid skiff did but an easier method is go to replit packager
and search for discord.py
and click the trash can button
and then search for pycord
and then install
oh ok, thx
wheres that though?
wait is he usin' replit? lol
😀 🔫
that cube thing
oh found it, thx
img = Image.open("base.png")
font = ImageFont.truetype("arial.ttf",40)
draw = ImageDraw.Draw(img)
nextcord.Member.display_avatar.replace(format="png", size=2048).url
data = user.display_avatar.with_format("PNG")
avatar_data = BytesIO(await data.read())
pfp = Image.open(data)
pfp.resize((177,177))
text =f"{message}"
textname =f"{ctx.author}"
draw.text((0,150), text, (255,255,250), font=font)
draw.text((0,1030), textname, (0,0,0), font=font)
img.paste(pfp, (50,500))
img.save("sus.png")
await ctx.send(file = nextcord.File("sus.png"))
error: AttributeError: 'property' object has no attribute 'replace'
You are calling the class Member, you don't have any member object
can i use user
depends what user is
and you have a context too, from the context you can retrieve informations
i got that when i just user
AttributeError: module 'nextcord.user' has no attribute 'display_avatar
bro using nextcord.Member or nextcord.User you are just calling the class
worst fork
essentially, you are doin this:
class User():
def __init__(self, id, name):
self.id = id
self.name = name
User.name
hes not calling the class
User is just a class, it is not an object
calling it is as so User() the error says it all
he is calling methods from the raw class, he needs an object
its the user file doesnt have that attrs not the class
guys no
its not the class
module
its the file
class nextcord.Member```
Represents a Discord member to a [`Guild`](https://nextcord.readthedocs.io/en/latest/api.html#nextcord.Guild "nextcord.Guild").
This implements a lot of the functionality of [`User`](https://nextcord.readthedocs.io/en/latest/api.html#nextcord.User "nextcord.User").
x == y Checks if two members are equal. Note that this works with [`User`](https://nextcord.readthedocs.io/en/latest/api.html#nextcord.User "nextcord.User") instances too.
x != y Checks if two members are not equal. Note that this works with [`User`](https://nextcord.readthedocs.io/en/latest/api.html#nextcord.User "nextcord.User") instances too.
hash(x) Returns the member’s hash.
str(x) Returns the member’s name with the discriminator.
the class starts with PascalCasing and you dont call classes like that
AttributeError: ** module** 'nextcord.user' has no attribute 'display_avatar
bro
bro
youre wrong
THE TRACEBACK IS SAYING IT
class nextcord.Member```
Represents a Discord member to a [`Guild`](https://nextcord.readthedocs.io/en/latest/api.html#nextcord.Guild "nextcord.Guild").
This implements a lot of the functionality of [`User`](https://nextcord.readthedocs.io/en/latest/api.html#nextcord.User "nextcord.User").
x == y Checks if two members are equal. Note that this works with [`User`](https://nextcord.readthedocs.io/en/latest/api.html#nextcord.User "nextcord.User") instances too.
x != y Checks if two members are not equal. Note that this works with [`User`](https://nextcord.readthedocs.io/en/latest/api.html#nextcord.User "nextcord.User") instances too.
hash(x) Returns the member’s hash.
str(x) Returns the member’s name with the discriminator.
No, he’s actually right 
THE FILE IS NAMED USER
you know what i mean right
bro
read the dang error
A maintained fork of Danny's discord.py. Contribute to nextcord/nextcord development by creating an account on GitHub.
well you look at that?
the file is named user
lowercased
not PascalCasing
and he isnt even calling the class
Happy now?
and the error is saying that the file doesnt have that attr
learn oop
bro
don't think what the error says
the error says it
^ Jesus why does this file exist. All these forks went to shit
Member has the attribute display_avatar, he is tryin' to calling that attribute and then calling a method from that attribute
nextcord.user is a module
that's why the error is sayin that
hes not calling the class
nextcord.User is a class from nextcord.user.User
^
which hes trying to call the file
Bro Member is the class, member is the module
where, can you reply to it
thats what im trying to say
what is so hard? do you notice the capital letter?
mobile is being an ass as usual
bro
you dont see that
you said it was the class when you can see its not PascalCasing
do you need that i find you the display_avatar attribute?
That too. But look a line under it, they must have from nextcord import user’d it in.. so the name user is occupied by that imported module. That means there’s actually two errors in the code, and you all can calm down 😄
Hey!!, I made a discord bot a while ago , its name is DSA-bot which basically sends DSA codes in 3 different languages along with some other commands.
This bot is opensource and currently under development , it encourages opensource contribution so if you are interested in contributing here's the link:
https://github.com/Bhuvnesh875/DSA-Bot/blob/main/Contributing.md
You can add the bot to your server via link given in readme. pls do checkout once!
nextcord.member is a module
nextcord.Member is a class (shortcut)
nextcord.member.Member is a class
This is what i'm sayin' lol
what im trying to say
but you guys think hes calling the class when hes not
That’s right, and also one line down, because there’s no variable called user in that function even, so Python chooses the nextcord.user module 🤷♂️
Anyway, this is becoming too hostile imo
ok example time:
i have two classes, an asset class and an user class, they are both in the same module and one attribute of the user class is an attribute of the asset class:
import asset
class User(object):
def __init__(self, id, name, display_avatar: asset):
self.id = id
self.name = name
self.display_avatar = display_avatar()
What the guy is tryin to do is this:
import User
print(User.display_avatar)
yes but hes calling the module
hes doing
filename.attr
Class.attr
when hes supposed to do
bruh i am so confused
he is supposed to have an object to call that method
sure
then why are you guys saying hes calling the class?
img = Image.open("base.png")
font = ImageFont.truetype("arial.ttf",40)
draw = ImageDraw.Draw(img)
nextcord.Member.display_avatar.replace(format="png", size=2048).url
data = user.display_avatar.with_format("PNG")
avatar_data = BytesIO(await data.read())
pfp = Image.open(data)
pfp.resize((177,177))
text =f"{message}"
textname =f"{ctx.author}"
draw.text((0,150), text, (255,255,250), font=font)
draw.text((0,1030), textname, (0,0,0), font=font)
img.paste(pfp, (50,500))
img.save("sus.png")
await ctx.send(file = nextcord.File("sus.png"))
still not solving his error
lol
learn oop
nextcord.Member.display_avatar
You have to ask yourself, though, which user’s avatar are you getting exactly
File takes two arguments
cant sift can do it and i dont have time
it's ctx.author.display_avatar
look, i'm so tired of arguin that i'll explain you simple, you need a member object to use the display_avatar attribute, you have a member object in your context so you can do ctx.author.display_avatar
you cant use a class, you have to use an instance of it
yeah because you argue with nothing to back your statements
bro an object is an instance of a class
ik that? hes not even calling an instance hes calling the file?
he is not using an instance, he is using the class
🗿
AttributeError: MODULE 'nextcord.user' has no attribute 'display_avatar
🗿
that work now i have a new error: TypeError: a bytes-like object is required, not 'coroutine'
yall gotta be playing with me now👁️👁️
an istance is this:
class User(object):
def __init__(self, id, name):
self.id = id
self.name = name
user = User(1, "abc") # istance of the User class
where is the error?
im not sure why youre explaining it when you yourself dont know what hes calling
TypeError: a bytes-like object is required, not 'coroutine'
i know it perfectly, it is you that are focussed on what the error is sayin' insteand of thinkin' what the error is reportin'
what is the code that raise this error? .-.
Classes automatically inherit object in newer versions of python
img = Image.open("base.png")
font = ImageFont.truetype("arial.ttf",40)
draw = ImageDraw.Draw(img)
ctx.author.display_avatar.replace(format="png", size=2048).url
data = ctx.author.display_avatar.with_format("png")
avatar_data = BytesIO(await data.read())
pfp = Image.open(data)
pfp.resize((177,177))
text =f"{message}"
textname =f"{ctx.author}"
draw.text((0,150), text, (255,255,250), font=font)
draw.text((0,1030), textname, (0,0,0), font=font)
img.paste(pfp, (50,500))
img.save("sus.png")
await ctx.send(file = nextcord.File("sus.png"))
the error is saying it all the file doesnt have such an attr seems like you dont since a file doesnt have the attr but the class does those are 2 different things
i know xD
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
Yes because the python intherpreter is searchin' a function because when he doesn't have an object it try to search for a function, python interpreter calls "function" "module", and search function inside folders, but he didn't want to call a function, he want to call a method and methods are class functions
it is clear to you?
dont need it nor want to read it
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
i repeat it once again, you don't have to focus on what the error is saying, you have to think what the error is reporting in base of your code
bro im not stuck at all you barely can read a attr error? like pls move on
best advice dont listen to your interpreter
🍿 I should be sleeping, but this is great
i want to die right now for what i'm reading
its clear bro
Lol
Guys, please can you stop arguing about this. Drop the subject and move onto DiscordBot related convo
yes thank you
those kinda comments aren't appropriate
😟
Anyways, does disnake, nextcord, etc. support the new Discord modals?
I've not had a look yet
they seem cool
yes
time to go read
ty ty!
yw
what do modals do?
its just like google docs lol
oh
cool
with string input you can do a lot of things xD
maybe they will add them one day
that would be pretty cool.
oh thats garbage
can you add imgs to them?
i havent seen modals with attachments so i assume they didnt have them
yeah but i mean like attachments and not components so imgs videos etc
no bro
bro what?
they gotta fix slash command permissions first, dont forget
atleast a background img
the what?
dont forget how screwed up it is
slash commands bypass channel overwrites
meaning if the bot doesnt have access to a specific channel, you can still use its slash commands there
ask discord
yeah since its application commands
limits
how can i find the error of an code when the traceback doesnt show which line the error is in?
most tbs do
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\client.py", line 414, in _run_event
await coro(*args, **kwargs)
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\client.py", line 1864, in on_connect
await self.rollout_application_commands()
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\client.py", line 1894, in rollout_application_commands
await self.deploy_application_commands(
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\client.py", line 1808, in deploy_application_commands
await self._connection.deploy_application_commands(data=data, guild_id=None, associate_known=associate_known,
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\state.py", line 607, in deploy_application_commands
await self.register_application_command(app_cmd, guild_id)
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\state.py", line 751, in register_application_command
raw_response = await self.http.upsert_global_command(self.application_id, payload)
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\http.py", line 335, in request
raise HTTPException(response, data)
nextcord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In description: This field is required```
i tried fixing it by adding all the descriptions but still, this pops up
well the error says it all
i keep checking everything has a description but it still occurs
you should check pins
theres embed limits their
same its like cleaner and everyone knows the prefix unlike bots that have unique prefixes
its for a slash cmd, not in embed
so i might hav passed the limit on the descriptions
which take like 5 seconds to appear on mobile phones
its just example you dont know the prefix of a bot whats the first thing you would do ofc slash commands
your nokia man😔
shutup avg windows user
alright, ill check the embeds
you made a slash or application command but did not enter a description for that
just remove windows completely
be a chad
bro linux cant run the games i like smh
only use windows because of gaming reasons
might suspect this is the cause
yandere = Embed(color=0xFFC0CB)
yandere.set_image(url=yandere_api['file_url'])
yandere.set_footer(text="Fetched from Yande.re")```
and some cmds has something like this
it is required for all the libraries, disnake defaults the description to \u200b if no description is provided
yeah so it wont scream a 400 to you
its from some application command's description py register_application_command raw_response = await self.http.upsert_global_command(self.application_id, payload) read this part of your error
wait, let me try it as it is
pretty good thing to do
nope, nothing wrong with this one as it is
im such a nutjob i dont even make class instances for my embeds i just do everything directly 👁️ 👁️
tried to fix it, error still pops up
told you already, you have some slash command without a description..
how do i get this to post the img and not make it a download?
img = Image.open("base.png")
font = ImageFont.truetype("arial.ttf",40)
draw = ImageDraw.Draw(img)
ctx.author.display_avatar.replace(format="png", size=2048).url
data = ctx.author.display_avatar.with_format("png")
avatar_data = BytesIO(await data.read())
pfp = Image.open(data)
pfp.resize((177,177))
text =f"{message}"
textname =f"{ctx.author}"
draw.text((0,150), text, (255,255,250), font=font)
draw.text((0,1030), textname, (0,0,0), font=font)
img.paste(pfp, (50,500))
img.save("sus.png")
await ctx.send(file = nextcord.File("sus.png"))
error: TypeError: a bytes-like object is required, not 'coroutine'
get a link of the attachment and embed it yourself 
so just make it say the link to the img?

youre sus
oh god
alright
amogus
oh goodness, stop pinging me for lame reasons
my my, oki sure, now can you PLEASE fucking stop
not funny
you arent
not funny
!ot
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
not funny

lol Ares-
what
you're cute||r than hunter||
no u
!ot I'll just ot that
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
!d discord.User.mentioned_in
mentioned_in(message)```
Checks if the user is mentioned in the specified message.
or, you can check if Bot.user in Message.mentions
if mentioned_in(message)
How do I tell it
So if the bot mentioned?!
Client.mentioned_in?
Client.user.mentioned_in
ty
bad
it also triggers in @everyone mention
https://github.com/Rapptz/discord.py/blob/master/discord/user.py#L277 but it does basically the same
discord/user.py line 277
return any(user.id == self.id for user in message.mentions)```
Hello
so ive made a command that creates a role, and then edits the role permissions, like so:
role = await server.create_role(name = 'Moderator', colour = discord.Colour.brand_red())
await role.edit(permissions = discord.Permissions.ban_members)
await role.edit(permissions = discord.Permissions.manage_messages)
await role.edit(permissions = discord.Permissions.manage_guild)
await role.edit(permissions = discord.Permissions.manage_emojis_and_stickers)```
It creates the role, however while adding the perms, it gives me this error:
```discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'flag_value' object has no attribute 'value'```
Can anyone tell me how to make a discord bot online
how do fix this?
you mean 24/7 online?
Yed
use a hosting service
VPS
But I forget how to make online
@glass hill
you need to do like
perms = discord.Permissions()
perms.ban_members = True
await role.edit(permissions = perms)
``` for example
oh ok
@bot.command(name="ping".lower())will this work?
img = Image.open("base.png")
font = ImageFont.truetype("arial.ttf",40)
draw = ImageDraw.Draw(img)
ctx.author.display_avatar.replace(format="png", size=2048).url
data = ctx.author.display_avatar.with_format("png")
avatar_data = BytesIO(await data.read())
pfp = Image.open(data)
pfp.resize((177,177))
text =f"{message}"
textname =f"{ctx.author}"
draw.text((0,150), text, (255,255,250), font=font)
draw.text((0,1030), textname, (0,0,0), font=font)
img.paste(pfp, (50,500))
img.save("sus.png")
await ctx.send(file = nextcord.File("sus.png"))
error: TypeError: a bytes-like object is required, not 'coroutine'
Sure
rude
lmao
Hunter, is that even required ;-;
-> Run your PIL commands in an executor
-> Enclose await data.read() in a set of brackets (don't worry, it won't convert to a tuple unless you add a leading comma)
i have the await data.read()
in avatar_data = BytesIO(await data.read())
BytesIO((await data.read()))
how do i make a event for when the bot joins a new guild
on_guild_join
No, but he asked it and I just gave him an answer ¯_(ツ)_/¯
Why do people still call parenthesis brackets.
because we’re not americans
What do you call [] then
square brackets
{} ?
Yes
Braces right?
Curly brackets
americans arent very good at colonising (vietnam) hence why we dont call them parentheses
nope
Idk then. I was taught as a non-American.
() - Parenthesis
[] - Brackets
{} - Braces
sorry for the ot mods
america mustve colonised wherever you live ¯_(ツ)_/¯
!pesta
>pesta
hence, the nickname
Where do I put this?
In the on_message
any examples?
what exactly you want to achieve
.
d! disnake.ext.commands.when_mentioned_or
!d disnake.ext.commands.when_mentioned_or

if your goal is for the bot to answer when mentioned
!d disnake.ext.commands.when_mentioned_or
bot ded
!d disnake.Member.mentioned_in use this instead
mentioned_in(message)```
Whether the member is mentioned in the specified message.
when mentioned or > because it can work both when @ or prefix
Bro, it's for command_prefix arg. They simply wanna check if the bot is mentioned
and if it is what? what you gonna do? say hi ?
I mean, it depends on them...
im sure most of people look for "bot was mentioned in message" only for sending a message with the "my prefix is" shit
Indeed
Cannot blame them, since that is what most people do to see the bot's prefix
true
Not every server gives the perms to change nicknames to the everyone role
yea but not every servers gives that permission

i have my bot's default prefix in the username itself
Imagine having a status
¯_(ツ)_/¯
but pinging the bot owner in support server asking "whats the prefix" is more fun
And getting muted for not reading the FAQs is even funner
who stays in those servers anyways
just make the activity the help command
just set the prefix to None
U mean ""
yems
That isn't considered good tbh
it all narrows down to personal preference ¯_(ツ)_/¯
yes ma'am
smh
I still didn't get my answer?
what do you need?
Bro we told u
there are examples everywhere on the internet
I need your examples
async def on_message(msg):
if msg.guild.me.mentioned_in(msg):
await msg.channel.send("Hiiiii")
why? .-.
ty
Many are outdated
exactly
the function didn't change .-.
@bot.listen("on_message")
async def spoonfeeding_example(message: discord.Message):
if message.guild.me.mentioned_in(message): return await message.channel.send("Hunter uwu")
hunter uwu always the best example
Do u remember what mina said last night in #ot2-never-nester’s-nightmare? 👀
Yes i do
Okay cool
@client.event
async def on_message(message):
if client.user in message.mentions:
print("Working")
Will this work?
Yes it works
why not both?
supposing on variables he is using discord.Client
Client
Okay then it will work
I was asking him that since using commands.Bot and a message event like that can make the commands stop working
My bot had the client variable when I was using Bot 🥲
How the bot replies to the message sender?
you can use commands with discord.Client too
ctx.reply?
msg.reply
No please noooooo
you don't have a context, you have the message
!d discord.Message.reply
await reply(content=None, **kwargs)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
A shortcut method to [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") to reply to the [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message").
New in version 1.6.
rip
I still don't know the difference
!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.
????
how can i make a message that only the author can see?
I have the same question.
a message is just a message, a context represent the context of a command, precisely the context of the invocation
for example, this is a command, the bot as first argument takes the context which contains meta data of that invokation, like the command i used, the author of the command, the guild and the channel and so go on
U need to use slash commands or message/user commands or buttons for that
only interactions can be private
otherwise, use dms
which is not recommend ofc
Oh sorry, I have to learn English first -_-
.-.
sad translator noises
smh
Smh
rules
what's the different between print and PRINT
ty:)
Also, #python-discussion for these types of question
import asyncio
async def PRINT(text):
return print(text)
asyncio.get_event_loop().run_until_complete(PRINT("Hunter uwu"))
like this?
dont blame me
why are you always using hunter for your code examples? 
I have my reasons
Same, I also wanna know
no I did respones =
And this means, It's used before
And I remembered that PRINT and print are different
so I used RESPONSES
BTW, PEP 8 says that u use all caps only for constants
what are constants?
...
sorry
just what I expected
CONSTANT1 = "Some String"
I'm new to programming
Something that won't change throughout the code/program
I call this a string var
before you get to learnin discord.py you should know python first D_D
def PRINT():
x = "guh"
print(x)
PRINT()

Want to hear something crazy?
lmaoo
same-
#python-discussion please
Hello, HELLO
which language? xD
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
then you should know what a constant is, is nearly impossible that you didn't use them
ok
chill
And I still don't know some basic shit
Variables that don’t change in the programs life cycle
i am very chill thank you
this isn't JS lol
💀
7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.
!ot
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
#python-discussion please
discord
#my-bad...
....
i was thinking
don't
someone can use pillow to manipulate a spin the wheel gif to a random outcome
would be cool for a command
custom options
you probably can
im too lazy to code it but there's an idea for you
i way too busy coding my website lol
Bros, #python-discussion exists
so ive got this code, which makes the bot reply when pinged. I dont want it to respond to reply pings tho. how can i do that?
@client.event
async def on_message(message):
pcol = mdb["prefix"]
if client.user.mentioned_in(message) and message.mention_everyone is False:
result = pcol.find_one({"guild_id": message.guild.id})
result = result.get("prefix")
await message.channel.send(f"My prefix is ``{result[0]}``")
elif client.user.mentioned_in(message) and message.mention_everyone is False:
await message.channel.send(f"My prefix is ``!``")
await client.process_commands(message)```
!d discord.Message.reference
@client.event
async def on_message(message):
RESPONSES = ["Don't mention me!", "Stop mentioning me!", "I won't repeat it, DON'T MENTION ME!!!", ]
if client.user in message.mentions:
message.reply(f'{random.choice(RESPONSES)}')
I know this is a stupid question, And I know I don't have to use random library but, How do I make it so those responses count as a warning? So on the last warning it mutes the user?
The message that this message references. This is only applicable to messages of type MessageType.pins_add, crossposted messages created by a followed channel integration, or message replies.
New in version 1.5.
we were talking about discord rn wdym
Pillow
I never used it wdym
can we see error message?
oh
like all image commands are made like that, like dank memer tweet command
and all the filter and stuff
okay yea ik
anyone wanna answer my question? :'(
do you think pillow is the only lib that handles image processing? 
its the easiest
and quickest
can you both take this to #python-discussion please
is there a way to make discord not convert emoji to discord big emojis?
checkout the timeout function, and store the number of warns in a db, check everytime db updates for the warning and compare with the mute value, if it crosses the limit timeout them
you're being really annoying rn
have like small ones
How would I disable this?
please stop this is quite annoying already, and you don't want to be that kind of person
^
i didnt quite get the solution. do i put message.reference is False??
remove the default help command
or should i get the author of the message that it references?
Oh cool I’ll look that up, I must have looked up the wrong thing
Thx ares
def circle(pfp,size = (215,215)):
pfp = pfp.resize(size, Image.ANTIALIAS).convert("RGBA")
bigsize = (pfp.size[0] * 3, pfp.size[1] * 3)
mask = Image.new('L', bigsize, 0)
draw = ImageDraw.Draw(mask)
draw.ellipse((0, 0) + bigsize, fill=255)
mask = mask.resize(pfp.size, Image.ANTIALIAS)
mask = ImageChops.darker(mask, pfp.split()[-1])
pfp.putalpha(mask)
return pfp
#say
@client.command()
async def say(ctx, *, message=None):
if message==None:
return await ctx.send('You must tell me a message to say!')
else:
await ctx.message.delete()
img = Image.open("base.png")
font = ImageFont.truetype("arial.ttf",40)
draw = ImageDraw.Draw(img)
ctx.author.display_avatar.replace(format="png", size=2048).url
data = ctx.author.display_avatar.with_format("png")
avatar_data = BytesIO(await data.read())
pfp = Image.open(data)
pfp.resize((177,177))
BytesIO(data.save("data.png"))
text =f"{message}"
textname =f"{ctx.author}"
draw.text((0,150), text, (255,255,250), font=font)
draw.text((0,1030), textname, (0,0,0), font=font)
img.paste(pfp, (50,500))
img.save("sus.png")
error: TypeError: a bytes-like object is required, not 'coroutine'
Have u looked up th error?
yea iirc
@maiden fable pillow being used in a discord command
lol
alright
yeah
because it is the most popular (:
Nothing? I looked it up and got basically the same error
!pypi wand also exists
Smh I will just go out
Not the same error but same idea https://stackoverflow.com/questions/33054527/typeerror-a-bytes-like-object-is-required-not-str-when-writing-to-a-file-in
lol
Maybe idk
hi
This might help
who u
🤨
:D
Who are you?!?
@client.event
async def on_message(message):
if "who asked" in message:
message.reply("Your Mom?")
!ot
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
!pypi scikit-image
plz tell me it will work
that happens when u do function(ctx.author.avatar.read()) instead of function(await ctx.author.avatar.read())
pretty shit library
ok
Bruh are u being serious
:)
Please tell me it works
message.content
!d message,send
no thats not how it works
....whats happening here
idk
in the line where it has py bot = discord.Bot(command_prefix="!", help_command=None) do this
ok
Idk welcome to #discord-bots
!d discord.message.content
a shit lib don't have almost 5k starts on git lmao
it was able nvm
channel being in its usual form
its quite limited when compared to pillow
rip my memory
!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**.
it was the other way round what the-
why is that called that
and then make a custom help command @supple crescent
abc means abstract class
ohh
Oh alright, thanks!
interesting
its the initial alphabet
welcome
its message.content("who asked")
That too, but meh
and await message.send()
its the same error
lol anyways, any api recommendations for a bot? I'm out of ideas
avatar_data = BytesIO(ctx.author.avatar.read())
API rec for a bot? Like what API's
pokemon api
avatar_data = BytesIO(await ctx.author.avatar.read())
do your own api for a website 
any REST API will work
What was the addon that showed u the error line even if it was in your libraries? It had text in it but I forgor 💀
nah, I'm too lazy-
im making an api too for some generative art
Idk, there are many. Some Random API, OpenAI API, and thousands more 🤷
it works
that i made
HunAI uses a private API I made, anyways
damn nice
already used random api-
thanks though
flex
¯_(ツ)_/¯
its the same
open ai is very nice
avatar_data = BytesIO((await ctx.author.avatar.read()))
How do I make it so, If the message looks like who asked ...
same error
Do I need to hack google, Or it's easy?
show
TypeError: a bytes-like object is required, not 'coroutine'
Press a not 4 easy fix no need to thank me
you can work with a weather api, it's pretty easy, and useful sometimes 
show your code of that line
you want the bot to reply when some user says "who asked"?
uhh yeah I thought of that, will do, thanx you at least you are helpful than hunter
Oooh dramaaaaaa
?
no one cares ¯_(ツ)_/¯
huh?
were can i find the resroces page
Ignore my shitposting scarstic replies
elaborate the issue
see who's talking
Smh can we just ignore it? @slate swan @supple crescent
lmao
its hunter, wait you didnt knew, you blind?
Wrong Goff
Please stop it
ctx.author.display_avatar.replace(format="png", size=2048).url
data = ctx.author.display_avatar.with_format("png")
avatar_data = BytesIO((await ctx.author.avatar.read()))
pfp = Image.open(data)```
Gif
smh
Okay, I tried to troll my friend by replying to who asked but he sent 4ho asked and the bot didn't reply, How do I fix it so if the message looks like who asked reply
its alright you are fellow brother who plays tf2 in 2022
Yesir!
mind helping him? @slate swan
well if the friend says 4ho asked it wont reply unless its who asked
Yes!
And he will bypass it everytime
we will keep it alive dont worry
So how do I make it, So he never bypasses it?
🤝
Do “who asked” or “who 4asked”
Idk ur code tho
you want the bot to reply if your friend says who asked and 4ho asked with the same reply?
That might or might not work
what if he says whooo asked or wh0 askeddd
@client.event
async def on_message(message):
if "who asked" in message.content:
await message.reply("Your Mom?")
hmmmm well the bot will ignore it
Yes, And we need all the possibilities
Great!
yes then you gotta add every possibility into it, i dont think so its anyway to add any possibilities like it can be anything
who asked
4ho asked
who askeed, etc
Yeah that’s what I was gonna say
That's why bots are made, I want the bot to see the possibilities it self
hmmm i dont think its possible try to make a help channel and see if anyone helps you
You could try and make something with this tho
Set it up with the basic who asked and it might find who asked inside the wwwwwho askedddd
I mean I could but you can do it, cant you?
you can just use if message.content("asked") so bot replies with the same thing even if your friend do 4whoblahblah asked
Just an idea tho
That’s a good point
yep thanks
you open avatar_data since its a byte object, you dont open assets like that
i mean that's not even a "project" there are several ways to do that and it takes just few lines
but, This isn't my answer
oh
what if he says assked
or 4sk3d
or AskEd
try ("asked", "4ask3d",.......)
Well for that one there is a way to nullify caps but idk abt the other ones
omg no!
i would rather make that the bot replies to those who says "who asked" with "I asked"
i still get the same error: TypeError: a bytes-like object is required, not 'coroutine'
Okay I will do that, But
WHAT IF SOMEONE SAYS WHHHOOO ASKEEEED OR WH0 ASK3D
OR ALL THE POSSIBILITIES
alr taken that
treat your bot/code as kid you gotta teach it all possibilities
Whats the purpose of bots tho?
or you can do is just write in a txt file and then use it
like a txt file with all the "asked" "a4sked". etc
you could probably use regex
to make you rich if you got premium
Yes I've thought about that
And I don't know shit about it
Please someone help me
there is only solution you gotta make your bot to know every possibility and for that you gotta write them
How should I know all the possibilities
just use the message.content("asked" or "a4ked")
It has more than 1mil possibilites
then add a new possibility when you find one
yezz thats the problem
ez
damnnn
-_- what's the purpose of it
nothing
Why everyone is being dumb?
you are talking dumb.......
you said what if it is "4sked" "3asked" 2asked
sorry my bad
so thats the solution
you gotta add possibilities by your self
dont expect any way for a 4 line code to know millions of possibilities
lol
k
who asked how do I make this case_insensitive
So if it's Who Asked or who asked Or whatever
.lower() it
if message.content in []:
. . .
when in doubt, .lower() will help you out
how will it help tho?
😉
it makes the entire string lowercase
It’ll convert the given string to lowercase
So you can compare without worrying about case
@client.event
async def on_message(message):
if "who asked" in message.content:
How will I do it for this one?
message.content.lower()
@client.event
async def on_message(message):
if "who asked" in str(message.content).lower():
await message.channel.send('I asked.')```
if someone said wHO aSkED it would still match
Robin please help
What about who 4sked
won't work
i don't have a solutuon but i may have a solution
use regex or smth
idk why people here keep suggesting regex for stuff like this
i made a filter that works way better so no regex for me
Not much we can do about that either
I don't know shit about regex man
Then learn regex it's very powerful
Maybe there’s a library to convert leetspeech into English
👋
no ty <3
Since this could be considered leetspeak
🙂
py -m pip install translate
-_-
I never use py -m
I just do pip install