mirror of
https://github.com/toast-ts/Daggerbot-TS.git
synced 2024-11-17 00:10:58 -05:00
Compare commits
6 Commits
1b65010271
...
b212bfffd6
Author | SHA1 | Date | |
---|---|---|---|
|
b212bfffd6 | ||
|
02aef5eaff | ||
|
32f7bfcdca | ||
|
0314c1b1b4 | ||
|
02c9b880c6 | ||
|
9b49f88901 |
@ -1,7 +1,7 @@
|
||||
services:
|
||||
cache:
|
||||
container_name: daggerbot-redis
|
||||
image: redis/redis-stack-server:7.2.0-v10
|
||||
image: redis/redis-stack-server:7.4.0-rc2
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- 6379:6379/tcp
|
||||
|
@ -46,8 +46,8 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/ms": "0.7.34",
|
||||
"@types/node": "20.14.11",
|
||||
"@types/node": "20.14.12",
|
||||
"@types/node-cron": "3.0.11",
|
||||
"typescript": "5.4.5"
|
||||
"typescript": "5.5.4"
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,8 @@ export default class TClient extends Discord.Client {
|
||||
Discord.GatewayIntentBits.Guilds, Discord.GatewayIntentBits.GuildMembers,
|
||||
Discord.GatewayIntentBits.GuildModeration, Discord.GatewayIntentBits.GuildInvites,
|
||||
Discord.GatewayIntentBits.GuildPresences, Discord.GatewayIntentBits.MessageContent,
|
||||
Discord.GatewayIntentBits.GuildMessages, Discord.GatewayIntentBits.DirectMessages
|
||||
Discord.GatewayIntentBits.GuildMessages, Discord.GatewayIntentBits.DirectMessages,
|
||||
Discord.GatewayIntentBits.GuildMessageReactions
|
||||
],
|
||||
partials: [
|
||||
Discord.Partials.Message, Discord.Partials.Channel
|
||||
|
@ -157,20 +157,34 @@ export default class MP {
|
||||
}
|
||||
const msg_id = interaction.options.getString('message_id', true);
|
||||
const stripUrl = msg_id.replace(/https:\/\/discord.com\/channels\/\d+\/\d+\/(\d+)/, '$1');
|
||||
const msg = await (interaction.guild.channels.cache.get(MPChannels.announcements) as Discord.TextChannel).messages.fetch(stripUrl).catch(()=>null);
|
||||
const msg: Discord.Message = await (interaction.guild.channels.cache.get(MPChannels.announcements) as Discord.TextChannel).messages.fetch(stripUrl).catch(()=>null);
|
||||
if (!msg) return interaction.reply('Message not found, please make sure you have the correct message ID.');
|
||||
|
||||
if (msg.embeds[0].title !== 'Vote for next map!') return interaction.reply('This message is not a poll!');
|
||||
if (msg.embeds[0].footer?.text?.startsWith('Poll ended by')) return interaction.reply('This poll has already ended!');
|
||||
|
||||
const validEmojis = ['1️⃣','2️⃣','3️⃣','4️⃣','5️⃣','6️⃣','7️⃣','8️⃣','9️⃣','🔟'];
|
||||
const filterByDigits = msg.reactions.cache.filter(x=>validEmojis.includes(x.emoji.name));
|
||||
|
||||
(client.channels.cache.get(client.config.dcServer.channels.mpmod_chat) as Discord.TextChannel).send({files: [new client.attachment(
|
||||
Buffer.from(JSON.stringify({
|
||||
map_names: msg.embeds[0].description.split('\n').map(x=>x.slice(3).replace(/\*\*/g, '')),
|
||||
votes: msg.reactions.cache.map(x=>x.count)
|
||||
map_names: msg.embeds[0].description.split('\n').map(x=>x.slice(3).replace(/\*\*/g, '').trim()),
|
||||
votes: filterByDigits.map(x=>x.count)
|
||||
}, null, 2)), {name: `pollResults-${msg.id}.json`})
|
||||
]});
|
||||
|
||||
msg.edit({content: null, embeds: [new client.embed().setColor(client.config.embedColor).setTitle('Voting has ended!').setDescription('The next map will be '+msg.embeds[0].description.split('\n')[msg.reactions.cache.map(x=>x.count).indexOf(Math.max(...msg.reactions.cache.map(x=>x.count)))].slice(3)).setFooter({text: `Poll ended by ${interaction.user.tag}`, iconURL: interaction.member.displayAvatarURL({extension: 'webp', size: 1024})})]}).then(()=>msg.reactions.removeAll());
|
||||
const map_index = msg.reactions.cache.map(x=>x.count).indexOf(Math.max(...msg.reactions.cache.map(x=>x.count)));
|
||||
const next_map = msg.embeds[0].description.split('\n')[map_index].slice(3);
|
||||
|
||||
msg.edit({
|
||||
content: null,
|
||||
embeds: [new client.embed()
|
||||
.setColor(client.config.embedColor)
|
||||
.setTitle('Voting has ended!')
|
||||
.setDescription(`The next map will be ${next_map}`)
|
||||
.setFooter({text: `Poll ended by ${interaction.user.tag}`, iconURL: interaction.member.displayAvatarURL({extension: 'webp', size: 1024})})
|
||||
]
|
||||
}).then(()=>msg.reactions.removeAll());
|
||||
await interaction.reply(`Successfully ended the [poll](<https://discord.com/channels/${interaction.guildId}/${MPChannels.announcements}/${msg.id}>) in <#${MPChannels.announcements}>`)
|
||||
},
|
||||
maps: async()=>{
|
||||
|
@ -52,8 +52,8 @@ export default class InteractionCreate {
|
||||
const timeDiff = time - isRatelimited;
|
||||
if (timeDiff < 5000) return interaction.reply({content: 'You are on **__cooldown__**, please avoid spam-clicking next time.\n\n*This system is put in place due to selfbots.. I\'m sorry!*', ephemeral: true});
|
||||
|
||||
const MFFarm1 = '1149139369433776269';
|
||||
const MFFarm2 = '1149139583729160325';
|
||||
const MFFarm1 = '1266225167194001469';
|
||||
const MFFarm2 = '1266225291232280707';
|
||||
|
||||
if (interaction.member.roles.cache.has(RoleID)) interaction.member.roles.remove(RoleID, 'Button Role').then(()=>interaction.reply({content: `You have been removed from <@&${RoleID}>`, ephemeral: true}));
|
||||
else interaction.member.roles.add(RoleID, 'Button Role').then(async()=>{
|
||||
|
@ -86,7 +86,7 @@ export default class MessageCreate {
|
||||
for (let i = 0; i < times_of_day.length; i++) Response.create(message, GeneralChatID, times_of_day[i]); */
|
||||
|
||||
CmdTrigger.registerCmds(client, message, 'deploy');
|
||||
CmdTrigger.MFPwTrigger(message, 'farmpw');
|
||||
// CmdTrigger.MFPwTrigger(message, 'farmpw');
|
||||
|
||||
let picStorage = {
|
||||
cantRead: 'https://tenor.com/view/aristocats-george-pen-cap-meticulous-gif-5330931',
|
||||
|
@ -5,7 +5,7 @@ import {disabledChannels} from '../index.js';
|
||||
export default class MessageDelete {
|
||||
static run(client:TClient, msg:Discord.Message|Discord.PartialMessage){
|
||||
if (!client.config.botSwitches.logs) return;
|
||||
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.type === Discord.MessageType.ChannelPinnedMessage || 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');
|
||||
if (msg.content.length != 0) embed.addFields({name: 'Content', value: `\`\`\`\n${Discord.escapeCodeBlock(msg.content.slice(0,1000))}\n\`\`\``});
|
||||
|
29
src/index.ts
29
src/index.ts
@ -75,14 +75,17 @@ setInterval(async()=>{
|
||||
Logger.console('log', 'DailyMsgs', `Pushed [${formattedDate}, ${total}]`)
|
||||
|
||||
// Send notification to #bot-log that the data has been pushed to database.
|
||||
const commands = await client.guilds.cache.get(client.config.dcServer.id)?.commands.fetch();
|
||||
if (commands) (client.channels.resolve(client.config.dcServer.channels.bot_log) as Discord.TextChannel).send({embeds: [
|
||||
new client.embed().setDescription(`Pushed the following\ndata to </rank leaderboard:${commands.find(x=>x.name === 'rank').id}>`).setFields(
|
||||
{name: 'Day', value: formattedDate.toString(), inline: true},
|
||||
{name: 'Messages', value: Intl.NumberFormat('en-us').format(total).toString(), inline: true}
|
||||
).setColor(client.config.embedColor)
|
||||
]});
|
||||
else Logger.console('log', 'DailyMsgs', 'Rank command not found, cannot send notification in channel')
|
||||
try {
|
||||
const commands = await client.guilds.cache.get(client.config.dcServer.id)?.commands.fetch();
|
||||
if (commands) (client.channels.cache.get(client.config.dcServer.channels.bot_log) as Discord.TextChannel).send({embeds: [
|
||||
new client.embed().setDescription(`Pushed the following\ndata to </rank leaderboard:${commands.find(x=>x.name === 'rank').id}>`).setFields(
|
||||
{name: 'Day', value: formattedDate.toString(), inline: true},
|
||||
{name: 'Messages', value: Intl.NumberFormat('en-us').format(total).toString(), inline: true}
|
||||
).setColor(client.config.embedColor)
|
||||
]});
|
||||
} catch {
|
||||
Logger.console('log', 'DailyMsgs', 'Rank command not found, cannot send notification in channel');
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 5000)
|
||||
@ -104,18 +107,20 @@ if (!client.config.botSwitches.logs) {
|
||||
};
|
||||
client.on('raw', async (packet:RawGatewayPacket<RawMessageUpdate>)=>{
|
||||
if (rawSwitches[packet.t] || packet.t !== 'MESSAGE_UPDATE') return;
|
||||
if (packet.d.guild_id != client.config.dcServer.id || disabledChannels.includes(packet.d.channel_id) || typeof packet.d.content === 'undefined') return;
|
||||
if (packet.d.guild_id != client.config.dcServer.id || disabledChannels.includes(packet.d.channel_id) || typeof packet.d.content === undefined) return;
|
||||
|
||||
const channel = client.channels.cache.get(packet.d.channel_id) as Discord.TextBasedChannel;
|
||||
const channel: Discord.TextBasedChannel = client.channels.cache.get(packet.d.channel_id) as Discord.TextChannel;
|
||||
|
||||
// Switched to console.log to prevent useless embed creation that has same content as the original message.
|
||||
if (!rawSwitches.MESSAGE_UPDATE && !packet.d.author.bot) return Logger.console('log', 'RawEvent:Edit', `Message was edited in #${(channel as Discord.TextChannel).name}`);
|
||||
if (!rawSwitches.MESSAGE_UPDATE && !packet.d.author.bot) return Logger.console('log', 'RawEvent:Edit', `Message was edited in #${channel.name}`);
|
||||
});
|
||||
|
||||
client.on('raw', async (packet:RawGatewayPacket<RawMessageDelete>)=>{
|
||||
if (rawSwitches[packet.t]) return;
|
||||
if (packet.t !== 'MESSAGE_DELETE' || packet.d.guild_id != client.config.dcServer.id || disabledChannels.includes(packet.d.channel_id)) return;
|
||||
|
||||
Logger.console('log', 'RawEvent:Del', `Message was deleted in #${(client.channels.resolve(packet.d.channel_id) as Discord.TextChannel).name}`);
|
||||
const channel: Discord.TextBasedChannel = client.channels.cache.get(packet.d.channel_id) as Discord.TextChannel;
|
||||
|
||||
Logger.console('log', 'RawEvent:Del', `Message was deleted in #${channel.name}`);
|
||||
rawSwitches[packet.t] = true;
|
||||
});
|
||||
|
28
yarn.lock
28
yarn.lock
@ -531,12 +531,12 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@types/node@npm:*, @types/node@npm:20.14.11":
|
||||
version: 20.14.11
|
||||
resolution: "@types/node@npm:20.14.11"
|
||||
"@types/node@npm:*, @types/node@npm:20.14.12":
|
||||
version: 20.14.12
|
||||
resolution: "@types/node@npm:20.14.12"
|
||||
dependencies:
|
||||
undici-types: "npm:~5.26.4"
|
||||
checksum: 10/344e1ce1ed16c86ed1c4209ab4d1de67db83dd6b694a6fabe295c47144dde2c58dabddae9f39a0a2bdd246e95f8d141ccfe848e464884b48b8918df4f7788025
|
||||
checksum: 10/9205bf46ef6a99d99cdde9efeb8218cd15803cc407249c2336557cd630b006380dad68c03ee574934414639f8e450044f45530c92788a8e82078bae45ee40f93
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
@ -663,7 +663,7 @@ __metadata:
|
||||
"@sequelize/postgres": "npm:7.0.0-alpha.41"
|
||||
"@toast/tokenservice-client": "npm:1.2.8"
|
||||
"@types/ms": "npm:0.7.34"
|
||||
"@types/node": "npm:20.14.11"
|
||||
"@types/node": "npm:20.14.12"
|
||||
"@types/node-cron": "npm:3.0.11"
|
||||
ansi-colors: "npm:4.1.3"
|
||||
dayjs: "npm:1.11.12"
|
||||
@ -675,7 +675,7 @@ __metadata:
|
||||
redis: "npm:4.6.15"
|
||||
simple-git: "npm:3.25.0"
|
||||
systeminformation: "npm:5.22.11"
|
||||
typescript: "npm:5.4.5"
|
||||
typescript: "npm:5.5.4"
|
||||
undici: "npm:6.19.4"
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
@ -1332,23 +1332,23 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"typescript@npm:5.4.5":
|
||||
version: 5.4.5
|
||||
resolution: "typescript@npm:5.4.5"
|
||||
"typescript@npm:5.5.4":
|
||||
version: 5.5.4
|
||||
resolution: "typescript@npm:5.5.4"
|
||||
bin:
|
||||
tsc: bin/tsc
|
||||
tsserver: bin/tsserver
|
||||
checksum: 10/d04a9e27e6d83861f2126665aa8d84847e8ebabcea9125b9ebc30370b98cb38b5dff2508d74e2326a744938191a83a69aa9fddab41f193ffa43eabfdf3f190a5
|
||||
checksum: 10/1689ccafef894825481fc3d856b4834ba3cc185a9c2878f3c76a9a1ef81af04194849840f3c69e7961e2312771471bb3b460ca92561e1d87599b26c37d0ffb6f
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"typescript@patch:typescript@npm%3A5.4.5#optional!builtin<compat/typescript>":
|
||||
version: 5.4.5
|
||||
resolution: "typescript@patch:typescript@npm%3A5.4.5#optional!builtin<compat/typescript>::version=5.4.5&hash=5adc0c"
|
||||
"typescript@patch:typescript@npm%3A5.5.4#optional!builtin<compat/typescript>":
|
||||
version: 5.5.4
|
||||
resolution: "typescript@patch:typescript@npm%3A5.5.4#optional!builtin<compat/typescript>::version=5.5.4&hash=379a07"
|
||||
bin:
|
||||
tsc: bin/tsc
|
||||
tsserver: bin/tsserver
|
||||
checksum: 10/760f7d92fb383dbf7dee2443bf902f4365db2117f96f875cf809167f6103d55064de973db9f78fe8f31ec08fff52b2c969aee0d310939c0a3798ec75d0bca2e1
|
||||
checksum: 10/746fdd0865c5ce4f15e494c57ede03a9e12ede59cfdb40da3a281807853fe63b00ef1c912d7222143499aa82f18b8b472baa1830df8804746d09b55f6cf5b1cc
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user