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

Fix a few things that flew under the radar

This commit is contained in:
toast-ts 2023-12-25 14:02:59 +11:00
parent bfec8ec431
commit a90bf9f458
19 changed files with 29 additions and 41 deletions

View File

@ -1,10 +0,0 @@
botStartup.bat
.ncurc.json
.gitignore
README.md
.github
.vscode
.yarn/sdks
dist/
docker-compose.yml
startWithYarn.cjs

View File

@ -9,7 +9,7 @@ interface IRepeatedMessages {
import Discord from 'discord.js'; import Discord from 'discord.js';
import ConfigHelper from './helpers/ConfigHelper.js'; import ConfigHelper from './helpers/ConfigHelper.js';
import {readdirSync} from 'node:fs'; import {readdirSync} from 'node:fs';
import {Config} from './interfaces'; import {Config} from 'src/interfaces';
import { import {
DailyMsgsSvc, UserLevelsSvc, BonkCountSvc, DailyMsgsSvc, UserLevelsSvc, BonkCountSvc,
MPServerSvc, PunishmentsSvc, ProhibitedWordsSvc, MPServerSvc, PunishmentsSvc, ProhibitedWordsSvc,
@ -24,7 +24,7 @@ import TSClient from './helpers/TSClient.js';
export default class TClient extends Discord.Client { export default class TClient extends Discord.Client {
public invites: Map<any, any> = new Map(); public invites: Map<any, any> = new Map();
public commands: Discord.Collection<string, any> = new Discord.Collection(); public commands: Discord.Collection<string, any> = new Discord.Collection();
public registry: Array<Discord.ApplicationCommandDataResolvable> = []; public registry: Discord.ApplicationCommandDataResolvable[] = [];
public config: Config; public config: Config;
public embed: typeof Discord.EmbedBuilder = Discord.EmbedBuilder; public embed: typeof Discord.EmbedBuilder = Discord.EmbedBuilder;
public collection: typeof Discord.Collection = Discord.Collection; public collection: typeof Discord.Collection = Discord.Collection;

View File

@ -71,7 +71,7 @@ export default class Developer {
deletion: repoData.stats.deletions.toLocaleString('en-US') deletion: repoData.stats.deletions.toLocaleString('en-US')
}; };
const msgBody = MessageTool.concatMessage( const msgBody = MessageTool.concatMessage(
`[Commit pulled:](<${repoData.commit.url}>)`, `[Commit pulled](<${repoData.commit.url}>)`,
`Message: **${repoData.commit.message.length === 0 ? '*No commit message*' : repoData.commit.message}**`, `Message: **${repoData.commit.message.length === 0 ? '*No commit message*' : repoData.commit.message}**`,
`Author: **${repoData.commit.author.name}**`, `Author: **${repoData.commit.author.name}**`,
'Changes', 'Changes',

View File

@ -5,7 +5,7 @@ import CanvasBuilder from '../components/CanvasGraph.js';
import RanIntoHumor from '../helpers/RanIntoHumor.js'; import RanIntoHumor from '../helpers/RanIntoHumor.js';
import MessageTool from '../helpers/MessageTool.js'; import MessageTool from '../helpers/MessageTool.js';
import PalletLibrary from '../helpers/PalletLibrary.js'; import PalletLibrary from '../helpers/PalletLibrary.js';
import {FSData} from '../interfaces'; import {FSData} from 'src/interfaces';
import {requestServerData, mpModuleDisabled, refreshTimerSecs, playtimeStat} from '../modules/MPModule.js'; import {requestServerData, mpModuleDisabled, refreshTimerSecs, playtimeStat} from '../modules/MPModule.js';
async function fetchData(client:TClient, interaction:Discord.ChatInputCommandInteraction, serverName:string):Promise<FSData|Discord.InteractionResponse> { async function fetchData(client:TClient, interaction:Discord.ChatInputCommandInteraction, serverName:string):Promise<FSData|Discord.InteractionResponse> {
@ -60,9 +60,9 @@ export default class MP {
.setTitle(DSS.server?.name.length > 0 ? DSS.server.name : 'Offline') .setTitle(DSS.server?.name.length > 0 ? DSS.server.name : 'Offline')
.setColor(embedColor) .setColor(embedColor)
.setDescription(DSS?.slots?.used < 1 ? '*Nobody is playing*' : players.join('\n\n')) .setDescription(DSS?.slots?.used < 1 ? '*Nobody is playing*' : players.join('\n\n'))
.setImage('attachment://'+attachmentName) .setImage(`attachment://${attachmentName}`)
.setAuthor({name: `${DSS.slots.used}/${DSS.slots.capacity}`}) .setAuthor({name: `${DSS.slots.used}/${DSS.slots.capacity}`})
.setFooter({text: 'Current time: '+`${('0'+Math.floor((DSS?.server.dayTime/3600/1000))).slice(-2)}:${('0'+Math.floor((DSS?.server.dayTime/60/1000)%60)).slice(-2)}`}) .setFooter({text: `Current time: ${('0'+Math.floor((DSS?.server.dayTime/3600/1000))).slice(-2)}:${('0'+Math.floor((DSS?.server.dayTime/60/1000)%60)).slice(-2)}`})
], files: [new client.attachment(canvas.toBuffer(), {name: attachmentName})]}) ], files: [new client.attachment(canvas.toBuffer(), {name: attachmentName})]})
}, },
details: async()=>{ details: async()=>{
@ -73,7 +73,7 @@ export default class MP {
const dEmbed = new client.embed().setColor(client.config.embedColor).setAuthor({name: 'Crossplay server'}).setDescription(MessageTool.concatMessage( const dEmbed = new client.embed().setColor(client.config.embedColor).setAuthor({name: 'Crossplay server'}).setDescription(MessageTool.concatMessage(
`**Name:** \`${DSS?.server.name.length > 0 ? DSS.server.name : '\u200b'}\``, `**Name:** \`${DSS?.server.name.length > 0 ? DSS.server.name : '\u200b'}\``,
`**Password:** \`mf4700\``, '**Password:** `mf4700`',
`**Map:** \`${DSS.server.mapName.length > 0 ? DSS.server.mapName : 'No map'}\``, `**Map:** \`${DSS.server.mapName.length > 0 ? DSS.server.mapName : 'No map'}\``,
`**Mods:** [Click here](http://${server.ip}/mods.html) **|** [Direct link](http://${server.ip}/all_mods_download?onlyActive=true)`, `**Mods:** [Click here](http://${server.ip}/mods.html) **|** [Direct link](http://${server.ip}/all_mods_download?onlyActive=true)`,
'**Filters:** [Click here](https://discord.com/channels/468835415093411861/468835769092669461/926581585938120724)', '**Filters:** [Click here](https://discord.com/channels/468835415093411861/468835769092669461/926581585938120724)',

View File

@ -7,7 +7,7 @@ export default class Purge {
const amount = interaction.options.getInteger('amount') as number; 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}) if (amount > 100) return interaction.reply({content: 'Discord API limits purging up to 100 messages.', ephemeral: true})
const user = interaction.options.getUser('user'); const user = interaction.options.getUser('user');
let messagesArray: Array<string> = []; let messagesArray:string[] = [];
if (user){ if (user){
(interaction.channel as Discord.TextChannel).messages.fetch({limit: amount}).then(msgs=>{ (interaction.channel as Discord.TextChannel).messages.fetch({limit: amount}).then(msgs=>{

View File

@ -6,7 +6,7 @@ import GitHub from '../helpers/GitHub.js';
import si from 'systeminformation'; import si from 'systeminformation';
import os from 'node:os'; import os from 'node:os';
import ts from 'typescript'; import ts from 'typescript';
import {readFileSync} from 'fs'; import {readFileSync} from 'node:fs';
export default class Statistics { export default class Statistics {
static async run(client:TClient, interaction:Discord.ChatInputCommandInteraction<'cached'>) { static async run(client:TClient, interaction:Discord.ChatInputCommandInteraction<'cached'>) {
const initialMsg = await interaction.reply({content: '<a:sakjdfsajkfhsdjhjfsa:1065342869428252743>', fetchReply:true}); const initialMsg = await interaction.reply({content: '<a:sakjdfsajkfhsdjhjfsa:1065342869428252743>', fetchReply:true});

View File

@ -44,8 +44,8 @@ export default class Whois {
{name: `🔹 Roles: ${member.roles.cache.size - 1}`, value: member.roles.cache.size > 1 ? member.roles.cache.filter(x=>x.id !== interaction.guild.roles.everyone.id).sort((a,b)=>b.position - a.position).map(x=>x).join(member.roles.cache.size > 4 ? ' ' : '\n').slice(0,1024) : 'No roles'} {name: `🔹 Roles: ${member.roles.cache.size - 1}`, value: member.roles.cache.size > 1 ? member.roles.cache.filter(x=>x.id !== interaction.guild.roles.everyone.id).sort((a,b)=>b.position - a.position).map(x=>x).join(member.roles.cache.size > 4 ? ' ' : '\n').slice(0,1024) : 'No roles'}
) )
if (member.premiumSinceTimestamp !== null) embed.addFields({name: '🔹 Server Boosting since', value: `<t:${Math.round(member.premiumSinceTimestamp/1000)}>\n<t:${Math.round(member.premiumSinceTimestamp/1000)}:R>`, inline: true}) if (member.premiumSinceTimestamp !== null) embed.addFields({name: '🔹 Server Boosting since', value: `<t:${Math.round(member.premiumSinceTimestamp/1000)}>\n<t:${Math.round(member.premiumSinceTimestamp/1000)}:R>`, inline: true})
if (!presence) embed.addFields({name: `🔹 Status: ⚫`, value: '\u200b'}) if (!presence) embed.addFields({name: '🔹 Status: ⚫', value: '\u200b'})
if (member.presence) embed.addFields({name: `🔹 Status:`, value: `${member.presence.status === 'offline' ? '⚫' : `Desktop: ${convert(presence.desktop)}\nWeb: ${convert(presence.web)}\nMobile: ${convert(presence.mobile)}`}`, inline: true}) if (member.presence) embed.addFields({name: '🔹 Status:', value: `${member.presence.status === 'offline' ? '⚫' : `Desktop: ${convert(presence.desktop)}\nWeb: ${convert(presence.web)}\nMobile: ${convert(presence.mobile)}`}`, inline: true})
embedArray.push(embed) embedArray.push(embed)
if (member.presence?.activities.find(a=>a.type === 2)) { if (member.presence?.activities.find(a=>a.type === 2)) {
const spotifyStatus = member.presence?.activities.find(a=>a.name === 'Spotify') as Discord.Activity; const spotifyStatus = member.presence?.activities.find(a=>a.name === 'Spotify') as Discord.Activity;

View File

@ -1,5 +1,5 @@
import {createCanvas, Canvas, CanvasRenderingContext2D} from 'canvas'; import {createCanvas, Canvas, CanvasRenderingContext2D} from 'canvas';
import {Config} from '../interfaces'; import {Config} from 'src/interfaces';
import ConfigHelper from '../helpers/ConfigHelper.js'; import ConfigHelper from '../helpers/ConfigHelper.js';
export default class CanvasBuilder { export default class CanvasBuilder {
private canvas: Canvas; private canvas: Canvas;

View File

@ -1,9 +1,9 @@
import Discord, { AuditLogEvent } from 'discord.js'; import Discord from 'discord.js';
import TClient from '../client.js'; import TClient from '../client.js';
export default class GuildBanAdd { export default class GuildBanAdd {
static async run(client:TClient, member:Discord.GuildMember){ static async run(client:TClient, member:Discord.GuildMember){
if (member.guild?.id != client.config.dcServer.id) return; if (member.guild?.id != client.config.dcServer.id) return;
const banLog = (await member.guild.fetchAuditLogs({ limit: 1, type: AuditLogEvent.MemberBanAdd })).entries.first(); const banLog = (await member.guild.fetchAuditLogs({ limit: 1, type: Discord.AuditLogEvent.MemberBanAdd })).entries.first();
if (!banLog) return console.log(`Member was banned from ${member.guild.name} but no audit log for this member.`) if (!banLog) return console.log(`Member was banned from ${member.guild.name} but no audit log for this member.`)
const {executor, target, reason } = banLog; const {executor, target, reason } = banLog;
if (target.id === member.user.id) { if (target.id === member.user.id) {

View File

@ -1,9 +1,9 @@
import Discord, { AuditLogEvent } from 'discord.js'; import Discord from 'discord.js';
import TClient from '../client.js'; import TClient from '../client.js';
export default class GuildBanRemove { export default class GuildBanRemove {
static async run(client:TClient, member:Discord.GuildMember){ static async run(client:TClient, member:Discord.GuildMember){
if (member.guild?.id != client.config.dcServer.id) return; if (member.guild?.id != client.config.dcServer.id) return;
const unbanLog = (await member.guild.fetchAuditLogs({limit: 1, type: AuditLogEvent.MemberBanRemove})).entries.first(); const unbanLog = (await member.guild.fetchAuditLogs({limit: 1, type: Discord.AuditLogEvent.MemberBanRemove})).entries.first();
if (!unbanLog) return console.log(`User was unbanned from ${member.guild.name} but no audit log for this user.`) if (!unbanLog) return console.log(`User was unbanned from ${member.guild.name} but no audit log for this user.`)
const { executor, target, reason } = unbanLog; const { executor, target, reason } = unbanLog;
if (target.id === member.user.id) (client.channels.resolve(client.config.dcServer.channels.logs) as Discord.TextChannel).send({embeds: [ if (target.id === member.user.id) (client.channels.resolve(client.config.dcServer.channels.logs) as Discord.TextChannel).send({embeds: [

View File

@ -1,7 +1,6 @@
import Discord from 'discord.js'; import Discord from 'discord.js';
import TClient from '../client.js'; import TClient from '../client.js';
import Logger from '../helpers/Logger.js'; import Logger from '../helpers/Logger.js';
import {escapeCodeBlock} from 'discord.js';
export default class MessageDelete { export default class MessageDelete {
static run(client:TClient, msg:Discord.Message){ static run(client:TClient, msg:Discord.Message){
if (!client.config.botSwitches.logs) return; if (!client.config.botSwitches.logs) return;
@ -9,12 +8,12 @@ export default class MessageDelete {
if (msg.guild?.id != client.config.dcServer.id || msg.partial || msg.author.bot || disabledChannels.includes(msg.channelId)) return; if (msg.guild?.id != client.config.dcServer.id || msg.partial || msg.author.bot || disabledChannels.includes(msg.channelId)) return;
if (Discord.DiscordAPIError.name === '10008') return Logger.console('log', 'MsgDelete', 'Caught an unexpected error returned by Discord API. (Unknown Message)'); if (Discord.DiscordAPIError.name === '10008') return Logger.console('log', 'MsgDelete', 'Caught an unexpected error returned by Discord API. (Unknown Message)');
const embed = new client.embed().setColor(client.config.embedColorRed).setTimestamp().setAuthor({name: `Author: ${msg.author.username} (${msg.author.id})`, iconURL: `${msg.author.displayAvatarURL()}`}).setTitle('Message deleted').setDescription(`<@${msg.author.id}>\n\`${msg.author.id}\``); const embed = new client.embed().setColor(client.config.embedColorRed).setTimestamp().setAuthor({name: `Author: ${msg.author.username} (${msg.author.id})`, iconURL: `${msg.author.displayAvatarURL()}`}).setTitle('Message deleted').setDescription(`<@${msg.author.id}>\n\`${msg.author.id}\``);
if (msg.content.length != 0) embed.addFields({name: 'Content', value: `\`\`\`\n${escapeCodeBlock(msg.content.slice(0,1000))}\n\`\`\``}); if (msg.content.length != 0) embed.addFields({name: 'Content', value: `\`\`\`\n${Discord.escapeCodeBlock(msg.content.slice(0,1000))}\n\`\`\``});
embed.addFields( embed.addFields(
{ name: 'Channel', value: `<#${msg.channelId}>` }, { name: 'Channel', value: `<#${msg.channelId}>` },
{ name: 'Sent at', value: `<t:${Math.round(msg.createdTimestamp/1000)}>\n<t:${Math.round(msg.createdTimestamp/1000)}:R>` } { name: 'Sent at', value: `<t:${Math.round(msg.createdTimestamp/1000)}>\n<t:${Math.round(msg.createdTimestamp/1000)}:R>` }
) )
const attachments: Array<string> = []; const attachments:string[] = [];
msg.attachments.forEach(x=>attachments.push(x.url)); msg.attachments.forEach(x=>attachments.push(x.url));
(client.channels.resolve(client.config.dcServer.channels.logs) as Discord.TextChannel).send({embeds: [embed], files: attachments}) (client.channels.resolve(client.config.dcServer.channels.logs) as Discord.TextChannel).send({embeds: [embed], files: attachments})
} }

View File

@ -6,6 +6,6 @@ export default class MessageReactionAdd {
if (reaction.message.guildId != client.config.dcServer.id || reaction.message.partial) return; if (reaction.message.guildId != client.config.dcServer.id || reaction.message.partial) return;
const ReactedFirst = reaction.users.cache.first(); const ReactedFirst = reaction.users.cache.first();
if (ReactedFirst.id != user.id) return; if (ReactedFirst.id != user.id) return;
if (reaction.emoji.name === '🖕') return (client.channels.cache.get(client.config.dcServer.channels.logs) as Discord.TextChannel).send({embeds:[new client.embed().setColor(client.config.embedColorYellow).setTimestamp().setAuthor({name: `Author: ${ReactedFirst.username} (${ReactedFirst.id})`, iconURL: `${ReactedFirst.displayAvatarURL()}`}).setTitle('Message reaction').setDescription(`<@${ReactedFirst.id}>\nAdded a reaction to the message.\n**Emoji**\n${reaction.emoji.name}\n**Channel**\n<#${reaction.message.channelId}>`).setFooter({text: 'Possibly this member, bot fetches who reacted first.'})], components: [new Discord.ActionRowBuilder<Discord.ButtonBuilder>().addComponents(new Discord.ButtonBuilder().setStyle(5).setURL(`${reaction.message.url}`).setLabel('Jump to message'))]}); if (reaction.emoji.name === '🖕') return (client.channels.cache.get(client.config.dcServer.channels.logs) as Discord.TextChannel).send({embeds:[new client.embed().setColor(client.config.embedColorYellow).setTimestamp().setAuthor({name: `Author: ${ReactedFirst.username} (${ReactedFirst.id})`, iconURL: ReactedFirst.displayAvatarURL()}).setTitle('Message reaction').setDescription(`<@${ReactedFirst.id}>\nAdded a reaction to the message.\n**Emoji**\n${reaction.emoji.name}\n**Channel**\n<#${reaction.message.channelId}>`).setFooter({text: 'Possibly this member, bot fetches who reacted first.'})], components: [new Discord.ActionRowBuilder<Discord.ButtonBuilder>().addComponents(new Discord.ButtonBuilder().setStyle(5).setURL(`${reaction.message.url}`).setLabel('Jump to message'))]});
} }
} }

View File

@ -3,6 +3,6 @@ import TClient from '../client.js';
export default class MessageReactionRemove { export default class MessageReactionRemove {
static run(client:TClient, reaction:Discord.MessageReaction, user:Discord.User){ static run(client:TClient, reaction:Discord.MessageReaction, user:Discord.User){
if (!client.config.botSwitches.logs || reaction.message.guildId != client.config.dcServer.id || reaction.message.partial) return; if (!client.config.botSwitches.logs || reaction.message.guildId != client.config.dcServer.id || reaction.message.partial) return;
if (reaction.emoji.name === '🖕') return (client.channels.cache.get(client.config.dcServer.channels.logs) as Discord.TextChannel).send({embeds:[new client.embed().setColor(client.config.embedColorRed).setTimestamp().setAuthor({name: `Author: ${user.username} (${user.id})`, iconURL: `${user.displayAvatarURL()}`}).setTitle('Message reaction').setDescription(`<@${user.id}>\nRemoved a reaction from the message.\n**Emoji**\n${reaction.emoji.name}\n**Channel**\n<#${reaction.message.channelId}>`)]}) if (reaction.emoji.name === '🖕') return (client.channels.cache.get(client.config.dcServer.channels.logs) as Discord.TextChannel).send({embeds:[new client.embed().setColor(client.config.embedColorRed).setTimestamp().setAuthor({name: `Author: ${user.username} (${user.id})`, iconURL: user.displayAvatarURL()}).setTitle('Message reaction').setDescription(`<@${user.id}>\nRemoved a reaction from the message.\n**Emoji**\n${reaction.emoji.name}\n**Channel**\n<#${reaction.message.channelId}>`)]})
} }
} }

View File

@ -1,13 +1,12 @@
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 {escapeCodeBlock} from 'discord.js';
export default class MessageUpdate { export default class MessageUpdate {
static async run(client:TClient, oldMsg:Discord.Message, newMsg:Discord.Message){ static async run(client:TClient, oldMsg:Discord.Message, newMsg:Discord.Message){
if (!client.config.botSwitches.logs) return; if (!client.config.botSwitches.logs) return;
if (oldMsg.guild?.id != client.config.dcServer.id || oldMsg.author === null || oldMsg?.author.bot || oldMsg.partial || newMsg.partial || !newMsg.member || ['548032776830582794', '541677709487505408', '949380187668242483'].includes(newMsg.channelId)) return; if (oldMsg.guild?.id != client.config.dcServer.id || oldMsg.author === null || oldMsg?.author.bot || oldMsg.partial || newMsg.partial || !newMsg.member || ['548032776830582794', '541677709487505408', '949380187668242483'].includes(newMsg.channelId)) return;
if (await client.prohibitedWords.findWord(newMsg.content.toLowerCase().replaceAll(/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?\n?0-9]|[]|ing\b/g, '').split(' ').join('')) && (!MessageTool.isStaff(newMsg.member))) newMsg.delete(); if (await client.prohibitedWords.findWord(newMsg.content.toLowerCase().replaceAll(/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?\n?0-9]|[]|ing\b/g, '').split(' ').join('')) && (!MessageTool.isStaff(newMsg.member))) newMsg.delete();
if (newMsg.content === oldMsg.content) return; if (newMsg.content === oldMsg.content) return;
(client.channels.resolve(client.config.dcServer.channels.logs) as Discord.TextChannel).send({embeds: [new client.embed().setColor(client.config.embedColor).setTimestamp().setAuthor({name: `Author: ${oldMsg.author.username} (${oldMsg.author.id})`, iconURL: `${oldMsg.author.displayAvatarURL()}`}).setTitle('Message edited').setDescription(`<@${oldMsg.author.id}>\nOld content:\n\`\`\`\n${oldMsg.content.length < 1 ? '(Attachment)' : escapeCodeBlock(oldMsg.content.slice(0,2048))}\n\`\`\`\nNew content:\n\`\`\`\n${escapeCodeBlock(newMsg.content.slice(0,2048))}\`\`\`\nChannel: <#${oldMsg.channelId}>`)], components: [new Discord.ActionRowBuilder<Discord.ButtonBuilder>().addComponents(new Discord.ButtonBuilder().setStyle(5).setURL(`${oldMsg.url}`).setLabel('Jump to message'))]}); (client.channels.resolve(client.config.dcServer.channels.logs) as Discord.TextChannel).send({embeds: [new client.embed().setColor(client.config.embedColor).setTimestamp().setAuthor({name: `Author: ${oldMsg.author.username} (${oldMsg.author.id})`, iconURL: oldMsg.author.displayAvatarURL()}).setTitle('Message edited').setDescription(`<@${oldMsg.author.id}>\nOld content:\n\`\`\`\n${oldMsg.content.length < 1 ? '(Attachment)' : Discord.escapeCodeBlock(oldMsg.content.slice(0,2048))}\n\`\`\`\nNew content:\n\`\`\`\n${Discord.escapeCodeBlock(newMsg.content.slice(0,2048))}\`\`\`\nChannel: <#${oldMsg.channelId}>`)], components: [new Discord.ActionRowBuilder<Discord.ButtonBuilder>().addComponents(new Discord.ButtonBuilder().setStyle(5).setURL(`${oldMsg.url}`).setLabel('Jump to message'))]});
} }
} }

View File

@ -1,5 +1,5 @@
import {readFileSync} from 'node:fs'; import {readFileSync} from 'node:fs';
import {Config} from '../interfaces'; import {Config} from 'src/interfaces';
export default class ConfigHelper { export default class ConfigHelper {
static loadConfig() { static loadConfig() {
let importconfig:Config; let importconfig:Config;

View File

@ -1,4 +1,4 @@
import {FSData} from '../interfaces'; import {FSData} from 'src/interfaces';
export default function(data:FSData) { export default function(data:FSData) {
const pallets = data.vehicles.filter(x=>x.category === 'PALLETS'); const pallets = data.vehicles.filter(x=>x.category === 'PALLETS');

View File

@ -6,7 +6,7 @@ import Logger from './helpers/Logger.js';
import YTModule from './modules/YTModule.js'; import YTModule from './modules/YTModule.js';
import MPModule, {refreshTimerSecs} from './modules/MPModule.js'; import MPModule, {refreshTimerSecs} from './modules/MPModule.js';
import UsernameHelper from './helpers/UsernameHelper.js'; import UsernameHelper from './helpers/UsernameHelper.js';
import {Punishment} from './interfaces'; import {Punishment} from 'src/interfaces';
import {readFileSync} from 'node:fs'; import {readFileSync} from 'node:fs';
// Error handler // Error handler
@ -21,7 +21,7 @@ process.on('error', (error: Error)=>_(error, 'processError'));
client.on('error', (error: Error)=>_(error, 'clientError')); client.on('error', (error: Error)=>_(error, 'clientError'));
// Interval timers for modules // Interval timers for modules
setInterval(async()=>await MPModule(client), refreshTimerSecs); // Second param got moved to inside MPModule function to reduce the amount of failure rates. setInterval(async()=>await MPModule(client), refreshTimerSecs);
setInterval(()=>YTModule(client), 180000); // 3 minutes setInterval(()=>YTModule(client), 180000); // 3 minutes
// Event loop for punishments and daily msgs // Event loop for punishments and daily msgs

View File

@ -1,7 +1,7 @@
import Discord from 'discord.js'; import Discord from 'discord.js';
import TClient from '../client.js'; import TClient from '../client.js';
import ms from 'ms'; import ms from 'ms';
import {Punishment} from '../interfaces'; import {Punishment} from 'src/interfaces';
import DatabaseServer from '../components/DatabaseServer.js'; import DatabaseServer from '../components/DatabaseServer.js';
import {Model, DataTypes} from 'sequelize'; import {Model, DataTypes} from 'sequelize';
import CacheServer from '../components/CacheServer.js'; import CacheServer from '../components/CacheServer.js';
@ -119,7 +119,7 @@ export class PunishmentsSvc {
`**${member.user.username}** (\`${member.user.id}\`) has been detected for case evasion.`, `**${member.user.username}** (\`${member.user.id}\`) has been detected for case evasion.`,
'Timeout has been automatically added. (25 days)' 'Timeout has been automatically added. (25 days)'
)).setTimestamp()]}); )).setTimestamp()]});
await this.punishmentAdd('mute', {time: '25d'}, this.client.user.id, '[AUTOMOD] Case evasion', member.user, member) await this.punishmentAdd('mute', {time: '25d'}, this.client.user.id, 'AUTOMOD:Case evasion', member.user, member)
} }
} }
async findInCache():Promise<any> { async findInCache():Promise<any> {
@ -134,7 +134,7 @@ export class PunishmentsSvc {
return result; return result;
} }
async createModlog(punishment:Punishment) { async createModlog(punishment:Punishment) {
const channel = ['kick', 'ban', 'softban'].includes(punishment.type) ? this.client.config.dcServer.channels.bankick_log : this.client.config.dcServer.channels.logs; const channel = ['kick', 'ban'].includes(punishment.type) ? this.client.config.dcServer.channels.bankick_log : this.client.config.dcServer.channels.logs;
const embed = new this.client.embed() const embed = new this.client.embed()
.setColor(this.client.config.embedColor) .setColor(this.client.config.embedColor)
.setTitle(`${punishment.type[0].toUpperCase() + punishment.type.slice(1)} | Case #${punishment.case_id}`) .setTitle(`${punishment.type[0].toUpperCase() + punishment.type.slice(1)} | Case #${punishment.case_id}`)

View File

@ -6,7 +6,7 @@ import FormatPlayer from '../helpers/FormatPlayer.js';
import Logger from '../helpers/Logger.js'; import Logger from '../helpers/Logger.js';
import HookMgr from '../components/HookManager.js'; import HookMgr from '../components/HookManager.js';
import {IServer} from '../models/MPServer.js'; import {IServer} from '../models/MPServer.js';
import {FSPlayer, FSData, FSCareerSavegame} from '../interfaces.js'; import {FSPlayer, FSData, FSCareerSavegame} from 'src/interfaces';
let loggingPrefix:string = 'MPModule'; let loggingPrefix:string = 'MPModule';
let dataUnavailable:string = 'Unavailable'; let dataUnavailable:string = 'Unavailable';