refactor: pretty imports (#24)

This commit is contained in:
Evo
2022-10-03 21:02:54 +05:30
committed by GitHub
parent 1a5479ea41
commit e6581e6eba
23 changed files with 74 additions and 50 deletions

View File

@@ -8,6 +8,11 @@
"name": "EvolutionX-10",
"url": "https://github.com/EvolutionX-10"
},
"imports": {
"#plugins": "./dist/src/plugins/index.js",
"#utils": "./dist/src/utils/index.js",
"#constants": "./dist/src/constants.js"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "tsup && node .",

View File

@@ -1,8 +1,8 @@
import { commandModule, CommandType } from '@sern/handler';
import { ApplicationCommandOptionType, Colors, EmbedBuilder } from 'discord.js';
import { Kind, PurpleComment, PurpleSummary, TentacledKindString } from '../../typings/docs.js';
import { Paginator } from '../utils/Paginator.js';
import { publish } from '../plugins/publish.js';
import { Paginator } from '#utils';
import { publish } from '#plugins';
import DocHandler from '../trie/doc-autocmp.js';
function handleComments(sum : PurpleSummary) {

View File

@@ -12,9 +12,8 @@ import {
TextChannel,
} from "discord.js";
import { fetch } from "undici";
import { cooldown } from "../plugins/cooldown.js";
import { publish } from "../plugins/publish.js";
import { Resolver } from "../utils/Resolver.js";
import { cooldown, publish } from "#plugins";
import { Resolver } from "#utils";
export default commandModule({
type: CommandType.Slash,

View File

@@ -1,7 +1,7 @@
import { commandModule, CommandType } from "@sern/handler";
import { EmbedBuilder } from "discord.js";
import { inspect } from "util";
import { ownerOnly } from "../plugins/ownerOnly.js";
import { ownerOnly } from "#plugins";
export default commandModule({
type: CommandType.Text,

View File

@@ -8,10 +8,11 @@ import {
ComponentType,
User,
} from "discord.js";
import { publish } from "../../plugins/publish.js";
import { publish } from "#plugins";
export default commandModule({
type: CommandType.Slash,
plugins: [publish()],
plugins: [publish({ dmPermission: false })],
description: "wanna win in rps?",
options: [
{
@@ -125,10 +126,12 @@ export default commandModule({
collector.on("end", async (_, r) => {
if (r === "finished") return;
await context.interaction.editReply({
content: "Time up!",
components: [row.setComponents(buttons)],
}).catch(() => null);
await context.interaction
.editReply({
content: "Time up!",
components: [row.setComponents(buttons)],
})
.catch(() => null);
});
},
});

View File

@@ -6,7 +6,7 @@ import { Timestamp } from "../../utils/Timestamp.js";
export default commandModule({
type: CommandType.Slash,
plugins: [publish()],
plugins: [publish({ dmPermission: false })],
options: [
{
name: "opponent",

View File

@@ -1,3 +1,4 @@
import { ownerIDs } from "#constants";
import { commandModule, CommandType } from "@sern/handler";
import {
ActionRowBuilder,
@@ -5,7 +6,6 @@ import {
TextInputBuilder,
TextInputStyle,
} from "discord.js";
import { ownerIDs } from "../../plugins/ownerOnly.js";
export default commandModule({
type: CommandType.Button,

View File

@@ -1,6 +1,6 @@
import { ownerIDs } from "#constants";
import { commandModule, CommandType } from "@sern/handler";
import { ActionRowBuilder, ButtonBuilder, EmbedBuilder } from "discord.js";
import { ownerIDs } from "../../plugins/ownerOnly.js";
export default commandModule({
type: CommandType.Button,
@@ -32,6 +32,11 @@ export default commandModule({
.setColor("Red")
.setTimestamp();
await ctx.message?.edit({ content: null, embeds: [embed], components, files: [] });
await ctx.message?.edit({
content: null,
embeds: [embed],
components,
files: [],
});
},
});

View File

@@ -1,5 +1,5 @@
import { commandModule, CommandType } from "@sern/handler";
import type { TagMessage } from "../../types/index.js";
import type { TagMessage } from "../../types";
export default commandModule({
type: CommandType.Button,

View File

@@ -1,6 +1,6 @@
import { commandModule, CommandType } from "@sern/handler";
import { existsSync, writeFileSync } from "fs";
import type { TagData } from "../../types/index.js";
import type { TagData } from "../../types";
import { createRequire } from "module";
const require = createRequire(import.meta.url);

View File

@@ -1,7 +1,7 @@
import { commandModule, CommandType } from "@sern/handler";
import { writeFileSync } from "fs";
import { createRequire } from "module";
import type { TagData } from "../../types/index.js";
import type { TagData } from "../../types";
const require = createRequire(import.meta.url);
export default commandModule({

View File

@@ -9,9 +9,8 @@ import {
ChannelType,
EmbedBuilder,
} from "discord.js";
import { ownerOnly } from "../plugins/ownerOnly.js";
import { publish } from "../plugins/publish.js";
import { Resolver } from "../utils/Resolver.js";
import { ownerOnly, publish } from "#plugins";
import { Resolver } from "#utils";
export default commandModule({
plugins: [ownerOnly(), publish()],

View File

@@ -1,5 +1,6 @@
import { commandModule, CommandType } from "@sern/handler";
import { publish } from "../plugins/publish.js";
import { publish } from "#plugins";
export default commandModule({
type: CommandType.Slash,
plugins: [publish()],

View File

@@ -1,10 +1,7 @@
import { commandModule, CommandType } from "@sern/handler";
import { publish } from "../plugins/publish.js";
import { fetch } from "undici";
import { ApplicationCommandOptionType, EmbedBuilder } from "discord.js";
import { cooldown } from "../plugins/cooldown.js";
import { cooldown, publish } from "#plugins";
import { parse } from "jsdoc-parse-plus";
import { refreshCache } from "../plugins/refreshCache.js";
export default commandModule({
type: CommandType.Slash,
description: "View sern plugins",
@@ -38,7 +35,6 @@ export default commandModule({
},
],
plugins: [
refreshCache(),
publish(),
cooldown.add([["user", "1/10"]], ({ seconds, context }) =>
context.reply({

View File

@@ -1,14 +1,14 @@
import { commandModule, CommandType } from "@sern/handler";
import { Collection, Client } from "discord.js";
import { publish } from "../plugins/publish.js";
import { fetch } from "undici";
import type { Data } from "./plugin.js";
import { ownerOnly } from "../plugins/ownerOnly.js";
import { Evo } from "../constants.js";
import { ownerOnly, publish, refreshCache } from "#plugins";
import { Evo } from "#constants";
export default commandModule({
type: CommandType.Slash,
plugins: [
refreshCache(),
publish({
dmPermission: false,
defaultMemberPermissions: ["Administrator"],

View File

@@ -1,8 +1,7 @@
import { commandModule, CommandType } from "@sern/handler";
import { ChannelType } from "discord.js";
import { channelOnly } from "../plugins/channelOnly.js";
import { ownerIDs } from "../plugins/ownerOnly.js";
import { publish } from "../plugins/publish.js";
import { publish, channelOnly } from "#plugins";
import { ownerIDs } from "#constants";
export default commandModule({
type: CommandType.Slash,

View File

@@ -1,8 +1,8 @@
import { commandModule, CommandType } from "@sern/handler";
import { ApplicationCommandOptionType, EmbedBuilder } from "discord.js";
import { existsSync } from "fs";
import { Paginator } from "../utils/Paginator.js";
import { publish } from "../plugins/publish.js";
import { publish } from "#plugins";
import { Paginator } from "#utils";
import { createRequire } from "module";
import type { TagData } from "../types/index.js";

View File

@@ -8,10 +8,9 @@ import {
} from "discord.js";
import { existsSync, writeFileSync } from "fs";
import { createRequire } from "module";
import { Evo } from "../constants.js";
import { ownerOnly } from "../plugins/ownerOnly.js";
import { publish } from "../plugins/publish.js";
import type { TagData } from "../types/index.js";
import { Evo } from "#constants";
import { ownerOnly, publish } from "#plugins";
import type { TagData } from "../types";
const require = createRequire(import.meta.url);
export default commandModule({

View File

@@ -1 +1,4 @@
export const Evo = "697795666373640213";
export const Seren = "182326315813306368";
export const Ropox = "756393473430519849";
export const ownerIDs = [Evo, Seren, Ropox];

5
src/plugins/index.ts Normal file
View File

@@ -0,0 +1,5 @@
export * from "./channelOnly.js";
export * from "./cooldown.js";
export * from "./ownerOnly.js";
export * from "./publish.js";
export * from "./refreshCache.js";

View File

@@ -1,20 +1,18 @@
import { CommandType, EventPlugin, PluginType } from "@sern/handler";
export const ownerIDs = [
"697795666373640213",
"182326315813306368",
"756393473430519849",
];
import { ownerIDs } from "#constants";
export function ownerOnly(override?: string[]): EventPlugin<CommandType.Both> {
return {
type: PluginType.Event,
description: "Allows only bot owner to run command",
async execute(event, controller) {
const [ctx] = event;
if ((override ?? ownerIDs).includes(ctx.user.id)) return controller.next();
if ((override ?? ownerIDs).includes(ctx.user.id))
return controller.next();
await ctx.reply({
content: 'Not for you!',
ephemeral: true
})
content: "Not for you!",
ephemeral: true,
});
return controller.stop();
},
};

7
src/utils/index.ts Normal file
View File

@@ -0,0 +1,7 @@
export * from "./FuzzyMatcher.js";
export * from "./Paginator.js";
export * from "./Resolver.js";
export * from "./TicTacToe.js";
export * from "./Timestamp.js";
export * from "./pagination.js";
export * from "./randomStatus.js";

View File

@@ -11,6 +11,11 @@
"strictNullChecks": true,
"importsNotUsedAsValues": "error",
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
"forceConsistentCasingInFileNames": true,
"paths": {
"#plugins": ["./src/plugins/index.js"],
"#utils": ["./src/utils/index.js"],
"#constants": ["./src/constants.js"]
}
}
}