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

Commit

Permalink
Release 1.1.0
Browse files Browse the repository at this point in the history
- Fixed the last of the cache bugs
- Updated the Discord.js package for the latest stable release (12.0.1)
- Updated AniList-Node package and AniList command for statistics.
- Added a check for queue lengths in the queue command
  • Loading branch information
AurelicButter committed Mar 2, 2020
1 parent bbc5cf5 commit adacaa7
Show file tree
Hide file tree
Showing 14 changed files with 490 additions and 74 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# MargarineBot - Version: Release 1.0.2
# MargarineBot - Version: Release 1.1.0
![License](https://img.shields.io/github/license/Butterstroke/MargarineBot.svg?style=flat-square) ![Support Server](https://discordapp.com/api/guilds/303253034551476225/widget.png)

<b>Dependencies</b>
Expand Down
5 changes: 2 additions & 3 deletions assets/settingsExample.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{
"token": "Token Key",
"ownerID": "User ID",
"prefix": "Prefix",
"build": {
"version": "Release 1.0.2",
"releaseDate": "February 22nd, 2020"
"version": "Release 1.1.0",
"releaseDate": "March 1st, 2020"
},
"owner": {
"channels": {
Expand Down
14 changes: 10 additions & 4 deletions assets/speech/en-CA/music.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,16 @@ exports.play = {
] //Next song playing
};

exports.queue = [ //Parameter 1: Page count
"I can't show you that page for its page number is greater than my queue pages. There are currently -pgs",
"Your number is higher than -pgs. So, there is nothing to see there."
];
exports.queue = {
"noList": [
"You don't have anything in your queue at the moment. Add some with the queueadd command.",
"There's nothing here. You should add some songs with queueadd!"
],
"highCount": [
"I can't show you that page for its page number is greater than my queue pages. There are currently -pgs",
"Your number is higher than -pgs. So, there is nothing to see there."
]
};

exports.queueadd = {
"noURL": [
Expand Down
32 changes: 23 additions & 9 deletions commands/General/anilist.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +46,38 @@ module.exports = class extends Command {
}

var data = await anilist.user.all(username);

if (data.status === 404) { return msg.channel.send(this.client.speech(msg, ["anilist", "404Err"])); }
var anime = data.stats.animeStatusDistribution,
manga = data.stats.mangaStatusDistribution;

var animeL = [`💚 Watching: ${anime[0].amount}`, `🗓 Planned: ${anime[1].amount}`, `💙 Completed: ${anime[2].amount}`, `💔 Dropped: ${anime[3].amount}`, `💛 Paused: ${anime[4].amount}`];
var mangaL = [`📗 Reading: ${manga[0].amount}`, `🗓 Planned: ${manga[1].amount}`, `📘 Completed: ${manga[2].amount}`, `📕 Dropped: ${manga[3].amount}`, `📙 Paused: ${manga[4].amount}`];

const embed = new MessageEmbed()
.setTitle(`${username}'s AniList Profile`)
.setURL(data.siteUrl)
.setDescription(`🕓 Watch Days: ${Number(data.stats.watchedTime / 60 / 24).toFixed(1)}\n🔖 Manga Chapters: ${data.stats.chaptersRead}`)
.addField("__Anime:__", `📊 Mean Score: ${data.stats.animeListScores.meanScore}\n${animeL.join("\n")}`, true)
.addField("__Manga:__", `📊 Mean Score: ${data.stats.mangaListScores.meanScore}\n${mangaL.join("\n")}`, true)
.setTimestamp()
.setColor(0x2E51A2)
.setThumbnail(data.avatar.large)
.setFooter(`Requested by: ${msg.author.tag}`);

var animeStat = data.statistics.anime,
mangaStat = data.statistics.manga;

var anime = { "CURRENT": 0, "PLANNING": 0, "COMPLETED": 0, "DROPPED": 0, "PAUSED": 0 },
manga = { "CURRENT": 0, "PLANNING": 0, "COMPLETED": 0, "DROPPED": 0, "PAUSED": 0 };

animeStat.statuses.forEach((e) => {
if (e.status !== "REPEATING" || e.status !== "COMPLETED") { anime[e.status] = e.count; }
else { anime["COMPLETED"] += e.count; }
});

mangaStat.statuses.forEach((e) => {
if (e.status !== "REPEATING" || e.status !== "COMPLETED") { manga[e.status] = e.count; }
else { manga["COMPLETED"] += e.count; }
});

var animeL = [`💚 Watching: ${anime.CURRENT}`, `🗓 Planned: ${anime.PLANNING}`, `💙 Completed: ${anime.COMPLETED}`, `💔 Dropped: ${anime.DROPPED}`, `💛 Paused: ${anime.PAUSED}`];
var mangaL = [`📗 Reading: ${manga.CURRENT}`, `🗓 Planned: ${manga.PLANNING}`, `📘 Completed: ${manga.COMPLETED}`, `📕 Dropped: ${manga.DROPPED}`, `📙 Paused: ${manga.PAUSED}`];

embed.setDescription(`🕓 Watch Days: ${Number(data.statistics.anime.minutesWatched / 60 / 24).toFixed(1)}\n🔖 Manga Chapters: ${data.statistics.manga.chaptersRead}`)
.addField("__Anime:__", `📊 Mean Score: ${data.statistics.anime.meanScore}\n${animeL.join("\n")}`, true)
.addField("__Manga:__", `📊 Mean Score: ${data.statistics.manga.meanScore}\n${mangaL.join("\n")}`, true);

msg.channel.send({embed});
}
Expand Down
2 changes: 1 addition & 1 deletion commands/Mod/ban.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, [user, reason]) {
if (user === null) { return; }
user = msg.guild.members.get(user.id);
user = msg.guild.members.cache.get(user.id);
if (user.bannable === false) { return msg.reply("I cannot ban that member"); }

var data = this.client.util.modEmbed(msg, "ban", user, reason);
Expand Down
2 changes: 1 addition & 1 deletion commands/Mod/kick.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = class extends Command {

async run(msg, [user, reason]) {
if (user === null) { return; }
user = msg.guild.members.get(user.id);
user = msg.guild.members.cache.get(user.id);
if (user.kickable === false) { return msg.reply("I cannot kick that member"); }

var data = this.client.util.modEmbed(msg, "kick", user, reason);
Expand Down
14 changes: 7 additions & 7 deletions commands/Mod/mute.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ module.exports = class extends Command {
});
}

async run(msg, [user, reason]) {
async run(msg, [user, reason="No reason given."]) {
if (user === null) { return; }
if (msg.guild.settings.muteRole === null) { return msg.channel.send(this.client.speech(msg, ["mute", "noRole"])); }
user = msg.guild.members.get(user.id);
user = msg.guild.members.cache.get(user.id);

var role = msg.guild.roles.get(msg.guild.settings.muteRole);
if (role.position > msg.guild.members.get(this.client.user.id).roles.highest.position) { return msg.channel.send(this.client.speech(msg, ["mute", "rolePos"])); }
var role = msg.guild.roles.cache.get(msg.guild.settings.muteRole);
if (role.position > msg.guild.members.cache.get(this.client.user.id).roles.highest.position) { return msg.channel.send(this.client.speech(msg, ["mute", "rolePos"])); }

if (msg.channel.permissionsFor(user).has("ADMINISTRATOR")) { //Admins can talk regardless. Send message to warn that it will not work.
msg.channel.send(this.client.speech(msg, ["mute", "admin"]));
}

if (user.roles.has(role.id)) {
if (user.roles.cache.get(role.id)) {
var data = this.client.util.modEmbed(msg, "unmute", user, reason);
user.roles.remove(role.id);
user.roles.remove(role.id, `Automated Action - Moderator: ${msg.author.username} | ${reason}`);

//Send embeds to logs and target user.
user.send({embed: data.DMembed});
Expand All @@ -38,7 +38,7 @@ module.exports = class extends Command {
}

var data = this.client.util.modEmbed(msg, "mute", user, reason);
user.roles.add(role.id);
user.roles.add(role.id, `Automated Action - Moderator: ${msg.author.username} | ${reason}`);

//Send embeds to logs and target user.
user.send({embed: data.DMembed});
Expand Down
2 changes: 1 addition & 1 deletion commands/Music/join.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = class extends Command {
var check = this.client.util.musicCheck(msg, "join");
if (check === false) { return; }

var vcID = msg.guild.channels.get(msg.member.voice.channelID);
var vcID = msg.guild.channels.cache.get(msg.member.voice.channelID);
const permissions = vcID.permissionsFor(msg.guild.me);
if (permissions.has("CONNECT") === false) { return msg.channel.send(this.client.speech(msg, ["join", "noConnect"])); }
if (permissions.has("SPEAK") === false) { return msg.channel.send(this.client.speech(msg, ["join", "noSpeak"])); }
Expand Down
3 changes: 2 additions & 1 deletion commands/Music/queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ module.exports = class extends Command {
async run(msg, [page=1]) {
const handler = this.client.music.get(msg.guild.id);
if (!handler) { throw this.client.speech(msg, ["func-music", "general", "noQueue"]); }
if (handler.queue.length < 1) { throw this.client.speech(msg, ["queue", "noList"]); }

if (page.length < 1 || page === 1) { page = 1; var count = 0; }
else { var count = (10 * (page - 1)); }

if (handler.queue.length < count) { return this.client.speech(msg, ["queue"], [Math.ceil(handler.queue.length / 10)]); }
if (handler.queue.length < count) { return this.client.speech(msg, ["queue", "highCount"], [Math.ceil(handler.queue.length / 10)]); }

const embed = new MessageEmbed()
.setColor(0x04d5fd)
Expand Down
2 changes: 1 addition & 1 deletion commands/System/permlevel.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports = class extends Command {
if (!guild) { permLevel = 0; }
else if (guild.owner.id === msg.author.id) { permLevel = 3; }
else if (author.permissions.has("ADMINISTRATOR")) { permLevel = 2; }
else if (author.roles.has(guild.settings.modRole)) { permLevel = 1; }
else if (author.roles.cache.has(guild.settings.modRole)) { permLevel = 1; }
else { permLevel = 0; }

var info = this.client.ownerSetting.get("permLevel").addPerms[permLevel];
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const client = new Client({
});

Client.defaultPermissionLevels
.add(5, ({ guild, member }) => guild && member.roles.has(guild.settings.modRole))
.add(5, ({ guild, member }) => guild && member.roles.cache.has(guild.settings.modRole))
.add(6, ({ guild, member }) => guild && member.permissions.has("ADMINISTRATOR"))
.add(9, ({ author, client }) => author === client.owner || author.id === config.secondary)
.add(10, ({ author, client }) => author === client.owner);
Expand Down
Loading

0 comments on commit adacaa7

Please sign in to comment.