Add custom event logs

This commit is contained in:
Tarrgon
2025-06-07 08:57:06 -04:00
parent 920477b8b7
commit d64a29b55b
9 changed files with 184 additions and 22 deletions
+1
View File
@@ -22,6 +22,7 @@ export default {
.setName('reason')
.setDescription('The reason for the ban')
.setRequired(false)
.setMaxLength(400)
)
.addNumberOption(option =>
option
+46 -6
View File
@@ -1,6 +1,6 @@
import { ApplicationCommandOptionType, ApplicationIntegrationType, AutocompleteInteraction, ChatInputCommandInteraction, Client, GuildBasedChannel, InteractionContextType, MessageFlags, PermissionFlagsBits, SlashCommandBuilder } from 'discord.js';
import { Database } from '../shared/Database';
import { channelIsInStaffCategory, deferInteraction } from '../utils';
import { channelIsInStaffCategory, deferInteraction, logCustomEvent } from '../utils';
import { getNoteMessage } from '../utils/note-utils';
export default {
@@ -66,18 +66,58 @@ export default {
if (subcommand == 'add') {
const reason = interaction.options.getString('reason', true);
logCustomEvent(interaction.guild!, {
title: 'Note Added',
description: null,
color: 0x00FF00,
timestamp: new Date(),
fields: [
{
name: 'User',
value: `<@${interaction.user.id}>\n${interaction.user.username}`,
inline: true
},
{
name: 'Note',
value: reason,
inline: true
}
]
});
await Database.putNote(user.id, reason, interaction.user.id);
interaction.editReply('Added note.');
} else if (subcommand == 'remove') {
const user = interaction.options.getUser('user', true);
const noteId = interaction.options.getInteger('note', true);
if (await Database.removeNote(noteId)) {
interaction.editReply('Removed note.');
const notes = await Database.getNotes(user.id);
const note = notes.find(n => n.id == noteId);
} else {
interaction.editReply('Note not found.');
}
if (!note) return interaction.editReply('Note not found.');
logCustomEvent(interaction.guild!, {
title: 'Note Removed',
description: null,
color: 0xFF0000,
timestamp: new Date(),
fields: [
{
name: 'User',
value: `<@${interaction.user.id}>\n${interaction.user.username}`,
inline: true
},
{
name: 'Note',
value: `${note.reason}\nBy: <@${note.mod_id}>`,
inline: true
}
]
});
await Database.removeNote(noteId);
interaction.editReply('Removed note.');
} else if (subcommand == 'list') {
const noteMessage = await getNoteMessage(user.id, 1);
+70 -1
View File
@@ -1,6 +1,6 @@
import { ApplicationIntegrationType, AutocompleteInteraction, ChatInputCommandInteraction, Client, InteractionContextType, MessageFlags, PermissionFlagsBits, SlashCommandBuilder, User } from 'discord.js';
import { Database } from '../shared/Database';
import { getE621User } from '../utils';
import { getE621User, logCustomEvent } from '../utils';
import { config } from '../config';
import { TicketPhrase } from '../types';
@@ -142,8 +142,33 @@ export default {
async function purgePhrases(interaction: ChatInputCommandInteraction, user: User) {
const phrases: TicketPhrase[] = await Database.getTicketPhrasesFor(user.id);
const count = await Database.removeAllTicketPhrasesFor(user.id);
logCustomEvent(interaction.guild!, {
title: 'Ticket Phrases Purged',
description: null,
color: 0xFF0000,
timestamp: new Date(),
fields: [
{
name: 'User',
value: `<@${interaction.user.id}>\n${interaction.user.username}`,
inline: true
},
{
name: 'Target User',
value: `<@${user.id}>\n${user.username}`,
inline: true
},
{
name: 'Count',
value: count.toString(),
inline: true
}
]
});
interaction.reply(`Purged the following phrases (${count}): ${phrases.map(p => `\`${p.phrase}\``).join('\n')}`);
}
@@ -167,11 +192,55 @@ async function dumpPhrases(interaction: ChatInputCommandInteraction) {
async function addPhrase(interaction: ChatInputCommandInteraction, phrase: string, group: SubcommandGroup) {
await Database.putTicketPhrase(group == 'admin' ? 'admin' : interaction.user.id, phrase);
logCustomEvent(interaction.guild!, {
title: `${group == 'admin' ? 'Admin ' : ''}Ticket Phrase Added`,
description: null,
color: 0x00FF00,
timestamp: new Date(),
fields: [
{
name: 'User',
value: `<@${interaction.user.id}>\n${interaction.user.username}`,
inline: true
},
{
name: 'Phrase',
value: phrase,
inline: true
}
]
});
interaction.reply(`Phrases matching "${phrase}" will now alert ${group == 'admin' ? 'admins' : 'you'}.`);
}
async function removePhrase(interaction: ChatInputCommandInteraction, phraseId: number, group: SubcommandGroup) {
const phrase = await Database.getTicketPhrase(phraseId);
if (!phrase) return interaction.reply('Phrase not found');
await Database.removeTicketPhrase(phraseId);
logCustomEvent(interaction.guild!, {
title: `${group == 'admin' ? 'Admin ' : ''}Ticket Phrase Removed`,
description: null,
color: 0xFF0000,
timestamp: new Date(),
fields: [
{
name: 'User',
value: `<@${interaction.user.id}>\n${interaction.user.username}`,
inline: true
},
{
name: 'Phrase',
value: phrase.phrase,
inline: true
}
]
});
interaction.reply(`Phrase will no longer alert ${group == 'admin' ? 'admins' : 'you'}.`);
}
+1
View File
@@ -21,6 +21,7 @@ export default {
.setName('reason')
.setDescription('The reason for the softban')
.setRequired(false)
.setMaxLength(400)
)
.addNumberOption(option =>
option