Skip to content

Commit c4895ca

Browse files
Pdzlybristermitten
authored andcommitted
Add softBan and tempBan commands, enhance ModerationModule, and improve unban functionality
1 parent 4212c8f commit c4895ca

File tree

6 files changed

+26
-11
lines changed

6 files changed

+26
-11
lines changed

src/modules/moderation/kick.command.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
import { config } from "../../Config.js";
77
import { actualMention, fakeMention } from "../../util/users.js";
88

9-
export const BanCommand: Command<ApplicationCommandType.ChatInput> = {
9+
export const KickCommand: Command<ApplicationCommandType.ChatInput> = {
1010
name: "kick",
1111
description: "Ban a baaaaad boy",
1212
type: ApplicationCommandType.ChatInput,

src/modules/moderation/moderation.module.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,18 @@ import { InviteListeners } from "./discordInvitesMonitor.module.js";
33
import { BanCommand } from "./ban.command.js";
44
import { UnbanCommand } from "./unban.command.js";
55
import { TempBanListener } from "./tempBan.module.js";
6+
import { SoftBanCommand } from "./softBan.command.js";
7+
import { TempBanCommand } from "./tempBan.command.js";
8+
import { KickCommand } from "./kick.command.js";
69

710
export const ModerationModule: Module = {
811
name: "moderation",
9-
commands: [BanCommand, UnbanCommand],
12+
commands: [
13+
BanCommand,
14+
UnbanCommand,
15+
SoftBanCommand,
16+
TempBanCommand,
17+
KickCommand,
18+
],
1019
listeners: [...InviteListeners, TempBanListener],
1120
};

src/modules/moderation/softBan.command.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import { config } from "../../Config.js";
77
import { actualMention, fakeMention } from "../../util/users.js";
88

99
export const SoftBanCommand: Command<ApplicationCommandType.ChatInput> = {
10-
name: "ban",
11-
description: "Ban a baaaaad boy",
10+
name: "softban",
11+
description: "Soft Ban a baaaaad boy",
1212
type: ApplicationCommandType.ChatInput,
1313
default_permission: false,
1414
options: [

src/modules/moderation/tempBan.command.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { config } from "../../Config.js";
77
import { actualMention, fakeMention } from "../../util/users.js";
88
import { createTempBanModAction } from "./tempBan.js";
99

10-
export const SoftBanCommand: Command<ApplicationCommandType.ChatInput> = {
10+
export const TempBanCommand: Command<ApplicationCommandType.ChatInput> = {
1111
name: "tempban",
1212
description: "Temp Ban a baaaaad boy",
1313
type: ApplicationCommandType.ChatInput,
@@ -19,17 +19,18 @@ export const SoftBanCommand: Command<ApplicationCommandType.ChatInput> = {
1919
description: "The user to be banned",
2020
required: true,
2121
},
22-
{
23-
type: ApplicationCommandOptionType.String,
24-
name: "reason",
25-
description: "The reason why the user gets banned",
26-
},
2722
{
2823
type: ApplicationCommandOptionType.Number,
2924
name: "ban_duration_days",
3025
description: "The duration of the ban in days",
3126
required: true,
3227
},
28+
{
29+
type: ApplicationCommandOptionType.String,
30+
name: "reason",
31+
description: "The reason why the user gets banned",
32+
},
33+
3334
{
3435
type: ApplicationCommandOptionType.Boolean,
3536
name: "delete_messages",

src/modules/moderation/unban.command.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
} from "discord.js";
66
import { config } from "../../Config.js";
77
import { actualMention, fakeMention } from "../../util/users.js";
8+
import { getActiveTempBanModAction } from "./tempBan.js";
89

910
export const UnbanCommand: Command<ApplicationCommandType.ChatInput> = {
1011
name: "unban",
@@ -41,6 +42,9 @@ export const UnbanCommand: Command<ApplicationCommandType.ChatInput> = {
4142

4243
await interaction.guild.bans.remove(user.id, reason ?? undefined);
4344

45+
const modAction = await getActiveTempBanModAction(BigInt(user.id));
46+
if (modAction) await modAction.destroy();
47+
4448
const auditLogChannel = await interaction.guild.channels.fetch(
4549
config.channels.auditLog,
4650
);

src/store/storage.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { AbstractDialect, DialectName, Sequelize } from "@sequelize/core";
77
import { SqliteDialect } from "@sequelize/sqlite3";
88
import { ConnectionConfig } from "pg";
99
import { Bump } from "./models/Bump.js";
10+
import { ModeratorActions } from "./models/ModeratorActions.js";
1011

1112
function sequelizeLog(sql: string, timing?: number) {
1213
if (timing) {
@@ -54,7 +55,7 @@ export async function initStorage() {
5455
}
5556
await sequelize.authenticate();
5657

57-
const models = [DDUser, ColourRoles, FAQ, Bump];
58+
const models = [DDUser, ColourRoles, FAQ, Bump, ModeratorActions];
5859
sequelize.addModels(models);
5960

6061
Bump.belongsTo(DDUser, {

0 commit comments

Comments
 (0)