I’m new to JavaScript and need assistance adding a command to my custom Discord bot called /betlink (user provided link). This command should allow the bot to send an Embed with a message formatted like this:
Input: /betlink (link from user)
Output: A message embedded that reads “Please click this link (user provided link) to place your bet on (Betting Platform).”
I would appreciate any guidance or code snippets that can help achieve this.
So far, I have written an Embed command that can return a fixed URL, but I require one that dynamically incorporates the URL provided by the user in their input. Here’s my existing code:
const { SlashCommandBuilder, EmbedBuilder, hyperlink } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('betlink')
.setDescription('Sends an embed with a link to your betslip')
.addStringOption(option =>
option.setName('url')
.setDescription('Your betslip URL')
.setRequired(true)
.setMaxLength(2000)),
async execute(interaction) {
const url = interaction.options.getString('url');
const embed = new EmbedBuilder()
.setColor('Blue')
.setTitle(`Please ${hyperlink('click here', url)} to place your bet on FanDuel.`)
.setDescription('Verify all selections and odds before placing a wager. Gamble responsibly.')
.setTimestamp();
await interaction.reply({embeds: [embed]});
}
};
Currently, I am receiving output like: ‘Please click here to place this bet on FanDuel.’