Skip to content

Migrate kick, ban and unban command - #244

Merged
Zabuzard merged 21 commits into
developfrom
feature/kick_and_ban_commands
Nov 16, 2021
Merged

Zabuzard merged 21 commits into
developfrom
feature/kick_and_ban_commands

Conversation

@Zabuzard

@Zabuzard Zabuzard commented Nov 3, 2021 •

Copy link
Copy Markdown
Member

Overview

Continuation from #196 .

Adds the ban, kick and unban commands.

Partially implements #63 and #64 .


Role based instead of Permissions

The moderation commands for this bot are role based instead of being based on permissions. For that, the config introduces two new entries:

"heavyModerationRolePattern": "Moderator",
"softModerationRolePattern": "Moderator|Staff Assistant"

This allows us to give roles, for example Staff Assistant the possibility to kick(mute, delete-messages, ...) without actually having permission to do so in Discord. That way, we can force them to use the bot instead of other bots or the Discord GUI - making it easier for us to control the flow and in particular give visibility through audit logs, since all actions have to go through our bot now.


Test Checklist

Before merging, we now have to test the following scenarios:

Base cases:

  • Ban an user
  • Kick an user
  • Unban a banned user

Permissions:

  • Ban without having ban perms
  • Kick without having kick perms
  • Unban without having ban perms
  • Ban without the bot having ban perms
  • Kick without the bot having kick perms
  • Unban without the bot having ban perms

Interaction power:

  • Ban users higher up in the hierarchy than the author
  • Kick users higher up in the hierarchy than the author
  • Ban users higher up in the hierarchy than the bot
  • Kick users higher up in the hierarchy than the bot

DM:

  • Ban (or kick) an user who enabled DMs from non-friends
  • Ban (or kick) an user who disabled DMs from non-friends

Reason:

  • Ban (or kick, or unban) an user with a reason longer than 512 characters

Logic:

  • Unban a user who is not banned (found issue, test again after issue fixed)
  • Ban an already banned user (found issue, test again after issue fixed)
  • Kick an already kicked user
  • Ban a user who does not exist
  • Kick a user who does not exist
  • Unban a user who does not exist

@Zabuzard Zabuzard added the new command Add a new command or group of commands to the bot label Nov 3, 2021
@Zabuzard Zabuzard added this to the Migrate existing commands milestone Nov 3, 2021
@Zabuzard Zabuzard self-assigned this Nov 3, 2021
@Zabuzard
Zabuzard requested review from a team as code owners November 3, 2021 09:23
@RealYusufIsmail

Copy link
Copy Markdown
Contributor

Do i still get credits @Zabuzard

@Zabuzard

Zabuzard commented Nov 3, 2021

Copy link
Copy Markdown
Member Author

Do i still get credits @Zabuzard

Of course. Look at the commit history, the first commit is still by you.

@RealYusufIsmail

Copy link
Copy Markdown
Contributor

Do i still get credits @Zabuzard

Of course. Look at the commit history, the first commit is still by you.

Ok thank you.

@RealYusufIsmail

Copy link
Copy Markdown
Contributor

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs Vulnerability A 0 Vulnerabilities Security Hotspot A 0 Security Hotspots Code Smell A 3 Code Smells

0.0% 0.0% Coverage 19.2% 19.2% Duplication

Should i try and fix this

@Zabuzard

Zabuzard commented Nov 3, 2021

Copy link
Copy Markdown
Member Author

SonarCloud Quality Gate failed. Quality Gate failed
Bug A 0 Bugs Vulnerability A 0 Vulnerabilities Security Hotspot A 0 Security Hotspots Code Smell A 3 Code Smells
0.0% 0.0% Coverage 19.2% 19.2% Duplication

Should i try and fix this

You cant contribute to this branch since you lack write permission. Ill just take over and finish this quickly.

@RealYusufIsmail

Copy link
Copy Markdown
Contributor

SonarCloud Quality Gate failed. Quality Gate failed
Bug A 0 Bugs Vulnerability A 0 Vulnerabilities Security Hotspot A 0 Security Hotspots Code Smell A 3 Code Smells
0.0% 0.0% Coverage 19.2% 19.2% Duplication

Should i try and fix this

You cant contribute to this branch since you lack write permission. Ill just take over and finish this quickly.

Can I get write permission?

@Zabuzard

Zabuzard commented Nov 3, 2021

Copy link
Copy Markdown
Member Author

SonarCloud Quality Gate failed. Quality Gate failed
Bug A 0 Bugs Vulnerability A 0 Vulnerabilities Security Hotspot A 0 Security Hotspots Code Smell A 3 Code Smells
0.0% 0.0% Coverage 19.2% 19.2% Duplication

Should i try and fix this

You cant contribute to this branch since you lack write permission. Ill just take over and finish this quickly.

Can I get write permission?

Github unfortunately does not allow that. Otherwise I would have continued in your original PR.

@java-coding-prodigy

Copy link
Copy Markdown
Contributor

SonarCloud Quality Gate failed. Quality Gate failed
Bug A 0 Bugs Vulnerability A 0 Vulnerabilities Security Hotspot A 0 Security Hotspots Code Smell A 3 Code Smells
0.0% 0.0% Coverage 19.2% 19.2% Duplication

Should i try and fix this

You cant contribute to this branch since you lack write permission. Ill just take over and finish this quickly.

Can I get write permission?

Once this gets merged, @Zabuzard will send you an invite to our GitHub team and you will be able to get write access to the base repository itself.

@RealYusufIsmail

Copy link
Copy Markdown
Contributor

SonarCloud Quality Gate failed. Quality Gate failed
Bug A 0 Bugs Vulnerability A 0 Vulnerabilities Security Hotspot A 0 Security Hotspots Code Smell A 3 Code Smells
0.0% 0.0% Coverage 19.2% 19.2% Duplication

Should i try and fix this

You cant contribute to this branch since you lack write permission. Ill just take over and finish this quickly.

Can I get write permission?

Once this gets merged, @Zabuzard will send you an invite to our GitHub team and you will be able to get write access to the base repository itself.

Ok thank you.

@Zabuzard
Zabuzard force-pushed the feature/kick_and_ban_commands branch from c57f5d4 to 1ee5544 Compare November 3, 2021 10:00
RealYusufIsmail
RealYusufIsmail previously approved these changes Nov 3, 2021

@RealYusufIsmail RealYusufIsmail left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah all looks good.

@RealYusufIsmail

Copy link
Copy Markdown
Contributor

@Tais993 @java-coding-prodigy Can you approve this

@Zabuzard

Zabuzard commented Nov 3, 2021

Copy link
Copy Markdown
Member Author

@RealYusufIsmail Please check out this branch and do all the tests from the checklist I just added. Blocking this PR until everything has been tested.

@RealYusufIsmail

Copy link
Copy Markdown
Contributor

@RealYusufIsmail Please check out this branch and do all the tests from the checklist I just added. Blocking this PR until everything has been tested.

Ok will I do when i go home

@java-coding-prodigy

Copy link
Copy Markdown
Contributor

Just curious, why is ModerationUtils an enum and not a class?

@Zabuzard

Zabuzard commented Nov 3, 2021

Copy link
Copy Markdown
Member Author

Just curious, why is ModerationUtils an enum and not a class?

Utility-enum-pattern. The safest option to forbid creation of instances, safer than private constructors and other options.

@RealYusufIsmail

Copy link
Copy Markdown
Contributor

@Zabuzard the bot can not dm users who have there dms disabled for non-friends I have tested it

Comment thread .gitignore Resolved
@Zabuzard
Zabuzard force-pushed the feature/kick_and_ban_commands branch from bff063f to 8b48e47 Compare November 15, 2021 09:55
@CLAassistant

CLAassistant commented Nov 15, 2021 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@sonarqubecloud

Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@Zabuzard

Copy link
Copy Markdown
Member Author

Merging since 7 days after last unapproved code change.
Was accepted by marko, Yusuf and Tais in the meantime already.

@Zabuzard
Zabuzard merged commit 036b893 into develop Nov 16, 2021
@Zabuzard
Zabuzard deleted the feature/kick_and_ban_commands branch November 16, 2021 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new command Add a new command or group of commands to the bot priority: major

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants