I am very new to .js and I'm wanting to add a command to my custom bot called /betslip (link) which will then have the bot return an Embed with the betslip link in such an example as below:
Input: /betslip (user provided link)
Output: Embedded message stating "Please click Here (user provided link) to place this bet on (Betting Platform).
Any leads in the right direction or code samples for this request would be greatly appreciated.
TIA
I've set up an Embed command that can return a static URL, however I'm needing an Embed command that would return the URL the user provides in their message.
This is what I have right now
const { SlashCommandBuilder, EmbedBuilder, Embed, hyperlink } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('betslip')
.setDescription('this will send an embed with a link to your betslip')
.addStringOption(option =>
option.setName('link')
.setDescription('Your betslip link')
.setRequired(true)
.setMaxLength(2000)),
async execute(interaction) {
const link = interaction.options.getString(link);
const embed = new EmbedBuilder()
.setColor('Aqua')
.setTitle(`Please ${hyperlink('click here', link)} to place this bet on FanDuel.`)
.setDescription({text: `Always check selections and odds before placing wager. Gamble responsibly.`})
.setTimestamp()
await interaction.reply({embeds: [embed]});
}
}
Current Output: Please [click here](null) to place this bet on FanDuel(https://fanduel.com/).
You can mask the link by using Discords markdown support. It's as simple as [my text](url)
and would look like this in your case:
Please [click here](user provided link) to place this bet on [Betting Platform](link).
or use the hyperlink method from discord.js
const { EmbedBuilder, hyperlink } = require('discord.js');
const link = interaction.options.getString('link');
const embed = new EmbedBuilder()
.setColor('Aqua')
.setDescription(`Please ${hyperlink('click here', link)} to place this bet on FanDuel.`)
.setFooter({ text: 'Always check selections and odds before placing wager. Gamble responsibly.' });
.setTimestamp();
The catch is that embed titles don't support markdown you can alternatively set a link to the title but this will mark the whole title as a link.
const embed = new EmbedBuilder()
.setColor('Aqua')
.setTitle(`Please click here to place this bet on FanDuel.`)
.setURL(link)
.setDescription('Always check selections and odds before placing wager. Gamble responsibly.');
.setTimestamp();