Skip to content
This repository was archived by the owner on Aug 14, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
188 changes: 105 additions & 83 deletions commands/help.js
Original file line number Diff line number Diff line change
@@ -1,100 +1,122 @@
const { Command } = require('discord-akairo');
const { version } = require('../package.json')
const { Command } = require("discord-akairo");
const { version } = require("../package.json");

class HelpCommand extends Command {
constructor() {
super('help', {
aliases: ['help', 'halp', 'h'],
category: 'general',
clientPermissions: ['EMBED_LINKS'],
args: [
{
id: 'command',
type: 'commandAlias',
prompt: {
start: 'Which command do you need help with?',
retry: 'Please provide a valid command.',
optional: true
}
}
],
description: {
content: 'Displays a list of commands or information about a command.',
usage: '[command]',
examples: ['', 'star', 'remove-rep']
}
});
}
constructor() {
super("help", {
aliases: ["help", "halp", "h"],
category: "general",
clientPermissions: ["EMBED_LINKS"],
args: [
{
id: "command",
type: "commandAlias",
prompt: {
start: "Which command do you need help with?",
retry: "Please provide a valid command.",
optional: true,
},
},
],
description: {
content: "Displays a list of commands or information about a command.",
usage: "[command]",
examples: ["", "star", "remove-rep"],
},
});
}

exec(message, { command }) {
message.delete();
if (!command) return this.execCommandList(message);
exec(message, { command }) {
message.delete();
if (!command) return this.execCommandList(message);

const prefix = this.handler.prefix;
const description = Object.assign({
content: 'No description available.',
usage: '',
examples: [],
fields: []
}, command.description);
const prefix = this.handler.prefix;
const description = Object.assign(
{
content: "No description available.",
usage: "",
examples: [],
fields: [],
},
command.description
);

const embed = this.client.util.embed()
.setColor(0xFFAC33)
.setTitle(`\`${prefix}${command.aliases[0]} ${description.usage}\``)
.addField('Description', description.content);
const embed = this.client.util
.embed()
.setColor(0xffac33)
.setTitle(`\`${prefix}${command.aliases[0]} ${description.usage}\``)
.addField("Description", description.content);

for (const field of description.fields) embed.addField(field.name, field.value);
for (const field of description.fields)
embed.addField(field.name, field.value);

if (description.examples.length) {
const text = `${prefix}${command.aliases[0]}`;
embed.addField('Examples', `\`${text} ${description.examples.join(`\`\n\`${text} `)}\``, true);
}
if (description.examples.length) {
const text = `${prefix}${command.aliases[0]}`;
embed.addField(
"Examples",
`\`${text} ${description.examples.join(`\`\n\`${text} `)}\``,
true
);
}

if (command.aliases.length > 1) {
embed.addField('Aliases', `\`${command.aliases.join('` `')}\``, true);
}
if (command.aliases.length > 1) {
embed.addField("Aliases", `\`${command.aliases.join("` `")}\``, true);
}

return message.util.send({ embed });
}
return message.util.send({ embed });
}

async execCommandList(message) {
const embed = this.client.util.embed()
.setTitle("Panda Jr. **Help**")
.setFooter(`Panda Jr. v${version}`)
.setThumbnail('https://minecraft-mp.com/images/favicon/277055.png')
.setColor('#FF0033')
.addField('Command List',
[
'This is a list of commands.',
'To view details for a command, do `!!help <command>`.'
]);
async execCommandList(message) {
const embed = this.client.util
.embed()
.setTitle("Panda Jr. **Help**")
.setFooter(`Panda Jr. v${version}`)
.setThumbnail("https://minecraft-mp.com/images/favicon/277055.png")
.setColor("#FF0033")
.addField("Command List", [
"This is a list of commands.",
"To view details for a command, do `!!help <command>`.",
]);

for (const category of this.handler.categories.values()) {
const title = {
general: '📝\u2000General',
music: '🎵\u2000Music',
utility: ':briefcase:\u2000Utility',
minecraft: '🧱\u2000Minecraft'
}[category.id];
for (const category of this.handler.categories.values()) {
const title = {
general: "📝\u2000General",
music: "🎵\u2000Music",
utility: ":briefcase:\u2000Utility",
minecraft: "🧱\u2000Minecraft",
}[category.id];

if (title) embed.addField(title, `\`${category.map(cmd => cmd.aliases[0]).join('` `')}\``, true);
}
if (title)
embed.addField(
title,
`\`${category.map((cmd) => cmd.aliases[0]).join("` `")}\``,
true
);
}

const shouldReply = message.guild && message.channel.permissionsFor(this.client.user).has('SEND_MESSAGES');
const shouldReply =
message.guild &&
message.channel.permissionsFor(this.client.user).has("SEND_MESSAGES");

try {
await message.author.send({ embed });
if (shouldReply) return message.util.reply('I\'ve sent you a DM with the command list.').then(msg => {
msg.delete({ timeout: 10000 })
});
} catch (err) {
if (shouldReply) return message.util.reply('I could not send you the command list in DMs.').then(msg => {
msg.delete({ timeout: 10000 })
});
}
try {
await message.author.send({ embed });
if (shouldReply)
return message.util
.reply("I've sent you a DM with the command list.")
.then((msg) => {
msg.delete({ timeout: 10000 });
});
} catch (err) {
if (shouldReply)
return message.util
.reply("I could not send you the command list in DMs.")
.then((msg) => {
msg.delete({ timeout: 10000 });
});
}

return undefined;
}
return undefined;
}
}

module.exports = HelpCommand;
module.exports = HelpCommand;
133 changes: 65 additions & 68 deletions commands/hivemc.js
Original file line number Diff line number Diff line change
@@ -1,77 +1,74 @@
// HiveAPI
const hive = require('hive-api');
const { version } = require('../package.json');
const Discord = require('discord.js');
const hive = require("hive-api");
const { version } = require("../package.json");
const Discord = require("discord.js");

const { Command } = require('discord-akairo');
const { Command } = require("discord-akairo");

class HiveCommand extends Command {
constructor(){
super('hive', {
aliases: ['hivemc', 'hmc'],
category: 'minecraft',
description: {
content: "Get's your hive stats",
usage: '<player name>',
examples: ['TheCuddlyBear', 'TheDevilsRoses', 'MagixSpellz']
},
args: [{
id: 'playername',
}]
})
}

exec(message, { playername }){
let player = new hive.Player(playername);
constructor() {
super("hive", {
aliases: ["hivemc", "hmc"],
category: "minecraft",
description: {
content: "Get's your hive stats",
usage: "<player name>",
examples: ["TheCuddlyBear", "TheDevilsRoses", "MagixSpellz"],
},
args: [
{
id: "playername",
},
],
});
}

player.info().then(info => {
exec(message, { playername }) {
let player = new hive.Player(playername);

if (playername.endsWith('s')) {
var suffix = "'"
} else {
var suffix = "'s"
}
player
.info()
.then((info) => {
if (playername.endsWith("s")) {
var suffix = "'";
} else {
var suffix = "'s";
}

const statEmbed = new Discord.MessageEmbed()
.setColor('#FF0033')
.setTitle(playername + suffix + " HiveMC stats")
.setThumbnail('https://minotar.net/avatar/' + playername)
.setTimestamp()
.setFooter(`HiveMC Stats • Panda Jr. v${version}`)
.addFields({
name: 'Rank',
value: info.rank.humanName,
inline: true
}, {
name: 'Tokens',
value: info.tokens,
inline: true
}, {
name: 'Medals',
value: info.medals,
inline: true
}, {
name: 'Credits',
value: info.credits,
inline: true
}, {
name: 'First login',
value: info.firstLogin,
inline: true
}, {
name: 'Last login',
value: info.lastLogin,
inline: true
}, {
name: 'Last logout',
value: info.lastLogout
})
message.channel.send(statEmbed);
message.delete();
}).catch(e => {
console.log(e)
})
}
const statEmbed = new Discord.MessageEmbed()
.setColor("#FF0033")
.setTitle(playername + suffix + " HiveMC stats")
.setThumbnail("https://minotar.net/avatar/" + playername)
.setTimestamp()
.setFooter(`HiveMC Stats • Panda Jr. v${version}`)
.addFields(
{
name: "Rank",
value: info.rank.humanName,
inline: true,
},
{ name: "Tokens", value: info.tokens, inline: true },
{ name: "Medals", value: info.medals, inline: true },
{ name: "Credits", value: info.credits, inline: true },
{
name: "First login",
value: info.firstLogin,
inline: true,
},
{
name: "Last login",
value: info.lastLogin,
inline: true,
},
{ name: "Last logout", value: info.lastLogout }
);
message.channel.send(statEmbed);
message.delete();
})
.catch((e) => {
console.log(e);
});
}
}

module.exports = HiveCommand;
module.exports = HiveCommand;
Loading