1
0

link.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. const check_wiki = {
  2. fandom: require('./wiki/fandom.js'),
  3. gamepedia: require('./wiki/gamepedia.js'),
  4. test: require('./test.js').run
  5. };
  6. const help_setup = require('../functions/helpsetup.js');
  7. /**
  8. * Processes the wiki linking command.
  9. * @param {import('../util/i18n.js')} lang - The user language.
  10. * @param {import('discord.js').Message} msg - The Discord message.
  11. * @param {String} title - The page title.
  12. * @param {String} wiki - The wiki for the page.
  13. * @param {String} [cmd] - The command at this point.
  14. */
  15. function cmd_link(lang, msg, title, wiki, cmd = '') {
  16. if ( msg.isAdmin() && msg.defaultSettings ) help_setup(lang, msg);
  17. if ( /^\|\|(?:(?!\|\|).)+\|\|$/.test(title) ) {
  18. title = title.substring( 2, title.length - 2);
  19. var spoiler = '||';
  20. }
  21. msg.reactEmoji('⏳').then( reaction => {
  22. if ( wiki.isFandom() ) check_wiki.fandom(lang, msg, title, wiki, cmd, reaction, spoiler);
  23. else check_wiki.gamepedia(lang, msg, title, wiki, cmd, reaction, spoiler);
  24. } );
  25. }
  26. module.exports = {
  27. name: 'LINK',
  28. everyone: true,
  29. pause: false,
  30. owner: true,
  31. run: cmd_link
  32. };