#¿Is a user bannable?

95 messages · Page 1 of 1 (latest)

kindred rain
#

I'm trying to make a discord bot that can be able to ban users but I'm running into a problem and it´s that, I want to check if the user is superior, like if it´s bannable or not checking whether the role that the user have is above the one who is trying to ban him but it isn't working. Is there something wrong with my logic?

torn sundial
#

How's the roles set up

kindred rain
#

I mean, I'm experimenting, I don't want to ban the user that I mention, I just want the message to be sent, that´s why I commented the '.kick()' line

torn sundial
#

on the server?

#

Cause if the role of the bot is below other roles in the list, it won't be able to do anything to any user above them

kindred rain
#

Let me check

#

It's at the top

torn sundial
#
Role1
Role2
Role3
BotRole
Role4

If the roles are like this, the bot will be able to only ban Role4

kindred rain
#

Nonon

#

The bot does ban people

#

But what if a moderator is trying to ban an admin?

#

Like

torn sundial
#

Admin > Moderator

kindred rain
#

Yes

torn sundial
#

Role clash

#

Mods can't ban admins as default

#

They're below admins in the hierarchy of role permissions

kindred rain
#

Exaclty

torn sundial
#

Bot has to have higher permissions to do that

kindred rain
#

But when I run the command as a lower rank the bot sends the message that I can ban them

torn sundial
#

What matters here isn't the rank/role of the person running the command

#

But the rank/role of the Bot, and the member it's trying to ban

#

If the bot has got moderator permissions, and not administrator permissions, it won't be able to ban any administrators

#

No matter who runs the command

kindred rain
#

What if it does?

torn sundial
#

Does it though?

kindred rain
#

yes

torn sundial
#

So

#

What's the question here again?

kindred rain
#

Ah

torn sundial
#

You have the bot banning wrong people?

kindred rain
#

I'm sorry I read wrong

#

XDXD

torn sundial
#

Or you can't get it to ban people?

kindred rain
#

Okay I'm gonna try to explain it again

#

As you can see in my code, I'm checking if a user is bannable

#

And when a moderator wants to ban an administrator, the bot says it is bannable

torn sundial
#

Discord rank hierarchy for servers, if the rank is below a rank, it's bannable by anyone above:

Owner (Cannot be banned by people in the server)
Administrator (Only bannable by the Owner)
Moderator (Got moderating permissions, no "Administrator" permission)
Member
#

If your bot got Administrator role, they can ban any administrator

torn sundial
#

You'll have to check the person running the command and what their role is, instead of checking the bot role

#

If you don't want mods banning admins

kindred rain
#

Well, they have the permission to ban people

#

That's it

torn sundial
#

The bot?

#

Or the people running the commands?

kindred rain
#

the moderators

kindred rain
torn sundial
#

Then you'll have to check that they aren't trying to ban anyone with administrator role

kindred rain
#

We´re experimenting

#

And I'm admin

torn sundial
#

Bot will be able to do it, even if a normal member runs the command, cause the Bot got the admin permissions

kindred rain
#

And the bot says I'm bannable

#

Shit

torn sundial
#

You're thinking about this in a slightly wrong way

kindred rain
#

XD

torn sundial
#

You're thinking that it goes based on the person using the command

#

No, it's based on the Bot role and The member being banned

kindred rain
#

Hmmmmm

#

Interesting

torn sundial
#

You'll have to code in the check to see that the command isn't used by anyone else but people it should be used by

kindred rain
#

It already does

#

Because I check whether a user has ban permission

torn sundial
#

Then add in additional checks that whoever is running the command can only ban people below them, even with the bot

kindred rain
#

How can I do that?

#

Do I have to specify every role? That doesn't sound right to me

#

How does the other bots do it?

torn sundial
#

Usually by limiting ban commands to a single trusted rank

#

But at the core, you can only check that if a person with a role named Moderator for example is trying to use the bot to ban someone with a different role, and prevent that if they are

#

Say you had these roles for staff:

Owner
Administrator (Bot belongs to this role)
Moderator

All 3 got Ban Members permissions

If the person running the ban has got Moderator role, disallow or prevent them from banning anyone with the role Administrator

#

Check the roles for the member running the command, and the member mentioned in the command

If the mentioned member is in the same group, or higher as the person running the ban command, prevent the ban

kindred rain
#

Okay okay okay okay got it

#

But now, The bot belongs to its own category

#

I mean, it has its role by default

torn sundial
#

Does that role have the Administrator permission turned on?

kindred rain
#

Yes!

torn sundial
#

Then they're exactly that

kindred rain
#

And it is at the top of everyone

torn sundial
#

In the hierarchy

#

Doesn't matter if you got 19237612786 other roles with Administrator permission

#

If the bot has got that permission, and is above the other roles, it can ban any role below them

kindred rain
#

Ohhhhh

#

Wait a minute

#

I'm gonnra try somehting and I'll be right back

torn sundial
#

If there's one Administrator rank you don't want to get banned

#

Move it above the bot role

#

Problem solved

kindred rain
#

That was the KEY

#

That´s what I went to try and it worked!

#

Thank you very much for the help!

torn sundial
#

Keep in mind that now the admin role can't be banned even by other people in the same group via the bot

kindred rain
#

Yes of course

torn sundial
#

That role essentially is now untouchable by the bot

kindred rain
#

It's okay though cuz I'm the only one with the role

#

XD