Source

commands/a_utility/change-pre-fix.js

  1. const { Message } = require('discord.js');
  2. const PermissionCommand = require('../../classes/permission-command');
  3. const BotGuildModel = require('../../classes/bot-guild');
  4. const { StringPrompt } = require('advanced-discord.js-prompts');
  5. /**
  6. * Gives admin the ability to change the prefix used in the guild by the bot.
  7. */
  8. class ChangePreFix extends PermissionCommand {
  9. constructor(client) {
  10. super(client, {
  11. name: 'change-prefix',
  12. group: 'a_utility',
  13. memberName: 'change guild prefix',
  14. description: 'Change the prefix used in this guild by the bot.',
  15. guildOnly: true,
  16. }, {
  17. role: PermissionCommand.FLAGS.STAFF_ROLE,
  18. });
  19. }
  20. /**
  21. * @param {BotGuildModel} botGuild
  22. * @param {Message} message
  23. */
  24. async runCommand(botGuild, message) {
  25. let options = ['!', '#', '$', '%', '&', '?', '|', '°'];
  26. let prefix = StringPrompt.restricted({ prompt: 'What would you like to use as the prefix?', channel: message.channel, userId: message.author.id }, options);
  27. botGuild.prefix = prefix;
  28. botGuild.save();
  29. message.guild.commandPrefix = prefix;
  30. }
  31. }
  32. module.exports = ChangePreFix;