#discord-bots

1 messages · Page 848 of 1

sick birch
#

If you want to pick a random link from a list of random links you find in a text file, where do you put the text file?

echo wasp
#

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

sick birch
#

Well no since it has to be it's own thing, the

async with aiofiles.open(...) as f:
  ...
shrewd inlet
#

hm?

sick birch
#

Do you think that goes before or after random.choice()?

balmy ivy
#

how could i fix this

sick birch
#

Exactly

#

The start of the command would be a good place to do it

shrewd inlet
#

alright

small igloo
echo wasp
small igloo
sick birch
#
@commands.command(...)
async def myCommand(...):
  async with aiofiles.open(...) as f :
    ...
  ...
shrewd inlet
#

oh wait THATS JUST A PLACEHOLDER

sick birch
#

No, that's just pseudo-code

shrewd inlet
#

😂

sick birch
#

Yep, only meant to nudge you in the right direction

torn sail
#

Yep but consider using is not instead of !=

small igloo
shrewd inlet
small igloo
shrewd inlet
#

maybe the indentation is wrong?

quick gust
torn sail
sick birch
sick birch
#
async with aiofiles.open('/path/to/file', mode='r') as f:
  contents = await f.read()
quick gust
#

aiofiles.open("path/to/file", mode). w if you wanna write or r if u wanna read

#

there are others too i forgot

shrewd inlet
#

ohhh

shrewd inlet
small igloo
shrewd inlet
quick gust
unkempt canyonBOT
#

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

shrewd inlet
shrewd inlet
small igloo
quick gust
#

you need to indent everything after your function properly

#

embed.set_image() and send() are not indented

shrewd inlet
#

i indented it but now the code after that is red

quick gust
#

what did I say?

shrewd inlet
#

oh wait send isn’t indented

quick gust
#

send() isnt properly indented

#

it is only spaced once

shrewd inlet
#

fixed it but now i’m getting that error

#

i also imported aiofiles because i also got an error, but fixed it afterwards

spring flax
#

Anyone knows pufferpannel?

quick gust
shrewd inlet
shrewd inlet
quick gust
# shrewd inlet

you also dont copy paste what robin gave, you need to actually give it a valid file path

quick gust
sick birch
#

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

shrewd inlet
sick birch
#

Then split by newlines

#
"file contents".split("\n")
#

> list of strings, each item is one line

shrewd inlet
#

alright

steel void
#

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:
slate swan
#
async def foo(ctx, member: pycord.Member):
  bot = False
  if member.bot: bot=True
alpine furnace
#

@slate swan Hey, it’s discord mod from the English server, I don’t meme nearly as much outside of there

slate swan
#

oh wait

#

the name xD

alpine furnace
#

I was literally in the chat and you pinged me

slate swan
#

lol sorry

spring flax
#

Just asking again, anyone here has any knowledge of using puffer pannel for a dpy bot?

slate swan
#

wait, thatsa software, how can you dpy it

spring flax
slate swan
spring flax
#

I downloaded one from github but dont know how to put it to puffer panel

#

That's not for templates

alpine furnace
#

The first section. You just need to place your template’s json into that directory

echo wasp
#

Anything on my issue?

slate swan
echo wasp
slate swan
echo wasp
# slate swan 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

echo wasp
#

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

slate swan
echo wasp
#

Just in the same folder 📂 with 2 different start files and cogs folders

slate swan
#

🏃

slate swan
#

since okimii is here

echo wasp
slate swan
#

ha no

#

still havent finished🏃

echo wasp
#

Huh?

alpine furnace
slate swan
alpine furnace
echo wasp
echo wasp
#

Files sure code no

alpine furnace
slate swan
alpine furnace
#

No

slate swan
#

yes

alpine furnace
#

Just run them in different asyncio tasks

#

How else would you run multiple bots at once

slate swan
#

the discord api ratelimits ips

alpine furnace
#

🤷‍♂️

echo wasp
#

Here

alpine furnace
#

Same thing as running two bots independently then

slate swan
alpine furnace
# echo wasp

You’d have peace of mind if you put everything into a cogs module

slate swan
#

lol

alpine furnace
#

Then you can glob that cogs module for your cogs and load them, in your main file

alpine furnace
#

Think the discord rate limits are per bot token

#

Or user token

slate swan
#

im sure its ips

#

how else do replit users get ratelimited

alpine furnace
#

Just checked docs

alpine furnace
slate swan
#

yes

#

which if the ip gets ratelimited the bots get a 429

loud hedge
#

How do a command /say in bot?

slate swan
#

a slashcommand that echos?

loud hedge
#

Mmm yes

slate swan
#

just make a slash command with a kwarg

loud hedge
#

Example: /say (message) = bot:(message)

alpine furnace
alpine furnace
slate swan
alpine furnace
# slate swan ?

I’m not denying that ip rate limits exist, I’m saying that they’re on cloudflare

echo wasp
alpine furnace
#

Not the actual discord api

alpine furnace
#

Which, on repl.it, 10k requests per 10 minutes is nothing considering the amount of selfbot spammers and discord bot devs on there

alpine furnace
slate swan
slate swan
acoustic sleet
#

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

alpine furnace
#

You need to wait a bit, or use a proxy

placid skiff
acoustic sleet
acoustic sleet
alpine furnace
#

You are better off using a proxy, or a vps to host, somewhere that you have your own ip

acoustic sleet
brittle axle
alpine furnace
#

Unfortunately repl.it doesn’t give you your own ip so you have to share with spammers

acoustic sleet
quick gust
#

Yeah, because replit uses shared IPs. So if someone else gets API banned from discord, it's likely you will aswell.

acoustic sleet
#

thx

acoustic sleet
brittle axle
alpine furnace
#

Maybe the rate limit expired kekw

acoustic sleet
brittle axle
brittle axle
#

i didnt dive that deep into the command

alpine furnace
#

It says 10 minutes in the docs

brittle axle
acoustic sleet
acoustic sleet
alpine furnace
#

Maybe you’re lucky 🤷‍♂️

brittle axle
#

but for me when mine was temp banned from the api for too many requests it took a ton of hours

acoustic sleet
#

i just came online a few mins ago and noticed

brittle axle
#

i just runned this command and it solved everything

acoustic sleet
#

o lol

alpine furnace
#

Or maybe it just spins up the container on a new node, not sure, either way it’s good it’s working now

karmic tartan
#

I’m relearning python after a longtime and just discovered discord.py is dead, what are the alternatives?

alpine furnace
#

Pycord is by far the most popular

acoustic sleet
karmic tartan
#

Alright thx

alpine furnace
#

It’s dead, but it works, and will work for a while for small bots

karmic tartan
acoustic sleet
#

I didn't know that. Thanks, I'll switch my bot to one of the alternatives

karmic tartan
alpine furnace
#

Pycord is a drop in replacement

#

It is a fork yea

karmic tartan
#

All 4 or just pycord?

alpine furnace
#

All of them are forks, pycord is a drop in replacement

karmic tartan
#

Ah ok, thanks

alpine furnace
#

Last I checked nextcord doesn’t support slash commands without some other crappy third-party interactions module.. couldn’t work with that ever

karmic tartan
#

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

acoustic sleet
#

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

karmic tartan
alpine furnace
#

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

brittle axle
#

since it is available

#

pycord is still in development

alpine furnace
#

Oh yeah, how are you enjoying that discord-interactions crap?

alpine furnace
#

I swear, the dev had like 3 different websites all with zero docs

brittle axle
alpine furnace
#

Or confusing ones at best

#

Yeah, nextcord itself is good, just that interactions module I dislike

brittle axle
#

oh ok

karmic tartan
#

Btw since these things are so new, is it possible to find good tutorials and how to use them properly?

brittle axle
karmic tartan
#

I think I’ll prolly use pycord tbh, but if I do I’ll try and remember the name lmao

alpine furnace
karmic tartan
#

Alright awesome

acoustic sleet
alpine furnace
#

Even keeps the package name the same it’s just import discord

karmic tartan
#

Glad I can use old tutorials then lmao

#

Oh good, that was like the one thing that i remembered lmao

acoustic sleet
alpine furnace
#

Lol

#

Nope, that’s only if you install pycord

acoustic sleet
#

ah

karmic tartan
#

Yeah wouldn’t you need to like actually install it to import the libraries lmao

slate swan
brittle axle
acoustic sleet
#

oh

#

how do i uninstall it? do i have to go to the folder or can i just use a command in terminal

placid skiff
#

pip uninstall <package_name>

brittle axle
#

and click the trash can button

#

and then search for pycord

#

and then install

acoustic sleet
#

oh ok, thx

placid skiff
#

wait is he usin' replit? lol
😀 🔫

brittle axle
acoustic sleet
lyric tusk
#
    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'

placid skiff
#

You are calling the class Member, you don't have any member object

lyric tusk
#

can i use user

placid skiff
#

depends what user is

#

and you have a context too, from the context you can retrieve informations

lyric tusk
#

i got that when i just user

#

AttributeError: module 'nextcord.user' has no attribute 'display_avatar

placid skiff
#

bro using nextcord.Member or nextcord.User you are just calling the class

placid skiff
#

essentially, you are doin this:

class User():
  def __init__(self, id, name):
    self.id = id
    self.name = name

User.name
placid skiff
#

User is just a class, it is not an object

slate swan
#

calling it is as so User() the error says it all

placid skiff
slate swan
#

guys no

#

its not the class

#

module

#

its the file

unkempt canyonBOT
#

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.
slate swan
#

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

unkempt canyonBOT
#

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.
alpine furnace
#

No, he’s actually right thonk

slate swan
#

THE FILE IS NAMED USER

slate swan
#

bro

slate swan
#

well you look at that?

#

the file is named user

#

lowercased

#

not PascalCasing

#

and he isnt even calling the class

slate swan
#

and the error is saying that the file doesnt have that attr

slate swan
#

bro

placid skiff
slate swan
#

the error says it

alpine furnace
placid skiff
#

Member has the attribute display_avatar, he is tryin' to calling that attribute and then calling a method from that attribute

heavy folio
#

nextcord.user is a module

placid skiff
#

that's why the error is sayin that

heavy folio
#

nextcord.User is a class from nextcord.user.User

slate swan
#

which hes trying to call the file

placid skiff
heavy folio
#

where, can you reply to it

slate swan
placid skiff
#

what is so hard? do you notice the capital letter?

heavy folio
#

mobile is being an ass as usual

slate swan
#

bro

slate swan
#

you said it was the class when you can see its not PascalCasing

placid skiff
alpine furnace
#

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 😄

dry widget
#

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!

GitHub

A discord bot which provide code to learn DSA along with having fun! - DSA-Bot/Contributing.md at main · Bhuvnesh875/DSA-Bot

heavy folio
slate swan
#

but you guys think hes calling the class when hes not

heavy folio
#

where

#

send the message link

slate swan
#

^

#

smh you guys start arguments that dont even make sense

#

its obvious

#

yes

alpine furnace
#

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

placid skiff
# slate swan what im trying to say

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)
slate swan
#

yes but hes calling the module

#

hes doing

filename.attr
#
Class.attr

when hes supposed to do

lyric tusk
#

bruh i am so confused

placid skiff
#

he is supposed to have an object to call that method

lyric tusk
#

sure

slate swan
lyric tusk
#
    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"))


slate swan
#

still not solving his error

alpine furnace
#

lol

alpine furnace
boreal ravine
slate swan
#

cant sift can do it and i dont have time

boreal ravine
placid skiff
# lyric tusk bruh i am so confused

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

heavy folio
#

you cant use a class, you have to use an instance of it

slate swan
#

yeah because you argue with nothing to back your statements

placid skiff
slate swan
placid skiff
#

he is not using an instance, he is using the class

slate swan
#

🗿

heavy folio
#

whatever it is

#

use an instance of a class, not a class

slate swan
#

🗿

lyric tusk
slate swan
placid skiff
#

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
slate swan
lyric tusk
placid skiff
#

i know it perfectly, it is you that are focussed on what the error is sayin' insteand of thinkin' what the error is reportin'

placid skiff
boreal ravine
lyric tusk
# placid skiff what is the code that raise this error? .-.
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"))
slate swan
slate swan
#

bro you know a member obj is a class right?

#

bro what

unkempt canyonBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

placid skiff
#

it is clear to you?

slate swan
#

dont need it nor want to read it

unkempt canyonBOT
placid skiff
#

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

slate swan
#

bro im not stuck at all you barely can read a attr error? like pls move on

#

best advice dont listen to your interpreter

alpine furnace
#

🍿 I should be sleeping, but this is great

placid skiff
slate swan
#

its clear bro

alpine furnace
round kernel
#

Guys, please can you stop arguing about this. Drop the subject and move onto DiscordBot related convo

slate swan
#

yes thank you

round kernel
#

those kinda comments aren't appropriate

placid skiff
#

😟

round kernel
#

Anyways, does disnake, nextcord, etc. support the new Discord modals?

#

I've not had a look yet

#

they seem cool

slate swan
#

yes

round kernel
#

time to go read

slate swan
round kernel
#

ty ty!

slate swan
#

yw

placid skiff
#

what do modals do?

slate swan
#

its just like google docs lol

placid skiff
#

oh

slate swan
#

this is a modal

placid skiff
#

cool

#

with string input you can do a lot of things xD

#

maybe they will add them one day

heavy folio
#

oo

#

checkboxes look good imo

slate swan
#

multibutton selection would be good

#

you can attach components?

round kernel
#

that would be pretty cool.

slate swan
#

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

heavy folio
#

no bro

slate swan
#

bro what?

heavy folio
#

they gotta fix slash command permissions first, dont forget

slate swan
#

atleast a background img

heavy folio
#

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

slate swan
#

smh

#

how is that possible

heavy folio
#

ask discord

slate swan
#

yeah since its application commands

heavy folio
#

limits

brave moth
#

how can i find the error of an code when the traceback doesnt show which line the error is in?

heavy folio
#

it definitely will

#

show your traceback

brave moth
#
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
slate swan
#

well the error says it all

brave moth
slate swan
#

theres embed limits their

#

same its like cleaner and everyone knows the prefix unlike bots that have unique prefixes

brave moth
#

so i might hav passed the limit on the descriptions

slate swan
#

its just example you dont know the prefix of a bot whats the first thing you would do ofc slash commands

slate swan
slate swan
slate swan
#

im not gonna dual boot ok

brave moth
#

alright, ill check the embeds

slate swan
slate swan
#

be a chad

#

bro linux cant run the games i like smh

#

only use windows because of gaming reasons

brave moth
slate swan
#

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

slate swan
brave moth
#

wait, let me try it as it is

slate swan
#

pretty good thing to do

brave moth
slate swan
#

im such a nutjob i dont even make class instances for my embeds i just do everything directly 👁️ 👁️

brave moth
#

tried to fix it, error still pops up

slate swan
supple crescent
#

how do i get this to post the img and not make it a download?

lyric tusk
#
    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'

slate swan
supple crescent
hoary cargo
slate swan
slow fog
#

sus

slate swan
slow fog
slate swan
slow fog
#

you always were sus

slate swan
slow fog
#

not funny

slate swan
slow fog
#

not funny

slate swan
unkempt canyonBOT
slow fog
#

not funny

hoary cargo
slate swan
hoary cargo
slate swan
hoary cargo
#

flushedpoint no u

slate swan
unkempt canyonBOT
stiff anvil
#

How to check for bot mentions?

#

So if the bot is mentioned?

slate swan
#

!d discord.User.mentioned_in

unkempt canyonBOT
slate swan
#

or, you can check if Bot.user in Message.mentions

stiff anvil
#

How do I tell it

#

So if the bot mentioned?!

#

Client.mentioned_in?

visual island
#

Client.user.mentioned_in

stiff anvil
#

ty

boreal ravine
visual island
#

it also triggers in @everyone mention

unkempt canyonBOT
#

discord/user.py line 277

return any(user.id == self.id for user in message.mentions)```
glass hill
#

Hello

valid galleon
#

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'```
glass hill
#

Can anyone tell me how to make a discord bot online

valid galleon
#

how do fix this?

valid galleon
glass hill
valid galleon
#

use a hosting service

austere herald
#

VPS

glass hill
#

But I forget how to make online

valid galleon
#

@glass hill

visual island
left crater
#

@bot.command(name="ping".lower())will this work?

lyric tusk
#
    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'

hoary cargo
slate swan
slate swan
austere herald
lyric tusk
#

in avatar_data = BytesIO(await data.read())

austere herald
#

BytesIO((await data.read()))

frozen elk
#

how do i make a event for when the bot joins a new guild

honest vessel
#

on_guild_join

maiden fable
sage otter
#

Why do people still call parenthesis brackets.

manic wing
sage otter
#

What do you call [] then

manic wing
#

square brackets

sage otter
#

{} ?

maiden fable
#

Yes

sage otter
#

Braces right?

maiden fable
manic wing
#

americans arent very good at colonising (vietnam) hence why we dont call them parentheses

manic wing
sage otter
#

Idk then. I was taught as a non-American.
() - Parenthesis
[] - Brackets
{} - Braces
sorry for the ot mods

manic wing
#

america mustve colonised wherever you live ¯_(ツ)_/¯

frozen elk
#

!pesta

hoary cargo
#

MR_uncanny_10 >pesta

slate swan
stiff anvil
#

Where do I put this?

maiden fable
#

In the on_message

stiff anvil
hoary cargo
#

MR_uncanny_10 what exactly you want to achieve

stiff anvil
hoary cargo
#

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

maiden fable
#

!d disnake.ext.commands.when_mentioned_or

slim ibex
#

bot ded

maiden fable
#

!d disnake.Member.mentioned_in use this instead

unkempt canyonBOT
hoary cargo
maiden fable
#

Bro, it's for command_prefix arg. They simply wanna check if the bot is mentioned

hoary cargo
#

MR_uncanny_1 and if it is what? what you gonna do? say hi ?

maiden fable
#

I mean, it depends on them...

slate swan
#

im sure most of people look for "bot was mentioned in message" only for sending a message with the "my prefix is" shit

maiden fable
#

Indeed

#

Cannot blame them, since that is what most people do to see the bot's prefix

slate swan
#

true

sage otter
#

Quick thinking: change the bots nickname to show prefix.

#

just kidding

maiden fable
#

Not every server gives the perms to change nicknames to the everyone role

slate swan
#

yea but not every servers gives that permission

maiden fable
slate swan
#

i have my bot's default prefix in the username itself

maiden fable
#

Mhm

#

Or just use the About Me

#

but meh pinging bots is easier

slate swan
#

Imagine having a status

maiden fable
#

¯_(ツ)_/¯

slate swan
#

but pinging the bot owner in support server asking "whats the prefix" is more fun

maiden fable
slate swan
#

who stays in those servers anyways

left crater
#

just make the activity the help command

slate swan
#

just set the prefix to None

maiden fable
#

U mean ""

slate swan
maiden fable
#

That isn't considered good tbh

slate swan
#

oh wow, new about me

maiden fable
#

it all narrows down to personal preference ¯_(ツ)_/¯

maiden fable
#

smh

stiff anvil
#

I still didn't get my answer?

placid skiff
#

what do you need?

stiff anvil
#

I need an example

#

of on_message event

#

please?

maiden fable
#

Bro we told u

placid skiff
#

there are examples everywhere on the internet

stiff anvil
#

I need your examples

maiden fable
#
async def on_message(msg):
    if msg.guild.me.mentioned_in(msg):
        await msg.channel.send("Hiiiii")
placid skiff
#

why? .-.

maiden fable
stiff anvil
placid skiff
#

the function didn't change .-.

slate swan
#

hunter uwu always the best example

maiden fable
maiden fable
#

Okay cool

stiff anvil
#
@client.event
async def on_message(message):
    if client.user in message.mentions:
        print("Working")
#

Will this work?

maiden fable
#

Yea

#

Also u using commands.Bot or discord.Client?

stiff anvil
#

Yes it works

slate swan
placid skiff
#

supposing on variables he is using discord.Client

stiff anvil
maiden fable
#

Okay then it will work

maiden fable
# slate swan why not both?

I was asking him that since using commands.Bot and a message event like that can make the commands stop working

slate swan
stiff anvil
#

How the bot replies to the message sender?

placid skiff
#

you can use commands with discord.Client too

stiff anvil
#

ctx.reply?

maiden fable
maiden fable
placid skiff
#

you don't have a context, you have the message

maiden fable
#

!d discord.Message.reply

unkempt canyonBOT
#

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.
slate swan
#

rip

stiff anvil
placid skiff
unkempt canyonBOT
#
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.
stiff anvil
#

????

left crater
#

how can i make a message that only the author can see?

stiff anvil
placid skiff
# placid skiff !d discord.ext.commands.Context

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

maiden fable
#

U need to use slash commands or message/user commands or buttons for that

slate swan
#

otherwise, use dms

#

which is not recommend ofc

stiff anvil
placid skiff
#

.-.

slate swan
stiff anvil
#

We need a translate button

slate swan
#

smh

unkempt canyonBOT
#

6. Do not post unapproved advertising.

maiden fable
#

Smh

hoary cargo
#

MR_uncanny_1 rules

stiff anvil
#

what's the different between print and PRINT

maiden fable
#

print is a function

#

PRINT is nothing, but can become a variable

stiff anvil
#

ty:)

maiden fable
hoary cargo
#

Carrot

slate swan
#

dont blame me

boreal ravine
#

why are you always using hunter for your code examples? lemon_thinking

maiden fable
#

Same, I also wanna know

stiff anvil
#

no I did respones =

#

And this means, It's used before

#

And I remembered that PRINT and print are different

#

so I used RESPONSES

maiden fable
#

BTW, PEP 8 says that u use all caps only for constants

stiff anvil
#

what are constants?

placid skiff
#

...

stiff anvil
#

sorry

slate swan
#

just what I expected

maiden fable
#
CONSTANT1 = "Some String"
stiff anvil
#

I'm new to programming

maiden fable
#

Something that won't change throughout the code/program

stiff anvil
placid skiff
#

before you get to learnin discord.py you should know python first D_D

hoary cargo
stiff anvil
slate swan
stiff anvil
#

I made all those

maiden fable
boreal ravine
placid skiff
stiff anvil
#

All python

hoary cargo
unkempt canyonBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

placid skiff
#

then you should know what a constant is, is nearly impossible that you didn't use them

boreal ravine
#

ok

boreal ravine
stiff anvil
slim ibex
hoary cargo
boreal ravine
slim ibex
#

💀

unkempt canyonBOT
#

7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.

hoary cargo
#

!ot

unkempt canyonBOT
maiden fable
red sundial
#

discord

stiff anvil
#

#my-bad...

slate swan
#

....

red sundial
#

i was thinking

hoary cargo
#

don't

red sundial
#

someone can use pillow to manipulate a spin the wheel gif to a random outcome

#

would be cool for a command

#

custom options

hoary cargo
#

PopcornPepe you probably can

red sundial
#

im too lazy to code it but there's an idea for you

#

i way too busy coding my website lol

maiden fable
valid galleon
#

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)```
stiff anvil
#
@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?

unkempt canyonBOT
#

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.

red sundial
maiden fable
red sundial
#

in a discord command

#

pillow is used very often in discord bots

hoary cargo
#

not really

#

depends what your bot does

maiden fable
stiff anvil
#

I don't have a error message?

#

And that's not what I asked

left crater
#

oh

red sundial
#

and all the filter and stuff

maiden fable
#

okay yea ik

stiff anvil
hoary cargo
maiden fable
slate swan
#

is there a way to make discord not convert emoji to discord big emojis?

red sundial
slate swan
#

no i mean

#

instead of this

#

🟦🟦🟦🟦🟦

red sundial
slate swan
#

have like small ones

supple crescent
#

How would I disable this?

hoary cargo
red sundial
#

^

valid galleon
hoary cargo
slate swan
#

\🟦

#

o you can do that

valid galleon
#

or should i get the author of the message that it references?

supple crescent
#

Thx ares

lyric tusk
#
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'

supple crescent
red sundial
#

lol

valid galleon
lyric tusk
maiden fable
supple crescent
maiden fable
#

!pypi wand also exists

unkempt canyonBOT
#

Ctypes-based simple MagickWand API binding for Python

red sundial
#

wand is good yeah

#

now who's being off topic lol

#

chill a little bit yk

maiden fable
#

Smh I will just go out

supple crescent
# lyric tusk ```py def circle(pfp,size = (215,215)): pfp = pfp.resize(size, Image.AN...
quick gust
supple crescent
#

Maybe idk

red sundial
supple crescent
#

This might help

quick gust
red sundial
quick gust
#

:D

supple crescent
stiff anvil
#
@client.event
async def on_message(message):
    if "who asked" in message:
        message.reply("Your Mom?")
quick gust
unkempt canyonBOT
hoary cargo
unkempt canyonBOT
stiff anvil
#

plz tell me it will work

maiden fable
red sundial
supple crescent
quick gust
quick gust
#

message.content

supple crescent
#

Hope it does

red sundial
quick gust
#

no thats not how it works

slate swan
#

....whats happening here

red sundial
slate swan
quick gust
#

ok

supple crescent
brittle axle
hoary cargo
slate swan
#

it was able nvm

maiden fable
red sundial
slate swan
#

rip my memory

maiden fable
#

!d discord.abc.Messageable.send

unkempt canyonBOT
#

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**.
slate swan
#

it was the other way round what the-

red sundial
slate swan
maiden fable
red sundial
#

ohh

supple crescent
red sundial
#

interesting

slate swan
slate swan
brittle axle
maiden fable
red sundial
#

and await message.send()

maiden fable
#

Which line

#

please send that line only

slate swan
lyric tusk
maiden fable
maiden fable
hoary cargo
slate swan
supple crescent
#

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 💀

slate swan
red sundial
#

im making an api too for some generative art

maiden fable
stiff anvil
#

it works

red sundial
maiden fable
#

HunAI uses a private API I made, anyways

red sundial
#

damn nice

slate swan
slate swan
maiden fable
#

¯_(ツ)_/¯

red sundial
#

open ai is very nice

maiden fable
stiff anvil
#

How do I make it so, If the message looks like who asked ...

stiff anvil
#

Do I need to hack google, Or it's easy?

maiden fable
lyric tusk
supple crescent
hoary cargo
maiden fable
slate swan
slate swan
maiden fable
slate swan
plucky current
#

were can i find the resroces page

supple crescent
slate swan
slate swan
maiden fable
#

Smh can we just ignore it? @slate swan @supple crescent

slate swan
supple crescent
#

Wrong Goff

maiden fable
lyric tusk
# maiden fable show your code of that line
    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)```
supple crescent
#

Gif

slate swan
stiff anvil
# slate swan elaborate the issue

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

slate swan
maiden fable
slate swan
supple crescent
#

Tf2=god tier game

stiff anvil
#

And he will bypass it everytime

slate swan
stiff anvil
#

So how do I make it, So he never bypasses it?

supple crescent
supple crescent
#

Idk ur code tho

slate swan
supple crescent
#

That might or might not work

stiff anvil
supple crescent
#

Can I see ur code?

#

Ah

stiff anvil
#
@client.event
async def on_message(message):
    if "who asked" in message.content:
        await message.reply("Your Mom?")
slate swan
supple crescent
#

There is a way to do that. Pick up words inside garbage text.

#

I’ll find it

stiff anvil
slate swan
supple crescent
stiff anvil
slate swan
supple crescent
#

Set it up with the basic who asked and it might find who asked inside the wwwwwho askedddd

slate swan
#

you can just use if message.content("asked") so bot replies with the same thing even if your friend do 4whoblahblah asked

supple crescent
#

Just an idea tho

slate swan
slate swan
hoary cargo
stiff anvil
stiff anvil
#

or 4sk3d

#

or AskEd

slate swan
supple crescent
stiff anvil
hoary cargo
#

i would rather make that the bot replies to those who says "who asked" with "I asked"

lyric tusk
stiff anvil
#

WHAT IF SOMEONE SAYS WHHHOOO ASKEEEED OR WH0 ASK3D

#

OR ALL THE POSSIBILITIES

quaint epoch
#

alr taken that

slate swan
stiff anvil
slate swan
#

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

hoary cargo
slate swan
stiff anvil
#

And I don't know shit about it

#

Please someone help me

slate swan
stiff anvil
slate swan
#

just use the message.content("asked" or "a4ked")

stiff anvil
#

It has more than 1mil possibilites

brittle axle
stiff anvil
slate swan
brittle axle
#

ez

slate swan
stiff anvil
brittle axle
stiff anvil
#

Why everyone is being dumb?

slate swan
brittle axle
#

you said what if it is "4sked" "3asked" 2asked

stiff anvil
brittle axle
#

so thats the solution

slate swan
#

you gotta add possibilities by your self
dont expect any way for a 4 line code to know millions of possibilities

brittle axle
#

lol

stiff anvil
#

who asked how do I make this case_insensitive

#

So if it's Who Asked or who asked Or whatever

sick birch
#

.lower() it

hoary cargo
quaint epoch
stiff anvil
#

how will it help tho?

sick birch
#

😉

quaint epoch
sick birch
#

It’ll convert the given string to lowercase

#

So you can compare without worrying about case

stiff anvil
#
@client.event
async def on_message(message):
    if "who asked" in message.content:
#

How will I do it for this one?

sick birch
#

message.content.lower()

quaint epoch
sick birch
#

if someone said wHO aSkED it would still match

stiff anvil
#

What about who 4sked

quaint epoch
stiff anvil
#

And all the other possibilities

#

Yeah, I know

#

But tell me a solution!

quaint epoch
#

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

sick birch
stiff anvil
#

I don't know shit about regex man

quaint epoch
#

here comes pikachu

keen talon
sick birch
#

Maybe there’s a library to convert leetspeech into English

keen talon
stiff anvil
sick birch
#

Since this could be considered leetspeak

keen talon
quaint epoch
stiff anvil
#

I never use py -m

#

I just do pip install