feat: interactions (#5448)

Co-authored-by: izexi <43889168+izexi@users.noreply.github.com>
Co-authored-by: Sugden <28943913+NotSugden@users.noreply.github.com>
Co-authored-by: Advaith <advaithj1@gmail.com>
Co-authored-by: Shiaupiau <stu43005@gmail.com>
Co-authored-by: monbrey <rsm999@uowmail.edu.au>
Co-authored-by: Tiemen <ThaTiemsz@users.noreply.github.com>
Co-authored-by: Carter <carter@elhnet.net>
This commit is contained in:
Jan
2021-05-07 17:22:33 +02:00
committed by GitHub
parent af00ec8970
commit f7643f7bbe
24 changed files with 1340 additions and 35 deletions

View File

@@ -271,6 +271,7 @@ exports.Events = {
TYPING_START: 'typingStart',
TYPING_STOP: 'typingStop',
WEBHOOKS_UPDATE: 'webhookUpdate',
INTERACTION_CREATE: 'interaction',
ERROR: 'error',
WARN: 'warn',
DEBUG: 'debug',
@@ -343,6 +344,7 @@ exports.PartialTypes = keyMirror(['USER', 'CHANNEL', 'GUILD_MEMBER', 'MESSAGE',
* * VOICE_STATE_UPDATE
* * VOICE_SERVER_UPDATE
* * WEBHOOKS_UPDATE
* * INTERACTION_CREATE
* @typedef {string} WSEventType
*/
exports.WSEvents = keyMirror([
@@ -382,6 +384,7 @@ exports.WSEvents = keyMirror([
'VOICE_STATE_UPDATE',
'VOICE_SERVER_UPDATE',
'WEBHOOKS_UPDATE',
'INTERACTION_CREATE',
]);
/**
@@ -434,6 +437,7 @@ exports.InviteScopes = [
* * GUILD_DISCOVERY_GRACE_PERIOD_INITIAL_WARNING
* * GUILD_DISCOVERY_GRACE_PERIOD_FINAL_WARNING
* * REPLY
* * APPLICATION_COMMAND
* @typedef {string} MessageType
*/
exports.MessageTypes = [
@@ -457,15 +461,19 @@ exports.MessageTypes = [
'GUILD_DISCOVERY_GRACE_PERIOD_FINAL_WARNING',
null,
'REPLY',
'APPLICATION_COMMAND',
];
/**
* The types of messages that are `System`. The available types are `MessageTypes` excluding:
* * DEFAULT
* * REPLY
* * APPLICATION_COMMAND
* @typedef {string} SystemMessageType
*/
exports.SystemMessageTypes = exports.MessageTypes.filter(type => type && type !== 'DEFAULT' && type !== 'REPLY');
exports.SystemMessageTypes = exports.MessageTypes.filter(
type => type && !['DEFAULT', 'REPLY', 'APPLICATION_COMMAND'].includes(type),
);
/**
* <info>Bots cannot set a `CUSTOM_STATUS`, it is only for custom statuses received from users</info>
@@ -742,6 +750,64 @@ exports.StickerFormatTypes = createEnum([null, 'PNG', 'APNG', 'LOTTIE']);
*/
exports.OverwriteTypes = createEnum(['role', 'member']);
/**
* The type of an {@link ApplicationCommandOption} object:
* * SUB_COMMAND
* * SUB_COMMAND_GROUP
* * STRING
* * INTEGER
* * BOOLEAN
* * USER
* * CHANNEL
* * ROLE
* * MENTIONABLE
* @typedef {string} ApplicationCommandOptionType
*/
exports.ApplicationCommandOptionTypes = createEnum([
null,
'SUB_COMMAND',
'SUB_COMMAND_GROUP',
'STRING',
'INTEGER',
'BOOLEAN',
'USER',
'CHANNEL',
'ROLE',
'MENTIONABLE',
]);
/**
* The type of an {@link ApplicationCommandPermissions} object:
* * ROLE
* * USER
* @typedef {string} ApplicationCommandPermissionType
*/
exports.ApplicationCommandPermissionTypes = createEnum([null, 'ROLE', 'USER']);
/**
* The type of an {@link Interaction} object:
* * PING
* * APPLICATION_COMMAND
* @typedef {string} InteractionType
*/
exports.InteractionTypes = createEnum([null, 'PING', 'APPLICATION_COMMAND']);
/**
* The type of an interaction response:
* * PONG
* * CHANNEL_MESSAGE_WITH_SOURCE
* * DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE
* @typedef {string} InteractionResponseType
*/
exports.InteractionResponseTypes = createEnum([
null,
'PONG',
null,
null,
'CHANNEL_MESSAGE_WITH_SOURCE',
'DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE',
]);
function keyMirror(arr) {
let tmp = Object.create(null);
for (const value of arr) tmp[value] = value;