Advertisement
DudeThatsErin

message.js

Jan 12th, 2021
1,086
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const BaseEvent = require('../BaseEvent.js');
  2. const guildCommandPrefixes = new Map();
  3. const StateManager = require('../StateManager.js');
  4.  
  5. module.exports = class MessageEvent extends BaseEvent {
  6.     constructor() {
  7.         super('message');
  8.     }
  9.  
  10.     async run(client, message) {
  11.         console.log(guildCommandPrefixes);
  12. /*if (message.author.bot) return;
  13. const prefix = guildCommandPrefixes.get(message.guild.id);
  14. const usedPrefix = message.content.slice(0, prefix.length);
  15.  
  16. if (prefix === usedPrefix) {
  17.     const [cmdName, ...cmdArgs] = message.content.slice(prefix.length).split(/\s+/);
  18. }
  19. if(message.content.toLowerCase().startsWith(prefix + 'test')) {
  20.     message.channel.send(`You triggered this comamnd with prefix: ${prefix}`);
  21. }
  22. else if(message.content.toLowerCase().startsWith(prefix + 'changeprefix')) {
  23.     if(message.member.id === message.guild.ownerID) {
  24.         const [cmdName, newPrefix] = message.content.split(" ");
  25.         if(newPrefix) {
  26.             try {
  27.                 await connection.query(
  28.                     `UPDATE GuildSetup SET cmdPrefix = '${newPrefix}' WHERE guildId = '${message.guild.id}'`
  29.                 );
  30.                 guildCommandPrefixes.set(message.guild.id, newPrefix);
  31.                 message.channel.send(`Updated guild prefix to ${newPrefix}`);
  32.             } catch(err) {
  33.                 console.log(err);
  34.                 message.channel.send(`Failed to update guild prefix to ${newPrefix}`);
  35.             }
  36.         } else {
  37.             message.channel.send(`Incorrect amount of arguments.`);
  38.         }
  39.     } else {
  40.         message.channel.send(`❌ You do not have permission to use this command. You must be the guild owner to use this command.`);
  41.     }
  42.     }*/
  43. }
  44. }
  45.  
  46. StateManager.on('prefixFetched', (guildId, prefix) => {
  47.     guildCommandPrefixes.set(guildId, prefix);
  48. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement