Pm2 Ubuntu Discord Bot Not running:`语法错误:意外的标记“.”

cl25kdpy  于 2023-08-03  发布在  其他
关注(0)|答案(1)|浏览(107)

我最近用nodejs和pm2安装了我的服务器(unbuntu22.04)来运行我的discord bot。每当我尝试运行pm2 start时,我得到下面的错误,我没有得到这个错误之前。
pm2 5.3
djs 14.11

SyntaxError: Unexpected token '.'
    at wrapSafe (internal/modules/cjs/loader.js:915:16)
    at Module._compile (internal/modules/cjs/loader.js:963:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at Module.Hook._require.Module.require (/usr/local/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:101:39)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/root/ObjectionerBot/node_modules/discord.js/src/index.js:6:22)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
/root/ObjectionerBot/node_modules/discord.js/src/client/BaseClient.js:29
        userAgentAppendix: options.rest?.userAgentAppendix
                                        ^

字符串
这是文件位置:


的数据
这是我的索引文件(Pm2运行这个我相信):

const fs = require('fs');
const { Client, Collection, Events, GatewayIntentBits, EmbedBuilder, SlashCommandBuilder, Partials  } = require('discord.js');
const { token, incoming_messages } = require('./config.json');

const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers] });

client.commands = new Collection();
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));

for (const file of commandFiles) {
  const command = require(`./commands/${file}`);
  client.commands.set(command.data.name, command);
}

client.on('guildMemberAdd', (member) => {

      let welcome = Math.floor(Math.random() * incoming_messages.length)

      

      let NewMem = incoming_messages[welcome].replace("${member}", member)

      const E = new EmbedBuilder()
        .setTitle("**New Member**")
        .setDescription(NewMem)
        .setColor("#A020F0")
        .setTimestamp()
      
      console.log("MEMBER JOINED")
      member.roles.add([`951942010309345311`])
client.channels.cache.get("952666424436994078").send({ embeds: [E] });
});

client.once('ready', () => {
  console.log('System is yes!');
  const I = new EmbedBuilder()
    .setColor(`#0a9239`)
    .setTitle("**RESTART**")
    .setDescription(`The bot has restarted, this is normal or a update.`)
    .setTimestamp()

  

    client.channels.cache.get("952958463317794826").send({ embeds: [I] });
    client.user.setActivity("objectionstudios.com");
});

client.on('interactionCreate', async interaction => {
  if (!interaction.isCommand()) return;

  const command = client.commands.get(interaction.commandName);

  if (!command) return;

  try {
    await command.execute(interaction, client);
  } catch (error) {
    console.error(error);
    await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
  }
});

client.on(Events.InteractionCreate, interaction => {
    if (interaction.isButton()) {
    console.log(interaction.id)
 
  }
});

client.login(token);


如果有更多的相关信息,我可以补充,请通知我。

6l7fqoea

6l7fqoea1#

正如elitezen所说,我的节点运行v12而不是v16+已经过时了。
我按照这个指南更新了我的节点,因为ubuntu linux包含一个过时的版本:https://blog.hubspot.com/website/update-node-js
我通过更新它并重新启动该过程来修复此问题。

相关问题