mirror of
https://github.com/toast-ts/Daggerbot-TS.git
synced 2024-11-17 16:30:58 -05:00
Compare commits
No commits in common. "263d3d1cdd7630388905f85f9cafc0af44cc2b6e" and "48069755d8f2c940bdc898491bcfd2763370072f" have entirely different histories.
263d3d1cdd
...
48069755d8
10
.dockerignore
Normal file
10
.dockerignore
Normal file
@ -0,0 +1,10 @@
|
||||
botStartup.bat
|
||||
.ncurc.json
|
||||
.gitignore
|
||||
README.md
|
||||
.github
|
||||
.vscode
|
||||
.yarn/sdks
|
||||
dist/
|
||||
docker-compose.yml
|
||||
startWithYarn.cjs
|
@ -1,7 +1,6 @@
|
||||
<p align="center">
|
||||
<img width="630" height="250" src="https://github.com/AnxietyisReal/Daggerbot-TS/assets/96593068/87a3c8b2-2209-42f0-851c-6cdebf9ef740">
|
||||
<img width="630" height="250" src="https://cdn.toast-server.net/daggerwin/DaggerbotV3-Repo.gif">
|
||||
<h1 align="center">Daggerbot V3 Description</h1>
|
||||
|
||||
</p>
|
||||
This is a repository for V3 revision that has been transitioned and rewritten from V2 bot to be more robust and reliable with today's standards.
|
||||
|
||||
|
@ -9,7 +9,7 @@ interface IRepeatedMessages {
|
||||
import Discord from 'discord.js';
|
||||
import ConfigHelper from './helpers/ConfigHelper.js';
|
||||
import {readdirSync} from 'node:fs';
|
||||
import {Config} from 'src/interfaces';
|
||||
import {Config} from './interfaces';
|
||||
import {
|
||||
DailyMsgsSvc, UserLevelsSvc, BonkCountSvc,
|
||||
MPServerSvc, PunishmentsSvc, ProhibitedWordsSvc,
|
||||
@ -24,7 +24,7 @@ import TSClient from './helpers/TSClient.js';
|
||||
export default class TClient extends Discord.Client {
|
||||
public invites: Map<any, any> = new Map();
|
||||
public commands: Discord.Collection<string, any> = new Discord.Collection();
|
||||
public registry: Discord.ApplicationCommandDataResolvable[] = [];
|
||||
public registry: Array<Discord.ApplicationCommandDataResolvable> = [];
|
||||
public config: Config;
|
||||
public embed: typeof Discord.EmbedBuilder = Discord.EmbedBuilder;
|
||||
public collection: typeof Discord.Collection = Discord.Collection;
|
||||
|
@ -71,7 +71,7 @@ export default class Developer {
|
||||
deletion: repoData.stats.deletions.toLocaleString('en-US')
|
||||
};
|
||||
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}**`,
|
||||
`Author: **${repoData.commit.author.name}**`,
|
||||
'Changes',
|
||||
|
@ -5,7 +5,7 @@ import CanvasBuilder from '../components/CanvasGraph.js';
|
||||
import RanIntoHumor from '../helpers/RanIntoHumor.js';
|
||||
import MessageTool from '../helpers/MessageTool.js';
|
||||
import PalletLibrary from '../helpers/PalletLibrary.js';
|
||||
import {FSData} from 'src/interfaces';
|
||||
import {FSData} from '../interfaces';
|
||||
import {requestServerData, mpModuleDisabled, refreshTimerSecs, playtimeStat} from '../modules/MPModule.js';
|
||||
|
||||
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')
|
||||
.setColor(embedColor)
|
||||
.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}`})
|
||||
.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})]})
|
||||
},
|
||||
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(
|
||||
`**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'}\``,
|
||||
`**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)',
|
||||
|
@ -7,7 +7,7 @@ export default class Purge {
|
||||
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');
|
||||
let messagesArray:string[] = [];
|
||||
let messagesArray: Array<string> = [];
|
||||
|
||||
if (user){
|
||||
(interaction.channel as Discord.TextChannel).messages.fetch({limit: amount}).then(msgs=>{
|
||||
|
@ -6,7 +6,7 @@ import GitHub from '../helpers/GitHub.js';
|
||||
import si from 'systeminformation';
|
||||
import os from 'node:os';
|
||||
import ts from 'typescript';
|
||||
import {readFileSync} from 'node:fs';
|
||||
import {readFileSync} from 'fs';
|
||||
export default class Statistics {
|
||||
static async run(client:TClient, interaction:Discord.ChatInputCommandInteraction<'cached'>) {
|
||||
const initialMsg = await interaction.reply({content: '<a:sakjdfsajkfhsdjhjfsa:1065342869428252743>', fetchReply:true});
|
||||
|
@ -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'}
|
||||
)
|
||||
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 (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 (!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})
|
||||
embedArray.push(embed)
|
||||
if (member.presence?.activities.find(a=>a.type === 2)) {
|
||||
const spotifyStatus = member.presence?.activities.find(a=>a.name === 'Spotify') as Discord.Activity;
|
||||
|
@ -1,5 +1,5 @@
|
||||
import {createCanvas, Canvas, CanvasRenderingContext2D} from 'canvas';
|
||||
import {Config} from 'src/interfaces';
|
||||
import {Config} from '../interfaces';
|
||||
import ConfigHelper from '../helpers/ConfigHelper.js';
|
||||
export default class CanvasBuilder {
|
||||
private canvas: Canvas;
|
||||
|
@ -1,9 +1,9 @@
|
||||
import Discord from 'discord.js';
|
||||
import Discord, { AuditLogEvent } from 'discord.js';
|
||||
import TClient from '../client.js';
|
||||
export default class GuildBanAdd {
|
||||
static async run(client:TClient, member:Discord.GuildMember){
|
||||
if (member.guild?.id != client.config.dcServer.id) return;
|
||||
const banLog = (await member.guild.fetchAuditLogs({ limit: 1, type: Discord.AuditLogEvent.MemberBanAdd })).entries.first();
|
||||
const banLog = (await member.guild.fetchAuditLogs({ limit: 1, type: AuditLogEvent.MemberBanAdd })).entries.first();
|
||||
if (!banLog) return console.log(`Member was banned from ${member.guild.name} but no audit log for this member.`)
|
||||
const {executor, target, reason } = banLog;
|
||||
if (target.id === member.user.id) {
|
||||
|
@ -1,9 +1,9 @@
|
||||
import Discord from 'discord.js';
|
||||
import Discord, { AuditLogEvent } from 'discord.js';
|
||||
import TClient from '../client.js';
|
||||
export default class GuildBanRemove {
|
||||
static async run(client:TClient, member:Discord.GuildMember){
|
||||
if (member.guild?.id != client.config.dcServer.id) return;
|
||||
const unbanLog = (await member.guild.fetchAuditLogs({limit: 1, type: Discord.AuditLogEvent.MemberBanRemove})).entries.first();
|
||||
const unbanLog = (await member.guild.fetchAuditLogs({limit: 1, type: AuditLogEvent.MemberBanRemove})).entries.first();
|
||||
if (!unbanLog) return console.log(`User was unbanned from ${member.guild.name} but no audit log for this user.`)
|
||||
const { executor, target, reason } = unbanLog;
|
||||
if (target.id === member.user.id) (client.channels.resolve(client.config.dcServer.channels.logs) as Discord.TextChannel).send({embeds: [
|
||||
|
@ -1,6 +1,7 @@
|
||||
import Discord from 'discord.js';
|
||||
import TClient from '../client.js';
|
||||
import Logger from '../helpers/Logger.js';
|
||||
import {escapeCodeBlock} from 'discord.js';
|
||||
export default class MessageDelete {
|
||||
static run(client:TClient, msg:Discord.Message){
|
||||
if (!client.config.botSwitches.logs) return;
|
||||
@ -8,12 +9,12 @@ export default class MessageDelete {
|
||||
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)');
|
||||
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${Discord.escapeCodeBlock(msg.content.slice(0,1000))}\n\`\`\``});
|
||||
if (msg.content.length != 0) embed.addFields({name: 'Content', value: `\`\`\`\n${escapeCodeBlock(msg.content.slice(0,1000))}\n\`\`\``});
|
||||
embed.addFields(
|
||||
{ name: 'Channel', value: `<#${msg.channelId}>` },
|
||||
{ name: 'Sent at', value: `<t:${Math.round(msg.createdTimestamp/1000)}>\n<t:${Math.round(msg.createdTimestamp/1000)}:R>` }
|
||||
)
|
||||
const attachments:string[] = [];
|
||||
const attachments: Array<string> = [];
|
||||
msg.attachments.forEach(x=>attachments.push(x.url));
|
||||
(client.channels.resolve(client.config.dcServer.channels.logs) as Discord.TextChannel).send({embeds: [embed], files: attachments})
|
||||
}
|
||||
|
@ -6,6 +6,6 @@ export default class MessageReactionAdd {
|
||||
if (reaction.message.guildId != client.config.dcServer.id || reaction.message.partial) return;
|
||||
const ReactedFirst = reaction.users.cache.first();
|
||||
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'))]});
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,6 @@ import TClient from '../client.js';
|
||||
export default class MessageReactionRemove {
|
||||
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 (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}>`)]})
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,13 @@
|
||||
import Discord from 'discord.js';
|
||||
import TClient from '../client.js';
|
||||
import MessageTool from '../helpers/MessageTool.js';
|
||||
import {escapeCodeBlock} from 'discord.js';
|
||||
export default class MessageUpdate {
|
||||
static async run(client:TClient, oldMsg:Discord.Message, newMsg:Discord.Message){
|
||||
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 (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;
|
||||
(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}>\n\`${oldMsg.author.id}\``).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'))]});
|
||||
(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'))]});
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import {readFileSync} from 'node:fs';
|
||||
import {Config} from 'src/interfaces';
|
||||
import {Config} from '../interfaces';
|
||||
export default class ConfigHelper {
|
||||
static loadConfig() {
|
||||
let importconfig:Config;
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {FSData} from 'src/interfaces';
|
||||
import {FSData} from '../interfaces';
|
||||
|
||||
export default function(data:FSData) {
|
||||
const pallets = data.vehicles.filter(x=>x.category === 'PALLETS');
|
||||
|
@ -6,7 +6,7 @@ import Logger from './helpers/Logger.js';
|
||||
import YTModule from './modules/YTModule.js';
|
||||
import MPModule, {refreshTimerSecs} from './modules/MPModule.js';
|
||||
import UsernameHelper from './helpers/UsernameHelper.js';
|
||||
import {Punishment} from 'src/interfaces';
|
||||
import {Punishment} from './interfaces';
|
||||
import {readFileSync} from 'node:fs';
|
||||
|
||||
// Error handler
|
||||
@ -21,7 +21,7 @@ process.on('error', (error: Error)=>_(error, 'processError'));
|
||||
client.on('error', (error: Error)=>_(error, 'clientError'));
|
||||
|
||||
// Interval timers for modules
|
||||
setInterval(async()=>await MPModule(client), refreshTimerSecs);
|
||||
setInterval(async()=>await MPModule(client), refreshTimerSecs); // Second param got moved to inside MPModule function to reduce the amount of failure rates.
|
||||
setInterval(()=>YTModule(client), 180000); // 3 minutes
|
||||
|
||||
// Event loop for punishments and daily msgs
|
||||
|
@ -1,7 +1,7 @@
|
||||
import Discord from 'discord.js';
|
||||
import TClient from '../client.js';
|
||||
import ms from 'ms';
|
||||
import {Punishment} from 'src/interfaces';
|
||||
import {Punishment} from '../interfaces';
|
||||
import DatabaseServer from '../components/DatabaseServer.js';
|
||||
import {Model, DataTypes} from 'sequelize';
|
||||
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.`,
|
||||
'Timeout has been automatically added. (25 days)'
|
||||
)).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> {
|
||||
@ -134,7 +134,7 @@ export class PunishmentsSvc {
|
||||
return result;
|
||||
}
|
||||
async createModlog(punishment:Punishment) {
|
||||
const channel = ['kick', 'ban'].includes(punishment.type) ? this.client.config.dcServer.channels.bankick_log : this.client.config.dcServer.channels.logs;
|
||||
const channel = ['kick', 'ban', 'softban'].includes(punishment.type) ? this.client.config.dcServer.channels.bankick_log : this.client.config.dcServer.channels.logs;
|
||||
const embed = new this.client.embed()
|
||||
.setColor(this.client.config.embedColor)
|
||||
.setTitle(`${punishment.type[0].toUpperCase() + punishment.type.slice(1)} | Case #${punishment.case_id}`)
|
||||
|
@ -6,7 +6,7 @@ import FormatPlayer from '../helpers/FormatPlayer.js';
|
||||
import Logger from '../helpers/Logger.js';
|
||||
import HookMgr from '../components/HookManager.js';
|
||||
import {IServer} from '../models/MPServer.js';
|
||||
import {FSPlayer, FSData, FSCareerSavegame} from 'src/interfaces';
|
||||
import {FSPlayer, FSData, FSCareerSavegame} from '../interfaces.js';
|
||||
|
||||
let loggingPrefix:string = 'MPModule';
|
||||
let dataUnavailable:string = 'Unavailable';
|
||||
|
Loading…
Reference in New Issue
Block a user