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

Compare commits

..

3 Commits

Author SHA1 Message Date
toast-ts
eba24d6570 Use scanMsg from Automoderator instead. 2024-03-01 22:13:00 +11:00
toast-ts
e3ea51221e Finally fix the annoying link embedding issue 2024-03-01 22:06:47 +11:00
toast-ts
2beead7022 2024-03-01 19:12:18 +11:00
2 changed files with 9 additions and 5 deletions

View File

@ -28,12 +28,12 @@ const channels = {
serverInfo: '543494084363288637',
}
export default class MP {
static async autocomplete(client: TClient, interaction: Discord.AutocompleteInteraction<'cached'>) {
static async autocomplete(client:TClient, interaction:Discord.AutocompleteInteraction<'cached'>) {
const serversInCache = await client.MPServer?.findInCache();
const filterByActive = serversInCache?.filter(x=>x.isActive)?.map(x=>x.serverName);
await interaction?.respond(filterByActive?.map(server=>({name: server, value: server})));
}
static async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>) {
static async run(client:TClient, interaction:Discord.ChatInputCommandInteraction<'cached'>) {
if (client.config.botSwitches.mpSys === false) return interaction.reply({embeds: [mpModuleDisabled(client)]});
if (client.uptime < refreshTimerSecs) return interaction.reply('MPModule isn\'t initialized yet, please wait a moment and try again.');
if ([channels.mainMpChat, client.config.dcServer.channels.multifarm_chat].includes(interaction.channelId) && !MessageTool.isStaff(interaction.member) && ['status', 'players'].includes(interaction.options.getSubcommand())) return interaction.reply(`Please use <#${channels.activePlayers}> for \`/mp status/players\` commands to prevent clutter in this channel.`).then(()=>setTimeout(()=>interaction.deleteReply(), 6000));
@ -77,6 +77,9 @@ export default class MP {
if (!DSS) return console.log('Endpoint failed - details');
const db = await client.MPServer.findInCache();
const server = db.find(x=>x.serverName === choiceSelector);
if (!server) return;
// Shouldn't throw "Cannot read properties of undefined" error now,
// but I hate people finding new ways to cause the bot to have a minor aneurysm
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'}\``,

View File

@ -1,13 +1,14 @@
import Discord from 'discord.js';
import TClient from '../client.js';
import MessageTool from '../helpers/MessageTool.js';
import Automoderator from '../components/Automod.js';
import {disabledChannels, rawSwitches} from '../index.js';
export default class MessageUpdate {
static async run(client:TClient, oldMsg:Discord.Message|Discord.PartialMessage, newMsg:Discord.Message){
if (!client.config.botSwitches.logs) return;
if (oldMsg.guild?.id != client.config.dcServer.id || oldMsg.author === null || oldMsg?.author.bot || newMsg.partial || !newMsg.member || disabledChannels.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 (!rawSwitches.MESSAGE_UPDATE || (rawSwitches.MESSAGE_UPDATE && newMsg.content !== oldMsg.content)) {
if (oldMsg.guild?.id != client.config.dcServer.id || oldMsg.author === null || oldMsg?.author.bot || newMsg.partial || !newMsg.member || newMsg.content === oldMsg.content || disabledChannels.includes(newMsg.channelId)) return;
if (await client.prohibitedWords.findWord(Automoderator.scanMsg(newMsg)) && (!MessageTool.isStaff(newMsg.member))) newMsg.delete();
if (!rawSwitches.MESSAGE_UPDATE || rawSwitches.MESSAGE_UPDATE) {
rawSwitches.MESSAGE_UPDATE = true;
(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').addFields({name: 'Old content', value: `\`\`\`${oldMsg.content.length < 1 ? '(Attachment)' : Discord.escapeCodeBlock(oldMsg.content.slice(0,2048))}\`\`\``}, {name: 'New content', value: `\`\`\`${Discord.escapeCodeBlock(newMsg.content.slice(0,2048))}\`\`\``}, {name: 'Channel', value: `<#${oldMsg.channelId}>`})], components: [new Discord.ActionRowBuilder<Discord.ButtonBuilder>().addComponents(new Discord.ButtonBuilder().setStyle(5).setURL(oldMsg.url).setLabel('Jump to message'))]});
}