【发布时间】:2021-09-03 17:45:28
【问题描述】:
似乎无法让它工作。如您在此代码中所见,尝试了多种方式。我尝试了我能或至少知道的。我对此有点陌生,所以这对我来说有点难,我不明白错误想说什么!
我尝试了VIEW_CHANNEL 和VIEW_CHANNELS,但它们似乎都不起作用
const Discord = require("discord.js")
const ms = require('ms');
module.exports = {
name: 'ticket',
usage: '%ticket <reason>',
description: 'makes a ticket',
async execute(client, message, args, cmd, discord) {
const channel = await message.guild.channels.create(`ticket: ${message.author}`);
channel.setParent('855596395783127081');
channel.overwritePermissions([{
id: channel.guild.roles.everyone,
deny: ['VIEW_CHANNELS'],
}, ]);
channel.overwritePermissions([{
id: message.author.id,
allow: ['VIEW_CHANNELS'],
}]);
channel.overwritePermissions([{
id: channel.guild.roles.everyone,
deny: ['SEND_MESSAGES'],
},
{
id: message.author.id,
allow: ['SEND_MESSAGES'],
},
]);
'SEND_MESSAGES'
const reactionMessage = await channel.send(`Thank you for contacting support! A staff member will be with you as soon as possible`);
try {
await reactionMessage.react("????");
await reactionMessage.react("⛔");
} catch (err) {
channel.send(`Error Sending Emojis`);
throw err;
}
const collector = reactionMessage.createReactionCollector((reaction, user) =>
message.guild.member.cache.find((member) => member.id === userid).hasPermission('ADMINISTRATOR'), { dispose: true }
);
collector.on('collect', (reaction, user) => {
switch (reaction.emoji.name) {
case "????":
channel.overwritePermissions([{
id: message.author.id,
deny: ['SEND_MESSAGES']
}, ]);
break;
case "⛔":
message.channel.send('Deleteing ticket in 5 seconds');
setTimeout(() => channel.delete(), 5000);
break;
}
});
message.channel.send(`We will be right with you! ${channel}`).then((msg) => {
setTimeout(() => msg.delete(), 7000);
setTimeout(() => message.delete(), 3000);
}).catch((err) => {
throw err;
})
}
}
这是错误
PS C:\Users\lolzy\OneDrive\Desktop\discordbot> node .
Cbs slave is online!
(node:18012) UnhandledPromiseRejectionWarning: RangeError [BITFIELD_INVALID]: Invalid bitfield flag or number.
at Function.resolve (C:\Users\lolzy\OneDrive\Desktop\discordbot\node_modules\discord.js\src\util\BitField.js:150:19)
at C:\Users\lolzy\OneDrive\Desktop\discordbot\node_modules\discord.js\src\util\BitField.js:148:54
at Array.map (<anonymous>)
at Function.resolve (C:\Users\lolzy\OneDrive\Desktop\discordbot\node_modules\discord.js\src\util\BitField.js:148:40)
at Function.resolve (C:\Users\lolzy\OneDrive\Desktop\discordbot\node_modules\discord.js\src\structures\PermissionOverwrites.js:184:25)
at C:\Users\lolzy\OneDrive\Desktop\discordbot\node_modules\discord.js\src\structures\GuildChannel.js:341:87
at Array.map (<anonymous>)
at TextChannel.edit (C:\Users\lolzy\OneDrive\Desktop\discordbot\node_modules\discord.js\src\structures\GuildChannel.js:341:57)
at TextChannel.overwritePermissions (C:\Users\lolzy\OneDrive\Desktop\discordbot\node_modules\discord.js\src\structures\GuildChannel.js:212:17)
at Object.execute (C:\Users\lolzy\OneDrive\Desktop\discordbot\commands\ticket.js:13:17)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:18012) 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: 3)
(node:18012) [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.
(node:18012) UnhandledPromiseRejectionWarning: RangeError [BITFIELD_INVALID]: Invalid bitfield flag or number.
at Function.resolve (C:\Users\lolzy\OneDrive\Desktop\discordbot\node_modules\discord.js\src\util\BitField.js:150:19)
at C:\Users\lolzy\OneDrive\Desktop\discordbot\node_modules\discord.js\src\util\BitField.js:148:54
at Array.map (<anonymous>)
at Function.resolve (C:\Users\lolzy\OneDrive\Desktop\discordbot\node_modules\discord.js\src\util\BitField.js:148:40)
at Function.resolve (C:\Users\lolzy\OneDrive\Desktop\discordbot\node_modules\discord.js\src\structures\PermissionOverwrites.js:183:26)
at C:\Users\lolzy\OneDrive\Desktop\discordbot\node_modules\discord.js\src\structures\GuildChannel.js:341:87
at Array.map (<anonymous>)
at TextChannel.edit (C:\Users\lolzy\OneDrive\Desktop\discordbot\node_modules\discord.js\src\structures\GuildChannel.js:341:57)
at TextChannel.overwritePermissions (C:\Users\lolzy\OneDrive\Desktop\discordbot\node_modules\discord.js\src\structures\GuildChannel.js:212:17)
at Object.execute (C:\Users\lolzy\OneDrive\Desktop\discordbot\commands\ticket.js:18:17)
(node:18012) 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: 4)
【问题讨论】:
标签: javascript node.js discord.js