mirror of
https://github.com/Team-Neptune/Korral-JS.git
synced 2024-11-23 12:39:40 +00:00
Warn behavior based on config
This commit is contained in:
parent
b50e92347b
commit
d84f5ebae3
@ -6,8 +6,7 @@ export const config:Config = {
|
||||
"botLog": "",
|
||||
"modLog": "",
|
||||
"userLog":"",
|
||||
"suspiciousWordsLog":"",
|
||||
"suspiciousWordsFilter":true,
|
||||
"userLogging":true,
|
||||
"staffRoles":["", ""]
|
||||
"staffRoles":["", ""],
|
||||
"warnBehavior":[]
|
||||
}
|
@ -220,39 +220,34 @@ export const moderationCommands:Array<Command> = [
|
||||
warnings[mentionedUser.id].push(reason);
|
||||
|
||||
writeFileSync('./warnings.json', JSON.stringify(warnings))
|
||||
var eventMessage = `You were warned on ${message.guild.name}.\nThe given reason is: ${reason}\n\nPlease read the rules. This is warning #${(warnings[mentionedUser.id].length)}.`
|
||||
switch (warnings[mentionedUser.id].length) {
|
||||
case 1:
|
||||
// only base message
|
||||
mentionedUser.send(eventMessage);
|
||||
const warnAction = config.warnBehavior[warnings[mentionedUser.id].length].action
|
||||
const warnMessage = config.warnBehavior[warnings[mentionedUser.id].length].message
|
||||
switch (warnAction) {
|
||||
case "NONE":
|
||||
mentionedUser.send(warnMessage);
|
||||
break;
|
||||
case 2:
|
||||
eventMessage = eventMessage + "\n\n __**The next warn will result in an automatic kick.**__";
|
||||
mentionedUser.send(eventMessage)
|
||||
case "KICK":
|
||||
mentionedUser.send(warnMessage)
|
||||
.then(() => {
|
||||
mentionedUser.kick(`Auto kick: ${reason}`)
|
||||
})
|
||||
.catch((e) => {
|
||||
console.error(e)
|
||||
mentionedUser.kick(`Auto kick: ${reason}`)
|
||||
})
|
||||
break;
|
||||
case 3:
|
||||
eventMessage = eventMessage + "\n\nYou were kicked because of this warning. You can rejoin right away, but two more warnings will result in an automatic ban.";
|
||||
mentionedUser.send(eventMessage)
|
||||
mentionedUser.kick(`Auto kick: ${reason}`)
|
||||
break;
|
||||
case 4:
|
||||
eventMessage = eventMessage + "\n\nYou were kicked because of this warning. You can rejoin right away, but two more warnings will result in an automatic ban.";
|
||||
mentionedUser.send(eventMessage)
|
||||
mentionedUser.kick(`Auto kick: ${reason}`)
|
||||
break;
|
||||
case 5:
|
||||
eventMessage = eventMessage + "\n\nYou were kicked because of this warning. You can rejoin right away, but **one more warning will result in an automatic ban.**";
|
||||
mentionedUser.send(eventMessage)
|
||||
mentionedUser.kick(`Auto kick: ${reason}`)
|
||||
break;
|
||||
case 6:
|
||||
eventMessage = eventMessage + "\n\nYou were banned because of this warning. This ban will not expire.";
|
||||
mentionedUser.send(eventMessage)
|
||||
mentionedUser.ban({ reason: `Auto ban: ${reason}` })
|
||||
case "BAN":
|
||||
mentionedUser.send(warnMessage)
|
||||
.then(() => {
|
||||
mentionedUser.ban({reason:`Auto ban: ${reason}`})
|
||||
})
|
||||
.catch((e) => {
|
||||
console.error(e)
|
||||
mentionedUser.ban({reason:`Auto ban: ${reason}`})
|
||||
})
|
||||
break;
|
||||
default:
|
||||
// code block
|
||||
// nothing will happen by default
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
13
typings/index.d.ts
vendored
13
typings/index.d.ts
vendored
@ -12,16 +12,23 @@ export interface Command {
|
||||
execute(message:Message, args:Array<String>)
|
||||
}
|
||||
|
||||
type WarnAction = "NONE" | "KICK" | "BAN"
|
||||
|
||||
interface WarnBehavior {
|
||||
message:string,
|
||||
action:WarnAction
|
||||
}
|
||||
|
||||
export interface Config {
|
||||
"prefix": Array<string>,
|
||||
"token": string,
|
||||
"botLog": string,
|
||||
"modLog": string,
|
||||
"userLog":string,
|
||||
"suspiciousWordsLog":string,
|
||||
"suspiciousWordsFilter":boolean,
|
||||
"userLogging":boolean,
|
||||
"staffRoles":Array<string>
|
||||
"staffRoles":Array<string>,
|
||||
/** The behavior of warnings (first item in array is action for the first warning) */
|
||||
warnBehavior:Array<WarnBehavior>
|
||||
}
|
||||
|
||||
declare module 'discord.js' {
|
||||
|
Loading…
Reference in New Issue
Block a user