diff --git a/.github/workflows/image.yml b/.github/workflows/image.yml index 953adcc..f17915c 100644 --- a/.github/workflows/image.yml +++ b/.github/workflows/image.yml @@ -15,7 +15,7 @@ jobs: id: buildx uses: crazy-max/ghaction-docker-buildx@v1 with: - version: latest + buildx-version: latest - name: Login to Docker Hub run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin - name: Build the image diff --git a/src/commands/util.ts b/src/commands/util.ts index ed129dc..1070979 100644 --- a/src/commands/util.ts +++ b/src/commands/util.ts @@ -3,7 +3,7 @@ import Command from '../core/command'; import {CommonLibrary} from '../core/lib'; export default new Command({ - description: "", + description: "Various utilities.", endpoint: false, usage: '', async run($: CommonLibrary): Promise { @@ -16,14 +16,24 @@ export default new Command({ async run($: CommonLibrary): Promise { const nsfw: string | string[] = []; const pages = $.client.emojis.cache.filter(x => !nsfw.includes(x.guild.id), this).array(); - // $.log(pages); + const pagesSplit = $(pages).split(20); + $.log(pagesSplit) var embed = new MessageEmbed() .setTitle("**Emoji list!**") - .setColor("AQUA"); + .setColor("AQUA") + let desc = "" + for (const emote of pagesSplit[0]) { + desc += `${emote} | ${emote.name}\n` + } + embed.setDescription(desc) const msg = await $.channel.send({embed}); $.paginate(msg, $.author.id, pages.length, page => { - embed.setDescription(`${pages[page]} | ${pages[page].name}`); + let desc = "" + for(const emote of pagesSplit[page]) { + desc += `${emote} | ${emote.name}\n` + } + embed.setDescription(desc) msg.edit(embed); }); } diff --git a/src/core/lib.ts b/src/core/lib.ts index 40dde69..78e1ff9 100644 --- a/src/core/lib.ts +++ b/src/core/lib.ts @@ -166,34 +166,30 @@ $.paginate = async(message: Message, senderID: string, total: number, callback: callback(page); } const handle = (emote: string, reacterID: string) => { - switch(emote) - { - case '⬅️': turn(-1); break; - case '➡️': turn(1); break; - } -}; + switch(emote) + { + case '⬅️': turn(-1); break; + case '➡️': turn(1); break; + } + }; -// Listen for reactions and call the handler. -await message.react('⬅️'); -await message.react('➡️'); -eventListeners.set(message.id, handle); -await message.awaitReactions((reaction, user) => { - if(user.id === senderID) - { - // The reason this is inside the call is because it's possible to switch a user's permissions halfway and suddenly throw an error. - // This will dynamically adjust for that, switching modes depending on whether it currently has the "Manage Messages" permission. - const canDeleteEmotes = botHasPermission(message.guild, Permissions.FLAGS.MANAGE_MESSAGES); - handle(reaction.emoji.name, user.id); + // Listen for reactions and call the handler. + await message.react('⬅️'); + await message.react('➡️'); + eventListeners.set(message.id, handle); + await message.awaitReactions((reaction, user) => { + if(user.id === senderID) + { + // The reason this is inside the call is because it's possible to switch a user's permissions halfway and suddenly throw an error. + // This will dynamically adjust for that, switching modes depending on whether it currently has the "Manage Messages" permission. + const canDeleteEmotes = botHasPermission(message.guild, Permissions.FLAGS.MANAGE_MESSAGES); + handle(reaction.emoji.name, user.id); - if(canDeleteEmotes) - reaction.users.remove(user); - } - - return false; -}, {time: duration}); - - $.log("removal") - + if(canDeleteEmotes) + reaction.users.remove(user); + } + return false; + }, {time: duration}); // When time's up, remove the bot's own reactions. eventListeners.delete(message.id); message.reactions.cache.get('⬅️')?.users.remove(message.author); @@ -387,6 +383,7 @@ export abstract class GenericStructure public save(asynchronous = true) { const tag = this.__meta__; + /// @ts-ignore delete this.__meta__; FileManager.write(tag, this, asynchronous); this.__meta__ = tag; diff --git a/test/wrappers.ts b/test/wrappers.ts index 260c229..e6699d9 100644 --- a/test/wrappers.ts +++ b/test/wrappers.ts @@ -6,41 +6,41 @@ describe("Wrappers", () => { describe("NumberWrapper", () => { describe("#pluralise()", () => { it('should return "5 credits"', () => { - assert.equal(new NumberWrapper(5).pluralise("credit", "s"), "5 credits"); + assert.strictEqual(new NumberWrapper(5).pluralise("credit", "s"), "5 credits"); }) it('should return "1 credit"', () => { - assert.equal(new NumberWrapper(1).pluralise("credit", "s"), "1 credit"); + assert.strictEqual(new NumberWrapper(1).pluralise("credit", "s"), "1 credit"); }) it('should return "-1 credits"', () => { - assert.equal(new NumberWrapper(-1).pluralise("credit", "s"), "-1 credits"); + assert.strictEqual(new NumberWrapper(-1).pluralise("credit", "s"), "-1 credits"); }) it('should be able to work with a plural suffix', () => { - assert.equal(new NumberWrapper(2).pluralise("part", "ies", "y"), "2 parties"); + assert.strictEqual(new NumberWrapper(2).pluralise("part", "ies", "y"), "2 parties"); }) it('should be able to work with a singular suffix', () => { - assert.equal(new NumberWrapper(1).pluralise("part", "ies", "y"), "1 party"); + assert.strictEqual(new NumberWrapper(1).pluralise("part", "ies", "y"), "1 party"); }) it('should be able to exclude the number', () => { - assert.equal(new NumberWrapper(1).pluralise("credit", "s", "", true), "credit"); + assert.strictEqual(new NumberWrapper(1).pluralise("credit", "s", "", true), "credit"); }) }) describe("#pluraliseSigned()", () => { it('should return "-1 credits"', () => { - assert.equal(new NumberWrapper(-1).pluraliseSigned("credit", "s"), "-1 credits"); + assert.strictEqual(new NumberWrapper(-1).pluraliseSigned("credit", "s"), "-1 credits"); }) it('should return "+0 credits"', () => { - assert.equal(new NumberWrapper(0).pluraliseSigned("credit", "s"), "+0 credits"); + assert.strictEqual(new NumberWrapper(0).pluraliseSigned("credit", "s"), "+0 credits"); }) it('should return "+1 credit"', () => { - assert.equal(new NumberWrapper(1).pluraliseSigned("credit", "s"), "+1 credit"); + assert.strictEqual(new NumberWrapper(1).pluraliseSigned("credit", "s"), "+1 credit"); }) }) }) @@ -48,13 +48,13 @@ describe("Wrappers", () => { describe("StringWrapper", () => { describe("#replaceAll()", () => { it('should convert "test" to "zesz"', () => { - assert.equal(new StringWrapper("test").replaceAll('t', 'z'), "zesz"); + assert.strictEqual(new StringWrapper("test").replaceAll('t', 'z'), "zesz"); }) }) describe("#toTitleCase()", () => { it('should capitalize the first letter of each word', () => { - assert.equal(new StringWrapper("yeetus deletus find salvation from jesus").toTitleCase(), "Yeetus Deletus Find Salvation From Jesus"); + assert.strictEqual(new StringWrapper("yeetus deletus find salvation from jesus").toTitleCase(), "Yeetus Deletus Find Salvation From Jesus"); }) }) }) @@ -62,7 +62,7 @@ describe("Wrappers", () => { describe("ArrayWrapper", () => { describe("#split()", () => { it('should split [1,2,3,4,5,6,7,8,9,10] into [[1,2,3],[4,5,6],[7,8,9],[10]]', () => { - assert.deepEqual(new ArrayWrapper([1,2,3,4,5,6,7,8,9,10]).split(3), [[1,2,3],[4,5,6],[7,8,9],[10]]); + assert.deepStrictEqual(new ArrayWrapper([1,2,3,4,5,6,7,8,9,10]).split(3), [[1,2,3],[4,5,6],[7,8,9],[10]]); }) }) })