#discord-bots

1 messages · Page 699 of 1

slate swan
#

so except discord.ext.commands.errors.CommandNotFound:

#

doesn't work tho

cedar stream
#

It says…

cold sonnet
#

maybe commands.errors.CommandNotFound is enough

slate swan
#

kk

lunar quail
#

Hey

cold sonnet
#

!d discord.ext.commands.errors.CommandNotFound

unkempt canyonBOT
#

exception discord.ext.commands.CommandNotFound(message=None, *args)```
Exception raised when a command is attempted to be invoked but no command under that name is found.

This is not raised for invalid subcommands, rather just the initial main command that is attempted to be invoked.

This inherits from [`CommandError`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CommandError "discord.ext.commands.CommandError").
slate swan
lunar quail
#

Can I get an example use of commands.PartialEmojiConverter?

cold sonnet
#

!d discord.ext.commands.CommandNotFound

unkempt canyonBOT
#

exception discord.ext.commands.CommandNotFound(message=None, *args)```
Exception raised when a command is attempted to be invoked but no command under that name is found.

This is not raised for invalid subcommands, rather just the initial main command that is attempted to be invoked.

This inherits from [`CommandError`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CommandError "discord.ext.commands.CommandError").
cold sonnet
slate swan
#

fuck?

#

What a Member.User?

cold sonnet
#

nothing

#

it don't exist

cedar stream
#

!d discord.ext.commands.PartialEmojiConverter

unkempt canyonBOT
#

class discord.ext.commands.PartialEmojiConverter(*args, **kwargs)```
Converts to a [`PartialEmoji`](https://discordpy.readthedocs.io/en/master/api.html#discord.PartialEmoji "discord.PartialEmoji").

This is done by extracting the animated flag, name and ID from the emoji.

Changed in version 1.5: Raise [`PartialEmojiConversionFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.PartialEmojiConversionFailure "discord.ext.commands.PartialEmojiConversionFailure") instead of generic [`BadArgument`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.BadArgument "discord.ext.commands.BadArgument")
cedar stream
cold sonnet
#

give the full path

lunar quail
#

It apparently doesn't any arguments in __init__()

#

And type hinting it doesn't seem to work either

#

commands.Greedy[commands.PartialEmoji] seems to work tho

full valley
#

is there a way to log the timeout feature yet????

cedar stream
#

Try making an instance

slate swan
#
if message.author != client.user:
        try:
            await bot.process_commands(message)
        except discord.ext.commands.errors.CommandNotFound:
            embed = discord.Embed(title="Command not found", description="Use a!help to find all commands.", color=0xFF0000)
            message.channel.send(embed=embed)```
cedar stream
full valley
#

theres no event for it yet

slate swan
#

no errors

lunar quail
#

Sending your full code will be helpful

slate swan
cedar stream
#

I checked, u can use on_member_update

lunar quail
#

Oh yea

slate swan
#

my code runs perfectly, it even runs the commands but the except doesn't work

#

doesn't send the command not found

cedar stream
lunar quail
#

You should have told me that the code was about a porn bot. I almost opened it in my family computer catsweat

#

Also

#

At this point

#

Don't use on_message

#

Instead use the listener

slate swan
#

hm

lunar quail
#
@bot.listen("on_message")
async def check_if_contains(msg):
    ... 
cedar stream
#

No

lunar quail
cedar stream
#

He is trying to handle errors

#

Dont do it in on message

lunar quail
#

🤔

lunar quail
cedar stream
#

Then why did u tell him to use the listener

lunar quail
#

^
this'll be better -> if not(message.author == client.user): ...

*This was an reply to an deleted message

slate swan
cedar stream
lunar quail
#

Well lol

slate swan
#

main.py:234: RuntimeWarning: coroutine 'Messageable.send' was never awaited
ctx.send(embed=embed)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

#

nvm

#

typo

#

& didn't read the error

#

!paste

placid skiff
#

you know that this is useless cuz it will run only when the bot goes online?

slate swan
#

yes?

#

thats the point dude

placid skiff
#

you need it to run allways?

slate swan
#

no?

#

I need it to run on start lol

#

but on_ready annoying asf

placid skiff
#

on_ready is called when the bot goes online so it is when the it start

slate swan
#

yes

placid skiff
#

but it is useless cuz you count the guild of your client and that value will update everytime the bot joins a guild

slate swan
#

but I need a alternative cuz on_ready is annoying and sometimes doesn't work 4 some reason

placid skiff
#

never had that problem but there aren't alternatives on on_ready

slate swan
#

well fuck

dire folio
#

How would I check if a user has a role?

placid skiff
#

mh it was the check for the command :L you have to get the list of the user roles and check if your role is in that list

cedar stream
cedar stream
fading harness
#

hi

#

should i use dpy or hikari

cedar stream
#

I use disnake

placid skiff
#

dpy is not mantained

placid skiff
cedar stream
#

Never heard of hikari

cedar stream
slate swan
#

Hello, can anyone tell me what is:
Message intents
intents

placid skiff
#

!d discord.Intents

unkempt canyonBOT
#

class discord.Intents(**kwargs)```
Wraps up a Discord gateway intent flag.

Similar to [`Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions"), the properties provided are two way. You can set and retrieve individual bits using the properties as if they were regular bools.

To construct an object you can pass keyword arguments denoting the flags to enable or disable.

This is used to disable certain gateway features that are unnecessary to run your bot. To make use of this, it is passed to the `intents` keyword argument of [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client").

New in version 1.5...
cedar stream
dire folio
#
role = ['Staff', 'Host']
if role in member.roles:
     #stuff

would this work?

placid skiff
#

You check if a list is in a list which is not possible in python

cedar stream
placid skiff
#

yeah i think

#

don't know if you try to evaluate it say no output

slate swan
slate swan
#

nvm

cedar stream
#

Lmao

placid skiff
#

otherwise if the user has more roles and you convert the list of roles into a string you will check if the string "staff, host" is in the list of roles which is a string

#

you won't get if the user has that role

cedar stream
placid skiff
#

the best way is to iterate through one list and check if the role iterating is in the list of member roles

cedar stream
#

Lmao I was tryna help

slate swan
#

ik

#

rn it only starts if a message is sent

#

and if on_ready doesn't work & doesn't send the message

#

it doesn't start so this sucks

cedar stream
#

Wdym?

slate swan
#

No?

#

the event is fired only when the bot starts

cedar stream
#

You want to send message every x amount of time?

slate swan
#

no

#

it should send it always

#

on the channels selected

placid skiff
#

always what?

slate swan
cedar stream
#

Wdym always

placid skiff
#

it needs a trigger

slate swan
#

infinetly

cedar stream
#

You can use a task

placid skiff
#

something that make it send

slate swan
#

on_ready should send a message which triggers on_message and on_message starts the loop

#

but it doesn't sometimes

#

and that breaks the whole damn bot

cedar stream
#

No bro lmao just use a task

limpid thicket
cedar stream
slate swan
#

nah

placid skiff
#

the transaction is too instant

cedar stream
placid skiff
#

and it is based on the host connection

#

that's why sometimes work and sometimes doesn't work

cedar stream
slate swan
#

example

cedar stream
#

Docs

slate swan
#

link

cedar stream
#

Type in task

#

Go to docs

#

Type tasks

placid skiff
#

ok cmon

slate swan
#

Nvm that but it exists

#

it's just not documented

slate swan
#

!d discord.ext.tasks.loop

unkempt canyonBOT
#

discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True, loop=...)```
A decorator that schedules a task in the background for you with optional reconnect logic. The decorator returns a [`Loop`](https://discordpy.readthedocs.io/en/master/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
slate swan
#

Here

cedar stream
#

!discord.ext.tasks

slate swan
#

how am I supposed to make that work if it can only be triggered for some channels

cedar stream
slate swan
#

its supposed to be triggered when someone uses a!start or if thier channel is already stated

placid skiff
#

wait are you making a raid bot? lol

slate swan
#

no

cedar stream
#

Start the loop when someone uses a!start

cedar stream
placid skiff
#

bruh hahaha

cedar stream
#

Lmao

placid skiff
#

btw yeah you have to use tasks, check some video on youtube they will explain how you use it you seems a lot confused

slate swan
#

Well

slate swan
#

Make sure you use this , or no botlists will like to add your bot

#

!d discord.ext.commands.is_nsfw

unkempt canyonBOT
#

@discord.ext.commands.is_nsfw()```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that checks if the channel is a NSFW channel.

This check raises a special exception, [`NSFWChannelRequired`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NSFWChannelRequired "discord.ext.commands.NSFWChannelRequired") that is derived from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").

Changed in version 1.1: Raise [`NSFWChannelRequired`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NSFWChannelRequired "discord.ext.commands.NSFWChannelRequired") instead of generic [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure"). DM channels will also now pass this check.
slate swan
#

For the start command

#

ofc I use it lol

placid skiff
#

so they will work even due to connection problems

cedar stream
#

You can start it in on ready but it aint necessary

slate swan
placid skiff
#

yes

cedar stream
slate swan
#

so it works better even on slow connections

slate swan
placid skiff
#

check it on youtube

cedar stream
#

Read the docs

#

Pls

slate swan
#

aka my romanian vds with 200ms normal ping

#

Use the decorator instead , it's better to make your code clear

#

and managing the exception

placid skiff
#

i'm going to run out of tobacco and i'm working so I can't go buy it lol
I'm sad 😦

cedar stream
thick crescent
#

What's happening here?

slate swan
#

my code is not supposed to be seen by anyone so idc if its a mess

hybrid fjord
#

missing brackets

cedar stream
thick crescent
#

thanks.

slate swan
#

shipit why do ppl remove the help command?

cedar stream
placid skiff
slate swan
slate swan
#

Wait

placid skiff
slate swan
#

Subclassed one , doesn't look ugly to me

hybrid fjord
#

are there any working code samples of the new timeout feature or is there still not a library for it yet?

placid skiff
#

!d disnake.Member.timeout

unkempt canyonBOT
#

await timeout(*, duration=..., until=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Times out the member from the guild; until then, the member will not be able to interact with the guild.

Exactly one of `duration` or `until` must be provided. To remove a timeout, set one of the parameters to `None`.

You must have the [`Permissions.moderate_members`](https://docs.disnake.dev/en/latest/api.html#disnake.Permissions.moderate_members "disnake.Permissions.moderate_members") permission to do this.

New in version 2.3.
hybrid fjord
#

could you link me it

slate swan
#

and pycord too iirc

hybrid fjord
#

yep thanks

placid skiff
#

i don't understand why you should use it btw

hybrid fjord
#

Do you have to import disnake?

cedar stream
#

Lmao timeout just made mute command useless

placid skiff
#

I mean, ban is more satisfying xD

slate swan
placid skiff
hybrid fjord
#

So I have to rewrite my whole code if I switch? @slate swan

cedar stream
placid skiff
cedar stream
placid skiff
#

Which has slash commands too

#

just change all discord with disnake xD

hybrid fjord
#

So everything I've written here will still work?

slate swan
cedar stream
slate swan
#

Things like .avatar_url have changed

hybrid fjord
#

Easily replaceable.

#

Alright, how do I do that?

placid skiff
#

install it from pip lol

cedar stream
#

slate swan
#

Your editor name?

hybrid fjord
#

fair enough lol

placid skiff
#

maybe I should upgrade my disnake even i thought i will not use that feature for my bot lol

boreal ravine
#

sure

slate swan
#

Slash commands etc exist

hybrid fjord
placid skiff
#

It is the * of *args

#

cuz that function will accept more arguments

hybrid fjord
#

Ah

boreal ravine
hybrid fjord
#

i see

boreal ravine
#

!e

def timeout(*, duration): return duration

print(timeout(duration=10))
hybrid fjord
#

so it would be user.timeout(args go here)

unkempt canyonBOT
#

@boreal ravine :white_check_mark: Your eval job has completed with return code 0.

10
dusk karma
#

please im losing my mind

boreal ravine
hybrid fjord
boreal ravine
hybrid fjord
#

ok cool

#

thanks

placid skiff
#

The duration argument is type Union of float or deltatime, until needs a datetime, if you use duration you have to set None to until and the opposite if you use until

cedar stream
slate swan
#

is there a error somewhere in this code? ```py
for guild in client.guilds:
for channel in guild.channels:
if os.path.exists("home/bot/adx/autoporn"+str(guild.id)):
with open("autoporn"+str(guild.id)) as file:
if file.read() != "enabled":
os.system("rm -r home/bot/adx/autoporn"+str(guild.id))

        if os.path.exists("home/bot/adx/channel"+str(guild.id)):
            with open("autoporn"+str(guild.id)) as file:
                if len(file.read() <= 5):
                    os.system("rm -r home/bot/adx/channel"+str(guild.id))

        if os.path.exists("/home/bot/adx/channel"+str(guild.id)) == True:
            file = open("channel"+str(guild.id), "r")
            if str(channel.id) == file.read():
                file.close()
                embed = discord.Embed(title="> __Channel inactive__", color=0xFF0000)
                embed.add_field(name="Reason for inactivity", value="Restart by developer", inline=False)
                embed.add_field(name="Note", value="Small bug fixes || Added new categories", inline=False)
                await channel.send(embed=embed, delete_after=60)
                break```
placid skiff
#

remember to do that or it will run to an error

slate swan
#

fuck

dusk karma
#

i installed discord interactions but vscode wont work as long as i have it imported. (Python 3.9.9 and 10.1). But on 3.60it sayhs discord isnta module.

shell wing
#

i want to make a voting command
in which a user can vote for a member and it gets logged and it resets every month.
Any idea how to make it ?

sour lodge
#

How can I check if a message has a mention

cedar stream
placid skiff
cedar stream
dusk karma
shell wing
#

can i use json data base for this ?

sour lodge
dusk karma
placid skiff
cedar stream
hybrid fjord
#

disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'User' object has no attribute 'timeout'
@boreal ravine

placid skiff
#

Well it is not suggested tho

dusk karma
#

Are there threads. This chat is crowded lol

cedar stream
shell wing
cedar stream
shell wing
#

i just need to store info for 1 month

boreal ravine
#

!d disnake.Member.timeout

slate swan
unkempt canyonBOT
#

await timeout(*, duration=..., until=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Times out the member from the guild; until then, the member will not be able to interact with the guild.

Exactly one of `duration` or `until` must be provided. To remove a timeout, set one of the parameters to `None`.

You must have the [`Permissions.moderate_members`](https://docs.disnake.dev/en/latest/api.html#disnake.Permissions.moderate_members "disnake.Permissions.moderate_members") permission to do this.

New in version 2.3.
boreal ravine
cedar stream
boreal ravine
#

it must be a member object

hybrid fjord
#

Ah.

shell wing
boreal ravine
#

mongo uses a json format

hybrid fjord
#

@boreal ravine it returns missing permissions even though i've given the bot Administrator permmisions

potent spear
cedar stream
hybrid fjord
#

and the Moderate Members permission

placid skiff
hybrid fjord
#

oh

#

im so dumb - i apologise

potent spear
placid skiff
cedar stream
cedar stream
potent spear
boreal ravine
placid skiff
#

NoSQL can be a mess if you don't know it

hybrid fjord
cedar stream
slate swan
#

just use Sqlite if it's a small/medium sized bot tbh

boreal ravine
#

i mean theres nothing wrong with using mongo as a db

placid skiff
slate swan
#

yea sure , if you're good with dictionaries

cedar stream
slate swan
potent spear
slate swan
unkempt canyonBOT
shell wing
potent spear
#

simple setup etc

honest vessel
#

@slate swanyou can also use python instead of os.system ```py
filename = "home/bot/adx/channel"+str(guild.id)
if os.path.isfile(filename):
try:
os.remove(filename)
except PermissionError:
print("Missing permission to remove file")

cedar stream
shell wing
#

ty!

cedar stream
slate swan
cedar stream
#

There is even async odm

sour lodge
#

How can I add a rate limit

slate swan
#

no

#

and why

#

would u do that

cedar stream
cedar stream
potent spear
potent spear
#

the docs of whatever lib you're using talk about decorators you can use on top of your command

sour lodge
#

alright

slate swan
#
Ignoring exception in on_ready
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/discord/client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 154, in on_ready
    await channel.send(embed=embed, delete_after=60)
  File "/usr/local/lib/python3.8/dist-packages/discord/abc.py", line 1065, in send
    data = await state.http.send_message(channel.id, content, tts=tts, embed=embed,
  File "/usr/local/lib/python3.8/dist-packages/discord/http.py", line 248, in request
    raise Forbidden(r, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access

is this bcs the bot doesn't have access to the channel?

#

Yep

sour lodge
#

is it possible to add aliases with ```py
@discord.ext.commands.cooldown()

slate swan
#

ofcourse

sour lodge
#

at what position

cedar stream
#

It will still work the same except there will be a cooldown

slate swan
#

is there a better way to do this

                if str(channel.id) == file.read():

cuz this sends it only to couple discords for some reason

tawdry perch
#

does command alias take a list and a tuple or just 1 of them?

slate swan
#

file = open("channel"+str(guild.id), "r")

slate swan
sour lodge
# cedar stream Yes
@discord.ext.commands.cooldown(rate = 1, per = 2.0, aliases = ["who is", "Who is", "who's", "Who's"])
```so like will this work?
#

oh

cedar stream
tawdry perch
#

if I have passed smth like aliases=("test", "smth") it would be wrong?

sour lodge
#

thanks

shadow wraith
#

im wondering rn how can you give a command alias a spaced alias like 'this for example'

cedar stream
slate swan
#

yes

shadow wraith
slate swan
shadow wraith
cedar stream
cedar stream
#

But It’ s not practical for 1 cmd

shadow wraith
#

what's a cmd group again i forgot 😓

slate swan
unkempt canyonBOT
#

class discord.ext.commands.Group(*args, **kwargs)```
A class that implements a grouping protocol for commands to be executed as subcommands.

This class is a subclass of [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") and thus all options valid in [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") are valid in here as well.
cedar stream
shadow wraith
#

ohhhh, that shit ive never heard of

slate swan
#

It's really useful

shadow wraith
#

example?

cedar stream
cedar stream
slate swan
#

which is gonna be pain to check them all

shadow wraith
cedar stream
slate swan
cedar stream
slate swan
#

no

#

not in the same file

#

seperate files, the file.read was in a loop

#

921875157688152074
921875157688152074
921875157688152074
921875157688152074
921425507998900245
921425507998900245
921425507998900245
921425507998900245
921425507998900245
920742277809332295
920742277809332295
920742277809332295
920742277809332295
920742277809332295
920742277809332295
920742277809332295
920742277809332295
920742277809332295
920742277809332295
920742277809332295
920742277809332295
920742277809332295
920742277809332295
920742277809332295
920742277809332295
920742277809332295
920742277809332295
920742277809332295
920742277809332295
920742277809332295
920742277809332295
920742277809332295
914927659992117271
914927659992117271
914927659992117271
914927659992117271

#

sorry flood

cedar stream
#

Dw

slate swan
#

but it returns shit ton of ids

shadow wraith
#

why are all the channel ids the same

cedar stream
#

So what is this returned by

slate swan
#

hm

slate swan
cedar stream
#

Send ss of the code

slate swan
#

!past

unkempt canyonBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

slate swan
slate swan
# shadow wraith example?

you're making a help command with the bad bot.remove_command and making a custom help command using async def help....
Now you would need help for commands too right? Like !help ping etc , you get to ways here
1 py async def help(ctx , command = None): if command == "ping": #do something to send ping help

With groups you can do it easier ```py
@bot.group()
async def help(ctx)
......

@help.command()
async def ping(ctx):

send help for ping```

cedar stream
#

Why do you store data in separate files

slate swan
#

easier

shadow wraith
#

i wonder what you would pass in on @bot.group() tho

cedar stream
#

No it complicates everything

shadow wraith
#

i mean below the asynchronous function of defining the bot group ofc

cedar stream
#

Pass

shadow wraith
#

tru

slate swan
#

or your main help command

cedar stream
#

Or some functionality that It’ s common for all of them

slate swan
#

yeah

#

invoke_without_command exists too

#

So if you just use . command it does something

cedar stream
#

Yes u can use it as It’ s own command as well

shadow wraith
#

darnit thought that existed

slate swan
#

*didn't ig

shadow wraith
#

does ctx.invoked_command even exist :(

slate swan
#

@cedar stream u got any idea why the code is brokeN+

#

Nah

#

invoked_subcommand exists tho

cedar stream
shadow wraith
#

bro i got a traceback and it's big so ima do smth

#

!past

unkempt canyonBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

shadow wraith
#

wtf is this

cedar stream
#

Send code

slate swan
cedar stream
slate swan
#

nah

shadow wraith
# cedar stream Send code
@bot.group()
async def Read(ctx):
  pass
  
@Read.command()
async def logs(ctx):
  with open('log.txt', 'r') as log:
      text = ""
      for log in logs:
        text += f"\n{log}"
      await ctx.send(f"```\n{text}```")
#

oh it glitched because i was doing the 3 backticks

#

no my discord code text

cedar stream
#

Make the function name snake_case

#

Not PascalCase

#

Btw you can use logging library for logs and store them in .log file

shadow wraith
#

u talking to me?

slate swan
#

Yea

shadow wraith
cedar stream
slate swan
#

would this work

        with open("channel"+str(message.guild.id), "r") as file:
            if len(file.read() <= 5):
                os.system("rm -r home/bot/adx/channel"+str(message.guild.id))
            else:
                with open("channels", "a") as file:
                    file.write(file.read())
shadow wraith
#

nvm i got it wrong, the command is named logs

cedar stream
slate swan
#

logs is your command name.lol @shadow wraith

shadow wraith
slate swan
#

Yea

#

Btw don't use CamelCase for function names

cedar stream
slate swan
#

If you really want the command to have its first letter capital , just use the name kwarg

cedar stream
#

This is camelCase

slate swan
#

Yea

cedar stream
#

Or make the bot case insensitive

slate swan
#

Thanks for correcting me

cedar stream
slate swan
#
            if os.path.exists("home/bot/adx/channel"+str(guild.id)):
                with open("channel"+str(guild.id), "r") as file:
                    tf = file.read()
                    if len(tf <= 5):
                        os.system("rm -r home/bot/adx/channel"+str(guild.id))
                    else:
                        with open("channels", "r") as file:
                            if tf not in file.read():
                                with open("channels", "a") as file:
                                    file.write(tf+"\n")
#

why aint this working

honest vessel
#

first of

#

os.path.exists is a directory, but u checking a file

slate swan
#

no lol

#

u can check files with it also

#

cuz file is a path

honest vessel
#

ah nvrm

slate swan
#

nvm tf variable wasn't int

#

gotta change that rq

#

wait nvm u can check len of str

honest vessel
#

what is it supposed to have in the file?

slate swan
#

its a channel id in the file

#

and im checking if the channel id has less than 5 numbers its invalid

#

which works

#

but the else:

honest vessel
#

len(tf <= 5) should't it be len(tf) <= 5:

slate swan
#

and stuff after that doesn't

shadow wraith
#

can command groups have aliases?

slate swan
honest vessel
#

all commands can have alias, juse add aliases=[]

shadow wraith
#

rigtht?

honest vessel
#
 @commands.group(name="dj", invoke_without_command=True)
    async def dejay(self, ctx)
...
@dejay.command(name="quit", aliases=["q"])
    async def quit_subcommand(self, ctx):
``` like this
#

@shadow wraith yeah that should do it

slate swan
honest vessel
#

any errors?

slate swan
#

no

shadow wraith
honest vessel
#

@shadow wraithjust try add that aliases=[""] and see

#

if it works it works, if not it dosnt 😛

shadow wraith
#

it works

honest vessel
#

😉

#

dont be afraid of try

#

your computer wont explode

shadow wraith
#

i dont use a computer, i use laptop ☠️

honest vessel
#

it is still a computer aint it?

shadow wraith
#

computer is this

#

laptop is smth else

honest vessel
#

thats a personal computer

#

laptop computer

slate swan
#

lmao how does that matter

honest vessel
#

it dosnt 😄

slate swan
#

it wont explode afterall

honest vessel
#

kek

shadow wraith
#

yeah, it'll defuse

honest vessel
#

damn christmas soon already dosnt feel like it

#

i have zero christmas vibes

slate swan
#
Traceback (most recent call last):
  File "/home/container/.local/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/home/container/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 855, in invoke
    await self.prepare(ctx)
  File "/home/container/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 789, in prepare
    await self._parse_arguments(ctx)
  File "/home/container/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 697, in _parse_arguments
    transformed = await self.transform(ctx, param)
  File "/home/container/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 542, in transform
    raise MissingRequiredArgument(param)
discord.ext.commands.errors.MissingRequiredArgument: info is a required argument that is missing.```
#

read the error bruh

#

add ,error

#

in args

#

but i still i dont errors brush

#

even if i read the error

#

info is a required argument that is missing.

slate swan
honest vessel
#

info argument is missing

slate swan
#

but what i need to do to get work

honest vessel
#

add in your def async comandname(ctx, info)

#

etc

slate swan
#

oh

#
async def statyinfo(ctx, info):
    server = ctx.guild
    if info == "memberCount":
        await ctx.send(server.member_count)
    elif info == "numberOfChannel":
        await ctx.send(len(server.voice_channels) + len(server.text_channels))
    elif info == "name":
        await ctx.send(server.name)
    else:
        await ctx.send("Dziwne... tego nie wiem")```
honest vessel
#

yeah

slate swan
#

i got like this

honest vessel
#

now your command <parafix>statyinfo memberCount

slate swan
#

but where to i need to add this

honest vessel
#

add what?

#

i mean if your command is !statyinfo

#

!statyinfo memberCount

slate swan
#

oh

shadow wraith
#

his prefix is + im sure

shadow wraith
honest vessel
#

anyway your error was only that missing argument info

slate swan
shadow wraith
#

np

slate swan
#

why does this return false ```py
if os.path.exists("home/bot/adx/channel"+str(message.guild.id)):

even tho the file exists
slate swan
#

nope

#

doesn't have

#

its literally just channel+id

#

wdym , you have files named 12345566667754 ?

#

huh

#

yes its channel+guildid

#

the name

#

without any extensions like .txt or something? , weird

#

no

#

no reason to have .txt

#

doesn't do anything

#

i have a question how i can make command that shows channles count and roles count

#

!d discord.Guild.roles

unkempt canyonBOT
#

property roles: List[discord.role.Role]```
Returns a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of the guild’s roles in hierarchy order.

The first element of this list will be the lowest role in the hierarchy.
slate swan
#

!d discord.Guild.channels

unkempt canyonBOT
slate swan
#

use len() on these

#

ok

#

fuck

#

im dumb

#

whats the opposite of append

#

like remove 1 line from code

quick gust
#

pop

quick gust
slate swan
#

file*

#

with open("channels", "pop") as file:?

#

await ctx.send(len(server.roles)) it could work or its wrong cuz i just wonna add thing in my command thats counts all roles the server but idk its good or not

#

or p or what

cinder fossil
#

just open as read ("r") and then delete the line you want

slate swan
quick gust
#

as "w"

cinder fossil
#

ye that ^

#

my mistake

slate swan
quick gust
slate swan
#

oh ok

cinder fossil
# slate swan u cant delete with read
with open ("filename.txt", "r") as f:
  lines = f.readlines()
with open("filename.txt", "w") as f:
  for line in lines:
    if line.strip("\n") != "line you want to delete":
      f.write(line)

should do the trick - gets the file by opening it in read, opens in w and overwrites the file with everything except the line you want to delete

slate swan
tawdry perch
#

to get channel I did await self.bot.get_channel(id), right?

quick gust
tawdry perch
#

and if I have a message obj, can I reply to that message using .reply?

slate swan
manic wing
#

you dont await get_

slate swan
#

i need to check what mz but do when i type +rolesCount

manic wing
#

you await fetch_

tawdry perch
#

oh..

manic wing
tawdry perch
#

ooh

cinder fossil
# slate swan oh

What you have is right, but before that you should have guild = ctx.guild

#

Also worth noting that everyone (defualt role) is counted as a role so you'd ideally want len(guild.roles)-1

slate swan
#

my python3 file keeps getting killed for no reason

#

just says "Killed"

#

and quits

#

no errors

slate swan
#

1 python bot cant be using 4gb ram

cinder fossil
cinder fossil
slate swan
#

nope

#

just killed

#

Literally just "Killed"

manic wing
#

yikes

cinder fossil
slate swan
#

sure

cinder fossil
slate swan
#

this on my laptop

#

16gb ram r7 4700u

honest vessel
#

not a shitty laptop

#

@slate swanwhy dont you host your bot on a vps?

slate swan
#

shitty laptop

#

bro what

#

r7 and 16gb ram

#

shitty laptop?

honest vessel
#

i said not a

slate swan
#

but oliver asked me to try it on my own

honest vessel
#

what is VDS?

#

ah virtual dedicated server

slate swan
#

yes

honest vessel
#

@slate swanbut yo thats 100% cpu of python3 seems scary

slate swan
#

100% of a thread

slate swan
# cinder fossil ```py guild = ctx.guild await ctx.send(len(guild.roles)-1) ```
async def statyinfo(ctx, info):
    server = ctx.guild
    if info == "memberCount":
        await ctx.send(server.member_count)
    elif info == "numberOfChannel":
        await ctx.send(len(server.voice_channels) + len(server.text_channels))
    elif info == "name":
        await ctx.send(server.roles_count)
    guild = ctx.guild
    elif info == "rolesCount":
        await ctx.send(len(guild.roles)-1)
    else:
        await ctx.send("Dziwne... tego nie wiem")``` like this
#
class HelpView(View):
    message : Message
    def __init__(self ):
        super().__init__(
            timeout=5
        )
    async def on_timeout(self):
        self.children[0].disabled = True
        await self.message.edit(
            content= '`Menu Options` is no longer active',
            view=self
        )

class InviteButton(Button):
    def __init__(self , ctx : Context):
        super().__init__(
            emoji= "🔗",
            label = 'Invite',
            url = ctx.bot.invite_url,
            style = ButtonStyle.url
        )

class VoteButton(Button):
    def __init__(self , ctx : Context):
        super().__init__(
            emoji= ctx.bot.get_emoji(841178289171333120),
            label = 'Vote',
            disabled=True,
            url = f"https://top.gg/bot"+str(ctx.bot.user.id),
            style = ButtonStyle.url
        )```

why does this show an error saying 
`In components.0.components.1: The specified component exceeds the maximum width`
`In components.0.components.2: The specified component exceeds the maximum width`
when the timeout is set to 60 , but not when at timeout =4 or some small number
slate swan
honest vessel
quick gust
slate swan
#

terminal is the bot

#

process

#

tho it has ssh also running in terminal

dire folio
#

Why ur discord look like that

slate swan
#

betterdiscord

honest vessel
#

@slate swanmaybe not leak ur serverip, and why run as root? :S

slate swan
#

!code

unkempt canyonBOT
#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

slate swan
#

my website running on the same ipv4

honest vessel
#

ah ok then i see

#

but you should't allow root on ssh

slate swan
#
    guild = ctx.guild
                    ^
IndentationError: unindent does not match any outer indentation level``` i got  this when run my bot
honest vessel
#

it means you havnt correct indentation

slate swan
#

so what i should do

honest vessel
slate swan
honest vessel
#

ok but i would recommend no root allowed and setup privatekeys

slate swan
#

nahh

honest vessel
#

@slate swanhave u figured it out yet?

#
@bot.command()
async def statyinfo(ctx, info):
    server = ctx.guild
    if info == "memberCount":
        await ctx.send(server.member_count)
    elif info == "numberOfChannel":
        await ctx.send(len(server.voice_channels) + len(server.text_channels))
    elif info == "name":
        await ctx.send(server.roles_count)
    guild = ctx.guild # hint: problem is here
    elif info == "rolesCount":
        await ctx.send(len(guild.roles)-1)
    else:
        await ctx.send("Dziwne... tego nie wiem")
#

but it makes no sense what u trying to do there

#
@bot.command()
async def statyinfo(ctx, info):
    server = ctx.guild
    if info == "memberCount":
        await ctx.send(server.member_count)
    elif info == "numberOfChannel":
        await ctx.send(len(server.voice_channels) + len(server.text_channels))
    elif info == "name":
        await ctx.send(server.roles_count)
    guild = ctx.guild #remove this
    elif info == "rolesCount":
        await ctx.send(len(guild.roles)-1) # edit this to len(server.roles)-1
    else:
        await ctx.send("Dziwne... tego nie wiem")
slate swan
#

fuck

#

i hate this gdamn python

#

how

#

in the fuck do I get a list of all channels in the guild

pliant gulch
#

!d discord.Guild.channels

unkempt canyonBOT
slate swan
#

bro

#

wtf is wrong with my code


@bot.command()
async def start(ctx):
    if ctx.author.guild_permissions.manage_channels:     
        if ctx.channel.is_nsfw() == False:
            embed = discord.Embed(description="Turn on NSFW mode!", color=0xFFFF)
            await ctx.send(content=None, embed=embed)
        else:
            with open("channels", "r") as file:
                text_channel_list = []
                for channel in ctx.guild.text_channels:
                    text_channel_list.append(channel)
                    if os.path.exists("/home/bot/adx/autoporn"+str(ctx.guild.id)) == False and str(text_channel_list) not in file.read():
                        autoporn = True
                        embed = discord.Embed(title="> __A-NSFW__", description="Started auto-nsfw. Use a!stop to stop.", color=0xFF000)
                        embed.add_field(name="Estimated time before start", value="1-10min", inline=False)
                        await ctx.send(embed=embed)
                        file = open("autoporn"+str(ctx.guild.id), "w")
                        file.write("enabled")
                        file.close()
                        file = open("channels", "a")
                        file.write(str(ctx.channel.id)+"\n")
                        print("debug99")
                        file.close()
                        break
                    else:
                        embed = discord.Embed(title="> __A-NSFW__", description="Auto-NSFW is already running.", color=0xFF0000)
                        await ctx.send(embed=embed)
                        break

    else:
        embed = discord.Embed(title="> Missing permissions!", description="manage_channels", color=0xFF0000)
        await ctx.send(embed=embed)

all commands stop working after doing a!start

tough lance
slate swan
#

not needed

tough lance
#

Hmm

#

This code is a bit blocking

#

You should use an asynchronous dB like aiosqlite or asyncpg or motor

slate swan
#

no

#

also nothing should be blocking

#

cuz it has break at the end

#

it should just break out of the loop as soon as its done

tough lance
#

open() is blocking

#

Its a synchronous function

hybrid fjord
#

what is the replacement for avatar_url for disnake?

slate swan
#

cant be the problem cuz this works

#
@bot.command()
async def stop(ctx):
    if ctx.author.guild_permissions.manage_channels:      
        text_channel_list = []
        for channel in ctx.guild.text_channels:
            text_channel_list.append(channel)
            with open("channels", "r") as file:
                print("debug5")
                if os.path.exists("/home/bot/adx/autoporn"+str(ctx.guild.id)) == True or os.path.exists("/home/bot/adx/channel"+str(ctx.guild.id)) == True or str(text_channel_list) in file.read():
                    file.close()
                    print("debug1")
                    os.system("rm -r /home/bot/adx/autoporn"+str(ctx.guild.id))
                    os.system("rm -r /home/bot/adx/channel"+str(ctx.guild.id))
                    g = str(text_channel_list)  
                    with open ("channels", "r") as f:
                        lines = f.readlines()
                    with open("channels", "w") as f:
                        for line in lines:
                            if line.strip("\n") != str(g):
                                f.write(line)
                    print("debug3")
                    autoporn = False
                    embed = discord.Embed(title="> __A-NSFW__", description="Stopped auto-nsfw. Use a!start to start again.", color=0xFF000)
                    await ctx.send(embed=embed)
                    break
                else:
                    embed = discord.Embed(title="> __A-NSFW__", description="Auto-NSFW isn't running on any channel.", color=0xFF0000)
                    await ctx.send(embed=embed)
                    break
    else:
        embed = discord.Embed(title="> Missing permissions!", description="manage_channels", color=0xFF0000)
        await ctx.send(embed=embed)
tough lance
hybrid fjord
#

okay thanks

wide tartan
#

?

cedar stream
wide tartan
cedar stream
#

I think get_commands is a list of command objects

#

Put it to string

wide tartan
#

Erm, what do you mean?

cedar stream
dense swallow
#

how do i fix category appearing 2 times in help command? im using HelpCommand btw

cedar stream
# wide tartan

Try using [cmd.name for cmd in command.get _commands()] to get list of command names as string

dense swallow
# cedar stream Show code
    async def send_bot_help(self, mapping):
        ctx = self.context
        em = discord.Embed(
            title=f"{ctx.me.display_name} Help Menu",
            timestamp=ctx.message.created_at,
            color=bot.christmas
        )
        em.set_thumbnail(url=ctx.me.avatar_url)
        usable = 0

        for cog, commands in mapping.items():
            if filtered_commands := await self.filter_commands(commands):
                amt_cmds = len(filtered_commands)
                usable += amt_cmds
                if cog:
                    name = cog.qualified_name
                    description = cog.description or "No description"
                else:
                    pass
                em.add_field(name=f"{name} [{amt_cmds}]", value=description, inline=False)
        em.description = f"""{len(ctx.bot.commands)} commands | {usable} usable\n\nUse "help [command | module]" for more info.\nIf you can't see any module, it means that you don't have the permission to view them.\n\n`<>` required | `[]` optional"""
        await self.send(embed=em)
cedar stream
#

Cus I’ m on mobile

dense swallow
#

ok

#

one sec

cedar stream
#

Ok

dense swallow
#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

dense swallow
slate swan
#

hello i want to make the bot automatically assign a role to member when i type a command with the mentioned member

honest vessel
wide tartan
#

Ah, it works

potent spear
cedar stream
wide tartan
cedar stream
wide tartan
#

Thank you.

cedar stream
#

Np

honest vessel
potent spear
slate swan
#
@commands.has_any_role(921080099061784646,921080899209142282,921089622979788800,921078007668568064,921079589860696074,920779847305932827)
async def CIA(ctx, *, text):
    
    try:
        await ctx.message.delete()
        timenow = time.strftime("%H:%M")
        content = value=text
        channel = client.get_channel(920779848073502816)
        embed=discord.Embed(title="CIA REDIRECTION", description=" ", color=0xfff705)
        embed.set_author(name="CIA", url="", icon_url="https://cdn.discordapp.com/icons/920779847012319233/1d540f5fed2274526dc69322ad56b312.png?size=4096")
        embed.set_thumbnail(url="https://cdn.discordapp.com/icons/920779847012319233/1d540f5fed2274526dc69322ad56b312.png?size=4096")
        embed.add_field(name="برجاء التوجة لروم الامن الوطني للتحقيق", value=text, inline=False)
        embed.set_image(url="https://cdn.discordapp.com/attachments/920779848073502816/922594384535506985/CIA2.gif")
        embed.set_footer(text=f"{CIA} {timenow}")
        test = await channel.send(embed=embed, content=content) # Define the messag
    except Exception as err:
        print(err)    ``` don't mind arabic words because i'm arabic
#

so all the things i want it to do is to automatically add a role to the mentioned user

dense swallow
cedar stream
unkempt canyonBOT
#
Huh? No.

No documentation found for the requested symbol.

slate swan
#

what is !d?

cedar stream
cedar stream
slate swan
#

and which line

honest vessel
#

@slate swanwhats the error?

slate swan
#

there is no error

cedar stream
#

!d discord.Member

unkempt canyonBOT
#

class discord.Member```
Represents a Discord member to a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").

This implements a lot of the functionality of [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User").

x == y Checks if two members are equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User") instances too.

x != y Checks if two members are not equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User") instances too.

hash(x) Returns the member’s hash.

str(x) Returns the member’s name with the discriminator.
potent spear
slate swan
#

i want it to add a role to the mentioned member in the embed

honest vessel
#

content = value=text this looks weird tho

slate swan
#

well discord.Member is the member i mentioned right?

potent spear
slate swan
#

how do I id of ctx.guild.text_channels

cinder fossil
slate swan
#

does member.add_roles accept role id?

honest vessel
cinder fossil
#

!d discord.Member.add_roles

unkempt canyonBOT
#

await add_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s.

You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the added [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
cedar stream
#

Yep

slate swan
#

how

#

do i get ids of ctx.guild.text_channels

honest vessel
potent spear
potent spear
slate swan
potent spear
#

you can do it in 1 line...

slate swan
#

cuz loops suck

#

yeah ik

potent spear
#

don't underestimate them

slate swan
#

but I need to indent all other lines

#

and add breaks

potent spear
#

it'll go fast af, you won't notice, it's not like you're doing this for millions of elements and need numpy xd

cedar stream
slate swan
potent spear
slate swan
#

local variable 'member' referenced before assignment

slate swan
potent spear
honest vessel
potent spear
#

that's a basic python error, obviously your first project

slate swan
#

sorry i'm just new so i may ask some bad questions

potent spear
#

well, what should the member be? the command invoker?

slate swan
honest vessel
#

maybe show code

dense swallow
slate swan
#

like when i do *CIA @slate swan

potent spear
honest vessel
#

of your comand function decleration

slate swan
#

yes

potent spear
cedar stream
honest vessel
#

like ctx, member: discord.member)

potent spear
# slate swan

async def CIA(ctx, member: discord.Member, *, text)

cedar stream
slate swan
#

wtf is wrong with my code


@bot.command()
async def start(ctx):
    if ctx.author.guild_permissions.manage_channels:     
        if ctx.channel.is_nsfw() == False:
            embed = discord.Embed(description="Turn on NSFW mode!", color=0xFFFF)
            await ctx.send(content=None, embed=embed)
        else:
            with open("channels", "r") as file:
                text_channel_list = []
                for channel in ctx.guild.text_channels:
                    text_channel_list.append(channel)
                    if os.path.exists("/home/bot/adx/autoporn"+str(ctx.guild.id)) == False and str(text_channel_list) not in file.read():
                        autoporn = True
                        embed = discord.Embed(title="> __A-NSFW__", description="Started auto-nsfw. Use a!stop to stop.", color=0xFF000)
                        embed.add_field(name="Estimated time before start", value="1-10min", inline=False)
                        await ctx.send(embed=embed)
                        file = open("autoporn"+str(ctx.guild.id), "w")
                        file.write("enabled")
                        file.close()
                        file = open("channels", "a")
                        file.write(str(ctx.channel.id)+"\n")
                        print("debug99")
                        file.close()
                        break
                    else:
                        embed = discord.Embed(title="> __A-NSFW__", description="Auto-NSFW is already running.", color=0xFF0000)
                        await ctx.send(embed=embed)
                        break

    else:
        embed = discord.Embed(title="> Missing permissions!", description="manage_channels", color=0xFF0000)
        await ctx.send(embed=embed)

all commands stop working after doing a!start

slate swan
slate swan
#

no

cedar stream
slate swan
#

nothing works after doing a!start

dense swallow
potent spear
slate swan
#

so wtf

cedar stream
slate swan
potent spear
slate swan
slate swan
cedar stream
slate swan
#

and yes I do have on_message

cedar stream
unkempt canyonBOT
#

class discord.Role```
Represents a Discord role in a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild")...
potent spear
slate swan
#

what

#

makes no sense

cedar stream
slate swan
slate swan
#

so for some reason this command that worked before, doesn't work anymore ?

honest vessel
#

await bot.process_commands(message)

slate swan
#

i have

potent spear
# slate swan makes no sense

on_message gets triggered before a command, if you'd say in on_message has to shut down the bot, then it would should it down before running any other command
is that more clear?

slate swan
slate swan
#

thats what happened when i added the async def @potent spear

cedar stream
slate swan
#

wdym thats english

#

i know its english

potent spear
#

I mean, that the error speaks for itself

slate swan
cedar stream
cinder fossil
potent spear
slate swan
slate swan
#

it assumes its == True:

cedar stream
unkempt canyonBOT
potent spear
slate swan
#

makes no sense what u said lol

potent spear
slate swan
#

bro

#

u wanna see my terminal

potent spear
slate swan
cedar stream
slate swan
#

@potent spear

potent spear
slate swan
#

bro

potent spear
# slate swan

ok, do you need additional info after adding *CIA @potent spear <extra text here>
yes or no?

slate swan
cedar stream
slate swan
#

i only want it to add the role to the mentioned user which is <@>

#

ah

#

File "main.py", line 210, in my_task
if os.path.exists("/home/bot/adx/channel"+str(msg.guild.id)):

#

is blocking the code

potent spear
# slate swan nope

then remove the *, test
in your function declaration and also remove where you use it in the command

slate swan
#

fucking fuc

cedar stream
unkempt canyonBOT
#

await add_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s.

You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the added [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
cedar stream
#

Read this

potent spear
slate swan
#

fixed

#

so i add this and replace *roles with role id right?

potent spear
slate swan
#

and it literally just keeps going

#

almost every if statement has a debug

#

and the nsfw shit is from reddit

cedar stream
slate swan
#

dont mind but anyways I have good debugging

cedar stream
#

So u can disable it w/o having to delete it

slate swan
cedar stream
mortal thistle
#

how do i make button clickable more than once

slate swan
#

2021-12-22 20:34:08,513:WARNING:discord.gateway: WebSocket in shard ID None is ratelimited, waiting 59.98 seconds

#

well well well

cedar stream
cedar stream
slate swan
#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

slate swan
#

A button only stops if you stop listening to a interaction

#

only sends it on couple channels

slate swan
#

cap

mortal thistle
cedar stream
cedar stream
mortal thistle
#

how can I get back to a button after restarting my bot

#

...

#

if it makes sense

cedar stream
#

Idk if it still works after u restart it

#

I’ m not sure

mortal thistle
#

it says this interaction failed

cedar stream
#

Lemme see

slate swan
slate swan
mortal thistle
#

ping?

mortal thistle
sour lodge
#

can we have multiple classes in one cog file?

cedar stream
#

Like, you cant send that many messages that fast

cedar stream
mortal thistle
sour lodge
#

alr thanks

mortal thistle
#

like this one

cedar stream
mortal thistle
slate swan
slate swan
#

it literally spams the same message on the same channel

#

and I have sleeps

cedar stream
cedar stream
slate swan
#

yes

#

it spams the message on the same channel so it should work

cedar stream
#

U can send 5 messages per 5 seconds I believe

slate swan
cedar stream
#

I was just assuming

slate swan
#

Most bots use private wrappers

#

Like mee6 i believe

cedar stream
#

🤷🏼‍♂️

slate swan
dense swallow
slate swan
#

so thats not the reason

#

its sommething else

sour lodge
dense swallow
#

!d discord.Embed.add_field

unkempt canyonBOT
#

add_field(*, name, value, inline=True)```
Adds a field to the embed object.

This function returns the class instance to allow for fluent-style chaining.
sour lodge
#

thanks

cedar stream
dense swallow
#

so indent it once?

cedar stream
#

Yes

#

And remove else, It’ s useless

dense swallow
#

thanks, its fixed now! :D

cedar stream
#

Np

slate swan
slate swan
#

He just made new lines and made the titles bold

sour lodge
#

Its fine thats what I needed

slate swan
#

Its all in the description kwarg

#

how do I send something to multiple guilds

manic wing
#

await channel_one.send(...); await channel_two.send(...)

slate swan
#

no

manic wing
#

you do it as one would expect

slate swan
#

I mean bulk send

#

I cant do it manually

manic wing
#

as in

#

for each channel in the guild you send something?

slate swan
#

no

#

I have a list of channel ids

#

I need to send msg to all of them

#

they are in different guilds

manic wing
#
for channel_id in channel_list: #where channel_list is a list of id's
  channel = bot.get_channel(channel_id) #searches bots cache for the channel
  await channel.send(...)```
slate swan
#

for loop doesnt work

#

with that

manic wing
#

why not?

slate swan
#

idk just didn't work before

#

future: <Task finished coro=<my_task() done, defined at main.py:216> exception=AttributeError("'NoneType' object has no attribute 'send'")>
Traceback (most recent call last):
File "main.py", line 268, in my_task
await channel.send(embed=embed)
AttributeError: 'NoneType' object has no attribute 'send'

manic wing
#

invalid id.

slate swan
#

not

manic wing
#

can you show the list

slate swan
#

['920751850649714738', '922978651803365417', '839546320820895747', '850592224700792872', '884962944482422784', '918770232485613568', '800069566519574536', '923135211003314206', '737324794852409358', '923205531852750948', '922898261507997726', '921875157688152074', '914927659992117271', '922133456102760520', '920742277809332295', '922133456102760520', '921425507998900245', '921496293002584074', '922771047760150568', '922771047760150568', '922865149105303622', '922864818191495191', '920751850649714738', '920742277809332295', '920751850649714738', '907915837049036850', '923283650911559711', '922771047760150568', '907915837049036850', '923290185783971913', '923290911016906852', '923295700484227076', '923295700484227076', '923295720147128370']

manic wing
slate swan
#

all those r channels

manic wing
#

they have to be ints

slate swan
#

bruh

manic wing
#
for channel_id in channel_list: #where channel_list is a list of id's
  channel = bot.get_channel(int(channel_id)) #searches bots cache for the channel
  await channel.send(...)
slate swan
#

channel_list = int(file.read()).split()
ValueError: invalid literal for int() with base 10: '920751850649714738\n922978651803365417\n839546320820895747\n850592224700792872\n884962944482422784\n918770232485613568\n800069566519574536\n923135211003314206\n737324794852409358\n923205531852750948
grool

#

nvm

manic wing
#

you dont int a list...

slate swan
#

yes

#

ik

#

I did it at the wrong variable

#

the for loop just chooses 1 random channel and keeps sending it there

manic wing
#

then you've done the loop wrong

slate swan
#

o

#

no

#
    for channel_id in channel_list: #where channel_list is a list of id's
        channel = bot.get_channel(int(channel_id)) #searches bots cache for the channel
        file.close()
        embed = discord.Embed(title="> __Channel inactive__", color=0xFF0000)
        embed.add_field(name="Reason for inactivity", value="Restart by developer", inline=False)
        embed.add_field(name="Note", value="Small bug fixes || Added new categories", inline=False)
        await asyncio.sleep(3)
        await channel.send(embed=embed)```
manic wing
#

file.close()

dense swallow
manic wing
slate swan
#

cuz there was file that n eeded to be closed

#

above

manic wing
#

why did you put it in the loop though?

slate swan
#

misplaced

manic wing
#

are you sure you saved itr?

slate swan
#

...

#

yes

manic wing
#

well you've fucked something up then :)

slate swan
#

nah dude

#

idk whats wrong with this bot