【问题标题】:having trouble sending discord "say" command message argument发送不和谐的“say”命令消息参数时遇到问题
【发布时间】:2021-07-09 01:27:58
【问题描述】:

所以,我正在使用 discord.js 编写一个不和谐机器人,并且我正在制作一个“说”命令。看了几个教程,没用,问了几个朋友,一无所获。这是文件的代码:

const Discord = require('discord.js');

module.exports = {
    name: 'say',
    description: "Says message",

    async run (client, message, args) {


        if(!message.member.hasPermission("MANAGE_MESSAGES")) return message.channel.send('????You dont have the permissions to do this command!????')
        if(!message.guild.me.hasPermission("MANAGE_MESSAGES")) return message.channel.send('????Sorry, it seems I dont have the permissions to do that command.????')


        if(!args[0]) return message.reply('please tell me what to say.');

        message.channel.send(`${args.join(" ")}`);
    }
}


有谁知道我怎样才能使它真正起作用?谢谢!

【问题讨论】:

  • 另外,我还不太擅长 JS,以防你们中的任何人想知道我是如何让它不起作用的。
  • 谢谢,但我遇到的问题是保存用户发送的消息并使用机器人发送该消息。抱歉没有那么具体。我现在解决这个问题。
  • 您是否遇到任何错误?
  • 如果不提供错误,很难知道出了什么问题。
  • 你能告诉我们调用命令的代码吗?

标签: javascript discord.js arguments command


【解决方案1】:

我不确定,但可能是因为您没有在模块中包含参数。

module.exports = {
    name: 'say',
    description: "Says message",

    args: true,

参数:真

【讨论】:

  • argsrun(...) 参数中
  • 我知道...但是您必须在 args 中设置为 true。你试过了吗?
  • 没有命令处理程序,包括由Discord.JS 正式提出的处理程序,需要将args 的键设置为true。这将如何影响函数的执行。
猜你喜欢
  • 2012-12-07
  • 1970-01-01
  • 2021-04-29
  • 2020-11-07
  • 2019-02-04
  • 2020-11-23
  • 1970-01-01
  • 2018-12-15
  • 1970-01-01
相关资源
最近更新 更多