!obfuscate 命令 Discord Bot

时间:2021-04-14 17:17:48

标签: javascript discord

我目前正在为我的剥削社区制作一个不和谐的机器人。我正在尝试为 Roblox Lua 制作一个 !obfuscate 命令。我已经尝试了很多东西,但我似乎无法做对。我在这里只看到 1 个可以接收文件的 Discord Bot 线程。例如,我执行命令“!混淆”。这样做之后,它会发送一个嵌入,说你必须发送一个文件。我发送了一个文件,但我不断收到错误消息。这是我的代码。

module.exports = {
    name: 'obfuscate',
    description: "obfuscates your files",
    execute(message, args, Discord){
    const exampleEmbed = new Discord.MessageEmbed()
    .setColor('#0099ff')
    .setTitle('CypherBrew Obfuscator')
    .setDescription('To obfuscate, please send a file with the extension, .txt or .lua. If not, obfuscation will not work.')
    .setFooter('If you want this to be private, please DM the bot.');
    message.channel.send(exampleEmbed);
    let filter = m => m.author == message.author;
    message.channel.awaitMessages(filter, {max: 1}).then(message => {
    let file = message.attachments.first().file;
    if (!file) return;
      fs.readFile(file, (err, data) => {
            const nooo = new Discord.MessageEmbed()
            .setColor('#0099ff')
            .setTitle('CypherBrew Obfuscator')
            .setDescription('File has been obfuscated! Thank you for using CypherBrew Obfuscator.')
            .setFooter('Epic, you obfuscated a file. lol.');
            message.Channel.send(nooo);
            message.Channel.send(data);
      });
    });
    }
}

我的错误是这个。 “类型错误:无法读取未定义的‘first’属性”。我从 2 年前的帖子中获得了代码,但 Discord JS 已更新。我一直在寻找服务器和人,并在他们身上问我同样的问题,但我从来没有得到一个好的答案。他们中的大多数都坏了。如果你帮助我,谢谢。

0 个答案:

没有答案