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

Compare commits

..

No commits in common. "9b49f889018b307eff7b43b34f834924ff2cfab6" and "b040aad719a660863ceb465ca6f3c2731e49c7da" have entirely different histories.

4 changed files with 28 additions and 43 deletions

View File

@ -33,16 +33,16 @@
"@sequelize/postgres": "7.0.0-alpha.41", "@sequelize/postgres": "7.0.0-alpha.41",
"@toast/tokenservice-client": "1.2.8", "@toast/tokenservice-client": "1.2.8",
"ansi-colors": "4.1.3", "ansi-colors": "4.1.3",
"dayjs": "1.11.12", "dayjs": "1.11.11",
"discord.js": "patch:discord.js@npm%3A14.15.3#~/.yarn/patches/discord.js-npm-14.15.3-0c74284e59.patch", "discord.js": "patch:discord.js@npm%3A14.15.3#~/.yarn/patches/discord.js-npm-14.15.3-0c74284e59.patch",
"fast-xml-parser": "4.4.0", "fast-xml-parser": "4.4.0",
"mathjs": "13.0.3", "mathjs": "13.0.2",
"ms": "2.1.3", "ms": "2.1.3",
"node-cron": "3.0.3", "node-cron": "3.0.3",
"redis": "4.6.15", "redis": "4.6.15",
"simple-git": "3.25.0", "simple-git": "3.25.0",
"systeminformation": "5.22.11", "systeminformation": "5.22.11",
"undici": "6.19.4" "undici": "6.19.2"
}, },
"devDependencies": { "devDependencies": {
"@types/ms": "0.7.34", "@types/ms": "0.7.34",

View File

@ -51,8 +51,7 @@ export default class TClient extends Discord.Client {
Discord.GatewayIntentBits.Guilds, Discord.GatewayIntentBits.GuildMembers, Discord.GatewayIntentBits.Guilds, Discord.GatewayIntentBits.GuildMembers,
Discord.GatewayIntentBits.GuildModeration, Discord.GatewayIntentBits.GuildInvites, Discord.GatewayIntentBits.GuildModeration, Discord.GatewayIntentBits.GuildInvites,
Discord.GatewayIntentBits.GuildPresences, Discord.GatewayIntentBits.MessageContent, Discord.GatewayIntentBits.GuildPresences, Discord.GatewayIntentBits.MessageContent,
Discord.GatewayIntentBits.GuildMessages, Discord.GatewayIntentBits.DirectMessages, Discord.GatewayIntentBits.GuildMessages, Discord.GatewayIntentBits.DirectMessages
Discord.GatewayIntentBits.GuildMessageReactions
], ],
partials: [ partials: [
Discord.Partials.Message, Discord.Partials.Channel Discord.Partials.Message, Discord.Partials.Channel

View File

@ -157,34 +157,20 @@ export default class MP {
} }
const msg_id = interaction.options.getString('message_id', true); const msg_id = interaction.options.getString('message_id', true);
const stripUrl = msg_id.replace(/https:\/\/discord.com\/channels\/\d+\/\d+\/(\d+)/, '$1'); const stripUrl = msg_id.replace(/https:\/\/discord.com\/channels\/\d+\/\d+\/(\d+)/, '$1');
const msg: Discord.Message = await (interaction.guild.channels.cache.get(MPChannels.announcements) as Discord.TextChannel).messages.fetch(stripUrl).catch(()=>null); const msg = 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) 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].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!'); 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( (client.channels.cache.get(client.config.dcServer.channels.mpmod_chat) as Discord.TextChannel).send({files: [new client.attachment(
Buffer.from(JSON.stringify({ Buffer.from(JSON.stringify({
map_names: msg.embeds[0].description.split('\n').map(x=>x.slice(3).replace(/\*\*/g, '').trim()), map_names: msg.embeds[0].description.split('\n').map(x=>x.slice(3).replace(/\*\*/g, '')),
votes: filterByDigits.map(x=>x.count) votes: msg.reactions.cache.map(x=>x.count)
}, null, 2)), {name: `pollResults-${msg.id}.json`}) }, null, 2)), {name: `pollResults-${msg.id}.json`})
]}); ]});
const map_index = msg.reactions.cache.map(x=>x.count).indexOf(Math.max(...msg.reactions.cache.map(x=>x.count))); 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 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}>`) await interaction.reply(`Successfully ended the [poll](<https://discord.com/channels/${interaction.guildId}/${MPChannels.announcements}/${msg.id}>) in <#${MPChannels.announcements}>`)
}, },
maps: async()=>{ maps: async()=>{

View File

@ -5,7 +5,7 @@ __metadata:
version: 8 version: 8
cacheKey: 10 cacheKey: 10
"@babel/runtime@npm:^7.24.8": "@babel/runtime@npm:^7.24.7":
version: 7.24.8 version: 7.24.8
resolution: "@babel/runtime@npm:7.24.8" resolution: "@babel/runtime@npm:7.24.8"
dependencies: dependencies:
@ -666,24 +666,24 @@ __metadata:
"@types/node": "npm:20.14.11" "@types/node": "npm:20.14.11"
"@types/node-cron": "npm:3.0.11" "@types/node-cron": "npm:3.0.11"
ansi-colors: "npm:4.1.3" ansi-colors: "npm:4.1.3"
dayjs: "npm:1.11.12" dayjs: "npm:1.11.11"
discord.js: "patch:discord.js@npm%3A14.15.3#~/.yarn/patches/discord.js-npm-14.15.3-0c74284e59.patch" discord.js: "patch:discord.js@npm%3A14.15.3#~/.yarn/patches/discord.js-npm-14.15.3-0c74284e59.patch"
fast-xml-parser: "npm:4.4.0" fast-xml-parser: "npm:4.4.0"
mathjs: "npm:13.0.3" mathjs: "npm:13.0.2"
ms: "npm:2.1.3" ms: "npm:2.1.3"
node-cron: "npm:3.0.3" node-cron: "npm:3.0.3"
redis: "npm:4.6.15" redis: "npm:4.6.15"
simple-git: "npm:3.25.0" simple-git: "npm:3.25.0"
systeminformation: "npm:5.22.11" systeminformation: "npm:5.22.11"
typescript: "npm:5.4.5" typescript: "npm:5.4.5"
undici: "npm:6.19.4" undici: "npm:6.19.2"
languageName: unknown languageName: unknown
linkType: soft linkType: soft
"dayjs@npm:1.11.12, dayjs@npm:^1.11.10": "dayjs@npm:1.11.11, dayjs@npm:^1.11.10":
version: 1.11.12 version: 1.11.11
resolution: "dayjs@npm:1.11.12" resolution: "dayjs@npm:1.11.11"
checksum: 10/8ee7c1e14961fd08d40b788d0c0e930dc6288b3d32911bb911b2fb31bb703c262788164fbe678ee9e50e2a35268d667b8c8ba43fd1806771c1f404c300a2b428 checksum: 10/f03948b172fbeed229837965988d1d5bac99c72a31c28731a457303259439f2f36289186489ae140adbeb10f591a926908c8de5d81eb449a2edbf5cbd6e9e30c
languageName: node languageName: node
linkType: hard linkType: hard
@ -904,11 +904,11 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"mathjs@npm:13.0.3": "mathjs@npm:13.0.2":
version: 13.0.3 version: 13.0.2
resolution: "mathjs@npm:13.0.3" resolution: "mathjs@npm:13.0.2"
dependencies: dependencies:
"@babel/runtime": "npm:^7.24.8" "@babel/runtime": "npm:^7.24.7"
complex.js: "npm:^2.1.1" complex.js: "npm:^2.1.1"
decimal.js: "npm:^10.4.3" decimal.js: "npm:^10.4.3"
escape-latex: "npm:^1.2.0" escape-latex: "npm:^1.2.0"
@ -919,7 +919,7 @@ __metadata:
typed-function: "npm:^4.2.1" typed-function: "npm:^4.2.1"
bin: bin:
mathjs: bin/cli.js mathjs: bin/cli.js
checksum: 10/6ef013f853be73b8efc8fab26522a6c76712ef9b73861a7cb88fee0be5b7638bcebafad10dc964f00455d1fa8715206adb300e6c2872d863e97c24ba1c9cd4d7 checksum: 10/1481dfdd969d09ee3c4f7e16aea409fcdbfa2f14e4ce9d873e7e6d1470c121c271ecaf87a7a0da3f1e6ce883dcaef63a569332199f4b6a5c169a3e67d4396750
languageName: node languageName: node
linkType: hard linkType: hard
@ -1319,9 +1319,9 @@ __metadata:
linkType: hard linkType: hard
"type-fest@npm:^4.14.0": "type-fest@npm:^4.14.0":
version: 4.23.0 version: 4.22.0
resolution: "type-fest@npm:4.23.0" resolution: "type-fest@npm:4.22.0"
checksum: 10/c411dea83262f9a4453e09ff82e3ac729dd26afc2e68b7a9fe93dd633b1a2bf7bf2bf3e041676497ae8b8411266019b3add91d4fe34b926a82ba09eb41e9e52b checksum: 10/f5e1471829166641cc52dd826839f40c43525a66c3fcd76bba8635bc2c42c339c7198b0f17395d23a91205da913be8294c58ab8d52cc03ef227386d24099f525
languageName: node languageName: node
linkType: hard linkType: hard
@ -1373,10 +1373,10 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"undici@npm:6.19.4, undici@npm:^6.15.0": "undici@npm:6.19.2, undici@npm:^6.15.0":
version: 6.19.4 version: 6.19.2
resolution: "undici@npm:6.19.4" resolution: "undici@npm:6.19.2"
checksum: 10/90e1a1ba12245e9928b8ed233bbef1e77c02b48b966f0a29b0f9b004499d92e183e516b6bba2707261d1845e629e504b0ddcec557ef557fa37335c5d59a5a712 checksum: 10/f4895c0c1e2fcde18076ac98965c231875811b8e14ceab1a7b19e940ed1a2fce69e0864e1186bfdc9347dffe0f39a00daf6dd5e7c0169b2b33de59a859dc2f1d
languageName: node languageName: node
linkType: hard linkType: hard