v3.3.3: Paged Commands #20

Merged
voidf1sh merged 15 commits from v3.3.3 into main 2024-09-26 13:24:55 +00:00
2 changed files with 29 additions and 13 deletions
Showing only changes of commit 00df6074d6 - Show all commits

View File

@ -3,18 +3,32 @@ module.exports = {
constructor(message) { constructor(message) {
// Get the location of the final period in the message // Get the location of the final period in the message
this.finalPeriod = message.content.lastIndexOf('.'); this.finalPeriod = message.content.lastIndexOf('.');
this.isCommand = finalPeriod >= 0 ? true : false; // Check if there is a period somewhere in the message to flag as a possible command this.isCommand = this.finalPeriod >= 0 ? true : false; // Check if there is a period somewhere in the message to flag as a possible command
this.args = message.content.slice(0,finalPeriod).toLowerCase(); // Grab everything leading up to the final period this.isValid = false;
this.command = message.content.slice(finalPeriod + 1).toLowerCase(); // Grab everything after the final period this.args = message.content.slice(0,this.finalPeriod).toLowerCase(); // Grab everything leading up to the final period
this.command = message.content.slice(this.finalPeriod + 1).toLowerCase(); // Grab everything after the final period
this.author = message.author.username; this.author = message.author.username;
return this; return this;
} }
isValid(validCommands) { validate(dotCommands) {
if (this.args.startsWith('http')) return false; if (this.args.startsWith('http')) return false;
if (this.args.startsWith('www')) return false; if (this.args.startsWith('www')) return false;
return validCommands.includes(this.command);
for (const [key, value] of dotCommands) {
if (key === this.command) {
this.isValid = true;
return this.isValid;
} else if (value.alias && value.alias.includes(this.command)) {
this.command = key;
this.isValid = true;
return this.isValid;
}
}
this.isValid = validCommands.includes(this.command);
return this.isValid;
} }
}, },
GifData: class { GifData: class {

View File

@ -82,13 +82,13 @@ const functions = {
for (const file of dotCommandFiles) { for (const file of dotCommandFiles) {
const dotCommand = require(`./dot-commands/${file}`); const dotCommand = require(`./dot-commands/${file}`);
client.dotCommands.set(dotCommand.name, dotCommand); client.dotCommands.set(dotCommand.name, dotCommand);
if (Array.isArray(dotCommand.alias)) { // if (Array.isArray(dotCommand.alias)) {
dotCommand.alias.forEach(element => { // dotCommand.alias.forEach(element => {
client.dotCommands.set(element, dotCommand); // client.dotCommands.set(element, dotCommand);
}); // });
} else if (dotCommand.alias != undefined) { // } else if (dotCommand.alias != undefined) {
client.dotCommands.set(dotCommand.alias, dotCommand); // client.dotCommands.set(dotCommand.alias, dotCommand);
} // }
} }
if (isDev) console.log('Dot Commands Collection Built'); if (isDev) console.log('Dot Commands Collection Built');
}, },
@ -174,7 +174,9 @@ const functions = {
dot: { dot: {
getCommandData(message) { getCommandData(message) {
const commandData = new CommandData(message); const commandData = new CommandData(message);
return commandData.isValid(require('./config.json').validCommands); const { validCommands } = require('./config.json');
commandData.validate(message.client.dotCommands);
return commandData;
} }
}, },
embeds: { embeds: {