Send message containing hyperlinks with: The text in format [text](example.com) will get replaced with a clickable blue text redirecting to example.com. Usage: !l hey [Don't ask to ask, just ask](https://dontasktoask.com) .
// I HAVE USE THE Discord — message.create.prefix ENDPOINT HERE, SO IT WILL ONPY HYPERLINK WHEN THE TEXT IS AT THE BEGINNING OF THE MESSAGE, YOU CAN USE message.create ONE TOO IF YOU CAN AFFORD IT...
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
//the message content
let content = context.params.event.content.split(' ').splice(1).join(' ');
//regex to match with [text](https://example.com) format
let regex = /\[([^\]]+)\]\((https?:\/\/[^\s]+)\)/;
if (regex.test(content)) {
//if the message contains the hyperlink format
//Deleting the message first
await lib.discord.channels['@0.3.4'].messages.destroy({
message_id: `${context.params.event.id}`,
channel_id: `${context.params.event.channel_id}`,
});
//Getting the avatar
const user = context.params.event.author;
const avatar = `https://cdn.discordapp.com/avatars/${user.id}/${user.avatar}.png?size=512`; //creating a discord webhook
let newAvatar = await lib.http.request['@1.1.7']({
method: 'GET',
url: avatar,
});
let webhook = await lib.discord.webhooks['@0.2.0'].create({
channel_id: `${context.params.event.channel_id}`,
name: `${context.params.event.author.username}`,
avatar: newAvatar.body,
});
//resendng the message using discord webhook
await lib.discord.webhooks['@0.2.0'].execute({
webhook_id: `${webhook.id}`,
webhook_token: `${webhook.token}`,
content: content,
wait: false,
});
//deleting that webhook
await lib.discord.webhooks['@0.2.0'].destroy({
webhook_id: `${webhook.id}`,
});
}