【发布时间】:2020-12-17 17:37:33
【问题描述】:
我开发了规则系统,但是有一个问题。当我输入 !rule 1 时,我想发送 rule 1 ,但错误提示:Cannot send an empty message
有代码:
const Discord = require('discord.js');
const fs = require('fs')
module.exports = {
name: 'rules',
guildOnly: true,
async execute(message, args) {
const rules = JSON.parse(fs.readFileSync("./rules.json", 'utf8'));
message.channel.send(rules.args.slice(1).join(" "))
}
}
json 文件:
{
"rule1": "**Admins and Discord Mods have the final judgement. If asked to stop, stop.**",
"rule2": "Be respectful, civil, and welcoming. Sometimes discussion can get heated, but you are responsible for your own behavior.",
"rule3": "No insults, racism, sexism, homophobia, transphobia, and other kinds of discriminatory speech. We do not welcome these types of speech.",
"rule4": "No NSFW content (including chat, avatars, and nicknames).",
"rule5": "Do not join the server to promote your content.\nDo not advertise streams, YouTube channels, Discord servers, Reddit posts, and referral links.",
"rule6": "Unsolicited advertisements sent to members via private messages will result in instant removal from the server.",
"rule7": "Do not solicit, buy, sell, trade, give away, or beg for accounts, cheats, **boosting**, RP, codes, money, referrals, or other goods.",
"rule8": "This is not a dating server: e-dating, fawning, excessive flirting, role-playing, and other similar behavior are not allowed.",
"rule9": ""
}
【问题讨论】:
-
args不是规则对象的属性。 -
知道如何解决
标签: javascript discord.js