DiscordAPIErrorL:缺少访问权限

时间:2021-05-24 01:18:06

标签: javascript node.js

我似乎无法弄清楚我的代码的问题。我没有看到任何错误,但是当它加入服务器时,它会出错并可能停止运行。我将不胜感激!

index.js

const Discord = require('discord.js');
const client = new Discord.Client();
const KeepAlive = require('./server');

client.on('message', function (msg) {
    const Logged = new Discord.MessageEmbed()
        .setTitle(msg.author.tag)
        .setDescription(msg.content)
        .setColor('0x00AAFF')
        .setTimestamp();

    if(msg.author.id === 'BOT-ID-GOES-HERE') {
        console.log('')
    } else if(msg.author.username) {
        const channel = client.channels.cache.find(channel => channel.name === 'logs')
        channel.send(Logged)
    }
});

client.on('ready', ()=> {
console.log('Connected as '+client.user.tag)
});

KeepAlive()
client.login(process.env.token);

server.js

const express = require('express')

const server = express()

server.all('/', (req, res) => {
res.send('Bot is running!')
});

function KeepAlive() {
    server.listen(671, () => {});
    console.log('Server is ready!')
}

module.exports = KeepAlive

现在错误是

(node:313) UnhandledPromiseRejectionWarning: DiscordAPIError: Missing Access
    at RequestHandler.execute (/home/runner/Censored-Logging/node_modules/discord.js/src/rest/RequestHandler.js:154:13)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async RequestHandler.push (/home/runner/Censored-Logging/node_modules/discord.js/src/rest/RequestHandler.js:39:14)
(node:313) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:313) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

我还是个新手,有错误,我无法正确阅读。

0 个答案:

没有答案