diff --git a/plugins/assertFields.ts b/plugins/assertFields.ts index e338d70..340eb25 100644 --- a/plugins/assertFields.ts +++ b/plugins/assertFields.ts @@ -52,7 +52,7 @@ export function assertFields(config: { errors.push( input + " failed to pass assertion " + - resolvedAssertion.toString() + resolvedAssertion.toString(), ); } } diff --git a/plugins/buttonConfirmation.ts b/plugins/buttonConfirmation.ts index ee2d75c..4f1f579 100644 --- a/plugins/buttonConfirmation.ts +++ b/plugins/buttonConfirmation.ts @@ -79,7 +79,7 @@ export function buttonConfirmation(options?: Partial) { await sent.edit({ components: [ new ActionRowBuilder().setComponents( - buttons + buttons, ), ], }); diff --git a/plugins/cooldown.ts b/plugins/cooldown.ts index 2d05866..e8336a8 100644 --- a/plugins/cooldown.ts +++ b/plugins/cooldown.ts @@ -45,7 +45,7 @@ export class ExpiryMap extends Map { public readonly expiry: number; constructor( expiry: number = Infinity, - iterable: [K, V][] | ReadonlyMap = [] + iterable: [K, V][] | ReadonlyMap = [], ) { super(iterable); this.expiry = expiry; @@ -65,7 +65,7 @@ export const map = new ExpiryMap(); function parseCooldown( location: CooldownLocation, - cooldown: CooldownString + cooldown: CooldownString, ): Cooldown { const [actions, seconds] = cooldown.split("/").map((s) => Number(s)); @@ -113,7 +113,7 @@ function add( | [CooldownLocation | keyof typeof CooldownLocation, CooldownString] | Cooldown >, - message?: CooldownResponse + message?: CooldownResponse, ) { const raw = items.map((c) => { if (!Array.isArray(c)) return c; diff --git a/plugins/disable.ts b/plugins/disable.ts index 873008a..2f61515 100644 --- a/plugins/disable.ts +++ b/plugins/disable.ts @@ -26,7 +26,7 @@ export function disable( onFail?: | string | Omit - | ReplyMessageOptions + | ReplyMessageOptions, ) { return CommandControlPlugin(async (ctx, [args]) => { if (onFail !== undefined) { diff --git a/plugins/dmOnly.ts b/plugins/dmOnly.ts index a9760ca..b33ff79 100644 --- a/plugins/dmOnly.ts +++ b/plugins/dmOnly.ts @@ -15,7 +15,7 @@ * //your code here * } * }) - * ``` + * ``` * @end */ import { CommandControlPlugin, CommandType, controller } from "@sern/handler"; diff --git a/plugins/filter.ts b/plugins/filter.ts index 12ac1dd..20fec0f 100644 --- a/plugins/filter.ts +++ b/plugins/filter.ts @@ -19,7 +19,7 @@ export class Criteria { public constructor( public readonly name: string, public readonly execute: Test, - public readonly children: Array + public readonly children: Array, ) {} toString() { return this.name + " " + this.children.map((c) => c.name).join(", "); @@ -43,7 +43,7 @@ export const or = (...filters: Array): FilterImpl => { return new FilterImpl( new Criteria("or", execute, children), - `or(${filters.map((x) => x.message).join(", ")})` + `or(${filters.map((x) => x.message).join(", ")})`, ); }; @@ -62,7 +62,7 @@ export const and = (...filters: Array): FilterImpl => { return new FilterImpl( new Criteria("and", execute, children), - `and(${filters.map((x) => x.message).join(", ")})` + `and(${filters.map((x) => x.message).join(", ")})`, ); }; @@ -73,7 +73,7 @@ export const not = (filter: FilterImpl): FilterImpl => { return new FilterImpl( new Criteria("not", execute, [filter.criteria]), - `not(${filter.criteria})` + `not(${filter.criteria})`, ); }; export const custom = (execute: Test, message?: string): FilterImpl => { @@ -82,22 +82,22 @@ export const custom = (execute: Test, message?: string): FilterImpl => { export const withCustomMessage = ( filter: FilterImpl, - message?: string + message?: string, ): FilterImpl => { return new FilterImpl(filter.criteria, message); }; export const hasGuildPermission = ( - permission: PermissionResolvable + permission: PermissionResolvable, ): FilterImpl => { const b = PermissionsBitField.resolve(permission); const field = Object.entries(PermissionsBitField.Flags).find( - ([, v]) => v === b + ([, v]) => v === b, ); if (field === undefined) { throw new Error( - `unknown permission \`${permission}\` in filter \`hasGuildPermission\`` + `unknown permission \`${permission}\` in filter \`hasGuildPermission\``, ); } @@ -107,7 +107,7 @@ export const hasGuildPermission = ( if (context.member !== null) { if (typeof context.member.permissions === "string") { return new PermissionsBitField( - BigInt(context.member.permissions) + BigInt(context.member.permissions), ).has(b); } return context.member.permissions.has(b); @@ -118,21 +118,21 @@ export const hasGuildPermission = ( return new FilterImpl( new Criteria("hasGuildPermission", execute, []), - `has guild permission: ${name}` + `has guild permission: ${name}`, ); }; export const hasChannelPermission = ( permission: PermissionResolvable, - channelId?: string + channelId?: string, ): FilterImpl => { const b = PermissionsBitField.resolve(permission); const field = Object.entries(PermissionsBitField.Flags).find( - ([, v]) => v === b + ([, v]) => v === b, ); if (field === undefined) { throw new Error( - `unknown permission \`${permission}\` in filter \`hasChannelPermission\`` + `unknown permission \`${permission}\` in filter \`hasChannelPermission\``, ); } @@ -161,7 +161,7 @@ export const hasChannelPermission = ( if (context.member !== null) { if (typeof context.member.permissions === "string") { return new PermissionsBitField( - BigInt(context.member.permissions) + BigInt(context.member.permissions), ).has(b); } @@ -181,7 +181,7 @@ export const hasChannelPermission = ( new Criteria("hasChannelPermission", execute, []), channelId !== undefined ? `has channel permission ${name} in <#${channelId}>` - : `has channel permission ${name}` + : `has channel permission ${name}`, ); }; @@ -314,20 +314,20 @@ export const channelIdIn = (channelIds: Array): FilterImpl => { return channelIds.includes( context.isMessage() ? context.message.channelId - : context.interaction.channelId + : context.interaction.channelId, ); } return new FilterImpl( new Criteria("channelIdIn", execute, []), - `channel is one of: ${channelIds.map((v) => `<#${v}>`).join(", ")}` + `channel is one of: ${channelIds.map((v) => `<#${v}>`).join(", ")}`, ); }; export const hasEveryRole = (roles: Array): FilterImpl => { return withCustomMessage( and(...roles.map((v) => hasRole(v))), - `has all of: ${roles.map((v) => `<@&${v}>`).join(", ")}` + `has all of: ${roles.map((v) => `<@&${v}>`).join(", ")}`, ); }; @@ -337,7 +337,7 @@ export const hasMentionableRole = (): FilterImpl => { if (context.member.roles instanceof GuildMemberRoleManager) { return ( context.member.roles.cache.filter( - (x) => x.mentionable === true + (x) => x.mentionable === true, ).size > 0 ); } @@ -356,7 +356,7 @@ export const hasMentionableRole = (): FilterImpl => { } return new FilterImpl( new Criteria("hasMentionableRole", execute, []), - "has a mentionable role" + "has a mentionable role", ); }; @@ -386,7 +386,7 @@ export const hasNickname = (nickname?: string): FilterImpl => { } return new FilterImpl( new Criteria("hasNickname", execute, []), - "has a nickname" + "has a nickname", ); }; @@ -405,7 +405,7 @@ export const hasParentId = (parentId: string): FilterImpl => { return new FilterImpl( new Criteria("hasParentId", execute, []), - `has channel parent <#${parentId}>` + `has channel parent <#${parentId}>`, ); }; @@ -429,14 +429,14 @@ export const hasRole = (roleId: string): FilterImpl => { return new FilterImpl( new Criteria("hasRole", execute, []), - `has role <@&${roleId}>` + `has role <@&${roleId}>`, ); }; export const hasSomeRole = (roles: Array): FilterImpl => { return withCustomMessage( or(...roles.map((role) => hasRole(role))), - `has any of: ${roles.map((v) => `<@&${v}>`).join(", ")}` + `has any of: ${roles.map((v) => `<@&${v}>`).join(", ")}`, ); }; @@ -455,7 +455,7 @@ export const isChannelId = (channelId: string): FilterImpl => { return new FilterImpl( new Criteria("isChannelId", execute, []), - `is channel <#${channelId}>` + `is channel <#${channelId}>`, ); }; @@ -473,7 +473,7 @@ export const isChannelNsfw = (): FilterImpl => { } return new FilterImpl( new Criteria("isChannelNsfw", execute, []), - "channel marked as nsfw" + "channel marked as nsfw", ); }; @@ -487,7 +487,7 @@ export const isGuildOwner = (): FilterImpl => { } return new FilterImpl( new Criteria("isGuildOwner", execute, []), - "is guild owner" + "is guild owner", ); }; @@ -502,7 +502,7 @@ export const isBotOwner = (): FilterImpl => { } return context.client.application.owner.members.has( - context.user.id + context.user.id, ); } } @@ -512,7 +512,7 @@ export const isBotOwner = (): FilterImpl => { } return new FilterImpl( new Criteria("isBotOwner", execute, []), - "is bot owner" + "is bot owner", ); }; @@ -522,7 +522,7 @@ export const isUserId = (userId: string): FilterImpl => { } return new FilterImpl( new Criteria("isUserId", execute, []), - `is user: <@${userId}>` + `is user: <@${userId}>`, ); }; @@ -531,14 +531,14 @@ export const parentIdIn = (parentIds: Array): FilterImpl => { or(...parentIds.map((v) => hasParentId(v))), `channel parent is one of: ${parentIds .map((v) => `<#${v}>`) - .join(", ")}` + .join(", ")}`, ); }; export const userIdIn = (userIds: Array): FilterImpl => { return withCustomMessage( or(...userIds.map((v) => isUserId(v))), - `user is one of: ${userIds.map((v) => `<@${v}>`).join(", ")}` + `user is one of: ${userIds.map((v) => `<@${v}>`).join(", ")}`, ); }; @@ -549,7 +549,7 @@ export const isInGuild = (): FilterImpl => { return new FilterImpl( new Criteria("isInGuild", execute, []), - "is in guild" + "is in guild", ); }; @@ -593,7 +593,7 @@ export class FilterImpl { public constructor( public readonly criteria: Criteria, - public message?: string + public message?: string, ) { this.test = this.criteria.execute; } diff --git a/plugins/nsfwOnly.ts b/plugins/nsfwOnly.ts index ca9a78e..a0ae9e4 100644 --- a/plugins/nsfwOnly.ts +++ b/plugins/nsfwOnly.ts @@ -15,7 +15,7 @@ * //your code here * } * }) - * ``` + * ``` * @end */ import { @@ -26,7 +26,7 @@ import { } from "discord.js"; import { CommandControlPlugin, CommandType, controller } from "@sern/handler"; function isGuildText( - channel: TextBasedChannel | null + channel: TextBasedChannel | null, ): channel is GuildTextBasedChannel { return ( channel?.type == ChannelType.GuildPublicThread || diff --git a/plugins/ownerOnly.ts b/plugins/ownerOnly.ts index 3986182..e45a9a4 100644 --- a/plugins/ownerOnly.ts +++ b/plugins/ownerOnly.ts @@ -15,7 +15,7 @@ * //your code here * } * }) - * ``` + * ``` * @end */ diff --git a/plugins/permCheck.ts b/plugins/permCheck.ts index c2809cf..7884997 100644 --- a/plugins/permCheck.ts +++ b/plugins/permCheck.ts @@ -26,7 +26,7 @@ export function permCheck(perm: PermissionResolvable, response: string) { if (ctx.guild === null) { await ctx.reply("This command cannot be used here"); console.warn( - "PermCheck > A command stopped because we couldn't check a users permissions (was used in dms)" + "PermCheck > A command stopped because we couldn't check a users permissions (was used in dms)", ); //delete this line if you dont want to be notified when a command is used outside of a guild/server return controller.stop(); } diff --git a/plugins/publish.ts b/plugins/publish.ts index fda3260..4a68618 100644 --- a/plugins/publish.ts +++ b/plugins/publish.ts @@ -16,7 +16,7 @@ * //your code here * } * }) - * ``` + * ``` * @end */ import { @@ -46,16 +46,16 @@ export function publish< | CommandType.Both | CommandType.Slash | CommandType.CtxMsg - | CommandType.CtxUser + | CommandType.CtxUser, >(options?: PublishOptions) { return CommandInitPlugin(async ({ module }) => { // Users need to provide their own useContainer function. let client; try { - client = (await import('@sern/handler')).Service('@sern/client') + client = (await import("@sern/handler")).Service("@sern/client"); } catch { - const { useContainer } = await import('../index.js') - client = useContainer("@sern/client")[0]; + const { useContainer } = await import("../index.js"); + client = useContainer("@sern/client")[0]; } const defaultOptions = { guildIds: [], @@ -98,7 +98,7 @@ export function publish< description: cmd(module.description, ""), options: cmd( optionsTransformer((module as SlashCommand).options ?? []), - [] + [], ), defaultMemberPermissions, dmPermission, @@ -110,17 +110,17 @@ export function publish< if (!guildIds.length) { const cmd = (await client.application!.commands.fetch()).find( - (c) => c.name === module.name && c.type === curAppType + (c) => c.name === module.name && c.type === curAppType, ); if (cmd) { if (!cmd.equals(commandData, true)) { logged( - `Found differences in global command ${module.name}` + `Found differences in global command ${module.name}`, ); cmd.edit(commandData).then( log( - `${module.name} updated with new data successfully!` - ) + `${module.name} updated with new data successfully!`, + ), ); } return controller.next(); @@ -136,7 +136,7 @@ export function publish< const guild = await client.guilds.fetch(id).catch(c); if (!guild) continue; const guildCmd = (await guild.commands.fetch()).find( - (c) => c.name === module.name && c.type === curAppType + (c) => c.name === module.name && c.type === curAppType, ); if (guildCmd) { if (!guildCmd.equals(commandData, true)) { @@ -145,8 +145,8 @@ export function publish< .edit(commandData) .then( log( - `${module.name} updated with new data successfully!` - ) + `${module.name} updated with new data successfully!`, + ), ) .catch(c); continue; diff --git a/plugins/requirePermission.ts b/plugins/requirePermission.ts index db9b5c3..92f508c 100644 --- a/plugins/requirePermission.ts +++ b/plugins/requirePermission.ts @@ -16,7 +16,7 @@ * //your code here * } * }) - * ``` + * ``` * @end */ @@ -35,13 +35,13 @@ function payload(resp?: string) { export function requirePermission( target: "user" | "bot" | "both", perm: PermissionResolvable[], - response?: string + response?: string, ) { return CommandControlPlugin(async (ctx, args) => { if (ctx.guild === null) { ctx.reply(payload("This command cannot be used here")); console.warn( - "PermCheck > A command stopped because we couldn't check a users permissions (was used in dms)" + "PermCheck > A command stopped because we couldn't check a users permissions (was used in dms)", ); //delete this line if you dont want to be notified when a command is used outside of a guild/server return controller.stop(); } @@ -55,7 +55,7 @@ export function requirePermission( if (!bot.permissions.has(perm)) { if (!response) response = `I cannot use this command, please give me \`${perm.join( - ", " + ", ", )}\` permission(s).`; await ctx.reply(payload(response)); return controller.stop(); @@ -66,7 +66,7 @@ export function requirePermission( if (!memm.permissions.has(perm)) { if (!response) response = `You cannot use this command because you are missing \`${perm.join( - ", " + ", ", )}\` permission(s).`; await ctx.reply(payload(response)); return controller.stop(); diff --git a/plugins/serverOnly.ts b/plugins/serverOnly.ts index 453fcd0..8f4378a 100644 --- a/plugins/serverOnly.ts +++ b/plugins/serverOnly.ts @@ -25,7 +25,7 @@ import { CommandType, controller, CommandControlPlugin } from "@sern/handler"; export function serverOnly( guildId: string[], - failMessage = "This command is not available in this guild. \nFor permission to use in your server, please contact my developer." + failMessage = "This command is not available in this guild. \nFor permission to use in your server, please contact my developer.", ) { return CommandControlPlugin(async (ctx, _) => { if (ctx.guildId == null) {