mirror of
https://github.com/sern-handler/awesome-plugins
synced 2026-06-06 01:16:51 +00:00
style: run prettier
Signed-off-by: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
committed by
GitHub Actions
parent
44e151d414
commit
efd52f5357
@@ -52,7 +52,7 @@ export function assertFields(config: {
|
||||
errors.push(
|
||||
input +
|
||||
" failed to pass assertion " +
|
||||
resolvedAssertion.toString()
|
||||
resolvedAssertion.toString(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ export function buttonConfirmation(options?: Partial<ConfirmationOptions>) {
|
||||
await sent.edit({
|
||||
components: [
|
||||
new ActionRowBuilder<ButtonBuilder>().setComponents(
|
||||
buttons
|
||||
buttons,
|
||||
),
|
||||
],
|
||||
});
|
||||
|
||||
@@ -45,7 +45,7 @@ export class ExpiryMap<K, V> extends Map<K, V> {
|
||||
public readonly expiry: number;
|
||||
constructor(
|
||||
expiry: number = Infinity,
|
||||
iterable: [K, V][] | ReadonlyMap<K, V> = []
|
||||
iterable: [K, V][] | ReadonlyMap<K, V> = [],
|
||||
) {
|
||||
super(iterable);
|
||||
this.expiry = expiry;
|
||||
@@ -65,7 +65,7 @@ export const map = new ExpiryMap<string, number>();
|
||||
|
||||
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;
|
||||
|
||||
@@ -26,7 +26,7 @@ export function disable(
|
||||
onFail?:
|
||||
| string
|
||||
| Omit<InteractionReplyOptions, "fetchReply">
|
||||
| ReplyMessageOptions
|
||||
| ReplyMessageOptions,
|
||||
) {
|
||||
return CommandControlPlugin<CommandType.Both>(async (ctx, [args]) => {
|
||||
if (onFail !== undefined) {
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* //your code here
|
||||
* }
|
||||
* })
|
||||
* ```
|
||||
* ```
|
||||
* @end
|
||||
*/
|
||||
import { CommandControlPlugin, CommandType, controller } from "@sern/handler";
|
||||
|
||||
@@ -19,7 +19,7 @@ export class Criteria {
|
||||
public constructor(
|
||||
public readonly name: string,
|
||||
public readonly execute: Test,
|
||||
public readonly children: Array<Criteria>
|
||||
public readonly children: Array<Criteria>,
|
||||
) {}
|
||||
toString() {
|
||||
return this.name + " " + this.children.map((c) => c.name).join(", ");
|
||||
@@ -43,7 +43,7 @@ export const or = (...filters: Array<FilterImpl>): 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>): 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<string>): 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<string>): 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<string>): 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<string>): FilterImpl => {
|
||||
or(...parentIds.map((v) => hasParentId(v))),
|
||||
`channel parent is one of: ${parentIds
|
||||
.map((v) => `<#${v}>`)
|
||||
.join(", ")}`
|
||||
.join(", ")}`,
|
||||
);
|
||||
};
|
||||
|
||||
export const userIdIn = (userIds: Array<string>): 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;
|
||||
}
|
||||
|
||||
@@ -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 ||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* //your code here
|
||||
* }
|
||||
* })
|
||||
* ```
|
||||
* ```
|
||||
* @end
|
||||
*/
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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<T>(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;
|
||||
|
||||
@@ -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<CommandType.Both>(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();
|
||||
|
||||
@@ -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<CommandType.Both>(async (ctx, _) => {
|
||||
if (ctx.guildId == null) {
|
||||
|
||||
Reference in New Issue
Block a user