mirror of
https://github.com/toast-ts/Daggerbot-TS.git
synced 2024-11-17 08:20:58 -05:00
Discord decided that the bot shouldn't view it
This commit is contained in:
parent
b5c9de9df8
commit
556401bc12
@ -51,7 +51,8 @@ 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
|
||||||
|
@ -6,7 +6,7 @@ import CanvasBuilder from '../components/CanvasBuilder.js';
|
|||||||
import RanIntoHumor from '../helpers/RanIntoHumor.js';
|
import RanIntoHumor from '../helpers/RanIntoHumor.js';
|
||||||
import MessageTool from '../helpers/MessageTool.js';
|
import MessageTool from '../helpers/MessageTool.js';
|
||||||
import {FSData} from 'src/interfaces';
|
import {FSData} from 'src/interfaces';
|
||||||
import {requestServerData, mpModuleDisabled, refreshTimerSecs, playtimeStat, MPChannels} from '../modules/MPModule.js';
|
import {requestServerData, mpModuleDisabled, /* refreshTimerSecs, */ playtimeStat, MPChannels} from '../modules/MPModule.js';
|
||||||
|
|
||||||
async function fetchData(client:TClient, interaction:Discord.ChatInputCommandInteraction, serverName:string):Promise<FSData|Discord.InteractionResponse> {
|
async function fetchData(client:TClient, interaction:Discord.ChatInputCommandInteraction, serverName:string):Promise<FSData|Discord.InteractionResponse> {
|
||||||
try {
|
try {
|
||||||
@ -31,7 +31,7 @@ export default class MP {
|
|||||||
}
|
}
|
||||||
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.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 (client.uptime < refreshTimerSecs) return interaction.reply('MPModule isn\'t initialized yet, please wait a moment and try again.');
|
||||||
if ([MPChannels.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 <#${MPChannels.activePlayers}> for \`/mp status/players\` commands to prevent clutter in this channel.`).then(()=>setTimeout(()=>interaction.deleteReply(), 6000));
|
if ([MPChannels.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 <#${MPChannels.activePlayers}> for \`/mp status/players\` commands to prevent clutter in this channel.`).then(()=>setTimeout(()=>interaction.deleteReply(), 6000));
|
||||||
const choiceSelector = interaction.options.getString('server');
|
const choiceSelector = interaction.options.getString('server');
|
||||||
({
|
({
|
||||||
@ -157,20 +157,34 @@ 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 = 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) 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, '')),
|
map_names: msg.embeds[0].description.split('\n').map(x=>x.slice(3).replace(/\*\*/g, '').trim()),
|
||||||
votes: msg.reactions.cache.map(x=>x.count)
|
votes: filterByDigits.map(x=>x.count)
|
||||||
}, null, 2)), {name: `pollResults-${msg.id}.json`})
|
}, 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}>`)
|
await interaction.reply(`Successfully ended the [poll](<https://discord.com/channels/${interaction.guildId}/${MPChannels.announcements}/${msg.id}>) in <#${MPChannels.announcements}>`)
|
||||||
},
|
},
|
||||||
maps: async()=>{
|
maps: async()=>{
|
||||||
|
Loading…
Reference in New Issue
Block a user