2023-08-08 17:25:07 +00:00
|
|
|
module.exports = {
|
2024-09-25 15:54:33 +00:00
|
|
|
CommandData: class {
|
|
|
|
constructor(message) {
|
|
|
|
// Get the location of the final period in the message
|
|
|
|
this.finalPeriod = message.content.lastIndexOf('.');
|
2024-09-25 19:30:51 +00:00
|
|
|
this.isCommand = this.finalPeriod >= 0 ? true : false; // Check if there is a period somewhere in the message to flag as a possible command
|
|
|
|
this.isValid = false;
|
|
|
|
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
|
2024-09-25 15:54:33 +00:00
|
|
|
this.author = message.author.username;
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2024-09-25 19:30:51 +00:00
|
|
|
validate(dotCommands) {
|
2024-09-25 15:54:33 +00:00
|
|
|
if (this.args.startsWith('http')) return false;
|
|
|
|
if (this.args.startsWith('www')) return false;
|
2024-09-25 19:30:51 +00:00
|
|
|
|
|
|
|
for (const [key, value] of dotCommands) {
|
|
|
|
if (key === this.command) {
|
|
|
|
this.isValid = true;
|
2024-09-25 19:35:01 +00:00
|
|
|
return this;
|
2024-09-25 19:30:51 +00:00
|
|
|
} else if (value.alias && value.alias.includes(this.command)) {
|
|
|
|
this.command = key;
|
|
|
|
this.isValid = true;
|
2024-09-25 19:35:01 +00:00
|
|
|
return this;
|
2024-09-25 19:30:51 +00:00
|
|
|
}
|
|
|
|
}
|
2024-09-25 19:35:01 +00:00
|
|
|
return this;
|
2024-09-25 15:54:33 +00:00
|
|
|
}
|
|
|
|
},
|
2023-08-08 17:25:07 +00:00
|
|
|
GifData: class {
|
|
|
|
constructor() {
|
2023-08-08 18:34:46 +00:00
|
|
|
this.id = 0;
|
|
|
|
this.name = "";
|
|
|
|
this.url = "";
|
2023-08-08 17:25:07 +00:00
|
|
|
}
|
|
|
|
|
2023-08-08 18:34:46 +00:00
|
|
|
// Initial GifData configuration
|
|
|
|
// Can also be used to update the data piecemeal
|
|
|
|
setInfo(name, url, id) {
|
|
|
|
// Check for existing or incoming name
|
|
|
|
if ((this.name === "") && (typeof name !== 'string')) throw `Error: This Gif doesn't have existing name, and no name is going to be set.`;
|
|
|
|
// Check for existing content or incoming content
|
|
|
|
if ((this.url === "") && (typeof url !== 'string')) throw `Error: This Gif doesn't have existing url, and no url is going to be set.`;
|
|
|
|
|
|
|
|
// Property is set if the variable is the right type,
|
|
|
|
// otherwise it keeps the existing property
|
|
|
|
this.id = typeof id === 'number' ? id : this.id;
|
|
|
|
this.name = typeof name === 'string' ? name : this.name;
|
|
|
|
this.url = typeof url === 'string' ? url : this.url;
|
|
|
|
|
|
|
|
return this; // For chaining
|
|
|
|
}
|
|
|
|
},
|
|
|
|
PastaData: class {
|
|
|
|
constructor() {
|
|
|
|
this.id = 0;
|
|
|
|
this.name = "";
|
|
|
|
this.content = "";
|
|
|
|
this.iconUrl = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
// Initial PastaData configuration
|
|
|
|
// Can also be used to update the data piecemeal
|
|
|
|
setInfo(name, content, iconUrl, id) {
|
|
|
|
// Check for existing or incoming name
|
|
|
|
if ((this.name === "") && (typeof name !== 'string')) throw `Error: This Pasta doesn't have existing name, and no name is going to be set.`;
|
|
|
|
// Check for existing content or incoming content
|
|
|
|
if ((this.content === "") && (typeof content !== 'string')) throw `Error: This Pasta doesn't have existing content, and no content is going to be set.`;
|
|
|
|
|
|
|
|
// Property is set if the variable is the right type,
|
|
|
|
// otherwise it keeps the existing property
|
|
|
|
this.id = typeof id === 'number' ? id : this.id;
|
|
|
|
this.name = typeof name === 'string' ? name : this.name;
|
|
|
|
this.content = typeof content === 'string' ? content : this.content;
|
|
|
|
this.iconUrl = typeof iconUrl === 'string' ? iconUrl : this.iconUrl;
|
|
|
|
|
|
|
|
return this; // For chaining
|
2023-08-08 17:25:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|