From 3a2b908ea63bf2d0fa388d09c566876f7fd028cb Mon Sep 17 00:00:00 2001 From: toast-ts <96593068+toast-ts@users.noreply.github.com> Date: Tue, 20 Feb 2024 17:34:12 +1100 Subject: [PATCH] Move message ID to top of file --- src/commands/mp.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/commands/mp.ts b/src/commands/mp.ts index 973899e..c480954 100644 --- a/src/commands/mp.ts +++ b/src/commands/mp.ts @@ -20,6 +20,7 @@ async function fetchData(client:TClient, interaction:Discord.ChatInputCommandInt } const logPrefix = 'MPDB'; +const MAP_POOL_HOOKMSG = '1141293129673232435'; const channels = { activePlayers: '739084625862852715', announcements: '1084864116776251463', @@ -154,11 +155,12 @@ export default class MP { 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 pollResults = Buffer.from(JSON.stringify({ - map_names: msg.embeds[0].description.split('\n').map(x=>x.slice(3)), - votes: msg.reactions.cache.map(x=>x.count) - }, null, 2)); - (client.channels.cache.get(client.config.dcServer.channels.mpmod_chat) as Discord.TextChannel).send({files: [new client.attachment(pollResults, {name: `pollResults-${msg.id}.json`})]}); + (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)), + votes: msg.reactions.cache.map(x=>x.count) + }, null, 2)), {name: `pollResults-${msg.id}.json`}) + ]}); msg.edit({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()); await interaction.reply(`Successfully ended the [poll]() in <#${channels.announcements}>`) @@ -167,7 +169,7 @@ export default class MP { if (client.config.dcServer.id === interaction.guildId) { if (!interaction.member.roles.cache.has(client.config.dcServer.roles.mpmod) && !interaction.member.roles.cache.has(client.config.dcServer.roles.bottech)) return MessageTool.youNeedRole(interaction, 'mpmod'); } - const suggestionPool = await (interaction.guild.channels.cache.get(client.config.dcServer.channels.mpmod_chat) as Discord.TextChannel).messages.fetch('1141293129673232435'); + const suggestionPool = await (interaction.guild.channels.cache.get(client.config.dcServer.channels.mpmod_chat) as Discord.TextChannel).messages.fetch(MAP_POOL_HOOKMSG); interaction.reply({embeds: [suggestionPool.embeds[0]]}); }, // Server management group create_server: async()=>{