【问题标题】:discordjs how to console log message without dmsdiscordjs如何在没有dms的情况下控制台日志消息
【发布时间】:2019-12-26 01:38:52
【问题描述】:

我希望我的机器人打印发送到服务器的消息,但是当该机器人发送 dm 时它会打印它。

client.on('message', message => {
    console.log(chalk.yellow(`[CHAT] `) + 
        chalk.bold.magentaBright(`[${message.guild.name}] `) + 
        chalk.bold.white(`User: ${message.author.username} ` +
            `Said: ${message.content} In: ${message.channel.name}`))
    }
});

【问题讨论】:

  • 您能否澄清一下:您认为发生了什么?你的问题呢?您希望您的机器人打印它收到的 DM 消息,但现在不需要,是这样吗?

标签: discord discord.js


【解决方案1】:

您可以忽略来自用户的所有 DM 消息

if (message.channel.type === 'dm') return;

添加到bot on message block

client.on('message', message => {
if (message.channel.type === 'dm') return;
console.log(chalk.yellow([CHAT]) + chalk.bold.magentaBright([${message.guild.name}]) + chalk.bold.white(User: ${message.author.username} Said: ${message.content} In: ${message.channel.name})) } 
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-03-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-08
    • 1970-01-01
    相关资源
    最近更新 更多