From 3593e489984e51afed559505c7ee2080305d560b Mon Sep 17 00:00:00 2001 From: AnxietyisReal <96593068+AnxietyisReal@users.noreply.github.com> Date: Tue, 23 May 2023 16:47:51 +1000 Subject: [PATCH] New command. --- src/commands/inviteinfo.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/commands/inviteinfo.ts diff --git a/src/commands/inviteinfo.ts b/src/commands/inviteinfo.ts new file mode 100644 index 0000000..1518bdf --- /dev/null +++ b/src/commands/inviteinfo.ts @@ -0,0 +1,22 @@ +import Discord from 'discord.js'; +import TClient from '../client.js'; +export default { + async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){ + const inviteCode = interaction.options.getString('code',true).replace(/(https:\/\/|discord.gg\/)/g,'') + await client.axios.get(`https://discord.com/api/v${Discord.APIVersion}/invites/${inviteCode}`).then(async inviteInfo=> + await interaction.reply({embeds: [ + new client.embed().setColor(client.config.embedColor).setURL(`https://discord.gg/${inviteInfo.data.code}`).setTitle(inviteInfo.data.guild.name).setDescription([ + `ID: \`${inviteInfo.data.guild.id}\``, + `Description: \`\`\`${inviteInfo.data.guild.description != null ? inviteInfo.data.guild.description : 'No description set.'}`, + `\`\`\`Total server boosters: \`${inviteInfo.data.guild.premium_subscription_count}\``, + `Channel: \`#${inviteInfo.data.channel.name}\`` + ].join('\n')) + ]})).catch(err=>interaction.reply(`\`${err}\``)) + }, + data: new Discord.SlashCommandBuilder() + .setName('inviteinfo') + .setDescription('View the invite data') + .addStringOption(x=>x + .setName('code') + .setDescription('Discord invite code')) +} \ No newline at end of file