#discord-bots

1 messages · Page 728 of 1

lucid gazelle
#

I dont have a command for that

#

bc I dont know how to do that

worldly bane
#

the cooldown

loud junco
#

This is the weirdest error I have ever seen

hoary gust
#

guys which is better disnake or hikari

slate swan
#

How would I do the following?

“””
if (role is higher than member):
blah blah blah
“””?

#

Or would I have to list every single role higher than member?

slate swan
#

if ctx.author.top_role.position:
blah blah blah?

loud junco
#

I'm facing an issue now

#

I can't define userid

slate swan
#

or in it rather

loud junco
#

Cuz the userid isn't in a function that define ctx

loud junco
#

Now I defines userid and ctx is not defined

slate swan
#

Because ctx is not defined..

hoary gust
#

guys which is better disnake or hikari

loud junco
#

Ik

slate swan
#

That's not how you do it, you need to have a command.

loud junco
#

But it's hard to define it

#

Cuz it's not in a function

slate swan
slate swan
spring flax
#

what's the most efficient way to make a global variable for returning an emoji?

loud junco
#

they say the bot var is the best

slate swan
#
@bot.command()
async def command(ctx):
    # ctx is defined
slate swan
loud junco
#

Lol ok

#

Then I define those var inside an async function?

#

How do I call them when I need

#

Just await funcname()

#

?

slate swan
spring flax
loud junco
slate swan
loud junco
#

Scoping error

#

:/

slate swan
#

Then you import the file where you need the emote and you can use emotes.emote1

spring flax
#

would it be as something like

def emoji():
  x = bot.get_emoji()
  return x```
or would it be as a bot variable under initializing the bot construction, or maybe even on `on_ready`
slate swan
#

That's a pretty much irrelevant function.

#

Just use bot.get_emoji in that case.

#

Creating a new function that does exactly the same as another function is pretty much useless code.

spring flax
#

Where do I put that?

slate swan
#

Just like doing

def print_something(str)
    print(str)
shadow wraith
#

is discord.Role a type?

spring flax
spring flax
slate swan
unkempt canyonBOT
#

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

no like would it work if if type(msg.content) == discord.Role: ... or did i forget basic python

slate swan
unkempt canyonBOT
#
Not in a million years.

No documentation found for the requested symbol.

slate swan
#

god

shadow wraith
#

oh i know isinstance

slate swan
#

!d isinstance

unkempt canyonBOT
#

isinstance(object, classinfo)```
Return `True` if the *object* argument is an instance of the *classinfo* argument, or of a (direct, indirect, or [virtual](https://docs.python.org/3/glossary.html#term-abstract-base-class)) subclass thereof. If *object* is not an object of the given type, the function always returns `False`. If *classinfo* is a tuple of type objects (or recursively, other such tuples) or a [Union Type](https://docs.python.org/3/library/stdtypes.html#types-union) of multiple types, return `True` if *object* is an instance of any of the types. If *classinfo* is not a type or tuple of types and such tuples, a [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "TypeError") exception is raised.

Changed in version 3.10: *classinfo* can be a [Union Type](https://docs.python.org/3/library/stdtypes.html#types-union).
slate swan
#

Yeah this

shadow wraith
#

haha guessed it before you! x]

spring flax
slate swan
#

First argument: Your variable
Second argument: The class

slate swan
#

You're just overcomplicating things.

spring flax
slate swan
#

And you want to send that emote sometimes I guess?

shadow wraith
spring flax
slate swan
#

Then just make a new file which contains the emote in format <...> saved in a variable and import it where needed.

hoary gust
#

guys which lib do u use?

slate swan
#

As I already said, it's a personal choice.

#

Try libraries out and find out which one is the more convenient for you.

spring flax
#

well I guess I can leave out the other file, since it's mostly two emojis ( a success emote and error emote) so I will just use the variable but would it be better to define it on the on_ready or seperately as another var?

slate swan
#

emotes.py

emote1 = "<...>"
emote2 = "<...>"

bot.py

import emotes
[...]
embed = discord.Embed(
    description=f"My emote: {emotes.emote1}"
)
[...]
shadow wraith
#

ngl @slate swan thats genius

spring flax
shadow wraith
#

but why not a star import?

shadow wraith
slate swan
slate swan
shadow wraith
#

just name it daheudfshdkfshksfdhfsdk and you have no similarities 👍

#

dw code completion will get it for you

slate swan
#

Enums are not per default in Python and the alternatives are gibberish. Whereas enums are not convenient for this use case.

slate swan
brazen raft
#

But he has constant values for these names

slate swan
#

Then why using enums when your can make simple variables?

brazen raft
#

And they're under a "category" of emotes

slate swan
#

And using enums, that are not per default.

shadow wraith
#

if your using a module for that sh*t then why not put it inside a class to avoid similarities?

brazen raft
#

Yeah you don't have to use enums

shadow wraith
#

how do u put perms in ctx.guild.create_role(perms=...), is it just a list like:

[manage_messages=True,...]
little ether
#

!d discord.Permissions

unkempt canyonBOT
#

class discord.Permissions(permissions=0, **kwargs)```
Wraps up the Discord permission value.

The properties provided are two way. You can set and retrieve individual bits using the properties as if they were regular bools. This allows you to edit permissions.

Changed in version 1.3: You can now use keyword arguments to initialize [`Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions") similar to [`update()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.update "discord.Permissions.update").
spring flax
#

well,

async def success_emoji(ctx):
    emoji = bot.get_emoji(840920214035628082)
    return emoji
    
@bot.command()
async def test(ctx):
    await ctx.send(success_emoji)

this sends <function success_emoji at 0x0000013F840D8670>

lament mesa
#

call the function

cold torrent
#
async def success_emoji(ctx):
    emoji = bot.get_emoji(840920214035628082)
    return emoji
    
@bot.command()
async def test(ctx):
    await ctx.send(success_emoji(ctx))
slate swan
#

Why adding a ctx argument when it's not used?

#

Remove the parameter from the function and remove the argument.

#

And I think it will send the object and not the emote.

#

So you'd want to str() it, or use f-strings.

spring flax
#

now

async def success_emoji():
    emoji = bot.get_emoji(840920214035628082)
    return str(emoji)
    
@bot.command()
async def test(ctx):
    await ctx.send(success_emoji())

does <coroutine object success_emoji at 0x000002726038D1C0>

#

I'm assuming I missed an await, but where?

tough lance
#

emoji = await success_emoji()
await ctx.send(emoji)

slate swan
#

str(emoji)

spring flax
slate swan
#

Only when sending.

slate swan
tough lance
spring flax
#

oh, okay but then is there a way to be able to do it without having to keep awaiting it in each command?

slate swan
#

Oh yeah, haven't seen they changed it, my bad.

slate swan
#

Just send the emotes like that: !python in your embed.

spring flax
#

oh...so then I guess I'll use a variable instead of a function

slate swan
#

Especially if you only use 2-3 emotes.

tough lance
#

I gave my credit card to Aws and they said they'd activate my account within 24 hours. Its been 48 hours since then

shadow wraith
tough lance
shadow wraith
#

you'd need help with aws, not discord bots

tough lance
#

I don't need help I was just telling

slate swan
tiny ibex
#

Mind telling me how they did that?

tiny ibex
drifting tulip
#

just a question why import discord as disnake

tiny ibex
spring flax
#

can i find the argument was was missed on the missing required argument error handler

#

nevermind, got it

slate swan
tiny ibex
slate swan
#

Here are the different formatting methods for the format part:

cold sonnet
#

<t:1641370173>

tiny ibex
#

<t:1641370173:f*>

#

<t:1641370396:f*>

tiny ibex
slate swan
#

No *

#

It means it's default

#

So you can remove it along with the "f"

#

<t:1641370396> => <t:1641370396>

tiny ibex
#

<t:1641370396>

#

DAMN cool

#

Thanks

tiny ibex
light violet
#

i need a event which detects audit log action of webhook create and bans the user and deletes the webhook

unkempt canyonBOT
#

discord.on_webhooks_update(channel)```
Called whenever a webhook is created, modified, or removed from a guild channel.

This requires [`Intents.webhooks`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.webhooks "discord.Intents.webhooks") to be enabled.
light violet
#

@client.event
async def on_webhooks_update(channel):
    try: 
        guild = channel.guild     
        async for i in channel.guild.audit_logs(limit=1, after=datetime.datetime.now() - datetime.timedelta(minutes = 2), action=discord.AuditLogAction.webhook_create):
          await channel.guild.ban(i.user, reason="Anti-Nuke: Creating Webhooks")
          await i.target.delete()    
    except:
        pass     
#

this code is not working

slate swan
#

well since you just pass the exception , you won't get where the problem is

slate swan
#

Remove the try except , and see what error you get

#

!d discord.TextChannel.guild

#

Alr

light violet
#
@client.event
async def on_webhooks_update(channel):
     
        guild = channel.guild     
        async for i in channel.guild.audit_logs(limit=1, after=datetime.datetime.now() - datetime.timedelta(minutes = 2), action=discord.AuditLogAction.webhook_create):
          await channel.guild.ban(i.user, reason="Anti-Nuke: Creating Webhooks")
          await i.target.delete()    
        ```
#

this?

slate swan
#

Yea try running this and see the error

light violet
# slate swan Yea try running this and see the error
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 326, in on_webhooks_update
    await channel.guild.ban(i.user, reason="Anti-Nuke: Creating Webhooks")
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/guild.py", line 2026, in ban
    await self._state.http.ban(user.id, self.id, delete_message_days, reason=reason)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/http.py", line 248, in request
    raise Forbidden(r, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions
Ignoring exception in on_webhooks_update
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 326, in on_webhooks_update
    await channel.guild.ban(i.user, reason="Anti-Nuke: Creating Webhooks")
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/guild.py", line 2026, in ban
    await self._state.http.ban(user.id, self.id, delete_message_days, reason=reason)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/http.py", line 248, in request
    raise Forbidden(r, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions
#

bruh

lean bolt
slate swan
#

^^^

light violet
slate swan
#

Since you created the webhook , and your bot cannot ban u

light violet
#

come and test cuz i am the owner lmao JsQcDExd

#

this is the invite code

slate swan
#

Send the link in dms

light violet
light violet
#

what to do

slate swan
light violet
#

ok

light violet
slate swan
#

Last line

light violet
#

ok

light violet
hoary gust
#

guys how can i make a slash command in cog using disnake ?

velvet tinsel
#

Morning

shadow wraith
#

morning dekriel, but anyways i tried figuring out how tf to use permission names

#

like manage_messages, manage_channels but then a super long name like manage_emojis_and_stickers or view_audit_logs

cold sonnet
#

they are listed in the api reference somewhere

slate swan
#

!d discord.Permissions

unkempt canyonBOT
#

class discord.Permissions(permissions=0, **kwargs)```
Wraps up the Discord permission value.

The properties provided are two way. You can set and retrieve individual bits using the properties as if they were regular bools. This allows you to edit permissions.

Changed in version 1.3: You can now use keyword arguments to initialize [`Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions") similar to [`update()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.update "discord.Permissions.update").
slate swan
#

They are all listed below.

#

!d disnake.Permissions

unkempt canyonBOT
#

class disnake.Permissions(permissions=0, **kwargs)```
Wraps up the Discord permission value.

The properties provided are two way. You can set and retrieve individual bits using the properties as if they were regular bools. This allows you to edit permissions.

Changed in version 1.3: You can now use keyword arguments to initialize [`Permissions`](https://docs.disnake.dev/en/latest/api.html#disnake.Permissions "disnake.Permissions") similar to [`update()`](https://docs.disnake.dev/en/latest/api.html#disnake.Permissions.update "disnake.Permissions.update").
slate swan
#

Same for disnake, just some different names and new permissions due to updates.

waxen onyx
#
# Custom help command
@client.command(name='help')
@commands.cooldown(1, 30, commands.BucketType.user)
async def help_command(ctx):
    embed = discord.Embed(title='3P PIE HELP CENTER', description='These are all the commands available on this bot.', color=discord.Color.gold())
    embed.set_thumbnail(url=bot_logo)
    embed.set_footer(text='There is no specific help for every command, it wastes time and the name of commands are related to their functions.')
    embed.add_field(name='Help Commands', value='`help`', inline=False)
    embed.add_field(name='Coming Soon', value='`support-server`', inline=False)
    msg = await ctx.reply(embed=embed)
    await msg.add_reaction(trash_emoji)
    def check(user, reaction):
        return user == ctx.author and reaction.emoji in [trash_emoji]
    user, reaction = await client.wait_for('reaction_add', check=check)
    if str(reaction.emoji) == trash_emoji:
        await msg.delete()
        await ctx.message.delete()

Please tell me why it don't delete the message on the reaction of delete emoji 😭

spring flax
#

Setting a command signature in the command decorater doesn't change the error.param of a command. Is there any way around this?

waxen onyx
#

Its a custom emoji

slate swan
#

Well

#

It's pretty simple.

#

You've defined user, reaction

#

But the event gives reaction, user back

#

!d discord.on_reaction_add

waxen onyx
#

Oh

unkempt canyonBOT
#

discord.on_reaction_add(reaction, user)```
Called when a message has a reaction added to it. Similar to [`on_message_edit()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_message_edit "discord.on_message_edit"), if the message is not found in the internal message cache, then this event will not be called. Consider using [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") instead.

Note

To get the [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") being reacted, access it via [`Reaction.message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Reaction.message "discord.Reaction.message").

This requires [`Intents.reactions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.reactions "discord.Intents.reactions") to be enabled.

Note

This doesn’t require [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") within a guild context, but due to Discord not providing updated user information in a direct message it’s required for direct messages to receive this event. Consider using [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") if you need this and do not otherwise want to enable the members intent.
slate swan
#

See the things in ()

#

This is what the event gives back, and order cannot be changed.

waxen onyx
#

@slate swan can you give me the simple code

#

for the check and wait for user

slate swan
waxen onyx
#

@slate swan

#

Still don't work😭

slate swan
#

Same in your check function.

waxen onyx
#

Did

#

def check(reaction, user):
return user == ctx.author and reaction.emoji in [trash_emoji]
reaction, user = await client.wait_for('reaction_add', check=check)
if str(reaction.emoji) == trash_emoji:
await msg.delete()
await ctx.message.delete()

#
def check(reaction, user):
        return user == ctx.author and reaction.emoji in [trash_emoji]
    reaction, user = await client.wait_for('reaction_add', check=check)
    if str(reaction.emoji) == trash_emoji:
        await msg.delete()
        await ctx.message.delete()
slate swan
#

Indentation is completely wrong, please take a look at it again.

waxen onyx
#

STILLL DON"T WORK

slate swan
#

!indents

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

waxen onyx
#
def check(reaction, user):
        return user == ctx.author and reaction.emoji in [trash_emoji]
reaction, user = await client.wait_for('reaction_add', check=check)
if str(reaction.emoji) == trash_emoji:
    await msg.delete()
    await ctx.message.delete()
#

@slate swan

#

This is my code

#

Pls someone hellp

brave ravine
#

u were already told your indentation is wrong and it clearly is...

slate swan
#

In your check function

slate swan
brave ravine
#

oh, i didnt scroll down when i type that whoops

cold sonnet
#

what's trash_emoji

slate swan
cold sonnet
#

!ytdl

unkempt canyonBOT
#

Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.

For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:

The following restrictions apply to your use of the Service. You are not allowed to:

1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service;  (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;

3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;

9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
slate swan
cold sonnet
#

is bad

#

can't help

slate swan
#

!rule 5

unkempt canyonBOT
#

5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.

spring flax
#

how does one get the argument that raises BadArgument?

cold sonnet
#

when you typehint an arg to int

#

and you get a string

#

for example

spring flax
#

did you even read what I asked?

cold sonnet
#

oh

#

almost understood

#

hmm

#

!d discord.ext.commands.BadArgument

unkempt canyonBOT
#

exception discord.ext.commands.BadArgument(message=None, *args)```
Exception raised when a parsing or conversion failure is encountered on an argument to pass into a command.

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

it doesn't seem to have any attributes

#

unlike BadUnionArgument which does

#

makes no sense to me

#

maybe if you use typing.Union on every argument then you can get it from BadUnionArgument 🤔

light violet
#

hey i want create a event in which if some person send embeds or someone has streaming status then hw would get banned as selfbot user

cold sonnet
#

I do not think that you can do that with embeds, since the embed could also be a youtube link or smth

light violet
#

btw i need only embed responder

cold sonnet
#

in which case you'd need to do some logical handling

cold sonnet
#

if there's an embed AND no url, then ban

light violet
#

btw i couldnt make it

cold sonnet
#

uh

#

I don't have it

#

u gotta write it

#

and I wouldn't spoonfeed even if I had it

light violet
#

i am stuck at
@client.event
async def on_member_message(message)

cold sonnet
#

use on_message

light violet
cold sonnet
#

not on_member_message lmao

light violet
#

wow

cold sonnet
#

if message.author.bot, then return

light violet
#

ohk

#

yep btw what about embed identification

cold sonnet
#

check the length of message.embeds

#

if there are more than 0, there's an embed

light violet
cold sonnet
#

if len(message.embeds) ...

light violet
#

if len(message.embed) >0?

cold sonnet
#

well the >0 isn't even needed

#

because if will return false if it's 0

#

and true if it's 1 or more

light violet
#

what to do then

#

=>

cold sonnet
#

no

light violet
#

?

cold sonnet
#

nothing's needed

light violet
#

only if len(message.embed)

cold sonnet
#

if len(message.embeds):

#

then you could check if some url is in the message

light violet
#

how?

#

i dk much about dc py

cold sonnet
#

if "https:" in message.content:?

#

this is only an example

light violet
#

ohk

cold sonnet
#

tho it could work most of the time

#

then u can ban the person if all of this is true

light violet
#
@client.event
async def on_message(message):
     try:
         if mesage.author.bot:
            return
         if len(message.embed):
            if "https:" in message.content:
               return
            else:
                await message.author(reason=f"ANTI SELFBOTS")
#

this?

cold sonnet
#

you don't need the try

light violet
#

wait except:
pass

light violet
#

without try

cold sonnet
#

if message.author.bot:

#

typo

light violet
#

ya

cold sonnet
#

and it's just await message.author.ban(...)

light violet
#

ok

#

now?

cold sonnet
#

ban

#

author.ban

light violet
#

ok

#

done thanks

light violet
cold sonnet
#

let's see if it works

light violet
#

hm

cold sonnet
#

idk if streaming status proves that he's a selfbot

#

you would need presence intent

light violet
#

yay itns enabled

#

btw how to start script

#

no idea

cold sonnet
light violet
cold sonnet
#

uh dunno

#

there are the docs for that

#

docs have all of the events

light violet
#

ohk

cold sonnet
#

even the one you need, where someone changes status

#

and the classes

#

!d discord.Status

unkempt canyonBOT
#

class discord.Status```
Specifies a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") ‘s status.
craggy cloak
#

Code:

    while not client.is_closed():
        status = random.choise(statuses)
        
        await client.change_presence(activity=discord.Game(name=status))
        
        await asyncio.sleep(10)
        
client.loop.create_task(ch_pr())

#

Error:

Traceback (most recent call last):
  File "main.py", line 41, in ch_pr
    status = random.choise(statuses)
AttributeError: module 'random' has no attribute 'choise'

cold sonnet
#

wait I'm pretty sure there was a streaming status

#

can't see it now

#

choice not choise @craggy cloak

craggy cloak
#

Thx

cold sonnet
#

and

#

are you changing presence every 10 seconds?

craggy cloak
#

Yeah it is a test maybe i will do it every 30 seconds

cold sonnet
#

that still seems much

craggy cloak
#

Is that to much?

cold sonnet
#

hope you don't get ratelimited

#

idk, I haven't tried it

#

the API should handle it

craggy cloak
#

What is a good number of seconds?

#

to change the status?

cold sonnet
#

shrug

lime vector
#

I'm and expert at Pycord

cold sonnet
#

nice

lime vector
#

dpy death

#

makes me sad

light violet
# cold sonnet nice

hey for final thing i just need another cmd
@client.event
async def on_channel_create(channel):

i want to make an event which will delete channels which are multiply created in less amount of time

#

like 500 channels in 1 sec threaded

cold sonnet
#

!d discord.on_guild_channel_create

light violet
#

wow

unkempt canyonBOT
#

discord.on_guild_channel_delete(channel)``````py

discord.on_guild_channel_create(channel)```
Called whenever a guild channel is deleted or created.

Note that you can get the guild from [`guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.GuildChannel.guild "discord.abc.GuildChannel.guild").

This requires [`Intents.guilds`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.guilds "discord.Intents.guilds") to be enabled.
cold sonnet
#

i do not know bruhkitty

#

how would you even create that many channels

#

that's discordly not possible

light violet
#
@client.event
async def on_guild_channel_create(channel):
    try:
        guild = channel.guild
        logs = await guild.audit_logs(limit=1, action=discord.AuditLogAction.channel_create).flatten()
        logs = logs[0]
        reason = "Channel Created "

        if client.user.id == logs.user.id:
            return
        
        await channel.delete(reason="R-Dynamic PROTECTION auto recover")
             
        await logs.user.ban(reason=f"R-Dynamic Protection System")
            
    except:
        pass    
``` this is the actuall code btw it cant del channels created by threaded nukers like 500 ch in 1 sec
#

he simply ignores actions

light violet
slate swan
light violet
cold sonnet
#

ye

light violet
#

to protect discord against this

tight obsidian
#

!rule 5 @light violet we're not going to help you with a nuke bot. stop.

unkempt canyonBOT
#

5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.

light violet
#

nukers i left nuking 1 year ago my id was banned

slate swan
#

Not what your message says though?

light violet
slate swan
#

threads bro "we r nukers" "we create that" with allacrity proxie and thread nukers 110 bans per second spped

light violet
#

@slate swanread above

slate swan
#

"We" implies you.

light violet
cold sonnet
#

why would it be a nuke bot if we just put self bot defense in it

light violet
#

not for nuke

slate swan
#

Then "we", which implies you, are "nukers".

light violet
light violet
slate swan
#

I'm just quoting from your message, maybe you wrote it in a way you didn't wanted to

light violet
#

never blame someone without reading

#

everything

slate swan
cold sonnet
#

you pinged all mods because of a message

light violet
slate swan
#

Someone asked how it is possible to create multiple channels in a few seconds, you said "we are nukers". The "we" includes you.

#

Not how, read carefully.

cold sonnet
#

you edited it

#

...

slate swan
#

How it is possible to create that many channels in a few seconds.

cold sonnet
#

okay let's stop

slate swan
#

And they said "we are nukers", so pretty self explaining.

#

Now I'd suggest to leave it behind and move on :p

cold sonnet
#

makin an antinuke bot

light violet
slate swan
#

Again, I was only quoting your message saying "we are nukers".

light violet
#

we r humans not bots so we r pinging a msg

#

without knowing reason

#

i think u r a human too

cold sonnet
#

back to topic?

light violet
#

yep

#

so how to detect that

#

my bot is simply ignoring it

cold sonnet
#

what does logs even return

opaque wadi
#

@light violet what ya need?

light violet
#

like recovery of server

cold sonnet
#

but

#

how does he have permission

#

or the person that would do this

light violet
cold sonnet
#

even if he has permission and does this, the bot deleting 500 channels is gonna ratelimit it instantly

light violet
#

and server in danger

opaque wadi
round kernel
#

If you are worried about this happening to your server, just force every channel creation to be done via the bot. So it can limit if required

cold sonnet
#

clever

cold sonnet
#

actually both works

#

griff's answer is even gonna keep yoir bot alive

light violet
#

and nothin else so threaded nukers nuke server easily

opaque wadi
cold sonnet
#

replace limit=1 with limit=5

#

and if it's all channel create events, you do what you have to

light violet
# opaque wadi Hmm,i mean i have you what ya gotta do...i am not sure how it will look in code
@clieant.event
async def on_guild_channel_create(channel):
    try:
        guild = channel.guild
        logs = await guild.audit_logs(limit=1, action=discord.AuditLogAction.channel_create).flatten()
        logs = logs[0]
        reason = "Channel Created "

        if client.user.id == logs.user.id:
            return
        
        await channel.delete(reason="R-Dynamic PROTECTION auto recover")
             
        await logs.user.ban(reason=f"R-Dynamic Protection System")
            
    except:
        pass    

actuall code and it need edit it dels only actions taken by user not threaded bots it would ignore channels craeted by thread

opaque wadi
#

What you mean by thread?

light violet
light violet
#

multiple channel like things controlled at same time

cold sonnet
#

discord threads

#

lmao

light violet
#

fastesr than u can imagine

opaque wadi
#

Ohh,i tough some shit with THREADS as module...

light violet
#

one blick server trashed

opaque wadi
#

Not sure tbh

light violet
#

such powerfull

round kernel
#

I mean, threading doesn't stop ratelimits

slate swan
#

You'd need multiple accounts anyways.

#

And as Griff said, Limit channel creation to the bot only. Then less to worry about.

round kernel
#

Prevention is probs better than trying to revert changes

cold sonnet
#

and if the server's owner is hacked, there's nothing left

#

then that's it

pale sorrel
slate swan
#

Well then don't create a server at all if you're so worried.

#

Or give the ownership to an account you never use and will never use, and have a very long and random password.

round kernel
#

remember to use your 2FA check

slate swan
#

Doesn't prevent token leaks though.

#

Which is what people would use to raid using the owner account.

#

But yeah as you said, prevention is better than revert.

round kernel
#

Probs best to move back towards the topic of bot creation for Discord. Kinda moving offtopic

slate swan
#

Yup

round kernel
#

Since Discord.py got deprecated, I aint even looked into making Discord bots.
What is the best framework/package at the moment? In your opinion

cold sonnet
#

disnake

slate swan
#

disnake is probably the most used and popular one with updated features.

round kernel
#

I'll take a look at their features page

slate swan
#

I'd go for that, most of the others are either half-baked or not updated.

light violet
#

not for selfbots

cold sonnet
#

it's the same as dpy
with slash commands and buttons

round kernel
slate swan
#

It's a discord.py fork, so the code is quite simple to migrate. (If you had a previous bot of course.)

cold sonnet
drifting tulip
#

caught a tos breaker in the act

light violet
#

@slate swanselfbots can do that without rate limit

cold sonnet
#

experienced

slate swan
#

Every account has rate limits.

drifting tulip
#

he obviously uses a selfbot

#

💀💀

slate swan
#

Try it yourself :p

light violet
slate swan
#

You will get rate limited.

light violet
slate swan
#

Same for sending messages, adding reactions, etc.

slate swan
round kernel
#

Can we keep it on topic to Discord bot development

drifting tulip
#

they aren't gonna stay ratelimited for weeks on weeks

light violet
#

@slate swanit did happen bro

slate swan
#

You know you don't need to ping me in every message right? 😅

drifting tulip
light violet
slate swan
light violet
#

is next cord faster than py?

#

@drifting tulip wott

#

nopehard

slate swan
light violet
#

@slate swanohk

#

btw js is slower than py

drifting tulip
#

i have one, fastest ttb was like 0.2s

drifting tulip
slate swan
drifting tulip
#

okay we are heavily off topic

light violet
drifting tulip
#

it's probably not as fast as u think

#

but dn me abt it not here

slate swan
#

my friend
How about you ask them since it's your friend?

light violet
drifting tulip
light violet
#

the vid of test allacrity vs darkz

slate swan
#

Videos can be easy to fake if you know how your bot handles things.

drifting tulip
#

dms

light violet
slate swan
#

Anyways, you asked how they did it; then ask them since it's your friend :p

velvet tinsel
#

what’s wrong

cold sonnet
#

wanting to make an antinuke bot
❌ help him
✅ accuse him of nuking

untold token
#

Lmao

covert turret
#

guys

#

how can i activate venv in vscode?

boreal ravine
#

@velvet tinsel why

slate swan
red sundial
#

also this isn't relevant to discord bots

covert turret
velvet tinsel
boreal ravine
#

nothing

#

I thought you were banned

velvet tinsel
#

🤔 ok

spring flax
#

there is nothing like set_slowmode on a TextChannel, right? You have to edit the channel to do that

broken igloo
#

Hello! I'm wondering which library is better: Nextcord, Pycord, Enhanced-dpy?

sage otter
#

None of those

#

disnake is the preferred lib right now.

slate swan
slim ibex
#

Nextcord

#

But there is this new one called Pincer. It looks very promising

#

It’s still in alpha stage I’m pretty sure though

slate swan
#

Yeah, heard of it. Doesn't look that bad, would need to see its performance, features, etc.

#

Once it's out of alpha, since alpha versions are known to be less stable and performant than official releases.

slim ibex
#

yea

barren oxide
#

hi

#

i want to make a python code

#

pls dm me

heavy folio
#

no

#

send it here

unkempt canyonBOT
broken igloo
#

Why it's better than other libraries?

manic wing
#

it just is

#

its got better syntax

#

better maintainers

#

better collaborators

#

better owners (we love eqeuenos)

#

better updates

#

better community

#

better consistency

tepid sage
#

Hmm.. relax. You are a fan, that's obvious.

manic wing
#

everyones a fan

tepid sage
#

Obviously not the people asking why it's better.

manic wing
#

everyone inthis channel loves disnake

slate swan
#

Debatable

manic wing
#

non-debatable

fluid spindle
#

Here's another stupid question: How many changes in the code would one have to make if they switch from Discord.py to disnake?

#

A lot?

manic wing
#

does your code use dislash

#

if not, all you have to do is ctrl+r every word discord to disnake

#

and you're done

regal leaf
manic wing
slate swan
fluid spindle
broken igloo
final iron
fluid spindle
#

Yeah, I'll be careful

slate swan
sacred sigil
#

how do I check for a .gif or .png/.jpeg in a message event?

#

if message.content....

little ether
#

!d discord.Message.attachments

unkempt canyonBOT
sacred sigil
#

ty

#

wait @little ether

#

nvm how do I check for a gif in that attachment?

#

there isnt a gif method or anything

#

is...

little ether
sacred sigil
#

appreciate it bro

sacred sigil
#
    for attachment in message.attachments:
        if attachment.filename.split(".")[1] == "gif":
            gif_embed = Embed(title="random gif", color=0x0f0f0f)
            gif_embed.set_image(url=attachment)
little ether
sacred sigil
#

ty

sacred sigil
#

would this work?

little ether
sacred sigil
#

been time since I coded lol

#

tyy

#

also is there a get method for message?

#

I could use bot

#

nvm

#

could this work

slate swan
#

how do I check if a message includes a user mention?

sacred sigil
#

for what event

sacred sigil
# little ether you'd replace the `==` with `in`
@bot.event
async def on_message(message):
    gif_channel = bot.get_channel(928014494142197820)
    icon_channel = bot.get_channel(928014556926738433)
    for attachment in message.attachments:
        if attachment.filename.split(".")[1] == "gif":
            gif_embed = Embed(title="random gif", color=0x0f0f0f)
            gif_embed.set_image(url=attachment.url)
            await message.gif_channel.send(embed=gif_embed)
        elif attachment.filename.split(".")[1] in ["jpg", "jpeg", "png"]:
            icon_embed = Embed(title="random icon", color=0x0f0f0f)
            icon_embed.set_image(url=attachment.url)
            await message.icon_channel.send(embed=icon_embed)
#

works or nah

little ether
sacred sigil
#

alri imma try it

#

what was that code to fix the commands

#

i forgot it

slate swan
#

if a message includes a user mention

little ether
#

!d discord.Message.mentions

unkempt canyonBOT
#

A list of Member that were mentioned. If the message is in a private message then the list will be of User instead. For messages that are not of type MessageType.default, this array can be used to aid in system messages. For more information, see system_content.

Warning

The order of the mentions list is not in any particular order so you should not rely on it. This is a Discord limitation, not one with the library.

sacred sigil
#

or smth

little ether
sacred sigil
#

to make the commands run whilst the event runs

#

thank u

slate swan
#

or is it just of members

little ether
sacred sigil
#

I forgot how to send messages to specific channels

#

I have the ids

little ether
little ether
sacred sigil
sacred sigil
#

Same error

#

wait

little ether
sacred sigil
#

yes

#

thank u

fluid spindle
#

When is on_command_error from pysnake executed?

#

I mean, is it executed when the command the user sent doesn't exist?

slate swan
#

What's pysnake ( another fork?)

#

it fired whenever any error in command occurs in discord.py

#

including checks , convert failures etc

slate swan
#

pysnake is actually a snake game

#

!pypi pysnake

unkempt canyonBOT
#

A curses-based cross-python version of Snake with zoom and rewind modes

slate swan
#

Rip

#

Lmao

#

They mean disnake , maybe...

#

Or pycord , they mixed both ☠️

fluid spindle
#

Lol, yeah, I meant disnake

final iron
#

discord.ext.commands.Bot

#

Not discord.Bot

potent spear
#

you mostly see commands.Bot since we import it as from discord.ext import commands

slate swan
#

Hello everyone, I have tried to make a bot from python, but I am facing a issue. Please anyone can look into this.

#

This ^ is the issue which I have faced, I have tried to resolved it but not do it.

potent spear
slate swan
#

Yeah I am sure

potent spear
#

it will print None if the token doesn't exist..

#

that's your case

slate swan
slate swan
slate swan
slate swan
#

Try using pycord.Bot instead of discord.Bot

potent spear
manic wing
# slate swan

am I the only one who wants someone to spend 45 minutes trying to hack this guys bot token just to realise its in 0 servers x.x

potent spear
slate swan
slate swan
potent spear
winter moth
#

you dont need to use a .env file if youre using replit

potent spear
#

I don't use replit, it stinks, you can ask others

slate swan
potent spear
#

why are you using a .env tho? don't tell me you're following a YT tutorial pls

potent spear
#

don't, use the docs instead

slate swan
#

Okay

potent spear
#

plenty of examples etc

slate swan
#

enter token as key , and the token in value

slate swan
slate swan
winter moth
#

under the lock tab on the side enter your bot token as token

lapis breach
winter moth
#

you dont need load.env at the end either

lapis breach
#

but... it is kinda cool

slate swan
winter moth
#

what is it showing you

slate swan
winter moth
#

and delete the .env file as well. not needed

honest vessel
#

using disnake, how can i get more information about failed slash command? This interaction failed <-- all i get

winter moth
#

i cant read it. its so blurry

placid skiff
slate swan
#

Wait

placid skiff
#

!d disnake.ext.commands.CommandError

unkempt canyonBOT
#

exception disnake.ext.commands.CommandError(message=None, *args)```
The base exception type for all command related errors.

This inherits from [`disnake.DiscordException`](https://docs.disnake.dev/en/latest/api.html#disnake.DiscordException "disnake.DiscordException").

This exception and exceptions inherited from it are handled in a special way as they are caught and passed into a special event from [`Bot`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.Bot "disnake.ext.commands.Bot"), [`on_command_error()`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.disnake.ext.commands.on_command_error "disnake.disnake.ext.commands.on_command_error").
slate swan
#

And I am also deleting the .env file

winter moth
#

open up the 🔒 tab on the left. make sure it is spelled "token" all lower case.

delete client.run line.

change case from "TOKEN" to "token"

#

and add the token inside it the lock tab

#

if you look here it tells you what line is causing the problem

slate swan
#

It shows error: bot is not defined

dense coral
winter moth
#

i said the wrong one its keep client.run(os.getenv('token'))

lapis breach
#

does any1 know how to make button interactions using discord.py?

slate swan
honest vessel
#

oh found it

#

disnake.ext.commands.on_slash_command_error(inter, error)

slate swan
slate swan
#
async def on_reaction_add(self,reaction, user):```
with this, how can i get the guild id?
slate swan
honest vessel
#
@commands.slash_command(description="Show others that you are Away-From-Keyboard.")
    async def AFK(inter):
        await inter.response.send_message("Test", delete_after=20)

Why this not work... all i get is "This interactionfailed."

    @commands.slash_command(description="Get an invite link to share!")
    async def invite(inter):
        try:
            invite = await inter.channel.create_invite(max_uses=0,unique=False)
        except disnake.errors.NotFound:
            print("NO INVITE THER!")
        await inter.response.send_message(invite, delete_after=20)

But this one does... ?

slate swan
red sundial
#

see the docs for more info

red sundial
#

did you install whatever package you're using after uninstalling discord.py?

#

well you gotta install your package first lol

#

do you know basic python?

#

you should learn basic python before moving to intermediate libraries like discord.py or its forks

slate swan
#

hmmmmm somethings wrong

#

oh wait its replit

#
role = get(user.guild.roles, id=pr[str(user.guild.id)])```

it is a valid role id, and a valid user in the server but is throwing - discord.errors.NotFound: 404 Not Found (error code: 10011): Unknown Role

I dont know why this is
slate swan
lapis breach
#

does any1 know how to make button interactions using discord.py? if yes pls ping me i need help doing interactions

slate swan
lapis breach
#

ohh... sorry i was busy

slate swan
#

No problem ^^

lapis breach
#

wait didnt you use components for the buttons?

slate swan
#

The example shows how to use buttons.

#

It gives 2 buttons for confirmation, so a "Yes" and a "No" button.

lapis breach
#

i used components for it didnt even know you could do it this way

#

also were do you actually send the buttons?

slate swan
slate swan
#

It creates a view with the different buttons, and sends them with the message.

lapis breach
#

do i need to install anything?

#

discord.ui or something?

dim oriole
boreal ravine
dim oriole
lapis breach
boreal ravine
winter moth
dim oriole
#

you mean like ctx.author?

boreal ravine
light violet
#

hey can any body say that how to make a event that bans user on member role update with admin or harm full permissions

dim oriole
#

the command author

boreal ravine
#

yes but what type of object is it?

dim oriole
#

discord.Member ig

boreal ravine
#

then yes

slate swan
lapis breach
light violet
winter moth
#

post the whole code here

boreal ravine
# dim oriole

!d discord.Member.add_roles only takes 1 positional argument by the way

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.
dim oriole
winter moth
#

no

light violet
#

what do u guyz need

winter moth
#

alais

lapis breach
dim oriole
#

still not working

light violet
#

@dim oriolebro

dim oriole
#

yea

boreal ravine
boreal ravine
untold token
#

or use poetry

dim oriole
#

it sends a get request to a webserver which returns a role id so its 914610998009282591

boreal ravine
light violet
#

@dim oriolewhat do u need kid

dim oriole
#

no

untold token
dim oriole
#

its a string

#

its just '914610998009282591'

light violet
dim oriole
#

i'm not

slate swan
untold token
#

because if you need the content, then you need to do answer.content

boreal ravine
untold token
light violet
#

@dim oriolewhat do u need anything i can provide u the whole code

untold token
#

!d discord.Message.content

unkempt canyonBOT
untold token
#

This returns the content of the message as a string

light violet
boreal ravine
untold token
light violet
untold token
#

Yeah that too

#

It takes an int

#

so, it would be

 int(answer)
dim oriole
#

worked

light violet
#

if anybody could help me pls reply

dim oriole
#

i thought it needed a string

untold token
#

Nah it needs an int

twilit karma
dim oriole
#

thanks ;D

untold token
#

Errors?

twilit karma
#

What's your name first

light violet
twilit karma
#

venom dc

light violet
#

ok i am comming waitlemme dinner

twilit karma
#

What's

light violet
#

dc = discord

twilit karma
#

The concern you're facing

boreal ravine
lapis breach
#

wait i am supposed to download the thing before installing or do i just put the link there?

honest vessel
#

disnake slashcommand, ok how can i grab created_at it does exists in ctx.message but how about slashcommands in disnake?

twilit karma
boreal ravine
honest vessel
#

inter, has no message attribute

untold token
#
pip install -U git+https://github.com/Rapptz/discord.py.git
#

This should work afaik

honest vessel
#

@boreal ravinectx.message.created_at but how i get that datetime when use slashcommands aka datetime of execution of slashcommand?

untold token
#

Yes it would

untold token
honest vessel
#

disnake

untold token
lapis breach
#

pip install git?

slate swan
# winter moth post the whole code here

`import discord
import os

client=discord.Client()

@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))

@client.event
async def on_message(message):
if message.author == client.user:
return

if message.content.startswith('$hello'):
    await message.channel.send('Hello!')

client.run(os.getenv('token'))`

untold token
#

For example

lapis breach
honest vessel
slate swan
#

It shows error at the last line i.e. line 20

untold token
#
@bot.slash_command(name="test", description="...")
async def test_command(inter: disnake.ApplicationCommandInteraction):
   created_at = inter.application_command.created_at   #  returns a datetime object
   ...  # your code here, to do whatever with the date
#

This should work

#

Try it and see

untold token
honest shoal
honest vessel
#

when it was invoked @untold token

untold token
#

Ah I see

dim oriole
#

how can i remove all roles of an user like

for role in user:
  await user.remove_roles(role)```
honest shoal
untold token
#

Did you install git?

#

You need install and set it up

honest shoal
slate swan
untold token
#

The link that they gave, install git in the path and then run the command

lapis breach
untold token
honest shoal
untold token
#

!d discord.Member.roles

unkempt canyonBOT
#

property roles: List[Role]```
A [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role") that the member belongs to. Note that the first element of this list is always the default [‘@everyone](mailto:'%40everyone)’ role.

These roles are sorted by their position in the role hierarchy.
dim oriole
honest shoal
lapis breach
untold token
#

Loop through

#

The way you did it

dim oriole
#

but it didnt worked

#

it says unknown role

slate swan
untold token
#

Because you are not getting the roles

dim oriole
untold token
#

Any error?

slate swan
dim oriole
untold token
#

The bot token isn't correct

untold token
honest shoal
dim oriole
untold token
#

Weird

#

Try printing ctx.author.roles

#

and see what you get

dim oriole
#

ok

untold token
#

!d discord.Member.remove_roles

unkempt canyonBOT
#

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

Removes [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s from this member.

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 removed [`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.
dim oriole
untold token
#

Hm

#

Yeah those are the role objects, so that's working

#

Try removing a role through its ID

light violet
#

how to make a event that bans user on member role update with admin or harm full permissions

dim oriole
#

so with

untold token
#

See that if the method is working or not

untold token
lapis breach
dim oriole
#
role = ctx.guild.get_role(role.id)```
dim oriole
untold token
#

Try it

#

Although its unnecessary

#

role is already an Role object

dim oriole
#

still error

light violet
#

bro if anybody is free pls respond

untold token
#
role = ctx.guild.get_role("ID of the role directly") 
await ctx.author.remove_roles(role)
#

The role ID should be an integer

dim oriole
untold token
#

Nonono

#

Don't do that yet

dim oriole
#

what should i do then?

lapis breach
honest shoal
light violet
#

what is the topic of discussion

dim oriole
#

ok

#

id as a string or int?

untold token
#

int

lapis breach
untold token
#

Check if the member has administrator perms and then do whatever you want

dim oriole
#

still unknown role

untold token
#

!d discord.on_member_update

unkempt canyonBOT
#

discord.on_member_update(before, after)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") updates their profile.

This is called when one or more of the following things change:

• nickname

• roles

• pending...
untold token
dim oriole
#

no

light violet
dim oriole
#

this worked

slate swan
untold token
#

Oh that worked?

dim oriole
#

yea

untold token
#

That's weird

#

Okay do one thinh

honest shoal
untold token
#

Thing

dim oriole
#

wait

untold token
#

@dim oriole use a try except exception handler to check what role that is raising that error

#

So like

lapis breach
honest shoal
honest shoal
untold token
#
for role in ctx.author.roles:
   try:
     await ctx.author.remove_roles(role)
   except commands.errors.NotFound:
    ...  # something here
slate swan
lapis breach
untold token
# dim oriole wait

If there is an error while removing the role it will not stop and continue skipping that role

untold token
dim oriole
light violet
#

@untold tokencan u tell me what is his question? what he wants help about

honest shoal
untold token
#

🔥 Enrol for FREE DevOps Course & Get your Completion Certificate: https://www.simplilearn.com/learn-git-basics-skillup?utm_campaign=Git&utm_medium=DescriptionFirstFold&utm_source=youtube
This Git installation video will take you through the step by step process involved in Git installation on Windows. Git is a distributed version control tool wh...

▶ Play video
#

@lapis breach watch this

honest shoal
#

^^

slate swan
untold token
#

That was the issue

honest shoal
winter moth
slate swan
winter moth
#

do you have the token set

untold token
#

!d discord.Member.guild_permissions

unkempt canyonBOT
#

property guild_permissions: discord.permissions.Permissions```
Returns the member’s guild permissions.

This only takes into consideration the guild permissions and not most of the implied permissions or any of the channel permission overwrites. For 100% accurate permission calculation, please use [`abc.GuildChannel.permissions_for()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.GuildChannel.permissions_for "discord.abc.GuildChannel.permissions_for").

This does take into consideration guild ownership and the administrator implication.
untold token
#

Then you need to check if they got any role or not using that event

slate swan
untold token
winter moth
#

click the lock

untold token
#

and not the proper way to make a discord bot

honest shoal
#

@slate swanyou can add py from dotenv import load_dotenv load_dotenv()

untold token
winter moth
honest shoal
slate swan
light violet
#

os.getenv('token')

untold token
#
import discord
from discord.ext import commands

bot = commands.Bot(command_prefix='.', intents=discord.Intents.all())  #  This is subclassed version of discord.Client(), but it has more features and comes with a message command framework built in, the framework allows us to create commands in a much more better and easier  way than raw on_message events.

@bot.listen()  # This decorator creates and adds an asynchronous event listener to the bot, with the type of the event to listen to 
async def on_ready():
    """Called when the client is done preparing the data received from Discord."""
    print("Bot is ready")

@bot.command()  #  This decorator creates and registers the command that you created, using the commands framework.
async def test(ctx: commands.Context):
 # takes context object as the first argument, Context object is special object that is passed by the commands framework that contains necessary data, like command invoker, the gold and channel where the command was invoked and more
    """A test command"""
    await ctx.send("test")

@bot.listen() 
async def on_message(message: discord.Message):
    """Called when a Message is created and sent."""
    if message.author.bot:
        return
    ...  #  your code here

bot.run(token)

A simple example on how to create a bot using the commands framework

light violet
#

this is the correct code for py

untold token
#

That's the issue

winter moth
#

key = the word "token"
value = your bot token

untold token
#

You need to use secrets and then get your data from that

honest shoal
light violet
#

easy

#

for replit