My brain is so massive

This commit is contained in:
Erik 2023-12-05 22:49:44 +02:00
parent 2fad9cc2d2
commit a637f1df22
2 changed files with 41 additions and 11 deletions

View File

@ -132,6 +132,37 @@ export type InfractionType =
| 'DELETE';
export enum CommandOptionType {
SUB_COMMAND = 'SUB_COMMAND',
SUB_COMMAND_GROUP = 'SUB_COMMAND_GROUP',
ROLES = 'ROLES', // Note plurality, strings can parse users, roles, and channels.
MEMBERS = 'MEMBERS',
USERS = 'USERS',
CHANNELS = 'CHANNELS',
TEXT_CHANNELS = 'TEXT_CHANNELS',
VOICE_CHANNELS = 'VOICE_CHANNELS',
TIME = 'TIME', // timestring
DATE = 'DATE',
COMPONENT = 'COMPONENT',
COMPONENTS = 'COMPONENTS',
COMMAND = 'COMMAND',
COMMANDS = 'COMMANDS',
MODULE = 'MODULE',
STRING = 'STRING',
INTEGER = 'INTEGER',
BOOLEAN = 'BOOLEAN',
MEMBER = 'MEMBER',
USER = 'USER',
TEXT_CHANNEL = 'TEXT_CHANNEL',
VOICE_CHANNEL = 'VOICE_CHANNEL',
CHANNEL = 'CHANNEL',
ROLE = 'ROLE',
MENTIONABLE = 'MENTIONABLE',
NUMBER = 'NUMBER',
FLOAT = 'FLOAT',
POINTS = 'POINTS'
}
export enum DiscordCommandOptionType {
SUB_COMMAND = 1,
SUB_COMMAND_GROUP = 2,
ROLES = 3, // Note plurality, strings can parse users, roles, and channels.

View File

@ -1,11 +1,7 @@
/* eslint-disable camelcase */
// const { ChannelType } = require("discord.js");
// const { Util } = require("../../utilities");
import { Util } from '../../utilities/index.js';
import DiscordClient from '../DiscordClient.js';
import { CommandOptionChoices, CommandOptionParams, CommandOptionShape, CommandOptionType, DependsOnMode, FormatOpts, FormatParams, RawCommandOption } from '../../../@types/Client.js';
import { CommandOptionChoices, CommandOptionParams, CommandOptionShape, CommandOptionType, DependsOnMode, DiscordCommandOptionType, FormatOpts, FormatParams, RawCommandOption } from '../../../@types/Client.js';
import { GuildWrapper } from '../components/wrappers/index.js';
import Component from './Component.js';
import Command from './commands/Command.js';
@ -246,11 +242,11 @@ class CommandOption
// console.log('-------PARSE BEGIN---------');
// console.log('1', this.name, this.#rawValue, this.valueOptional);
const { removed, value, error, index, params } = await this.types[this.type]();
if (this.valueOptional && error)
if (this.valueOptional && error)
{
this.#value = this.defaultValue;
}
else
else
{
if (error)
return { error, index, params };
@ -278,13 +274,13 @@ class CommandOption
get types ()
{
return {
POINTS: async () =>
POINTS: async () =>
{
if (this.slashOption)
return { value: this.#rawValue };
let value = null,
removed = null;
if (!this.#rawValue)
if (!this.#rawValue)
throw new Error('No rawValue supplied');
if (!(this.#rawValue instanceof Array))
throw new Error('Invalid rawValue');
@ -967,13 +963,16 @@ class CommandOption
this.#aliased = val;
}
get shape (): CommandOptionShape
get shape (): CommandOptionShape
{
const cmdType = CommandOptionType[this.#type];
const type = DiscordCommandOptionType[this.#type];
if (!type)
throw new Error('Invalid command type: ' + type);
return {
name: this.#name,
description: this.#description,
type: this.#type,
type,
required: this.#required,
choices: this.#choices,
options: this.#options.map((o) => o.shape as CommandOptionShape),