reorganize

This commit is contained in:
Ryan Cao 2022-08-29 12:02:16 +08:00
parent 0aaee0e0f1
commit d16bec1336
No known key found for this signature in database
GPG key ID: 528A2C1B6656B97F
6 changed files with 67 additions and 48 deletions

View file

@ -1,8 +1,10 @@
import type { CacheType, CommandInteraction } from 'discord.js';
import type { CacheType, ChatInputCommandInteraction } from 'discord.js';
import { COLORS } from '../constants';
export const membersCommand = async (i: CommandInteraction<CacheType>) => {
export const membersCommand = async (
i: ChatInputCommandInteraction<CacheType>
) => {
await i.deferReply();
const memes = await i.guild?.members.fetch().then((r) => r.toJSON());

View file

@ -15,14 +15,16 @@ export interface ModrinthProject {
}
import {
type CacheType,
type CommandInteraction,
EmbedBuilder,
type CacheType,
type ChatInputCommandInteraction,
} from 'discord.js';
import { COLORS } from '../constants';
export const modrinthCommand = async (i: CommandInteraction<CacheType>) => {
export const modrinthCommand = async (
i: ChatInputCommandInteraction<CacheType>
) => {
await i.deferReply();
const { value: id } = i.options.get('id') ?? { value: null };

View file

@ -1,7 +1,9 @@
import type { CacheType, CommandInteraction } from 'discord.js';
import type { CacheType, ChatInputCommandInteraction } from 'discord.js';
import { COLORS } from '../constants';
export const starsCommand = async (i: CommandInteraction<CacheType>) => {
export const starsCommand = async (
i: ChatInputCommandInteraction<CacheType>
) => {
await i.deferReply();
const count = await fetch('https://api.github.com/repos/PolyMC/PolyMC')

36
src/commands/tags.ts Normal file
View file

@ -0,0 +1,36 @@
import {
type ChatInputCommandInteraction,
type CacheType,
EmbedBuilder,
} from 'discord.js';
import { getTags } from '../tagsTags';
export const tagsCommand = async (
i: ChatInputCommandInteraction<CacheType>
) => {
const tags = await getTags();
const tagName = i.options.getString('name', true);
const tag = tags.find(
(tag) => tag.name === tagName || tag.aliases?.includes(tagName)
);
if (!tag) {
await i.reply({
content: `Tag \`${tagName}\` does not exist.`,
ephemeral: true,
});
return;
}
await i.reply({
content: tag.text ? `**${tag.name}**\n\n` + tag.text : tag.text,
embeds: tag.embed
? [
new EmbedBuilder(tag.embed).setFooter({
text: `Requested by ${i.user.tag}`,
iconURL: i.user.avatarURL() ?? undefined,
}),
]
: [],
});
};