【发布时间】:2021-05-05 01:19:51
【问题描述】:
我正在尝试为我的不和谐机器人开发更详细的日志记录系统,这就是我目前拥有的:
client.on('message', message => {
if (message.author.bot) return; //don't log its own messages
const channel = client.channels.cache.get('805457298867879936'); //sent logs to this channel
channel.send(
`${message.author} in ${message.channel} of ${message.guild} said ${message.content}`, //log in discord channel
);
console.log(
`${message.author.tag} in #${message.channel.name} of ${message.guild.name} said: ${message.content}`, //log in console
);
client.login(token); //login
此代码记录机器人可以在特定频道和我的控制台中看到的所有发送消息。但是,我还想有一个已发送消息的消息链接。
例如,这是我目前记录的:
Kingamezz#02XX in #testing of Testing Server said: test
我想要的是这样的:
Kingamezz#02XX in #testing of Testing Server said: test (https://discord.com/channels/763786268181397524/805457298867879936/805502804134330448) 这样我就可以直接跳转到消息了。
我不知道如何抓取消息的消息链接,discordjs 文档似乎没有关于消息链接的任何内容。我试过这个:
channel.send(
"https://discord.com/channels/" + guild.id + "/" + message.id
)
但它会导致“公会未定义”。我这样做对吗?
【问题讨论】:
标签: javascript discord