Skip to content
This repository has been archived by the owner on Jan 4, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
AurelicButter committed Jul 21, 2020
2 parents 821bae7 + 5fa80ef commit 9e23a3d
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 11 deletions.
6 changes: 5 additions & 1 deletion assets/speech/en-CA/system.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,5 +146,9 @@ module.exports = {
"-name is a required argument. You can't leave it blank!",
"You need to give me a value for -name! It is required for this command!"
]
}
},
"guarded": [
"You cannot disable -name! It's one of the essential commands I provide.",
"Disabling -name is a no. You'd break my services to your guild that way."
]
};
2 changes: 1 addition & 1 deletion commands/Fun/Polling/createPoll.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = class extends Command {
async run(msg, [title, desc, ...option]) {
if (!title) { return msg.sendLocale("POLL_NOTITLE", [msg]); }
if (!desc) { return msg.sendLocale("POLL_NODESC", [msg]); }
if (option.length < 2) { return msg.sendLocale("POLL_NOOPTION", [msg]); }
if (option.length < 2) { return msg.sendLocale("POLL_NOOPTIONS", [msg]); }

if (msg.guild.settings.poll.info) { return msg.sendLocale("POLL_NOCREATE", [msg]); }

Expand Down
2 changes: 1 addition & 1 deletion commands/General/anime.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module.exports = class extends Command {
if (data.title.english) { title = `${title} | ${data.title.english}`; }

var desc = `[Anilist](${data.siteUrl}) | [MyAnimeList](https://myanimelist.net/anime/${data.idMal})\n\n**Format:** `;
var time = `${this.client.util.toTitleCase(data.season)} ${data.startDate.year}`;
var time = (data.season) ? `${this.client.util.toTitleCase(data.season)} ${data.startDate.year}` : "To be announced";

if (data.format === "TV_SHORT") { data.format = "TV Short"; }
if (data.format === "SPECIAL") { data.format = "Special"; }
Expand Down
2 changes: 1 addition & 1 deletion languages/en-CA.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ module.exports = class extends Language {
]),
RESOLVER_INVALID_CHANNEL: (name) => this.client.speech(falseMsg, ["func-system", "resolver", "channel"], [["-name", name]]),
RESOLVER_INVALID_INT: (name) => this.client.speech(falseMsg, ["func-system", "resolver", "integer"], [["-name", name]]),
COMMAND_CONF_GUARDED: (name) => this.client.speech(falseMsg, ["func-system", "guarded"], [["-name", util.toTitleCase(name)]]),

/*
* Klasa System. Copied over from Klasa's en-US.
Expand Down Expand Up @@ -143,7 +144,6 @@ module.exports = class extends Language {
COMMAND_DISABLE_WARN: 'You probably don\'t want to disable that, since you wouldn\'t be able to run any command to enable it again',
COMMAND_CONF_NOKEY: 'You must provide a key',
COMMAND_CONF_NOVALUE: 'You must provide a value',
COMMAND_CONF_GUARDED: (name) => `${util.toTitleCase(name)} may not be disabled.`,
COMMAND_CONF_UPDATED: (key, response) => `Successfully updated the key **${key}**: \`${response}\``,
COMMAND_CONF_KEY_NOT_ARRAY: 'This key is not array type. Use the action \'reset\' instead.',
COMMAND_CONF_GET_NOEXT: (key) => `The key **${key}** does not seem to exist.`,
Expand Down
37 changes: 30 additions & 7 deletions utilities/presenceHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,26 @@ function Presence(client, type, name, status) {
client.user.setPresence({ activity: { name, type }, status });
}

/**
* Gets a random pre-defined status. If previous status is provide, function will
* determine a new and different status to display.
* @param {String} previous - The previous status of the bot.
* @returns {String[]} The status message and determined type.
*/
function determineStatus(previous) {
var items;
if (previous) {
do {
items = games[Math.floor(Math.random() * games.length)];
} while (items[0] === previous);
return items;
}

items = games[Math.floor(Math.random() * games.length)];

return items;
}

/**
* Sets the presence for Margarine and starts a 15 minute interval for automatic change
* @param { KlasaClient } client - Needed to grab the user and additional functions.
Expand All @@ -17,16 +37,19 @@ function Presence(client, type, name, status) {
*/
module.exports = (client, name, type=0, status="online") => { //Type defaulted to play and status defaulted to online.
const sliceCheck = `${client.globalPrefix}help |`.length;
var newStatus = null;

if (name === "-start" || name === "-reset") {
var items = games[Math.floor(Math.random() * games.length)]; //For random status upon startup
Presence(client, items[1], items[0], "online");
if (name === "-start" || name === "-reset" || name === null) {
newStatus = determineStatus();
Presence(client, newStatus[1], newStatus[0], "online");
client.timer = setInterval(function() {
do { //No duplicate statuses, Margarine. K thx.
var items = games[Math.floor(Math.random() * games.length)];
} while (client.user.presence.activities[0].name !== null && items[0] === client.user.presence.activities[0].name.slice(sliceCheck));
var presenceStatus = null;
if (client.user.presence.activities[0].name !== null) {
presenceStatus = client.user.presence.activities[0].name.slice(sliceCheck);
}

Presence(client, items[1], items[0], status);
newStatus = determineStatus(presenceStatus);
Presence(client, newStatus[1], newStatus[0], status);
}, 900000);
} else {
Presence(client, type, name, status);
Expand Down

0 comments on commit 9e23a3d

Please sign in to comment.