mirror of
https://github.com/toast-ts/Daggerbot-TS.git
synced 2024-11-17 20:30:58 -05:00
Missed a few bits here and there
This commit is contained in:
parent
ab6c6de9c1
commit
137a0ae7b8
@ -19,7 +19,7 @@ export default class Case {
|
||||
}
|
||||
}
|
||||
static run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
|
||||
if (!MessageTool.isStaff(interaction.member)) return MessageTool.youNeedRole(interaction, 'dcmod');
|
||||
if (!MessageTool.isModerator(interaction.member)) return MessageTool.youNeedRole(interaction, 'dcmod');
|
||||
const caseId = interaction.options.getInteger('id');
|
||||
({
|
||||
update: async()=>{
|
||||
@ -56,7 +56,7 @@ export default class Case {
|
||||
value: `Reason: \`${punishment.dataValues.reason}\`\n${punishment.dataValues.duration ? `Duration: ${Formatters.timeFormat(punishment.dataValues.duration, 3)}\n` : ''}Moderator: ${MessageTool.formatMention(punishment.dataValues.moderator, 'user')}${punishment.dataValues.expired ? `\nOverwritten by Case #${punishments.find(x=>x.dataValues.cancels===punishment.dataValues.case_id)?.case_id}` : ''}${punishment.dataValues.cancels ? `\nOverwrites Case #${punishment.dataValues.cancels}` : ''}`
|
||||
}
|
||||
});
|
||||
if (!punishments || !userPunishment) return interaction.reply(`**${user.username}** has a clean record.`)
|
||||
if (!userPunishment.length) return interaction.reply(`**${user.username}** has a clean record.`)
|
||||
const pageNum = interaction.options.getInteger('page') ?? 1;
|
||||
return interaction.reply({embeds: [new client.embed().setColor(client.config.embedColor).setTitle(`${user.username}'s punishment history`).setDescription(`**ID:** \`${user.id}\``).setFooter({text: `${userPunishment.length} total punishments. Viewing page ${pageNum} out of ${Math.ceil(userPunishment.length/6)}.`}).addFields(userPunishment.slice((pageNum - 1) * 6, pageNum * 6))]});
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import HookMgr from '../components/HookManager.js';
|
||||
import MessageTool from '../helpers/MessageTool.js';
|
||||
export default class ProhibitedWords {
|
||||
static async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
|
||||
if (!MessageTool.isStaff(interaction.member) && !client.config.whitelist.includes(interaction.member.id)) return MessageTool.youNeedRole(interaction, 'admin');
|
||||
if (!MessageTool.isModerator(interaction.member) && !client.config.whitelist.includes(interaction.member.id)) return MessageTool.youNeedRole(interaction, 'admin');
|
||||
const word = interaction.options.getString('word');
|
||||
const wordExists = await client.prohibitedWords.findWord(word);
|
||||
({
|
||||
|
@ -3,7 +3,7 @@ import TClient from '../client.js';
|
||||
import MessageTool from '../helpers/MessageTool.js';
|
||||
export default class Purge {
|
||||
static async run(_client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
|
||||
if (!MessageTool.isStaff(interaction.member)) return MessageTool.youNeedRole(interaction, 'dcmod');
|
||||
if (!MessageTool.isModerator(interaction.member)) return MessageTool.youNeedRole(interaction, 'dcmod');
|
||||
const amount = interaction.options.getInteger('amount') as number;
|
||||
if (amount > 100) return interaction.reply({content: 'Discord API limits purging up to 100 messages.', ephemeral: true})
|
||||
const user = interaction.options.getUser('user');
|
||||
|
@ -4,7 +4,7 @@ import Logger from '../helpers/Logger.js';
|
||||
import MessageTool from '../helpers/MessageTool.js';
|
||||
export default class Unpunish {
|
||||
static async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
|
||||
if (!MessageTool.isStaff(interaction.member as Discord.GuildMember)) return MessageTool.youNeedRole(interaction, 'dcmod');
|
||||
if (!MessageTool.isModerator(interaction.member as Discord.GuildMember)) return MessageTool.youNeedRole(interaction, 'dcmod');
|
||||
const punishment = await client.punishments.findCase(interaction.options.getInteger('case_id', true));
|
||||
if (!punishment) return interaction.reply({content: 'Case ID is not found in database.', ephemeral: true});
|
||||
if (['unban', 'unmute', 'punishmentOverride'].includes(punishment.dataValues.type)) return interaction.reply({content: 'This case ID is immutable. (Informative case)', ephemeral: true});
|
||||
|
@ -3,9 +3,7 @@ import TClient from '../client.js';
|
||||
import Logger from '../helpers/Logger.js';
|
||||
export default class Automoderator {
|
||||
private static lockQuery:Set<Discord.Snowflake> = new Set();
|
||||
static scanMsg(message:Discord.Message) {
|
||||
return message.content.toLowerCase().replaceAll(/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?\n?0-9]|[]|ing\b/g, '').split(' ').join('');
|
||||
}
|
||||
static scanMsg =(message:Discord.Message)=>message.content.toLowerCase().replaceAll(/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?\n?0-9]|[]|ing\b/g, '').split(' ').join('');
|
||||
static async repeatedMessages(client:TClient, message:Discord.Message, thresholdTime:number, thresholdAmount:number, type:string, duration:string, reason:string) {
|
||||
const now = Date.now();
|
||||
|
||||
|
@ -29,12 +29,8 @@ export default class CacheServer {
|
||||
if (jsonMode) return await RedisClient.json.set(key, '.', value);
|
||||
else return await RedisClient.set(key, JSON.stringify(value));
|
||||
}
|
||||
public static async expiry(key:any, time:number) {
|
||||
return await RedisClient.expire(key, time); // NOTE: time is in seconds, not milliseconds -- you know what you did wrong
|
||||
}
|
||||
public static async delete(key:any) {
|
||||
return await RedisClient.del(key);
|
||||
}
|
||||
public static expiry = async(key:any, time:number)=>await RedisClient.expire(key, time); // NOTE: time is in seconds, not milliseconds -- you know what you did wrong
|
||||
public static delete = async(key:any)=>await RedisClient.del(key);
|
||||
public static init() {
|
||||
try {
|
||||
RedisClient.connect();
|
||||
|
@ -14,9 +14,7 @@ export default class HookMgr {
|
||||
this.webhookId = webhookId;
|
||||
}
|
||||
|
||||
protected async channelFetch(client:TClient, channel:ChannelList) {
|
||||
return await client.channels.fetch(config.dcServer.channels[channel]) as Discord.TextChannel;
|
||||
}
|
||||
protected channelFetch = async(client:TClient, channel:ChannelList)=>await client.channels.fetch(config.dcServer.channels[channel]) as Discord.TextChannel;
|
||||
protected async fetch(client:TClient, channel:ChannelList, webhookId:Discord.Snowflake) {
|
||||
const hookInstance = await (await this.channelFetch(client, channel)).fetchWebhooks().then(x=>x.find(y=>y.id===webhookId));
|
||||
if (!hookInstance) throw new Error('[HookManager] Webhook not found.');
|
||||
|
@ -26,9 +26,7 @@ export class ProhibitedWordsSvc {
|
||||
})
|
||||
this.model.sync();
|
||||
}
|
||||
async findWord(word:string) {
|
||||
return await this.model.findByPk(word);
|
||||
}
|
||||
findWord = async(word:string)=>await this.model.findByPk(word);
|
||||
async importWords(file:string) {
|
||||
const jsonData = await new Promise<string>((resolve, reject)=>{
|
||||
get(file, res=>{
|
||||
|
Loading…
Reference in New Issue
Block a user