discord-motto
Version:
Welcome to Discord Motto, a simple and easy to use package to set a server motto.
54 lines (49 loc) • 1.37 kB
JavaScript
const db = require('./handler');
/**
* Gets the motto with the specified guild ID or returns `null` if none has been set. Set using the `.setMotto()` method.
* @param {String} guildID
* @returns {String} String
*/
module.exports.getMotto = (guildID) => {
if (!guildID) {
return db.get('defaultMotto')
} else {
return db.get(`${guildID}`)
};
};
/**
* Sets the motto for the specified guild ID. Can then be retrieved with the `getMotto()` method.
* @param {String} motto
* @param {String} guildID
*/
module.exports.setMotto = (motto, guildID) => {
if (typeof motto !== 'string') {
throw new TypeError('Motto must be of type string')
}
if (!motto) {
throw new TypeError('You must speecify a value for the motto')
}
if (!guildID) {
return db.set('defaultMotto', motto)
} else {
return db.set(`${guildID}`, motto)
}
};
/**
* Get an array with every server and its corresponding motto.
* @returns {Array} Array
*/
module.exports.getMottos = () => {
return db.all();
};
/**
* Removes the prefix for the specified server.
* @param {String} guildID
*/
module.exports.removeMotto = (guildID) => {
if (!guildID) {
return db.delete('defaultMotto')
} else {
return db.delete(guildID)
};
};