【发布时间】:2018-07-02 07:14:34
【问题描述】:
这个错误是在我向公会发送消息后添加.catch 语句到Promises 后出现的。
快速说明:我的机器人正在尝试从它不再属于的公会中检索数据。
这是我的代码:
文件名:roleDelete.js
'use strict';
const Discord = require('discord.js');
const Error = require('debug')('Event:roleDelete:Error');
/**
* @param {object} client - The client instance
* @param {object} role - The deleted role object
*/
module.exports.run = (client, role) => {
let embed = new Discord.RichEmbed();
const guildID = role.guild.id;
const guildName = role.guild.name;
const guildIcon = role.guild.iconURL;
const modLog = client.guilds.get(guildID).channels.find('name', client.config.modLog);
const tempIcon = 'https://images-ext-2.discordapp.net/external/ouGhEoGzz1ZyBG9mMFrYClvdv9V0FZ0jGSEHa_kLLYk/https/discordapp.com/assets/0e291f67c9274a1abdddeb3fd919cbaa.png';
if (!modLog) return;
embed = new Discord.RichEmbed()
.setAuthor(guildName, guildIcon ? guildIcon : tempIcon)
.addField('Role Name', role.name, true)
.addField('Role Color', role.hexColor, true)
.addField('Role Hoisted', role.hoist, true)
.setFooter('Role Deleted At')
.setTimestamp()
.setColor(client.config.colors.red);
return modLog.send(embed).catch(err => Error(err));
};
其他信息:
bufferutil: 3.0.3
chalk: 2.3.0
clear: 0.0.1
debug: 3.1.0
discord.js: 11.3.0
dotenv: 4.0.0
firebase-admin: 5.8.1
moment: 2.20.1
opusscript: 0.0.6
预期结果:
Discord.JS ignores and no error is thrown.
当前结果:
2018-01-23T12:34:05.029Z Event:guildDelete Left Guild: 395928739201941506, removed into database.
2018-01-23T12:34:05.212Z Event:roleDelete:Error DiscordAPIError: Missing Access
at item.request.gen.end (/app/node_modules/discord.js/src/client/rest/RequestHandlers/Sequential.js:71:65)
at then (/app/node_modules/snekfetch/src/index.js:218:21)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
2018-01-23T12:34:05.255Z Event:guildMemberRemove:Error DiscordAPIError: Missing Access
at item.request.gen.end (/app/node_modules/discord.js/src/client/rest/RequestHandlers/Sequential.js:71:65)
at then (/app/node_modules/snekfetch/src/index.js:218:21)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7
有什么办法可以忽略它已经离开的事实,完全忽略它?
【问题讨论】:
标签: node.js discord discord.js