2020-10-01 01:43:38 +03:00
import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint" ;
2020-07-23 00:37:33 +03:00
import { CasesPlugin } from "../Cases/CasesPlugin" ;
import { MutesPlugin } from "../Mutes/MutesPlugin" ;
2020-07-28 21:34:01 +03:00
import { BanOptions , ConfigSchema , KickOptions , ModActionsPluginType , WarnOptions } from "./types" ;
2020-07-23 00:37:33 +03:00
import { CreateBanCaseOnManualBanEvt } from "./events/CreateBanCaseOnManualBanEvt" ;
import { CreateUnbanCaseOnManualUnbanEvt } from "./events/CreateUnbanCaseOnManualUnbanEvt" ;
import { CreateKickCaseOnManualKickEvt } from "./events/CreateKickCaseOnManualKickEvt" ;
import { UpdateCmd } from "./commands/UpdateCmd" ;
import { NoteCmd } from "./commands/NoteCmd" ;
import { WarnCmd } from "./commands/WarnCmd" ;
import { MuteCmd } from "./commands/MuteCmd" ;
2020-07-24 02:25:33 +02:00
import { PostAlertOnMemberJoinEvt } from "./events/PostAlertOnMemberJoinEvt" ;
import { ForcemuteCmd } from "./commands/ForcemuteCmd" ;
import { UnmuteCmd } from "./commands/UnmuteCmd" ;
import { KickCmd } from "./commands/KickCmd" ;
import { SoftbanCmd } from "./commands/SoftbanCommand" ;
import { BanCmd } from "./commands/BanCmd" ;
import { UnbanCmd } from "./commands/UnbanCmd" ;
import { ForcebanCmd } from "./commands/ForcebanCmd" ;
import { MassbanCmd } from "./commands/MassBanCmd" ;
import { AddCaseCmd } from "./commands/AddCaseCmd" ;
import { CaseCmd } from "./commands/CaseCmd" ;
import { CasesUserCmd } from "./commands/CasesUserCmd" ;
import { CasesModCmd } from "./commands/CasesModCmd" ;
import { HideCaseCmd } from "./commands/HideCaseCmd" ;
import { UnhideCaseCmd } from "./commands/UnhideCaseCmd" ;
2020-10-01 01:43:38 +03:00
import { GuildMutes } from "../../data/GuildMutes" ;
import { GuildCases } from "../../data/GuildCases" ;
import { GuildLogs } from "../../data/GuildLogs" ;
2020-07-24 02:25:33 +02:00
import { ForceUnmuteCmd } from "./commands/ForceunmuteCmd" ;
2020-07-28 21:34:01 +03:00
import { warnMember } from "./functions/warnMember" ;
import { Member } from "eris" ;
import { kickMember } from "./functions/kickMember" ;
import { banUserId } from "./functions/banUserId" ;
2020-07-29 02:32:01 +02:00
import { MassmuteCmd } from "./commands/MassmuteCmd" ;
2020-07-30 13:08:06 +03:00
import { trimPluginDescription } from "../../utils" ;
2020-08-09 22:44:07 +03:00
import { DeleteCaseCmd } from "./commands/DeleteCaseCmd" ;
2020-08-19 00:19:12 +03:00
import { TimeAndDatePlugin } from "../TimeAndDate/TimeAndDatePlugin" ;
2020-07-23 00:37:33 +03:00
const defaultOptions = {
config : {
dm_on_warn : true ,
dm_on_kick : false ,
dm_on_ban : false ,
message_on_warn : false ,
message_on_kick : false ,
message_on_ban : false ,
message_channel : null ,
warn_message : "You have received a warning on the {guildName} server: {reason}" ,
kick_message : "You have been kicked from the {guildName} server. Reason given: {reason}" ,
ban_message : "You have been banned from the {guildName} server. Reason given: {reason}" ,
alert_on_rejoin : false ,
alert_channel : null ,
warn_notify_enabled : false ,
warn_notify_threshold : 5 ,
warn_notify_message :
"The user already has **{priorWarnings}** warnings!\n Please check their prior cases and assess whether or not to warn anyways.\n Proceed with the warning?" ,
ban_delete_message_days : 1 ,
can_note : false ,
can_warn : false ,
can_mute : false ,
can_kick : false ,
can_ban : false ,
can_view : false ,
can_addcase : false ,
can_massban : false ,
2020-07-29 02:32:01 +02:00
can_massmute : false ,
2020-07-23 00:37:33 +03:00
can_hidecase : false ,
2020-08-09 22:44:07 +03:00
can_deletecase : false ,
2020-07-23 00:37:33 +03:00
can_act_as_other : false ,
2020-12-23 04:44:43 +02:00
create_cases_for_manual_actions : true ,
2020-07-23 00:37:33 +03:00
} ,
overrides : [
{
level : ">=50" ,
config : {
can_note : true ,
can_warn : true ,
can_mute : true ,
can_kick : true ,
can_ban : true ,
can_view : true ,
can_addcase : true ,
} ,
} ,
{
level : ">=100" ,
config : {
can_massban : true ,
2020-07-29 02:32:01 +02:00
can_massmute : true ,
2020-07-23 00:37:33 +03:00
can_hidecase : true ,
can_act_as_other : true ,
} ,
} ,
] ,
} ;
2020-10-01 01:43:38 +03:00
export const ModActionsPlugin = zeppelinGuildPlugin < ModActionsPluginType > ( ) ( "mod_actions" , {
2020-07-30 13:08:06 +03:00
showInDocs : true ,
info : {
prettyName : "Mod actions" ,
description : trimPluginDescription ( `
This plugin contains the 'typical' mod actions such as warning , muting , kicking , banning , etc .
` ),
} ,
2020-08-19 00:19:12 +03:00
dependencies : [ TimeAndDatePlugin , CasesPlugin , MutesPlugin ] ,
2020-07-23 00:37:33 +03:00
configSchema : ConfigSchema ,
defaultOptions ,
2020-07-24 02:25:33 +02:00
events : [
CreateBanCaseOnManualBanEvt ,
CreateUnbanCaseOnManualUnbanEvt ,
CreateKickCaseOnManualKickEvt ,
PostAlertOnMemberJoinEvt ,
] ,
commands : [
UpdateCmd ,
NoteCmd ,
WarnCmd ,
MuteCmd ,
ForcemuteCmd ,
UnmuteCmd ,
ForceUnmuteCmd ,
KickCmd ,
SoftbanCmd ,
BanCmd ,
UnbanCmd ,
ForcebanCmd ,
MassbanCmd ,
2020-07-29 02:32:01 +02:00
MassmuteCmd ,
2020-07-24 02:25:33 +02:00
AddCaseCmd ,
CaseCmd ,
CasesUserCmd ,
CasesModCmd ,
HideCaseCmd ,
UnhideCaseCmd ,
2020-08-09 22:44:07 +03:00
DeleteCaseCmd ,
2020-07-24 02:25:33 +02:00
] ,
2020-07-23 00:37:33 +03:00
2020-07-28 21:34:01 +03:00
public : {
warnMember ( pluginData ) {
return ( member : Member , reason : string , warnOptions? : WarnOptions ) = > {
warnMember ( pluginData , member , reason , warnOptions ) ;
} ;
} ,
kickMember ( pluginData ) {
return ( member : Member , reason : string , kickOptions? : KickOptions ) = > {
kickMember ( pluginData , member , reason , kickOptions ) ;
} ;
} ,
banUserId ( pluginData ) {
return ( userId : string , reason? : string , banOptions? : BanOptions ) = > {
banUserId ( pluginData , userId , reason , banOptions ) ;
} ;
} ,
} ,
2020-07-24 02:25:33 +02:00
onLoad ( pluginData ) {
const { state , guild } = pluginData ;
state . mutes = GuildMutes . getGuildInstance ( guild . id ) ;
state . cases = GuildCases . getGuildInstance ( guild . id ) ;
state . serverLogs = new GuildLogs ( guild . id ) ;
state . ignoredEvents = [ ] ;
} ,
2020-07-23 00:37:33 +03:00
} ) ;