reorganize
This commit is contained in:
parent
0aaee0e0f1
commit
d16bec1336
6 changed files with 67 additions and 48 deletions
|
@ -36,16 +36,19 @@ import 'dotenv/config';
|
||||||
.addStringOption((option) =>
|
.addStringOption((option) =>
|
||||||
option.setName('id').setDescription('The ID or slug').setRequired(true)
|
option.setName('id').setDescription('The ID or slug').setRequired(true)
|
||||||
),
|
),
|
||||||
|
new SlashCommandBuilder()
|
||||||
|
.setName('say')
|
||||||
|
.setDescription('Say someothing through the bot')
|
||||||
|
.addStringOption((option) =>
|
||||||
|
option
|
||||||
|
.setName('content')
|
||||||
|
.setDescription('Just content?')
|
||||||
|
.setRequired(true)
|
||||||
|
),
|
||||||
].map((command) => command.toJSON());
|
].map((command) => command.toJSON());
|
||||||
|
|
||||||
const rest = new REST({ version: '10' }).setToken(process.env.DISCORD_TOKEN!);
|
const rest = new REST({ version: '10' }).setToken(process.env.DISCORD_TOKEN!);
|
||||||
|
|
||||||
await rest.put(Routes.applicationCommands(process.env.DISCORD_APP!), {
|
|
||||||
body: [],
|
|
||||||
});
|
|
||||||
|
|
||||||
console.log('Successfully deleted all application commands.');
|
|
||||||
|
|
||||||
await rest.put(Routes.applicationCommands(process.env.DISCORD_APP!), {
|
await rest.put(Routes.applicationCommands(process.env.DISCORD_APP!), {
|
||||||
body: commands,
|
body: commands,
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
import type { CacheType, CommandInteraction } from 'discord.js';
|
import type { CacheType, ChatInputCommandInteraction } from 'discord.js';
|
||||||
|
|
||||||
import { COLORS } from '../constants';
|
import { COLORS } from '../constants';
|
||||||
|
|
||||||
export const membersCommand = async (i: CommandInteraction<CacheType>) => {
|
export const membersCommand = async (
|
||||||
|
i: ChatInputCommandInteraction<CacheType>
|
||||||
|
) => {
|
||||||
await i.deferReply();
|
await i.deferReply();
|
||||||
|
|
||||||
const memes = await i.guild?.members.fetch().then((r) => r.toJSON());
|
const memes = await i.guild?.members.fetch().then((r) => r.toJSON());
|
||||||
|
|
|
@ -15,14 +15,16 @@ export interface ModrinthProject {
|
||||||
}
|
}
|
||||||
|
|
||||||
import {
|
import {
|
||||||
type CacheType,
|
|
||||||
type CommandInteraction,
|
|
||||||
EmbedBuilder,
|
EmbedBuilder,
|
||||||
|
type CacheType,
|
||||||
|
type ChatInputCommandInteraction,
|
||||||
} from 'discord.js';
|
} from 'discord.js';
|
||||||
|
|
||||||
import { COLORS } from '../constants';
|
import { COLORS } from '../constants';
|
||||||
|
|
||||||
export const modrinthCommand = async (i: CommandInteraction<CacheType>) => {
|
export const modrinthCommand = async (
|
||||||
|
i: ChatInputCommandInteraction<CacheType>
|
||||||
|
) => {
|
||||||
await i.deferReply();
|
await i.deferReply();
|
||||||
|
|
||||||
const { value: id } = i.options.get('id') ?? { value: null };
|
const { value: id } = i.options.get('id') ?? { value: null };
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
import type { CacheType, CommandInteraction } from 'discord.js';
|
import type { CacheType, ChatInputCommandInteraction } from 'discord.js';
|
||||||
import { COLORS } from '../constants';
|
import { COLORS } from '../constants';
|
||||||
|
|
||||||
export const starsCommand = async (i: CommandInteraction<CacheType>) => {
|
export const starsCommand = async (
|
||||||
|
i: ChatInputCommandInteraction<CacheType>
|
||||||
|
) => {
|
||||||
await i.deferReply();
|
await i.deferReply();
|
||||||
|
|
||||||
const count = await fetch('https://api.github.com/repos/PolyMC/PolyMC')
|
const count = await fetch('https://api.github.com/repos/PolyMC/PolyMC')
|
||||||
|
|
36
src/commands/tags.ts
Normal file
36
src/commands/tags.ts
Normal 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,
|
||||||
|
}),
|
||||||
|
]
|
||||||
|
: [],
|
||||||
|
});
|
||||||
|
};
|
44
src/index.ts
44
src/index.ts
|
@ -1,11 +1,4 @@
|
||||||
import {
|
import { Client, GatewayIntentBits, Partials, OAuth2Scopes } from 'discord.js';
|
||||||
Client,
|
|
||||||
EmbedBuilder,
|
|
||||||
GatewayIntentBits,
|
|
||||||
Partials,
|
|
||||||
ChannelType,
|
|
||||||
OAuth2Scopes,
|
|
||||||
} from 'discord.js';
|
|
||||||
|
|
||||||
import * as BuildConfig from './constants';
|
import * as BuildConfig from './constants';
|
||||||
import { parseLog } from './logs';
|
import { parseLog } from './logs';
|
||||||
|
@ -13,12 +6,12 @@ import { getLatestMinecraftVersion } from './utils/remoteVersions';
|
||||||
|
|
||||||
import { membersCommand } from './commands/members';
|
import { membersCommand } from './commands/members';
|
||||||
import { starsCommand } from './commands/stars';
|
import { starsCommand } from './commands/stars';
|
||||||
|
import { modrinthCommand } from './commands/modrinth';
|
||||||
|
import { tagsCommand } from './commands/tags';
|
||||||
|
|
||||||
import random from 'just-random';
|
import random from 'just-random';
|
||||||
import { green, bold, yellow } from 'kleur/colors';
|
import { green, bold, yellow } from 'kleur/colors';
|
||||||
import 'dotenv/config';
|
import 'dotenv/config';
|
||||||
import { getTags } from './tagsTags';
|
|
||||||
import { modrinthCommand } from './commands/modrinth';
|
|
||||||
|
|
||||||
const client = new Client({
|
const client = new Client({
|
||||||
intents: [
|
intents: [
|
||||||
|
@ -117,32 +110,13 @@ client.on('interactionCreate', async (interaction) => {
|
||||||
await interaction.reply(
|
await interaction.reply(
|
||||||
'https://media.discordapp.net/attachments/985048903126769764/985051373886382100/rollin-time.gif?width=324&height=216'
|
'https://media.discordapp.net/attachments/985048903126769764/985051373886382100/rollin-time.gif?width=324&height=216'
|
||||||
);
|
);
|
||||||
|
} else if (commandName === 'say') {
|
||||||
|
if (!interaction.channel) return;
|
||||||
|
await interaction.deferReply();
|
||||||
|
await interaction.channel.send(interaction.options.getString('content')!);
|
||||||
|
await interaction.editReply('I said what you said!');
|
||||||
} else if (commandName === 'tag') {
|
} else if (commandName === 'tag') {
|
||||||
const tags = await getTags();
|
tagsCommand(interaction);
|
||||||
const tagName = interaction.options.getString('name', true);
|
|
||||||
const tag = tags.find(
|
|
||||||
(tag) => tag.name === tagName || tag.aliases?.includes(tagName)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!tag) {
|
|
||||||
await interaction.reply({
|
|
||||||
content: `Tag \`${tagName}\` does not exist.`,
|
|
||||||
ephemeral: true,
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await interaction.reply({
|
|
||||||
content: tag.text ? `**${tag.name}**\n\n` + tag.text : tag.text,
|
|
||||||
embeds: tag.embed
|
|
||||||
? [
|
|
||||||
new EmbedBuilder(tag.embed).setFooter({
|
|
||||||
text: `Requested by ${interaction.user.tag}`,
|
|
||||||
iconURL: interaction.user.avatarURL() ?? undefined,
|
|
||||||
}),
|
|
||||||
]
|
|
||||||
: [],
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue