1
0
mirror of https://github.com/toast-ts/Daggerbot-TS.git synced 2024-11-17 20:30:58 -05:00

Punishment improvements

This commit is contained in:
AnxietyisReal 2024-01-22 15:45:25 +11:00
parent 3ff70e9236
commit 9b705a4219
4 changed files with 13 additions and 6 deletions

View File

@ -41,7 +41,7 @@ export default class Case {
{name: '\u200b', value: '\u200b', inline: true}, {name: '\u200b', value: '\u200b', inline: true},
{name: 'Reason', value: `\`${punishment.reason || 'Reason unspecified'}\``, inline: true}) {name: 'Reason', value: `\`${punishment.reason || 'Reason unspecified'}\``, inline: true})
if (punishment.dataValues.duration) embed.addFields({name: 'Duration', value: `${Formatters.timeFormat(punishment.dataValues.duration, 100)}`}) if (punishment.dataValues.duration) embed.addFields({name: 'Duration', value: `${Formatters.timeFormat(punishment.dataValues.duration, 100)}`})
if (punishment.dataValues.expired) embed.addFields({name: 'Expired', value: `This case has been overwritten by Case #${cancelledBy.dataValues.case_id} for reason \`${cancelledBy.dataValues.reason}\``}) if (punishment.dataValues.expired) embed.addFields({name: 'Expired', value: `This case has been overwritten by Case #${cancelledBy.dataValues.case_id} with reason \`${cancelledBy.dataValues.reason}\``})
if (punishment.dataValues.cancels) embed.addFields({name: 'Overwrites', value: `This case overwrites Case #${cancels.dataValues.case_id} with reason \`${cancels.dataValues.reason}\``}) if (punishment.dataValues.cancels) embed.addFields({name: 'Overwrites', value: `This case overwrites Case #${cancels.dataValues.case_id} with reason \`${cancels.dataValues.reason}\``})
interaction.reply({embeds: [embed]}); interaction.reply({embeds: [embed]});
}, },

View File

@ -11,8 +11,9 @@ export default class Unpunish {
const reason = interaction.options.getString('reason') ?? 'Reason unspecified'; const reason = interaction.options.getString('reason') ?? 'Reason unspecified';
await client.punishments.punishmentRemove(punishment.dataValues.case_id, interaction.user.id, reason, interaction); await client.punishments.punishmentRemove(punishment.dataValues.case_id, interaction.user.id, reason, interaction);
Logger.console('log', 'UnpunishmentLog', `Case #${interaction.options.getInteger('case_id')} was used in /${interaction.commandName} for ${reason}`); const unpunishLog = `Case #${interaction.options.getInteger('case_id')} was used in \`/${interaction.commandName}\` for \`${reason}\``;
(client.channels.cache.get(client.config.dcServer.channels.punishment_log) as Discord.TextChannel).send({embeds:[new client.embed().setColor(client.config.embedColor).setTitle('Unpunishment Log').setDescription(`Case #${interaction.options.getInteger('case_id')} was used in \`/${interaction.commandName}\` for \`${reason}\``).setTimestamp()]}); Logger.console('log', 'UnpunishmentLog', unpunishLog);
(client.channels.cache.get(client.config.dcServer.channels.punishment_log) as Discord.TextChannel).send({embeds:[new client.embed().setColor(client.config.embedColor).setTitle('Unpunishment Log').setDescription(unpunishLog).setTimestamp()]});
} }
static data = new Discord.SlashCommandBuilder() static data = new Discord.SlashCommandBuilder()
.setName('unpunish') .setName('unpunish')

View File

@ -1,18 +1,24 @@
import Discord from 'discord.js'; import Discord from 'discord.js';
import TClient from '../client.js'; import TClient from '../client.js';
import MessageTool from '../helpers/MessageTool.js'; import MessageTool from '../helpers/MessageTool.js';
import Logger from '../helpers/Logger.js';
export default async(client:TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>, type: 'ban'|'softban'|'kick'|'mute'|'warn'|'remind')=>{ export default async(client:TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>, type: 'ban'|'softban'|'kick'|'mute'|'warn'|'remind')=>{
if (!MessageTool.isModerator(interaction.member)) return MessageTool.youNeedRole(interaction, 'dcmod'); if (!MessageTool.isModerator(interaction.member)) return MessageTool.youNeedRole(interaction, 'dcmod');
const isInBKL = ['ban', 'kick'].includes(type) && interaction.channelId === client.config.dcServer.channels.bankick_log;
const time = interaction.options.getString('time') ?? undefined; const time = interaction.options.getString('time') ?? undefined;
const reason = interaction.options.getString('reason') ?? 'Reason unspecified'; const reason = interaction.options.getString('reason') ?? 'Reason unspecified';
const GuildMember = interaction.options.getMember('member') ?? undefined; const GuildMember = interaction.options.getMember('member') ?? undefined;
const User = interaction.options.getUser('member', true); const User = interaction.options.getUser('member', true);
const punishLog = `${GuildMember?.user?.username ?? User?.username ?? 'No user data'} ${time ? ['warn', 'kick'].includes(type) ? 'and no duration set' : `and ${time} (duration)` : ''} was used in \`/${interaction.commandName}\` for \`${reason}\``;
Logger.console('log', 'PunishmentLog', punishLog);
(client.channels.cache.get(client.config.dcServer.channels.punishment_log) as Discord.TextChannel).send({embeds:[new client.embed().setColor(client.config.embedColor).setTitle('Punishment Log').setDescription(punishLog).setTimestamp()]});
if (interaction.user.id === User.id) return interaction.reply(`You cannot ${type} yourself.`); if (interaction.user.id === User.id) return interaction.reply(`You cannot ${type} yourself.`);
if (!GuildMember && !['unban', 'ban'].includes(type)) return interaction.reply(`You cannot ${type} someone who is not in the server.`); if (!GuildMember && !['unban', 'ban'].includes(type)) return interaction.reply(`You cannot ${type} someone who is not in the server.`);
if (User.bot) return interaction.reply(`You cannot ${type} a bot!`); if (User.bot) return interaction.reply(`You cannot ${type} a bot!`);
await interaction.deferReply(); await interaction.deferReply({ephemeral: isInBKL});
await client.punishments.punishmentAdd(type, {time, interaction}, interaction.user.id, reason, User, GuildMember); await client.punishments.punishmentAdd(type, {time, interaction}, interaction.user.id, reason, User, GuildMember);
} }

View File

@ -129,7 +129,7 @@ export class PunishmentsSvc {
{name: '\u200b', value: '\u200b', inline: true}, {name: '\u200b', value: '\u200b', inline: true},
{name: '🔹 Reason', value: `\`${punishment.reason}\``, inline: true} {name: '🔹 Reason', value: `\`${punishment.reason}\``, inline: true}
).setTimestamp(punishment.time); ).setTimestamp(punishment.time);
if (punishment.duration) embed.addFields({name: '🔹 Duration', value: `${Formatters.timeFormat(punishment.duration, 4, {longNames: false, commas: true})}`, inline: true}, {name: '\u200b', value: '\u200b', inline: true}); if (punishment.duration) embed.addFields({name: '🔹 Duration', value: `${Formatters.timeFormat(punishment.duration, 4, {longNames: true, commas: true})}`, inline: true}, {name: '\u200b', value: '\u200b', inline: true});
if (punishment.cancels) { if (punishment.cancels) {
const cancels = await this.model.findOne({where: {case_id: punishment.cancels}}) const cancels = await this.model.findOne({where: {case_id: punishment.cancels}})
embed.addFields({name: '🔹 Overwrites', value: `This case invalidates Case #${cancels.dataValues.case_id}\n\`${cancels.dataValues.reason}\``}); embed.addFields({name: '🔹 Overwrites', value: `This case invalidates Case #${cancels.dataValues.case_id}\n\`${cancels.dataValues.reason}\``});
@ -252,7 +252,7 @@ export class PunishmentsSvc {
.setColor(this.client.config.embedColor) .setColor(this.client.config.embedColor)
.setTitle(`${removePunishmentData.type[0].toUpperCase() + removePunishmentData.type.slice(1)} | Case #${removePunishmentData.case_id}`) .setTitle(`${removePunishmentData.type[0].toUpperCase() + removePunishmentData.type.slice(1)} | Case #${removePunishmentData.case_id}`)
.setDescription(`${user.username}\n<@${user.id}>\n\`${user.id}\``) .setDescription(`${user.username}\n<@${user.id}>\n\`${user.id}\``)
.addFields({name: 'Reason', value: reason}, {name: 'Overwrites', value: `Case #${punishment.case_id}`}) .addFields({name: 'Reason', value: `\`${reason}\``}, {name: 'Overwrites', value: `Case #${punishment.case_id}`})
]}); ]});
else return `Successfully un${this.getPastTense(removePunishmentData.type.replace('un', ''))} ${user.username} (\`${user.id}\`) for ${reason}` else return `Successfully un${this.getPastTense(removePunishmentData.type.replace('un', ''))} ${user.username} (\`${user.id}\`) for ${reason}`
} }