big cleanup & use slash commands
This commit is contained in:
parent
386379b493
commit
01ce9ad000
15 changed files with 526 additions and 541 deletions
|
@ -1,36 +0,0 @@
|
|||
import { EmbedBuilder } from 'discord.js';
|
||||
import { commands } from '.';
|
||||
import type { Command } from '..';
|
||||
import { COLORS } from '../constants';
|
||||
|
||||
export const cmd: Command = {
|
||||
name: 'help',
|
||||
desc: 'Shows this menu.',
|
||||
exec: async (e) => {
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle('Help Menu')
|
||||
.setColor(COLORS.green);
|
||||
|
||||
const 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.addFields({ name: '!' + cmd.name, value: resp.join('\n') });
|
||||
}
|
||||
|
||||
await e.reply({ embeds: [embed] });
|
||||
},
|
||||
};
|
|
@ -1,7 +0,0 @@
|
|||
import { cmd as help } from './help';
|
||||
import { cmd as members } from './members';
|
||||
import { cmd as ping } from './ping';
|
||||
import { cmd as stars } from './stars';
|
||||
import { cmd as tags } from './tags';
|
||||
|
||||
export const commands = [help, members, ping, stars, tags];
|
|
@ -1,29 +1,25 @@
|
|||
import type { Command } from '..';
|
||||
import type { CacheType, CommandInteraction } from 'discord.js';
|
||||
|
||||
import { COLORS } from '../constants';
|
||||
|
||||
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;
|
||||
export const membersCommand = async (i: CommandInteraction<CacheType>) => {
|
||||
const memes = await i.guild?.members.fetch().then((r) => r.toJSON());
|
||||
if (!memes) return;
|
||||
|
||||
await 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: COLORS.blue,
|
||||
},
|
||||
],
|
||||
});
|
||||
},
|
||||
await i.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: COLORS.blue,
|
||||
},
|
||||
],
|
||||
});
|
||||
};
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
import type { Command } from '..';
|
||||
|
||||
export const cmd: Command = {
|
||||
name: 'ping',
|
||||
desc: 'Shows the ping of the bot',
|
||||
aliases: ['test'],
|
||||
exec: async (e) => {
|
||||
await e.reply(`${e.client.ws.ping}ms`);
|
||||
},
|
||||
};
|
|
@ -1,21 +1,17 @@
|
|||
import type { CacheType, CommandInteraction } from 'discord.js';
|
||||
import { COLORS } from '../constants';
|
||||
import type { 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);
|
||||
await e.reply({
|
||||
embeds: [
|
||||
{
|
||||
title: `⭐ ${count} total stars!`,
|
||||
color: COLORS.yellow,
|
||||
},
|
||||
],
|
||||
});
|
||||
},
|
||||
export const starsCommand = async (i: CommandInteraction<CacheType>) => {
|
||||
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);
|
||||
|
||||
await i.reply({
|
||||
embeds: [
|
||||
{
|
||||
title: `⭐ ${count} total stars!`,
|
||||
color: COLORS.yellow,
|
||||
},
|
||||
],
|
||||
});
|
||||
};
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
import { EmbedBuilder } from 'discord.js';
|
||||
import { getTags, type Command } from '..';
|
||||
import { COLORS } from '../constants';
|
||||
|
||||
export const cmd: Command = {
|
||||
name: 'tags',
|
||||
desc: 'Lists the tags available',
|
||||
exec: async (e) => {
|
||||
const em = new EmbedBuilder().setTitle('tags').setColor(COLORS.green);
|
||||
|
||||
const tags = await getTags();
|
||||
|
||||
for (const i in tags) {
|
||||
const tag = tags[i];
|
||||
let text = '';
|
||||
|
||||
if (tag.aliases && tag.aliases[0]) {
|
||||
text += '**Aliases**: ' + tag.aliases.join(', ') + '\n';
|
||||
}
|
||||
|
||||
if (tag.text) {
|
||||
text += tag.text;
|
||||
} else if (tag.embed) {
|
||||
text += '\n[embedded message]';
|
||||
}
|
||||
|
||||
em.addFields({ name: '?' + tag.name, value: text });
|
||||
}
|
||||
|
||||
await e.reply({ embeds: [em] });
|
||||
},
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue