所以這是我的代碼
const Discord = require('discord.js');
const { Client, Intents } = require('discord.js');
const client = new Client({ intents: [4611] });
let targetChannel = '906686653874176090' //target channel
client.once('ready', () => {
console.log('Ready! - Made By Woodington');
});
client.on('messageCreate', gotMessage);
function gotMessage(msg) {
if (msg.channel.id !== targetChannel) {
client.channels.fetch(targetChannel)
.then(channel => channel.send(msg.content `${client.user.tag}`))
.catch(console.error);
}
}
它的作用是將訊息轉發到另一個頻道,在底部帶有用戶 Discord 標簽。但是,它發送機器人 Discord 名稱而不是原始發件人。有任何想法嗎?
uj5u.com熱心網友回復:
您正在使用client您自己的機器人變數。您需要利用msg您在事件中收到的引數。這就是您的機器人發送自己的標簽的原因,因為client.user.tagequals YourBot#0000。
要發送作者的標簽,請替換client.user.tag為以下內容:
msg.author.tag
這將回傳 Author's Username#0000
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/353717.html
標籤:javascript 节点.js 不和谐 不和谐.js
