Advertisement
Nimbi

commands/mc.ts

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