no more ugly formatting

This commit is contained in:
Jacob Nguyen
2024-05-09 22:27:02 -05:00
parent 5c82de2418
commit eef459638a
64 changed files with 21999 additions and 22369 deletions

View File

@@ -1,4 +1,5 @@
{
"useTabs": true,
"printWidth": 100
"useTabs": false,
"printWidth": 100,
"tabWidth": 4
}

584
docs.json

File diff suppressed because it is too large Load Diff

View File

@@ -35,7 +35,9 @@ export default commandModule({
execute(autocomplete) {
const choices = docHandler.DocTrie.search(autocomplete.options.getFocused());
return autocomplete.respond(
choices.map((res) => ({ name: res.node.name, value: res.node.name })).slice(0, 25)
choices
.map((res) => ({ name: res.node.name, value: res.node.name }))
.slice(0, 25),
);
},
},
@@ -85,7 +87,11 @@ export default commandModule({
});
return new EmbedBuilder()
.addFields({ name: "Category", value: res.name }, ...(comments ?? []), ...(blockTags ?? []))
.addFields(
{ name: "Category", value: res.name },
...(comments ?? []),
...(blockTags ?? []),
)
.setTitle(`🔖 ${res.node.name}`)
.setColor(Colors.DarkVividPink)
.setAuthor({
@@ -94,7 +100,7 @@ export default commandModule({
})
.setURL(res.node.sources[0].url ?? "External implementation");
});
if(embeds.length === 1) {
if (embeds.length === 1) {
return context.reply({ embeds });
}
const paginator = new Paginator({ embeds });

View File

@@ -62,8 +62,9 @@ export default slashCommand({
(a) => a.contentType?.startsWith("image/") || false,
(a) =>
["image/png", "image/jpg", "image/gif"].includes(
a.contentType ?? "Something that is not png or jpg when contentType is null"
)
a.contentType ??
"Something that is not png or jpg when contentType is null",
),
);
if (!isValidAttachment) {
return ctx.interaction.editReply({
@@ -131,7 +132,7 @@ function sendTo(channelId: Snowflake, member: GuildMember, name: string) {
{
name: "Status",
value: "Pending Approval",
}
},
)
.setTimestamp();

View File

@@ -32,7 +32,8 @@ export default commandModule({
} catch (error) {
result = error;
}
if (result instanceof Promise) result = await result.catch((e: Error) => new Error(e.message));
if (result instanceof Promise)
result = await result.catch((e: Error) => new Error(e.message));
if (typeof result !== "string") {
result = inspect(result, {
depth: 0,
@@ -56,7 +57,9 @@ export default commandModule({
.setThumbnail(client.user?.displayAvatarURL() ?? "")
.setImage("https://raw.githubusercontent.com/sern-handler/.github/main/banner.png")
.setAuthor({ name: "sern", url: "https://sern.dev/" })
.setDescription(`__**Quick Look:**__\n\n${text()}\n\nThank you all for being patient!`)
.setDescription(
`__**Quick Look:**__\n\n${text()}\n\nThank you all for being patient!`,
)
.setFooter({ text: "Supports DJS v14.7 and above" })
.setTimestamp();
const content = ping ? "@everyone" : undefined;

View File

@@ -24,7 +24,8 @@ export default slashCommand({
execute: async (context) => {
const opponent = context.interaction.options.getUser("user") ?? context.client.user!;
if (opponent.id === context.user.id) return context.reply(`Can't play with yourself dumb dumb`);
if (opponent.id === context.user.id)
return context.reply(`Can't play with yourself dumb dumb`);
const buttons = ["🪨|Rock", "📄|Paper", "✂|Scissors"].map((s) => {
const [emoji, label] = s.split("|");
@@ -108,7 +109,7 @@ export default slashCommand({
if (!opponent.bot && choices.length !== 2) {
content = content.replace(
`> Waiting for ${i.user.username}`,
`> ${i.user.username} has chosen!`
`> ${i.user.username} has chosen!`,
);
return void i.update(content);
}

View File

@@ -4,7 +4,7 @@ import { ApplicationCommandOptionType } from "discord.js";
import { Timestamp } from "#utils";
import { Emojis } from "#constants";
const prefix = (t: unknown) => (t ? "$" : "#");
const octokit = Service('octokit');
const octokit = Service("octokit");
export default commandModule({
type: CommandType.Slash,
description: "Get info about a PR or issue",
@@ -27,7 +27,7 @@ export default commandModule({
if (!org) return ctx.respond([]);
const topRepos = org.data.sort(
(a, b) => (b.stargazers_count ?? 0) - (a.stargazers_count ?? 0)
(a, b) => (b.stargazers_count ?? 0) - (a.stargazers_count ?? 0),
);
const publicRepos = topRepos
@@ -43,8 +43,10 @@ export default commandModule({
return ctx
.respond(
publicRepos
.filter((repo) => repo.name.toLowerCase().includes(text.toLowerCase()))
.slice(0, 25)
.filter((repo) =>
repo.name.toLowerCase().includes(text.toLowerCase()),
)
.slice(0, 25),
)
.catch(() => null);
},
@@ -59,7 +61,6 @@ export default commandModule({
command: {
onEvent: [],
async execute(ctx) {
const text = ctx.options.getFocused();
const repo = ctx.options.getString("repo");
if (!repo) return ctx.respond([]);
@@ -87,7 +88,9 @@ export default commandModule({
if (!issues) return ctx.respond([]);
const map = issues.data.map((issue) => ({
name: cutText(`${prefix(issue.pull_request)}${issue.number} - ${issue.title}`),
name: cutText(
`${prefix(issue.pull_request)}${issue.number} - ${issue.title}`,
),
value: issue.number,
}));
@@ -99,10 +102,12 @@ export default commandModule({
search?.data.items
.filter((i) => i.title.toLowerCase().includes(text.toLowerCase()))
.map((issue) => ({
name: cutText(`${prefix(issue.pull_request)}${issue.number} - ${issue.title}`),
name: cutText(
`${prefix(issue.pull_request)}${issue.number} - ${issue.title}`,
),
value: issue.number,
}))
.slice(0, 25) ?? []
.slice(0, 25) ?? [],
)
.catch(() => null);
},
@@ -116,7 +121,6 @@ export default commandModule({
},
],
async execute(ctx, [, options]) {
const repo = options.getString("repo", true);
const number = options.getInteger("number", true);
const target = options.getUser("target");
@@ -194,7 +198,7 @@ export default commandModule({
reply += `${emoji(issue)} [\`${prefix(issue.pull_request)}${number} sern/${repo}\`](<${
issue.html_url
}>)\n___${issue.title}___ by [*${issue.user!.login}*](<${issue.user?.html_url}>) ${suffix(
issue
issue,
)}`;
return ctx.reply(reply);

View File

@@ -25,7 +25,7 @@ export default commandModule({
.setPlaceholder("Name of the emoji")
.setRequired()
.setStyle(TextInputStyle.Short)
.setValue(suggestedName)
.setValue(suggestedName),
);
modal.setComponents(row);

View File

@@ -16,7 +16,9 @@ export default commandModule({
const components = [
new ActionRowBuilder<ButtonBuilder>().setComponents(
ctx.message!.components[0].components.map((c) => new ButtonBuilder(c.data).setDisabled())
ctx.message!.components[0].components.map((c) =>
new ButtonBuilder(c.data).setDisabled(),
),
),
];
@@ -24,7 +26,8 @@ export default commandModule({
.setFields(ctx.message!.embeds[0].fields[0], {
name: "Status",
value:
`Denied by ${ctx.user}` + "\nThank you but we are not interested in this at the moment!",
`Denied by ${ctx.user}` +
"\nThank you but we are not interested in this at the moment!",
})
.setColor("Red")
.setTimestamp();

View File

@@ -32,7 +32,9 @@ export default commandModule({
const components = [
new ActionRowBuilder<ButtonBuilder>().setComponents(
ctx.message!.components[0].components.map((c) => new ButtonBuilder(c.data).setDisabled())
ctx.message!.components[0].components.map((c) =>
new ButtonBuilder(c.data).setDisabled(),
),
),
];
@@ -47,7 +49,7 @@ export default commandModule({
{
name: "Status",
value: `Accepted by ${ctx.user}`,
}
},
)
.setColor("Green")
.setFooter({

View File

@@ -10,7 +10,8 @@ export default commandModule({
const roles = interaction.values;
const menuRoles: string[] = (
interaction.message.components[0].components[0].data as Readonly<APIStringSelectComponent>
interaction.message.components[0].components[0]
.data as Readonly<APIStringSelectComponent>
).options.map((o: { label: string; value: string }) => o.value);
const member = interaction.member as GuildMember;

View File

@@ -23,7 +23,7 @@ export default commandModule({
.trim()
.split(",")
.map((c) => c.trim())
.filter((c) => !!c.length)
.filter((c) => !!c.length),
),
]
: [],
@@ -39,12 +39,14 @@ export default commandModule({
return ctx.reply(`Tag __${tagName}__ already exists`);
}
const similarKeywords = file.filter((t) => t.keywords.some((k) => tag.keywords.includes(k)));
const similarKeywords = file.filter((t) =>
t.keywords.some((k) => tag.keywords.includes(k)),
);
if (similarKeywords.length) {
return ctx.reply(
`Tag __${tagName}__ has similar keywords to __${similarKeywords
.map((t) => t.name)
.join(", ")}__`
.join(", ")}__`,
);
}
file.push(tag);

View File

@@ -33,13 +33,13 @@ export default commandModule({
(t) =>
t.keywords.some((k) => tag.keywords.includes(k)) &&
t.name !== oldTag.name &&
t.content !== oldTag.content
t.content !== oldTag.content,
);
if (similarKeywords.length) {
return ctx.reply(
`Tag __${tagName}__ has similar keywords to __${similarKeywords
.map((t) => t.name)
.join(", ")}__`
.join(", ")}__`,
);
}

View File

@@ -43,11 +43,11 @@ export default slashCommand({
if (role.size > 25) return ctx.reply("Too many roles");
const cdn = role.filter(
(r) => r.managed || r.position > (ctx.guild?.members.me)!.roles.highest.position
(r) => r.managed || r.position > (ctx.guild?.members.me)!.roles.highest.position,
).size;
if (cdn) {
return ctx.reply(
`Some roles are managed by integration or higher than my highest role.\nPlease try again`
`Some roles are managed by integration or higher than my highest role.\nPlease try again`,
);
}
await ctx.interaction.deferReply();
@@ -77,7 +77,7 @@ function createMenu(channel: TextChannel, role: Collection<string, Role>) {
label: r.name,
value: r.id,
};
})
}),
);
const row = new ActionRowBuilder<StringSelectMenuBuilder>().setComponents(menu);
return row;

View File

@@ -1,59 +1,64 @@
import { publish } from '#plugins';
import { commandModule, CommandType } from '@sern/handler';
import { ActionRowBuilder, codeBlock, ComponentType, inlineCode, StringSelectMenuBuilder } from 'discord.js';
import { createWorker } from 'tesseract.js';
import { publish } from "#plugins";
import { commandModule, CommandType } from "@sern/handler";
import {
ActionRowBuilder,
codeBlock,
ComponentType,
inlineCode,
StringSelectMenuBuilder,
} from "discord.js";
import { createWorker } from "tesseract.js";
export default commandModule({
type: CommandType.CtxMsg,
plugins: [publish()],
description: '',
description: "",
execute: async (ctx) => {
const select = new StringSelectMenuBuilder({
customId: 'ocr-lang',
placeholder: 'Select language',
customId: "ocr-lang",
placeholder: "Select language",
options: [
{ label: 'English', value: 'eng', emoji: '🇺🇸' },
{ label: 'Spanish', value: 'spa', emoji: '🇪🇸' },
{ label: 'Portuguese', value: 'por', emoji: '🇵🇹' },
{ label: 'French', value: 'fra', emoji: '🇫🇷' },
{ label: 'German', value: 'deu', emoji: '🇩🇪' },
{ label: 'Italian', value: 'ita', emoji: '🇮🇹' },
{ label: 'Japanese', value: 'jpn', emoji: '🇯🇵' },
]
})
const row = new ActionRowBuilder<StringSelectMenuBuilder>()
.addComponents(select)
{ label: "English", value: "eng", emoji: "🇺🇸" },
{ label: "Spanish", value: "spa", emoji: "🇪🇸" },
{ label: "Portuguese", value: "por", emoji: "🇵🇹" },
{ label: "French", value: "fra", emoji: "🇫🇷" },
{ label: "German", value: "deu", emoji: "🇩🇪" },
{ label: "Italian", value: "ita", emoji: "🇮🇹" },
{ label: "Japanese", value: "jpn", emoji: "🇯🇵" },
],
});
const row = new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(select);
const langMsg = await ctx.reply({
components: [row],
ephemeral: true,
})
});
const langCollector = langMsg.createMessageComponentCollector({
componentType: ComponentType.StringSelect,
time: 10000
})
langCollector.once('collect', async (i) => {
const lang = i.values[0]
langMsg.delete()
time: 10000,
});
langCollector.once("collect", async (i) => {
const lang = i.values[0];
langMsg.delete();
const readingMessage = await ctx.targetMessage.channel.send({
content: `Reading [this image](${ctx.targetMessage.url}) with language ${inlineCode(lang)}...`,
})
});
const image = ctx.targetMessage.attachments.first()
const image = ctx.targetMessage.attachments.first();
if (!image) {
await readingMessage.edit({
content: 'No image found',
})
return langCollector.stop('No image found')
content: "No image found",
});
return langCollector.stop("No image found");
}
const worker = await createWorker(lang)
const ocrData = await worker.recognize(image.proxyURL)
const worker = await createWorker(lang);
const ocrData = await worker.recognize(image.proxyURL);
await readingMessage.edit({
content: `Here's what I was able to read from ${ctx.targetMessage.url}:\n${codeBlock(ocrData.data.text)}`,
})
await worker.terminate()
})
});
await worker.terminate();
});
},
});

View File

@@ -7,7 +7,7 @@ export default slashCommand({
execute: async (context) => {
const uptime = new Timestamp(context.client.readyTimestamp!);
await context.reply(
`Pong 🏓 \`${context.client.ws.ping}ms\`\nStarted running ${uptime.getRelativeTime()}`
`Pong 🏓 \`${context.client.ws.ping}ms\`\nStarted running ${uptime.getRelativeTime()}`,
);
},
});

View File

@@ -19,17 +19,18 @@ export default slashCommand({
const plugins = require(PluginList) as Plugin[];
const focus = ctx.options.getFocused();
if (!plugins.length) return ctx.respond([{ name: "No plugins found", value: "" }]);
if (!plugins.length)
return ctx.respond([{ name: "No plugins found", value: "" }]);
const filtered = plugins.filter((p) =>
p.name.toLowerCase().includes(focus.toLowerCase())
p.name.toLowerCase().includes(focus.toLowerCase()),
);
return ctx.respond(
filtered.map((p) => ({
name: p.name,
value: p.link,
}))
})),
);
},
},
@@ -41,7 +42,7 @@ export default slashCommand({
context.reply({
content: `You gotta chill for ${seconds} seconds`,
ephemeral: true,
})
}),
),
],
async execute(ctx, [, options]) {
@@ -77,7 +78,7 @@ export default slashCommand({
{
name: "Example",
value: plugin.example,
}
},
);
return ctx.reply({

View File

@@ -26,7 +26,7 @@ export default slashCommand({
(ctx.channel.totalMessageSent ?? 0) + 1
}\` message(s) were sent in total here`;
const createdAt = `• This post was created ${new Timestamp(
ctx.channel.createdTimestamp!
ctx.channel.createdTimestamp!,
).getRelativeTime()}`;
const solvedAt = `• This post was solved ${new Timestamp(Date.now()).getRelativeTime()}`;

View File

@@ -37,9 +37,11 @@ export default slashCommand({
return ctx.respond(
tags
.filter((t) =>
focus.length ? t.toLowerCase().includes(focus.toLowerCase()) : true
focus.length
? t.toLowerCase().includes(focus.toLowerCase())
: true,
)
.map((t) => ({ name: t, value: t }))
.map((t) => ({ name: t, value: t })),
);
}
},
@@ -79,7 +81,7 @@ export default slashCommand({
label: embeds[i].data.title!,
value: `${i}`,
default: i === 0,
}))
})),
);
return paginator.run(ctx.interaction);

View File

@@ -46,9 +46,11 @@ export default slashCommand({
return ctx.respond(
tags
.filter((t) =>
focus.length ? t.toLowerCase().includes(focus.toLowerCase()) : true
focus.length
? t.toLowerCase().includes(focus.toLowerCase())
: true,
)
.map((t) => ({ name: t, value: t }))
.map((t) => ({ name: t, value: t })),
);
}
},
@@ -80,9 +82,11 @@ export default slashCommand({
return ctx.respond(
tags
.filter((t) =>
focus.length ? t.toLowerCase().includes(focus.toLowerCase()) : true
focus.length
? t.toLowerCase().includes(focus.toLowerCase())
: true,
)
.map((t) => ({ name: t, value: t }))
.map((t) => ({ name: t, value: t })),
);
}
},
@@ -98,7 +102,9 @@ export default slashCommand({
const file: TagData[] = require(TagList);
if (subcmd === "create") {
const modal = new ModalBuilder().setTitle("Tag Creation").setCustomId("@sern/tag/create");
const modal = new ModalBuilder()
.setTitle("Tag Creation")
.setCustomId("@sern/tag/create");
const tagName = new TextInputBuilder()
.setCustomId("tag-name")
@@ -127,7 +133,7 @@ export default slashCommand({
.setStyle(TextInputStyle.Short);
const rows = [tagName, tagContent, keywords].map((r) =>
new ActionRowBuilder<TextInputBuilder>().addComponents(r)
new ActionRowBuilder<TextInputBuilder>().addComponents(r),
);
modal.addComponents(rows);
@@ -172,7 +178,7 @@ export default slashCommand({
.setValue(tagData.keywords.join(", "));
const rows = [tagName, tagContent, keywords].map((r) =>
new ActionRowBuilder<TextInputBuilder>().addComponents(r)
new ActionRowBuilder<TextInputBuilder>().addComponents(r),
);
modal.addComponents(rows);
context.user.data = { tag };

View File

@@ -81,7 +81,7 @@ export default slashCommand({
case "get": {
const option = options.getMember("user") as GuildMember;
const request = await fetch(
`https://api.srizan.dev/sern/getTime?userid=${option.id}`
`https://api.srizan.dev/sern/getTime?userid=${option.id}`,
).catch(() => null);
const data = (await request?.json()) as APIResponse;
@@ -114,7 +114,7 @@ export default slashCommand({
`https://api.srizan.dev/sern/deleteTime?userid=${ctx.user.id}&key=${process.env.TIME_KEY}`,
{
method: "DELETE",
}
},
).catch(() => null);
const data = (await request?.json()) as Record<string, string>;

19
src/dependencies.d.ts vendored
View File

@@ -4,10 +4,18 @@
* Service(s) api rely on this file to provide a better developer experience.
*/
import type { SernEmitter, Logging, CoreModuleStore, ModuleManager, ErrorHandling, CoreDependencies, Singleton } from '@sern/handler'
import type { Client } from 'discord.js'
import type { SernLogger } from './utils/Logger';
import type { Octokit } from '@octokit/rest'
import type {
SernEmitter,
Logging,
CoreModuleStore,
ModuleManager,
ErrorHandling,
CoreDependencies,
Singleton,
} from "@sern/handler";
import type { Client } from "discord.js";
import type { SernLogger } from "./utils/Logger";
import type { Octokit } from "@octokit/rest";
declare global {
interface Dependencies extends Dependencies {
"@sern/client": Singleton<Client>;
@@ -16,5 +24,4 @@ declare global {
}
}
export {}
export {};

View File

@@ -8,7 +8,8 @@ export default eventModule({
plugins: [onCorrectThread(forumID)],
name: "threadCreate",
async execute(thread: AnyThreadChannel, _: boolean) {
if (thread.appliedTags.length > 3) await thread.setAppliedTags(thread.appliedTags.slice(0, 3));
if (thread.appliedTags.length > 3)
await thread.setAppliedTags(thread.appliedTags.slice(0, 3));
const msg = await thread.fetchStarterMessage().catch(() => null);
if (!msg) return thread.setLocked(true);
@@ -21,7 +22,7 @@ export default eventModule({
`Please make sure you've read the **__Post Guidelines__**!\n` +
`In the meanwhile you wait for your answer, It is recommended to provide details as much as possible\n`
.concat(list)
.concat(`\n\n\nIssue Solved? Run </solved:1026499792194510939>`)
.concat(`\n\n\nIssue Solved? Run </solved:1026499792194510939>`),
)
.setColor("Random")
.setTimestamp()

View File

@@ -21,14 +21,16 @@ const client = new Client({
},
});
await makeDependencies({
build: (root) =>
root.add({ "@sern/client": () => client })
root
.add({ "@sern/client": () => client })
.upsert({ "@sern/logger": () => new SernLogger("info") })
.add({ process: () => process,
octokit: () => new Octokit({ auth: process.env.GITHUB_TOKEN }) })
});
.add({
process: () => process,
octokit: () => new Octokit({ auth: process.env.GITHUB_TOKEN }),
}),
});
Sern.init({
defaultPrefix: "sern",

View File

@@ -97,7 +97,7 @@ type CooldownResponse = (cooldown: RecievedCooldown) => any;
function add(
items: Array<[CooldownLocation | keyof typeof CooldownLocation, CooldownString] | Cooldown>,
message?: CooldownResponse
message?: CooldownResponse,
) {
const raw = items.map((c) => {
if (!Array.isArray(c)) return c;

View File

@@ -42,11 +42,7 @@ export const CommandTypeRaw = {
} as const;
export function publish<
T extends
| CommandType.Both
| CommandType.Slash
| CommandType.CtxMsg
| CommandType.CtxUser,
T extends CommandType.Both | CommandType.Slash | CommandType.CtxMsg | CommandType.CtxUser,
>(options?: PublishOptions) {
return CommandInitPlugin<T>(async ({ module }) => {
// Users need to provide their own useContainer function.
@@ -63,8 +59,7 @@ export function publish<
defaultMemberPermissions: null,
};
options = { ...defaultOptions, ...options } as PublishOptions &
ValidPublishOptions;
options = { ...defaultOptions, ...options } as PublishOptions & ValidPublishOptions;
let { defaultMemberPermissions, dmPermission, guildIds } =
options as unknown as ValidPublishOptions;
@@ -96,10 +91,7 @@ export function publish<
name: module.name,
type: curAppType,
description: cmd(module.description, ""),
options: cmd(
optionsTransformer((module as SlashCommand).options ?? []),
[],
),
options: cmd(optionsTransformer((module as SlashCommand).options ?? []), []),
defaultMemberPermissions,
dmPermission,
} as ApplicationCommandData;
@@ -114,13 +106,9 @@ export function publish<
);
if (cmd) {
if (!cmd.equals(commandData, true)) {
logged(
`Found differences in global command ${module.name}`,
);
logged(`Found differences in global command ${module.name}`);
cmd.edit(commandData).then(
log(
`${module.name} updated with new data successfully!`,
),
log(`${module.name} updated with new data successfully!`),
);
}
return controller.next();
@@ -143,11 +131,7 @@ export function publish<
logged(`Found differences in command ${module.name}`);
guildCmd
.edit(commandData)
.then(
log(
`${module.name} updated with new data successfully!`,
),
)
.then(log(`${module.name} updated with new data successfully!`))
.catch(c);
continue;
}
@@ -173,9 +157,7 @@ export function optionsTransformer(ops: Array<SernOptionsData>) {
case ApplicationCommandOptionType.String:
case ApplicationCommandOptionType.Number:
case ApplicationCommandOptionType.Integer: {
return el.autocomplete && "command" in el
? (({ command, ...el }) => el)(el)
: el;
return el.autocomplete && "command" in el ? (({ command, ...el }) => el)(el) : el;
}
default:
return el;

View File

@@ -1,5 +1,5 @@
import { Presence } from '@sern/handler'
import { ActivityType, ClientPresenceStatus } from 'discord.js';
import { Presence } from "@sern/handler";
import { ActivityType, ClientPresenceStatus } from "discord.js";
function shuffleArray<T>(array: T[]) {
for (let i = array.length - 1; i > 0; i--) {
@@ -9,26 +9,26 @@ function shuffleArray<T>(array: T[]) {
return [...array];
}
const statuses =[[ActivityType.Watching, "the sern community", "online"],
const statuses = [
[ActivityType.Watching, "the sern community", "online"],
[ActivityType.Listening, "Evo", "dnd"],
[ActivityType.Playing, "with @sern/cli", "idle"],
[ActivityType.Watching, "sern bots", "dnd"],
[ActivityType.Watching, "github stars go brrr", "online"],
[ActivityType.Listening, "Spotify", "dnd"],
[ActivityType.Listening, "what's bofa", "idle"]] satisfies
[ActivityType, string, ClientPresenceStatus][];
[ActivityType.Listening, "what's bofa", "idle"],
] satisfies [ActivityType, string, ClientPresenceStatus][];
export default Presence.module({
execute: () => {
const [type, name, status] = statuses.at(0)!;
return Presence
.of({ activities: [ { type, name } ], status }) //start your presence with this.
return Presence.of({ activities: [{ type, name }], status }) //start your presence with this.
.repeated(() => {
const [type, name, status] = [...shuffleArray(statuses)].shift()!;
return {
status,
activities: [{ type, name }]
activities: [{ type, name }],
};
}, 60_000); //repeat and setPresence with returned result every minute
}
})
},
});

View File

@@ -34,7 +34,9 @@ export default class DocHandler {
}
} else {
const sectionChildNodes = section.children.map((id: string) => {
const node = docs.children.find((c: { id: string }) => c.id === id)! as DocsChild;
const node = docs.children.find(
(c: { id: string }) => c.id === id,
)! as DocsChild;
return {
name: section.title,
node,

View File

@@ -3,7 +3,10 @@ import { findBestMatch } from "string-similarity";
import type { TagData } from "typings";
export class FuzzyMatcher {
public constructor(private readonly message: Message, private readonly tags: TagData[]) {}
public constructor(
private readonly message: Message,
private readonly tags: TagData[],
) {}
readonly #regex = /<@!?(?<id>\d{17,20})>/g;
@@ -22,7 +25,9 @@ export class FuzzyMatcher {
if (matches.bestMatch.rating < 0.4) return null;
const words = this.cleanContent.toLowerCase().split(" ");
const firstMatchedTag = this.tags.find((t) => t.keywords.includes(matches.bestMatch.target));
const firstMatchedTag = this.tags.find((t) =>
t.keywords.includes(matches.bestMatch.target),
);
if (!firstMatchedTag) return null;
const keyword = firstMatchedTag.keywords.find((k) => {

View File

@@ -13,7 +13,7 @@ export class SernLogger implements Logging {
this._winston.add(
new winston.transports.Console({
format: winston.format.simple(),
})
}),
);
} else {
this._winston.add(new winston.transports.File({ filename: "error.log" }));

View File

@@ -32,7 +32,7 @@ export class Paginator {
this.options.embeds &&= this.options.embeds.map((embed, i) =>
new EmbedBuilder(embed.data).setFooter({
text: `Page ${i + 1}/${this.options.embeds!.length}`,
})
}),
);
if (this.pages > 25) this.options.includeSelectMenu = false;
@@ -90,7 +90,7 @@ export class Paginator {
private async handleMessage(
message: Message,
embeds: EmbedBuilder[],
rows: (ActionRowBuilder<StringSelectMenuBuilder> | ActionRowBuilder<ButtonBuilder>)[]
rows: (ActionRowBuilder<StringSelectMenuBuilder> | ActionRowBuilder<ButtonBuilder>)[],
) {
const msg = await message.channel.send({
embeds: [embeds![this.currentCount]],
@@ -102,7 +102,7 @@ export class Paginator {
private async handleInteraction(
interaction: CommandInteraction,
embeds: EmbedBuilder[],
rows: (ActionRowBuilder<StringSelectMenuBuilder> | ActionRowBuilder<ButtonBuilder>)[]
rows: (ActionRowBuilder<StringSelectMenuBuilder> | ActionRowBuilder<ButtonBuilder>)[],
) {
let msg: Message<boolean>;
if (interaction.replied || interaction.deferred) {
@@ -206,7 +206,7 @@ export class Paginator {
.setDisabled(
embeds.length === 1 ||
((i === 0 || i === 1) && first === this.currentCount) ||
((i === 3 || i === 4) && last === this.currentCount)
((i === 3 || i === 4) && last === this.currentCount),
)
.setStyle(ButtonStyle.Secondary);
buttons.push(button);
@@ -231,7 +231,7 @@ export class Paginator {
label: `Page ${i + 1}`,
value: `${i}`,
default: i === this.currentCount,
})))
}))),
);
const row = new ActionRowBuilder<StringSelectMenuBuilder>().setComponents(select);
return row;
@@ -256,7 +256,8 @@ export class Paginator {
}
private updateSelect(components: ActionRow<MessageActionRowComponent>[]) {
const selectMenuOption = (components[1].components[0].data as APIStringSelectComponent).options;
const selectMenuOption = (components[1].components[0].data as APIStringSelectComponent)
.options;
for (const option of selectMenuOption) {
if (option.value === `${this.currentCount}`) option.default = true;
else option.default = false;

View File

@@ -19,7 +19,7 @@ import {
export class Resolver {
public constructor(
private readonly content: string,
private readonly interaction: CommandInteraction
private readonly interaction: CommandInteraction,
) {}
readonly #regex = {

View File

@@ -58,7 +58,7 @@ export class TicTacToe {
mark: "X" | "O",
content: string,
pieces: ActionRowBuilder<ButtonBuilder>[],
opponent: User
opponent: User,
) {
collector.on("collect", async (i) => {
if (chance.id !== i.user.id) {
@@ -135,14 +135,16 @@ export class TicTacToe {
new ButtonBuilder()
.setCustomId(`${i + 1}-${j + 1}`)
.setEmoji(this.#Empty)
.setStyle(ButtonStyle.Secondary)
.setStyle(ButtonStyle.Secondary),
);
}
public buildRows() {
return Array<ActionRowBuilder>(3)
.fill(new ActionRowBuilder())
.map((_, i) => new ActionRowBuilder<ButtonBuilder>().setComponents(this.buildButtons(i)));
.map((_, i) =>
new ActionRowBuilder<ButtonBuilder>().setComponents(this.buildButtons(i)),
);
}
public mark(rows: ActionRowBuilder<ButtonBuilder>[], id: string, mark: "X" | "O") {
@@ -188,7 +190,7 @@ export class TicTacToe {
public disableAllButtons(
pieces: ActionRowBuilder<ButtonBuilder>[],
winner?: "X" | "O",
winPieces?: Combination[]
winPieces?: Combination[],
) {
for (const row of pieces) {
for (const piece of row.components) {
@@ -200,7 +202,7 @@ export class TicTacToe {
if (
win === emojiString &&
winPieces.some((w) =>
w.includes((piece.data as APIButtonComponentWithCustomId).custom_id)
w.includes((piece.data as APIButtonComponentWithCustomId).custom_id),
)
)
piece.setStyle(ButtonStyle.Success);

View File

@@ -25,7 +25,7 @@ declare module "trie-search" {
accumulator: A | undefined,
phrase: string,
matches: T[],
trieSearch: TrieSearch<T, I>
trieSearch: TrieSearch<T, I>,
) => A | undefined;
export default class TrieSearch<T, I = T> {
@@ -61,7 +61,11 @@ declare module "trie-search" {
get(phrases: string | string[], reducer?: null | undefined, limit?: number): T[];
get<A>(phrases: string | string[], reducer?: Reducer<A, T, I>, limit?: number): A | undefined;
get<A>(
phrases: string | string[],
reducer?: Reducer<A, T, I>,
limit?: number,
): A | undefined;
search(phrases: string | string[], reducer?: null | undefined): I[];
@@ -73,7 +77,7 @@ declare module "trie-search" {
accumulator: V[] | undefined,
phrase: string,
matches: V[],
trieSearch: TrieSearch<V, V>
trieSearch: TrieSearch<V, V>,
) => V[];
}
}

View File

@@ -1,3 +1,3 @@
export * from './docs.js'
export * from './plugin.js'
export * from './Tags.js'
export * from "./docs.js";
export * from "./plugin.js";
export * from "./Tags.js";