From 439323eeb499e6ef6c8d7d2a3f24f730bc128cde Mon Sep 17 00:00:00 2001 From: kieranrobson Date: Wed, 11 May 2022 22:11:18 +0100 Subject: [PATCH] Added link buton to the welcome embed --- commands/embeds/welcome.js | 16 +++++++++---- events/interactionCreate.js | 45 +++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 events/interactionCreate.js diff --git a/commands/embeds/welcome.js b/commands/embeds/welcome.js index 524613e..4f9fe69 100644 --- a/commands/embeds/welcome.js +++ b/commands/embeds/welcome.js @@ -24,11 +24,19 @@ module.exports = { const row = new discord.MessageActionRow() .addComponents( + new discord.MessageButton() + .setURL('https://github.com/hullcss/conduct/') + .setEmoji('') + .setLabel('Code of Conduct') + .setStyle('LINK') + ) + .addComponents( new discord.MessageButton() - .setCustomId('codeOfConduct') - .setLabel('✅ I have read the code of conduct!') - .setStyle('SUCCESS'), - ); + .setCustomId('codeOfConduct') + .setEmoji('✅') + .setLabel(' I have read the code of conduct!') + .setStyle('SUCCESS') + ) message.channel.send({ embeds: [embed], components: [row] }) }, diff --git a/events/interactionCreate.js b/events/interactionCreate.js new file mode 100644 index 0000000..15400a0 --- /dev/null +++ b/events/interactionCreate.js @@ -0,0 +1,45 @@ + +const client = require("../index"); + +client.on("interactionCreate", async (interaction) => { + // Slash Command Handling + if (interaction.isCommand()) { + await interaction.deferReply({ ephemeral: false }).catch(() => {}); + + const cmd = client.slashCommands.get(interaction.commandName); + if (!cmd) + return interaction.followUp({ content: "An error has occured " }); + + const args = []; + + for (let option of interaction.options.data) { + if (option.type === "SUB_COMMAND") { + if (option.name) args.push(option.name); + option.options?.forEach((x) => { + if (x.value) args.push(x.value); + }); + } else if (option.value) args.push(option.value); + } + interaction.member = interaction.guild.members.cache.get(interaction.user.id); + + cmd.run(client, interaction, args); + } + + // Context Menu Handling + if (interaction.isContextMenu()) { + await interaction.deferReply({ ephemeral: false }); + const command = client.slashCommands.get(interaction.commandName); + if (command) command.run(client, interaction); + } + + // Context Menu Handling + if (interaction.isButton()) { + interaction.member.roles.add("973646380771979304") + await interaction.reply({ content: 'Roles have been updated', ephemeral: true}); + + } + + + + +}) \ No newline at end of file