From abe4fe77565de7d449ce6a5b3be228e9d0451ae7 Mon Sep 17 00:00:00 2001 From: Supositware Date: Thu, 18 Aug 2022 01:46:04 +0200 Subject: [PATCH] Fakeuser command --- commands/fun/fakeuser.js | 38 +++++++++++++++++++++++++++++++++++++ scripts/deploy-commands.cjs | 16 ++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 commands/fun/fakeuser.js diff --git a/commands/fun/fakeuser.js b/commands/fun/fakeuser.js new file mode 100644 index 00000000..ed7ab0d8 --- /dev/null +++ b/commands/fun/fakeuser.js @@ -0,0 +1,38 @@ +import { SlashCommandBuilder } from '@discordjs/builders'; + +export default { + data: new SlashCommandBuilder() + .setName('fakeuser') + .setDescription('Fake a user with webhooks') + .addMentionableOption(option => + option.setName('user') + .setDescription('Who do you want to fake?') + .setRequired(true)) + .addStringOption(option => + option.setName('message') + .setDescription('What message do you want me to send?') + .setRequired(true)) + .addAttachmentOption(option => + option.setName('image') + .setDescription('Optional attachment.') + .setRequired(false)), + async execute(interaction) { + await interaction.deferReply({ ephemeral: true }); + const attachment = interaction.options.getAttachment('image'); + const message = interaction.options.getString('message'); + const member = interaction.options.getMentionable('user'); + + const webhook = await interaction.channel.createWebhook(member.user.username, { + avatar: member.user.displayAvatarURL(), + reason: `Fakebot/user command triggered by: ${interaction.user.username}`, + }); + if (attachment) { + await webhook.send({ content: message, files: [attachment] }); + } + else { + await webhook.send({ content: message }); + } + await webhook.delete(`Fakebot/user command triggered by: ${interaction.user.username}`); + await interaction.editReply({ content: `Faked the user ${member}` }); + }, +}; diff --git a/scripts/deploy-commands.cjs b/scripts/deploy-commands.cjs index aa5911d5..e6dc13a5 100644 --- a/scripts/deploy-commands.cjs +++ b/scripts/deploy-commands.cjs @@ -85,6 +85,22 @@ const commands = [ new SlashCommandBuilder() .setName('stats') .setDescription('Show some stats about the bot'), + + new SlashCommandBuilder() + .setName('fakeuser') + .setDescription('Fake a user with webhooks') + .addMentionableOption(option => + option.setName('user') + .setDescription('Who do you want to fake?') + .setRequired(true)) + .addStringOption(option => + option.setName('message') + .setDescription('What message do you want me to send?') + .setRequired(true)) + .addAttachmentOption(option => + option.setName('image') + .setDescription('Optional attachment (Image only.)') + .setRequired(false)), ] .map(command => command.toJSON());