diff --git a/packages/cocoa-discord/CHANGELOG.md b/packages/cocoa-discord/CHANGELOG.md index 02e3da1..213ef57 100644 --- a/packages/cocoa-discord/CHANGELOG.md +++ b/packages/cocoa-discord/CHANGELOG.md @@ -12,10 +12,12 @@ See also: [GitHub Releases](https://github.com/Leomotors/cocoa-discord/releases) - Some pre-release or beta build may not appear here -## [3.0.0] - 2023-07-17 +## [3.0.0] - 2023-??-?? - refactor: Package is now pure ESM -- feat: use `.set()` for syncing commands +- refactor: use `.set()` for syncing commands +- Deprecated Removed: `CocoaIntent`, add Singular methods, etc. +- Rename CocoaIntent.useGuildSlash to CocoaIntent.useGuild ## [2.3.0] - 2022-09-18 diff --git a/packages/cocoa-discord/src/base/Center.ts b/packages/cocoa-discord/src/base/Center.ts index 99bb08a..9457315 100644 --- a/packages/cocoa-discord/src/base/Center.ts +++ b/packages/cocoa-discord/src/base/Center.ts @@ -40,12 +40,6 @@ export abstract class ManagementCenter< store.subscribe("login", this.validateCommands.bind(this)); } - /** @deprecated Use `addCogs` instead */ - addCog(cog: Cog | CogClass) { - this.validated = false; - this.cogs.push(cog); - } - addCogs(...cogs: NonEmptyArray) { this.validated = false; this.cogs.push(...cogs); diff --git a/packages/cocoa-discord/src/main/embed.ts b/packages/cocoa-discord/src/main/embed.ts index 804bdc6..0793a2f 100644 --- a/packages/cocoa-discord/src/main/embed.ts +++ b/packages/cocoa-discord/src/main/embed.ts @@ -3,29 +3,10 @@ import { EmbedBuilder } from "discord.js"; // #region CocoaEmbed /** - * Like Embed but has method addField, addInlineField and addInlineFields, - * 2rd and 3rd methods allow you to save a line of `inline: true` + * Extended {@link EmbedBuilder} with {@link addInlineFields}. + * This allow you to save a line of `inline: true` */ export class CocoaEmbed extends EmbedBuilder { - /** - * Add a single field - * - * @deprecated use `addFields` instead - */ - addField(field: APIEmbedField) { - return this.addFields([field]); - } - - /** - * Adds a field to the embed (max 25), automatically set inline to true - * - * @deprecated use `AddInlineFields` instead - */ - addInlineField(field: Omit) { - (field as APIEmbedField).inline = true; - return this.addFields(field); - } - /** Adds fields to the embed (max 25), automatically set inline to true */ addInlineFields(...fields: Array>) { return this.addFields( diff --git a/packages/cocoa-discord/src/message/MessageCenter.ts b/packages/cocoa-discord/src/message/MessageCenter.ts index 8b1ce55..b06a1ec 100644 --- a/packages/cocoa-discord/src/message/MessageCenter.ts +++ b/packages/cocoa-discord/src/message/MessageCenter.ts @@ -159,7 +159,7 @@ export class MessageCenter extends ManagementCenter< this.validated = false; const emb = this.generateHelpCommandAsEmbed(); - this.addCog({ + this.addCogs({ name: "Help", commands: { help: { diff --git a/packages/cocoa-discord/src/message/class/index.ts b/packages/cocoa-discord/src/message/class/index.ts index e4f9d9f..79fae9e 100644 --- a/packages/cocoa-discord/src/message/class/index.ts +++ b/packages/cocoa-discord/src/message/class/index.ts @@ -10,7 +10,7 @@ const muckStorage: { [cogName: string]: commandsDict } = {}; /** * This class implements `CogMessage`, by OOP magic, you can use * ```js - * addCog(new [your_extended_classname]()) + * addCogs(new [your_extended_classname]()) * ``` */ export abstract class CogMessageClass implements CogMessage { diff --git a/packages/cocoa-discord/src/slash/class/cog.ts b/packages/cocoa-discord/src/slash/class/cog.ts index da3dd7b..5e08f5b 100644 --- a/packages/cocoa-discord/src/slash/class/cog.ts +++ b/packages/cocoa-discord/src/slash/class/cog.ts @@ -15,7 +15,7 @@ import { muckFuture, muckStorage } from "./legacy.js"; /** * This class implements `CogSlash`, by OOP magic, you can use * ```js - * addCog(new [your_extended_classname]()) + * addCogs(new [your_extended_classname]()) * ``` */ export abstract class CogSlashClass implements CogSlash { diff --git a/packages/cocoa-discord/src/slash/class/decorators.ts b/packages/cocoa-discord/src/slash/class/decorators.ts index 8ca68e8..e77d97a 100644 --- a/packages/cocoa-discord/src/slash/class/decorators.ts +++ b/packages/cocoa-discord/src/slash/class/decorators.ts @@ -47,15 +47,8 @@ type SlashCommandReturnType = ( ) => void; export function SlashCommand(description: string): SlashCommandReturnType; -/** @deprecated Use `@Guilds` instead */ -export function SlashCommand( - description: string, - guild_ids?: string[], -): SlashCommandReturnType; -export function SlashCommand( - description: string, - guild_ids?: string[], -): SlashCommandReturnType { + +export function SlashCommand(description: string): SlashCommandReturnType { return (cog: CogSlashClass, key: string, _: unknown) => { const cogStore = (V2Stores[cog.constructor.name] ??= {}); @@ -63,7 +56,6 @@ export function SlashCommand( ...cogStore[key], name: key, description, - guild_ids, }; }; } diff --git a/packages/cocoa-discord/src/template/options.ts b/packages/cocoa-discord/src/template/options.ts index 1f88caf..d46e145 100644 --- a/packages/cocoa-discord/src/template/options.ts +++ b/packages/cocoa-discord/src/template/options.ts @@ -8,55 +8,6 @@ import { import { Context } from "../main/index.js"; -/** - * Basic Template Intents includes - * - * GUILDS, GUILD_MESSAGES, GUILD_MESSAGE_REACTIONS, DIRECT_MESSAGES, DIRECT_MESSAGE_REACTIONS - * - * @deprecated use {@link CocoaIntent} instead, also avoid adding unused intents. - */ -export const CocoaIntents: ClientOptions["intents"] = [ - I.Guilds, - I.GuildMessages, - I.GuildMessageReactions, - I.DirectMessages, - I.DirectMessageReactions, -]; - -/** - * Template Intents with Voice, includes - * - * CocoaIntents + GUILD_VOICE_STATES - * - * @deprecated use {@link CocoaIntent} instead, also avoid adding unused intents. - */ -export const DJCocoaIntents: ClientOptions["intents"] = [ - ...CocoaIntents, - I.GuildVoiceStates, -]; - -/** - * Template ClientOptions used in Cocoa Grader - * - * @deprecated use {@link CocoaIntent} instead, also avoid adding unused intents. - */ -export const CocoaOptions: ClientOptions = { - intents: CocoaIntents, - // To Accept DM - partials: [P.Channel], -}; - -/** - * Template ClientOptions used in Harunon.js - * - * @deprecated use {@link CocoaIntent} instead, also avoid adding unused intents. - */ -export const DJCocoaOptions: ClientOptions = { - intents: DJCocoaIntents, - // To Accept DM - partials: [P.Channel], -}; - export interface MessageIntentOptions { withReaction?: true; withTyping?: true; @@ -96,7 +47,7 @@ export class CocoaIntent * * This is **required** if you are syncing commands by guild */ - useGuildSlash() { + useGuild() { this.intents.push(I.Guilds); return this; } @@ -104,6 +55,8 @@ export class CocoaIntent /** * Add `GuildMessages` * + * `useGuild` is also required for this to work + * * @param withReaction Use this if you want to recieve information about reactions change * @param withTyping Use this if you want to recieve information about user is typing */ diff --git a/packages/cocoa-discord/tests/command.spec.ts b/packages/cocoa-discord/tests/command.spec.ts index 0335829..c96b358 100644 --- a/packages/cocoa-discord/tests/command.spec.ts +++ b/packages/cocoa-discord/tests/command.spec.ts @@ -208,7 +208,7 @@ function testClass() { function helpCommand() { it("Should generate fine", () => { const center = new MessageCenter(client, { prefixes: ["!"] }); - center.addCog(CorrectMCog); + center.addCogs(CorrectMCog); center.useHelpCommand(); // @ts-ignore diff --git a/packages/cocoa-discord/tests/slashsync.spec.ts b/packages/cocoa-discord/tests/slashsync.spec.ts deleted file mode 100644 index 7fd74c6..0000000 --- a/packages/cocoa-discord/tests/slashsync.spec.ts +++ /dev/null @@ -1,199 +0,0 @@ -import { describe, expect, it } from "vitest"; - -import { ApplicationCommandOptionType } from "discord.js"; - -import { isSameOption } from "../src/slash"; - -describe("Slash Sync Utilities", () => { - it("Is Same Option: Single Option", () => { - expect(isSameOption([], [])).toBe(true); - - const oldOpt = [ - { - type: 4, - name: "index", - nameLocalizations: undefined, - nameLocalized: undefined, - description: "Index of removal", - descriptionLocalizations: undefined, - descriptionLocalized: undefined, - required: true, - autocomplete: undefined, - choices: undefined, - options: undefined, - channelTypes: undefined, - minValue: undefined, - maxValue: undefined, - }, - ]; - - const newOpt = [ - { - type: 4, - name: "index", - description: "Index of removal", - required: true, - autocomplete: false, - }, - ]; - - expect(isSameOption(oldOpt, newOpt)).toBe(true); - - newOpt[0].required = false; - expect(isSameOption(oldOpt, newOpt)).toBe(false); - - const o2 = [ - { - name: "a", - description: "a", - type: 69, - choices: [{ name: "e", value: "e" }], - }, - ]; - const n2 = [ - { - name: "a", - description: "a", - type: 69, - choices: [{ name: "e", value: "e" }], - }, - ]; - const n3 = [ - { - name: "a", - description: "a", - type: 69, - choices: [{ name: "e", value: "f" }], - }, - ]; - const n4 = [ - { - name: "a", - description: "a", - type: 69, - choices: [{ name: "f", value: "e" }], - }, - ]; - - expect(isSameOption(o2, n2)).toBe(true); - expect(isSameOption(o2, n3)).toBe(false); - expect(isSameOption(n3, n4)).toBe(false); - }); - - it("Is same Option: Multi Options", () => { - const mo1 = [ - { - type: ApplicationCommandOptionType.String, - name: "frame", - description: "Frame Name", - required: true, - choices: [ - { - name: "vladdy_daddy.jpg", - value: "vladdy_daddy.jpg", - }, - { - name: "big_frame.jpg", - value: "big_frame.jpg", - }, - { - name: "golden_frame.png", - value: "golden_frame.png", - }, - { - name: "wessuwan.png", - value: "wessuwan.png", - }, - { - name: "obamium_portrait.jpg", - value: "obamium_portrait.jpg", - }, - ], - }, - { - type: ApplicationCommandOptionType.User, - name: "who", - description: "Who to put in the golden frame", - required: false, - }, - { - type: ApplicationCommandOptionType.Attachment, - name: "img", - description: "Image to put in the frame", - required: false, - }, - ]; - - const mn1 = [ - { - choices: [ - { - name: "vladdy_daddy.jpg", - value: "vladdy_daddy.jpg", - }, - { - name: "big_frame.jpg", - value: "big_frame.jpg", - }, - { - name: "golden_frame.png", - value: "golden_frame.png", - }, - { - name: "wessuwan.png", - value: "wessuwan.png", - }, - { - name: "obamium_portrait.jpg", - value: "obamium_portrait.jpg", - }, - ], - type: ApplicationCommandOptionType.String, - name: "frame", - description: "Frame Name", - required: true, - }, - { - name: "who", - description: "Who to put in the golden frame", - required: false, - type: ApplicationCommandOptionType.User, - }, - { - name: "img", - description: "Image to put in the frame", - required: false, - type: ApplicationCommandOptionType.Attachment, - }, - ]; - - expect(isSameOption(mo1, mn1)).toBe(true); - - // * Shuffle Order - mn1[0].choices = [ - { - name: "big_frame.jpg", - value: "big_frame.jpg", - }, - { - name: "vladdy_daddy.jpg", - value: "vladdy_daddy.jpg", - }, - - { - name: "golden_frame.png", - value: "golden_frame.png", - }, - { - name: "wessuwan.png", - value: "wessuwan.png", - }, - { - name: "obamium_portrait.jpg", - value: "obamium_portrait.jpg", - }, - ]; - - expect(isSameOption(mo1, mn1)).toBe(false); - }); -});