commands.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. 'use strict'
  2. const subMod = require('./require')
  3. module.exports = function SPCommands(mod) {
  4. const ping = subMod(mod, './ping'),
  5. debug = subMod(mod, './debug')
  6. mod.command.add('sp', {
  7. $default() { message(`Unknown command "${this}".`) },
  8. $none: printHelp,
  9. help: printHelp,
  10. ping: printPing,
  11. debug(type = '') {
  12. switch(type.toLowerCase()) {
  13. case 'loc': case 'location':
  14. message(`Location debug ${(mod.settings.debug.loc = !mod.settings.debug.loc) ? 'enabled' : 'disabled'}.`)
  15. debug.reload()
  16. break
  17. case 'abnormal': case 'abnormals': case 'abnormality': case 'abnormalities':
  18. message(`Abnormality debug ${(mod.settings.debug.abnormals = !mod.settings.debug.abnormals) ? 'enabled' : 'disabled'}.`)
  19. debug.reload()
  20. break
  21. default:
  22. message(`Skill debug ${(mod.settings.debug.skills = !mod.settings.debug.skills) ? 'enabled' : 'disabled'}.`)
  23. debug.reload()
  24. break
  25. }
  26. },
  27. info: printRTFM,
  28. strictdef: printRTFM,
  29. mount: printRTFM,
  30. off: printRTFM,
  31. on: printRTFM,
  32. config: printRTFM,
  33. debugloc: printRTFM,
  34. debugabnorm: printRTFM
  35. })
  36. function printHelp() {
  37. message(`Commands:
  38. <FONT COLOR="#FFFFFF">ping</FONT> = Display ping statistics.
  39. <FONT COLOR="#FFFFFF">debug [skill|loc|abnormal]</FONT> = Toggle debug modes.`)
  40. }
  41. function printPing() {
  42. mod.command.message(`Ping: ${ping.history.length ? `Avg=${Math.round(ping.avg)} Min=${ping.min} Max=${ping.max} Spread=${ping.max - ping.min} Samples=${ping.history.length}` : '???'}`)
  43. }
  44. function message(msg) { mod.command.message(`${msg}`) }
  45. function printRTFM(msg) {
  46. message(`SaltyMonkey's public Skill-Prediction fork has been discontinued.
  47. You are now using Pinkie Pie's SP which doesn't support the command you tried.
  48. For feedback please contact Pinkie Pie on Discord.`)
  49. }
  50. }