Refactor bot. (#8)
This commit is contained in:
parent
e0374bea36
commit
259d540e6f
18 changed files with 491 additions and 300 deletions
32
src/commands/help.ts
Normal file
32
src/commands/help.ts
Normal file
|
@ -0,0 +1,32 @@
|
|||
import { MessageEmbed } from 'discord.js';
|
||||
import { commands } from '..';
|
||||
import { Command } from '..';
|
||||
|
||||
export const cmd: Command = {
|
||||
name: 'help',
|
||||
desc: 'Shows this menu.',
|
||||
exec: async (e) => {
|
||||
const embed = new MessageEmbed()
|
||||
.setTitle('Help Menu')
|
||||
.setColor('DARK_GREEN');
|
||||
let comman = commands;
|
||||
comman.sort((x, y) => {
|
||||
return x.name == 'help' ? -1 : y.name == 'help' ? 1 : 0;
|
||||
});
|
||||
for (const i in comman) {
|
||||
const cmd = comman[i];
|
||||
const resp = [];
|
||||
if (cmd.desc) {
|
||||
resp.push(cmd.desc);
|
||||
}
|
||||
if (cmd.aliases && cmd.aliases[0]) {
|
||||
resp.push(`**Aliases**: ${cmd.aliases.join(', ')}`);
|
||||
}
|
||||
if (cmd.examples && cmd.examples[0]) {
|
||||
resp.push(`**Examples**: \n${cmd.examples.join('\n> ')}`);
|
||||
}
|
||||
embed.addField('!' + cmd.name, resp.join('\n'));
|
||||
}
|
||||
return e.reply({ embeds: [embed] });
|
||||
},
|
||||
};
|
28
src/commands/members.ts
Normal file
28
src/commands/members.ts
Normal file
|
@ -0,0 +1,28 @@
|
|||
import { Command } from '../index';
|
||||
|
||||
export const cmd: Command = {
|
||||
name: 'members',
|
||||
desc: 'Shows the amount of online users in PolyMC Discord',
|
||||
aliases: ['mems', 'memcount'],
|
||||
exec: async (e) => {
|
||||
const memes = await e.guild?.members.fetch().then((r) => r.toJSON());
|
||||
if (!memes) return;
|
||||
|
||||
return e.reply({
|
||||
embeds: [
|
||||
{
|
||||
title: `${memes.length} total members!`,
|
||||
description: `${
|
||||
memes.filter(
|
||||
(m) =>
|
||||
m.presence?.status === 'online' ||
|
||||
m.presence?.status === 'idle' ||
|
||||
m.presence?.status === 'dnd'
|
||||
).length
|
||||
} online members`,
|
||||
color: 'GOLD',
|
||||
},
|
||||
],
|
||||
});
|
||||
},
|
||||
};
|
10
src/commands/ping.ts
Normal file
10
src/commands/ping.ts
Normal file
|
@ -0,0 +1,10 @@
|
|||
import { Command } from '../index';
|
||||
|
||||
export const cmd: Command = {
|
||||
name: 'ping',
|
||||
desc: 'Shows the ping of the bot',
|
||||
aliases: ['test'],
|
||||
exec: async (e) => {
|
||||
return await e.reply(`${e.client.ws.ping}ms`);
|
||||
},
|
||||
};
|
20
src/commands/stars.ts
Normal file
20
src/commands/stars.ts
Normal file
|
@ -0,0 +1,20 @@
|
|||
import { Command } from '../index';
|
||||
|
||||
export const cmd: Command = {
|
||||
name: 'stars',
|
||||
desc: 'Shows the number of stars in PolyMC',
|
||||
aliases: ['star', 'stargazers'],
|
||||
exec: async (e) => {
|
||||
const count = await fetch('https://api.github.com/repos/PolyMC/PolyMC')
|
||||
.then((r) => r.json() as Promise<{ stargazers_count: number }>)
|
||||
.then((j) => j.stargazers_count);
|
||||
return e.reply({
|
||||
embeds: [
|
||||
{
|
||||
title: `⭐ ${count} total stars!`,
|
||||
color: 'GOLD',
|
||||
},
|
||||
],
|
||||
});
|
||||
},
|
||||
};
|
27
src/commands/tags.ts
Normal file
27
src/commands/tags.ts
Normal file
|
@ -0,0 +1,27 @@
|
|||
import { MessageEmbed } from 'discord.js';
|
||||
import { Command } from '../index';
|
||||
import { tags } from '../index';
|
||||
|
||||
export const cmd: Command = {
|
||||
name: 'tags',
|
||||
desc: 'Lists the tags available',
|
||||
exec: async (e) => {
|
||||
const em = new MessageEmbed().setTitle('tags').setColor('DARK_GREEN');
|
||||
|
||||
for (let i in tags) {
|
||||
const tag = tags[i];
|
||||
let text = '';
|
||||
if (tag.aliases && tag.aliases[0]) {
|
||||
text += '**Aliases**: ' + tag.aliases.join(', ');
|
||||
}
|
||||
|
||||
if (tag.text) {
|
||||
text += tag.text;
|
||||
} else if (tag.embed) {
|
||||
text += '\n[embedded message]';
|
||||
}
|
||||
em.addField(tag.name, text);
|
||||
}
|
||||
return e.reply({ embeds: [em] });
|
||||
},
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue