1
0
mirror of https://github.com/toast-ts/Daggerbot-TS.git synced 2024-11-17 16:30:58 -05:00
Daggerbot-TS/src/commands/mp.ts

94 lines
3.8 KiB
TypeScript
Raw Normal View History

2023-05-23 01:14:17 -04:00
import Discord from 'discord.js';
2023-04-14 06:47:58 -04:00
import TClient from '../client.js';
2023-01-02 07:08:59 -05:00
import path from 'node:path';
2023-02-13 02:37:23 -05:00
import canvas from 'canvas';
2023-05-23 01:14:17 -04:00
import {readFileSync} from 'node:fs';
2022-11-18 11:56:18 -05:00
export default {
2023-03-05 05:04:10 -05:00
run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
2023-08-15 06:47:31 -04:00
async function hitEndpoint(){
const array = (await client.MPServer?._content.find())?.map(x=>x._id).filter(c=>['mainServer','secondServer'].includes(c));
console.log(array?.map(c=>c));
/* const database = {
mainServer: (await client.MPServer._content.findById(interaction.guildId)).mainServer,
secondServer: (await client.MPServer._content.findById(interaction.guildId)).secondServer
}
const endpoint = '/feed/dedicated-server-stats.json?code=';
if (serverSelector === 'mainServer') return database.mainServer.ip+endpoint+database.mainServer.code;
else if (serverSelector === 'secondServer') return database.secondServer.ip+endpoint+database.secondServer.code;
const Server = await client.axios.get(serverSelector, {
timeout: 7500,
headers: {'User-Agent':`Daggerbot - mp cmd/axios ${client.axios.VERSION}`}
}) */
}
if (interaction.channelId === '468835769092669461' && !client.isStaff(interaction.member) && ['status', 'players'].includes(interaction.options.getSubcommand())) {
interaction.reply(`Please use <#739084625862852715> for \`/mp status/players\` commands to prevent clutter in this channel.`).then(()=>setTimeout(()=>interaction.deleteReply(), 6000));
2023-03-05 05:04:10 -05:00
return;
}
({
status: async()=>{
2023-08-15 06:47:31 -04:00
hitEndpoint()
interaction.reply('x')
2023-06-05 10:39:06 -04:00
},
2023-08-15 06:47:31 -04:00
info: async()=>{},
url: async()=>{},
players: async()=>{}
2023-03-05 05:04:10 -05:00
} as any)[interaction.options.getSubcommand()]();
},
2023-05-23 01:14:17 -04:00
data: new Discord.SlashCommandBuilder()
2023-08-15 06:47:31 -04:00
.setName('mp')
.setDescription('Display MP status and other things')
.addSubcommand(x=>x
.setName('status')
.setDescription('Check server status and details')
.addStringOption(x=>x
.setName('server')
.setDescription('Which server to pull info from')
.setChoices(
{name: 'Main Server', value: 'mainServer'},
{name: 'Second Server', value: 'secondServer'})
.setRequired(true)))
.addSubcommand(x=>x
.setName('players')
.setDescription('Check who\'s playing on the server')
.addStringOption(x=>x
.setName('server')
.setDescription('Which server to pull the info from')
.setChoices(
{name: 'Main Server', value: 'mainServer'},
{name: 'Second Server', value: 'secondServer'})
.setRequired(true)))
.addSubcommand(x=>x
.setName('info')
.setDescription('Provides you with server information such as filters and so on')
.addStringOption(x=>x
.setName('server')
.setDescription('Which server to pull the info from')
.setChoices(
{name: 'Main Server', value: 'mainServer'},
{name: 'Second Server', value: 'secondServer'})
.setRequired(true)))
.addSubcommand(x=>x
.setName('url')
.setDescription('View the URL for this server\'s FSMP server or update the URL')
.addStringOption(x=>x
.setName('server')
.setDescription('Which server to view/update the URL')
.setChoices(
{name: 'Main Server', value: 'mainServer'},
{name: 'Second Server', value: 'secondServer'})
.setRequired(true))
.addStringOption(x=>x
.setName('address')
.setDescription('Insert a \'dedicated-server-stats\' URL')))
.addSubcommand(x=>x
.setName('maintenance')
.setDescription('Lock/unlock "#mp-active-players" channel when server is unavailable to the public')
.addStringOption(x=>x
.setName('message')
.setDescription('The reason why is the server unavailable for?')
.setRequired(true)))
2023-01-22 13:14:38 -05:00
}