有没有更好的方法将消息发送到特定服务器中的特定通道?
Is there a better way of sending messages to specific channels in specific servers?
我正在尝试制作一个日志脚本,但是我无法让它工作。有没有更好的方法?
我试过切换属性,但似乎不起作用。
client.on('message', message => {
var sender = message.member.user.tag
var channel = message.channel.name
var message = message.content
var server = message.guild
let embed = new Discord.RichEmbed()
.addField('**' + sender + '** said ' + message + ' in ' + channel + ', ' + server)
.setColor('#4286f4')
// This is the line I'm having problems with:
client.guilds.get('575957043211403265').channels.get('575957043211403267').sendEmbed(embed);
});
如果您使用的 ID 正确,那么您的代码应该是有效的,只要您使用 stable
分支 中的库。
您正在使用 TextChannel.sendEmbed()
method, which is deprecated: that means that it'll be removed in the future versions. If you installed the master
branch that method won't be available (check the docs here).
还有另一种发送嵌入的方法:
TextChannel.send({ embed: yourEmbed });
在你的情况下,它将是:
client.guilds.get('575957043211403265').channels.get('575957043211403267').send({ embed });
如果这不起作用,请在您的回复中包含错误,您可能遗漏了问题中的某些内容:)
我正在尝试制作一个日志脚本,但是我无法让它工作。有没有更好的方法?
我试过切换属性,但似乎不起作用。
client.on('message', message => {
var sender = message.member.user.tag
var channel = message.channel.name
var message = message.content
var server = message.guild
let embed = new Discord.RichEmbed()
.addField('**' + sender + '** said ' + message + ' in ' + channel + ', ' + server)
.setColor('#4286f4')
// This is the line I'm having problems with:
client.guilds.get('575957043211403265').channels.get('575957043211403267').sendEmbed(embed);
});
如果您使用的 ID 正确,那么您的代码应该是有效的,只要您使用 stable
分支 中的库。
您正在使用 TextChannel.sendEmbed()
method, which is deprecated: that means that it'll be removed in the future versions. If you installed the master
branch that method won't be available (check the docs here).
还有另一种发送嵌入的方法:
TextChannel.send({ embed: yourEmbed });
在你的情况下,它将是:
client.guilds.get('575957043211403265').channels.get('575957043211403267').send({ embed });
如果这不起作用,请在您的回复中包含错误,您可能遗漏了问题中的某些内容:)