Make /tag and auto tag replies work

(very cool)
This commit is contained in:
Isaac
2022-10-18 16:39:03 +01:00
parent 90c0521e35
commit 59c6ab3537
3 changed files with 73 additions and 10 deletions

View File

@@ -1,5 +1,6 @@
const { SlashCommand } = require('@eartharoid/dbf');
const { ApplicationCommandOptionType } = require('discord.js');
const ExtendedEmbedBuilder = require('../../lib/embed');
module.exports = class TagSlashCommand extends SlashCommand {
constructor(client, options) {
@@ -14,7 +15,7 @@ module.exports = class TagSlashCommand extends SlashCommand {
autocomplete: true,
name: 'tag',
required: true,
type: ApplicationCommandOptionType.String,
type: ApplicationCommandOptionType.Integer,
},
{
name: 'for',
@@ -48,5 +49,28 @@ module.exports = class TagSlashCommand extends SlashCommand {
});
}
async run(interaction) { }
/**
* @param {import("discord.js").ChatInputCommandInteraction} interaction
*/
async run(interaction) {
/** @type {import("client")} */
const client = this.client;
const user = interaction.options.getUser('for', false);
await interaction.deferReply({ ephemeral: !user });
const tag = await client.prisma.tag.findUnique({
include: { guild: true },
where: { id: interaction.options.getInteger('tag', true) },
});
await interaction.editReply({
allowedMentions: { users: user ? [user.id]: [] },
content: user?.toString(),
embeds: [
new ExtendedEmbedBuilder()
.setColor(tag.guild.primaryColour)
.setDescription(tag.content),
],
});
}
};