Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@johndavisdev/discord-emcee

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@johndavisdev/discord-emcee - npm Package Compare versions

Comparing version 1.15.0 to 1.16.0

test/ui/DiscordSelectables.spec.ts

2

dist/cjs/package.json
{
"name": "@johndavisdev/discord-emcee",
"version": "1.14.0",
"version": "1.15.0",
"description": "A library for easily building user interfaces on top of the Discord MessageComponent APIs.",

@@ -5,0 +5,0 @@ "main": "dist/esm/index.js",

@@ -11,3 +11,3 @@ "use strict";

}
let options = input.values.map((v) => createOptionValue(v, selectedValue));
let options = input.options.map((v) => createOptionValue(v, selectedValue));
eb.addOptions(options);

@@ -14,0 +14,0 @@ eb.setDisabled(input.disabled ?? false);

@@ -90,4 +90,4 @@ import { ButtonStyle } from 'discord.js';

type: 'Option';
options: IOption<T>[];
placeholder?: string;
values: IOption<T>[];
value?: T | null;

@@ -94,0 +94,0 @@ disabled?: boolean;

@@ -90,4 +90,4 @@ import { ButtonStyle } from 'discord.js';

type: 'Option';
options: IOption<T>[];
placeholder?: string;
values: IOption<T>[];
value?: T | null;

@@ -94,0 +94,0 @@ disabled?: boolean;

@@ -90,4 +90,4 @@ import { ButtonStyle } from 'discord.js';

type: 'Option';
options: IOption<T>[];
placeholder?: string;
values: IOption<T>[];
value?: T | null;

@@ -94,0 +94,0 @@ disabled?: boolean;

@@ -90,4 +90,4 @@ import { ButtonStyle } from 'discord.js';

type: 'Option';
options: IOption<T>[];
placeholder?: string;
values: IOption<T>[];
value?: T | null;

@@ -94,0 +94,0 @@ disabled?: boolean;

@@ -8,3 +8,3 @@ import { StringSelectMenuOptionBuilder, StringSelectMenuBuilder } from 'discord.js';

}
let options = input.values.map((v) => createOptionValue(v, selectedValue));
let options = input.options.map((v) => createOptionValue(v, selectedValue));
eb.addOptions(options);

@@ -11,0 +11,0 @@ eb.setDisabled(input.disabled ?? false);

@@ -15,4 +15,4 @@ import { ButtonStyle, ButtonInteraction, StringSelectMenuInteraction, InteractionUpdateOptions, InteractionResponse, UserSelectMenuInteraction } from 'discord.js';

type: 'Option';
options: IOption<T>[];
placeholder?: string;
values: IOption<T>[];
value?: T | null;

@@ -19,0 +19,0 @@ disabled?: boolean;

{
"name": "@johndavisdev/discord-emcee",
"version": "1.15.0",
"version": "1.16.0",
"description": "A library for easily building user interfaces on top of the Discord MessageComponent APIs.",

@@ -5,0 +5,0 @@ "main": "dist/esm/index.js",

@@ -22,4 +22,4 @@ import {

type: 'Option';
options: IOption<T>[];
placeholder?: string;
values: IOption<T>[];
value?: T | null;

@@ -26,0 +26,0 @@ disabled?: boolean;

@@ -6,4 +6,3 @@ import {

OptionStateInput,
UserStateInput,
User
UserStateInput
} from './Shared';

@@ -10,0 +9,0 @@

@@ -16,3 +16,3 @@ import {

}
let options = input.values.map((v) => createOptionValue(v, selectedValue));
let options = input.options.map((v) => createOptionValue(v, selectedValue));
eb.addOptions(options);

@@ -19,0 +19,0 @@ eb.setDisabled(input.disabled ?? false);

@@ -16,3 +16,3 @@ import { ButtonStyle } from 'discord.js';

const o = sb.optionInput<ModelType>({
values: [
options: [
{ label: 'ChatGPT4', value: 'ChatGPT4', result: 'ChatGPT4' },

@@ -45,3 +45,3 @@ { label: 'ChatGPT3', value: 'ChatGPT3', result: 'ChatGPT3' }

value: 'ChatGPT4',
values: [
options: [
{ label: 'ChatGPT4', value: 'ChatGPT4', result: 'ChatGPT4' },

@@ -65,5 +65,5 @@ { label: 'ChatGPT3', value: 'ChatGPT3', result: 'ChatGPT3' }

expect(io.placeholder).toBe('Select Model');
expect(io.values[0]).toStrictEqual({ label: 'ChatGPT4', value: 'ChatGPT4', result: 'ChatGPT4' });
expect(io.values[1]).toStrictEqual({ label: 'ChatGPT3', value: 'ChatGPT3', result: 'ChatGPT3' });
expect(io.options[0]).toStrictEqual({ label: 'ChatGPT4', value: 'ChatGPT4', result: 'ChatGPT4' });
expect(io.options[1]).toStrictEqual({ label: 'ChatGPT3', value: 'ChatGPT3', result: 'ChatGPT3' });
});
});

@@ -11,3 +11,3 @@ import { createUI as _createUI, createUI, createUIInput } from '../../src/ui/Frame';

const o = sb.optionInput<ModelType>({
values: [
options: [
{ label: 'ChatGPT4', value: 'ChatGPT4', result: 'ChatGPT4' },

@@ -14,0 +14,0 @@ { label: 'ChatGPT3', value: 'ChatGPT3', result: 'ChatGPT3' }

import { createOption } from '../../src/ui/Option';
import { IOption, OptionStateInput } from '../../src/Shared';
import { ComponentType, APIStringSelectComponent, StringSelectMenuComponent } from 'discord.js';
import { ComponentType, APIStringSelectComponent } from 'discord.js';
import { cMatches } from './Utils';
type Modes = '1' | '2';
let op1: IOption<Modes> = {result: '1'};
let op2: IOption<Modes> = {result: '2'};
const MinimalOptionState: OptionStateInput<Modes> = {
id: 'mode',
type: 'Option',
options: [op1, op2]
}
const OptionStateWithOptionals: OptionStateInput<Modes> = {
...MinimalOptionState,
placeholder: 'Select Me Please',
value: '1',
disabled: true
}
const getSelected = (c: APIStringSelectComponent): string | null => {
const se = c.options.filter(op => op.default);
if (se.length === 0) {
return null;
}
return se[0].value;
}
describe('createOption', () => {
test('creates correct selectmenu with defaults', () => {
let op1: IOption<string> = {result: '1'};
let op2: IOption<string> = {result: '2'};
const defaultConfig: OptionStateInput<string> = {
id: 'mode',
type: 'Option',
values: [ op1, op2 ]
}
const optionWithDefaults = createOption(defaultConfig, op1).toJSON();
const optionWithDefaults = createOption(MinimalOptionState, op1).toJSON();
cMatches({

@@ -23,19 +39,28 @@ custom_id: 'mode',

expect(optionWithDefaults.options.length).toBe(2);
});
test('creates correct selectmenu with optionals', () => {
const optionWithDefaults = createOption(OptionStateWithOptionals, op2).toJSON();
cMatches({
placeholder: 'Select Me Please',
disabled: true
}, optionWithDefaults);
expect(optionWithDefaults.options.length).toBe(2);
expect(getSelected(optionWithDefaults)).toBe(op2.result);
});
test('uses placeholder if provided', () => {
test('disables when instructed', () => {
let op1: IOption<string> = {result: '1'};
let op2: IOption<string> = {result: '2'};
const defaultConfig: OptionStateInput<string> = {
const disabledConfig: OptionStateInput<string> = {
id: 'eagerMode',
type: 'Option',
values: [ op1, op2 ],
placeholder: 'Select Me Please'
options: [ op1, op2 ],
disabled: true
}
const optionWithDefaults = createOption(defaultConfig, op1).toJSON();
const optionWithDefaults = createOption(disabledConfig, op1).toJSON();
cMatches({
placeholder: 'Select Me Please',
disabled: true
}, optionWithDefaults);

@@ -49,16 +74,12 @@ expect(optionWithDefaults.options.length).toBe(2);

let op2: IOption<string> = {result: '2'};
const defaultConfig: OptionStateInput<string> = {
const noValueConfig: OptionStateInput<string> = {
id: 'eagerMode',
type: 'Option',
value: '2',
values: [ op1, op2 ],
options: [ op1, op2 ],
placeholder: 'Select Me Please'
}
const optionWithDefaults = createOption(defaultConfig, undefined).toJSON();
expect(optionWithDefaults.options[0].default).toBeFalsy();
expect(optionWithDefaults.options[1].default).toBeTruthy();
expect(optionWithDefaults.options.length).toBe(2);
const op = createOption(noValueConfig, undefined).toJSON();
expect(getSelected(op)).toBe('2');
});
});

@@ -1,4 +0,5 @@

import { APIButtonComponent, APIStringSelectComponent, APISelectMenuOption } from 'discord.js';
import { APIButtonComponent, APIStringSelectComponent, APISelectMenuOption, APIUserSelectComponent, APIChannelSelectComponent, APIRoleSelectComponent, APIMentionableSelectComponent } from 'discord.js';
type C = APIButtonComponent | APIStringSelectComponent | APISelectMenuOption;
type C = APIButtonComponent | APIStringSelectComponent | APISelectMenuOption |
APIUserSelectComponent | APIChannelSelectComponent | APIRoleSelectComponent | APIMentionableSelectComponent;
function cMatches<T extends C>(expected: Partial<C>, actual: C): boolean {

@@ -5,0 +6,0 @@ let e = expected as Record<string, any>;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc