如何将超链接添加到从 subreddit 获得的 json 字符串
How do i add hyperlink to the json string i get from a subreddit
const allowed = body.data.children.filter((post: {
data: {
over_18: any;
};
}) => !post.data.over_18);
if (!allowed.length) return message.channel.send('It seems we are out of fresh memes!, Try again later.');
const randomnumber = Math.floor(Math.random() * allowed.length)
const embed = new MessageEmbed()
.setTitle(allowed[randomnumber].data.title)
return embed
信息:我正在使用带有打字稿的 Discordjs 13,我想让标题成为一个超链接,当您单击文本时,它会将您带到 post。
当我这样做时:
.setTitle(`[${allowed[randomnumber].data.title}](https://reddit.com${allowed[randomnumber].data.permalink})`)
显示此函数不可调用的错误
提前谢谢你。
已解决!,我必须使用
.setUrl('')
const allowed = body.data.children.filter((post: {
data: {
over_18: any;
};
}) => !post.data.over_18);
if (!allowed.length) return message.channel.send('It seems we are out of fresh memes!, Try again later.');
const randomnumber = Math.floor(Math.random() * allowed.length)
const embed = new MessageEmbed()
.setTitle(allowed[randomnumber].data.title)
return embed
信息:我正在使用带有打字稿的 Discordjs 13,我想让标题成为一个超链接,当您单击文本时,它会将您带到 post。 当我这样做时:
.setTitle(`[${allowed[randomnumber].data.title}](https://reddit.com${allowed[randomnumber].data.permalink})`)
显示此函数不可调用的错误 提前谢谢你。
已解决!,我必须使用 .setUrl('')