【发布时间】:2020-10-30 05:57:37
【问题描述】:
昨晚我重写了我的 index.js,现在它不再执行命令了。我尝试更新和降级我的 discord.js 版本,但没有任何改变,我尝试使用旧的 index.js,但由于某种原因也不起作用。
这是我的 index.js:
const {Client} = require('discord.js')
const bot = new Client()
const prefix = "%";
const owners = [''];
bot.login('')
bot.on('ready', (msg) => {
console.log(`${bot.user.tag}: [${new Date(Date.now()).toUTCString()}]`);
});
bot.on("message", async (message) => {
if(!message.author.bot) return;
if(!message.content.startsWith(prefix)) return;
let args = message.content.slice(prefix.length).trim().split(/ +/g);
let path = `./commands/${args.shift().toLowerCase()}.js`;
if(!require("fs").existsSync(path)) return;
const command = require(path);
if(!command.ownersOnly) command.run(bot, message, args);
else {return message.channel.send('You are not allowed to do that!')}
});
bot.on('message', (msg) => {
if(msg.content === "prefix") {
msg.reply("Prefix: " + prefix)
}
});
bot.on("messageDelete", (m) => {
if(m.author.bot) return
const path = __dirname + "/snipe.json"
let snipeFile = require(path)
snipeFile[m.channel.id] = [m.author.id, m.content, m.attachments.first() ? m.attachments.first().proxyURL : undefined]
require("fs").writeFileSync(path, JSON.stringify(snipeFile, null, 2))
});
谢谢!
【问题讨论】:
-
如果你在任何频道上写它,它会回复前缀吗?
-
是的,确实如此……
标签: javascript node.js discord discord.js