Nimbi

mc.ts

Nov 15th, 2020 (edited)
322
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { config } from '../../modules/config/cfg';
  2.  
  3. config.commands.handler.subcommand(
  4.   {
  5.     name: 'mc'
  6.   },
  7.   (subcmd) => {
  8.     subcmd.on(
  9.       {
  10.         name: 'status',
  11.         description: 'Check the current status of a Minecraft server.',
  12.         filters: config.modules.permissions.user
  13.       },
  14.       (args) => ({
  15.         input: args.text()
  16.       }),
  17.       async (message, { text }) => {
  18.         const res = await fetch(`https://api.mcsrvstat.us/2/${text}`);
  19.  
  20.         const data = await res.text();
  21.         if (
  22.           !config.modules.util.enabled &&
  23.           !config.modules.util.commands.mc.enabled
  24.         )
  25.           return;
  26.         await message.reply('Response:```json\n' + data + '```');
  27.       }
  28.     );
  29.   }
  30. );
  31.  
  32.  
Add Comment
Please, Sign In to add comment