Skip to content

Commit

Permalink
squash!
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolaRHristov committed Dec 17, 2023
1 parent cc8ac4d commit 76f2c7b
Show file tree
Hide file tree
Showing 10 changed files with 200 additions and 51 deletions.
4 changes: 2 additions & 2 deletions Source/Configuration/PM2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export type Ecosystem = {
apps: Apps;
};

export default {
export default ({
apps: [
{
name: "discord",
Expand All @@ -16,4 +16,4 @@ export default {
force: true,
},
],
} satisfies Ecosystem;
} satisfies Ecosystem);
4 changes: 2 additions & 2 deletions Source/Option/DISCORD.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const Clients: Client[] = [

if (!DISCORD_PUBLIC_KEY) {
throw new Error(
"The DISCORD_TOKEN environment variable is required."
"The DISCORD_TOKEN environment variable is required.",
);
}

Expand All @@ -72,7 +72,7 @@ export const Clients: Client[] = [

async function registerGlobalCommands() {
await registerCommands(
`https://discord.com/api/v10/applications/${applicationId}/commands`
`https://discord.com/api/v10/applications/${applicationId}/commands`,
);
}

Expand Down
11 changes: 10 additions & 1 deletion Target/Application/Discord.js
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
for(const{token:n,options:t,events:e}of(await import("../Option/DISCORD.js")).default){if(!t)continue;const o=new(await import("discord.js")).Client(t);for(const[i,a]of e??[])o.on(i,a);o.login(n)}var f={};export{f as default};
for (const { token: n, options: t, events: e } of (
await import("../Option/DISCORD.js")
).default) {
if (!t) continue;
const o = new (await import("discord.js")).Client(t);
for (const [i, a] of e ?? []) o.on(i, a);
o.login(n);
}
var f = {};
export { f as default };
16 changes: 8 additions & 8 deletions Target/Configuration/PM2.d.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import type { StartOptions } from "pm2";
export type Apps = StartOptions[];
export type Ecosystem = {
apps: Apps;
apps: Apps;
};
declare const _default: {
apps: {
name: string;
script: string;
watch: true;
autorestart: true;
force: true;
}[];
apps: {
name: string;
script: string;
watch: true;
autorestart: true;
force: true;
}[];
};
export default _default;
13 changes: 12 additions & 1 deletion Target/Configuration/PM2.js
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
var t={apps:[{name:"discord",script:"./Target/apps/discord.js",watch:!0,autorestart:!0,force:!0}]};export{t as default};
var t = {
apps: [
{
name: "discord",
script: "./Target/apps/discord.js",
watch: !0,
autorestart: !0,
force: !0,
},
],
};
export { t as default };
3 changes: 2 additions & 1 deletion Target/Index.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
import{default as a}from"./Application/Discord.js";export{a as Discord};
import { default as a } from "./Application/Discord.js";
export { a as Discord };
102 changes: 75 additions & 27 deletions Target/Library/Environment.d.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,76 @@
export declare const object: <T extends import("zod").ZodRawShape>(shape: T, params?: import("zod").RawCreateParams) => import("zod").ZodObject<T, "strip", import("zod").ZodTypeAny, { [k_1 in keyof import("zod").objectUtil.addQuestionMarks<import("zod").baseObjectOutputType<T>, { [k in keyof import("zod").baseObjectOutputType<T>]: undefined extends import("zod").baseObjectOutputType<T>[k] ? never : k; }[keyof T]>]: import("zod").objectUtil.addQuestionMarks<import("zod").baseObjectOutputType<T>, { [k_2 in keyof import("zod").baseObjectOutputType<T>]: undefined extends import("zod").baseObjectOutputType<T>[k_2] ? never : k_2; }[keyof T]>[k_1]; }, { [k_2 in keyof import("zod").baseObjectInputType<T>]: import("zod").baseObjectInputType<T>[k_2]; }>, string: (params?: ({
errorMap?: import("zod").ZodErrorMap | undefined;
invalid_type_error?: string | undefined;
required_error?: string | undefined;
description?: string | undefined;
} & {
coerce?: true | undefined;
}) | undefined) => import("zod").ZodString;
declare const _default: import("zod").ZodObject<{
DISCORD_APPLICATION_ID: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodString>>;
DISCORD_CLIENT_ID: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodString>>;
DISCORD_CLIENT_SECRET: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodString>>;
DISCORD_PUBLIC_KEY: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodString>>;
DISCORD_TOKENS: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodString>>;
}, "strip", import("zod").ZodTypeAny, {
DISCORD_APPLICATION_ID: string;
DISCORD_CLIENT_ID: string;
DISCORD_CLIENT_SECRET: string;
DISCORD_PUBLIC_KEY: string;
DISCORD_TOKENS: string;
}, {
DISCORD_APPLICATION_ID?: string | undefined;
DISCORD_CLIENT_ID?: string | undefined;
DISCORD_CLIENT_SECRET?: string | undefined;
DISCORD_PUBLIC_KEY?: string | undefined;
DISCORD_TOKENS?: string | undefined;
}>;
export declare const object: <T extends import("zod").ZodRawShape>(
shape: T,
params?: import("zod").RawCreateParams,
) => import("zod").ZodObject<
T,
"strip",
import("zod").ZodTypeAny,
{
[k_1 in keyof import("zod").objectUtil.addQuestionMarks<
import("zod").baseObjectOutputType<T>,
{
[k in keyof import("zod").baseObjectOutputType<T>]: undefined extends import("zod").baseObjectOutputType<T>[k]
? never
: k;
}[keyof T]
>]: import("zod").objectUtil.addQuestionMarks<
import("zod").baseObjectOutputType<T>,
{
[k_2 in keyof import("zod").baseObjectOutputType<T>]: undefined extends import("zod").baseObjectOutputType<T>[k_2]
? never
: k_2;
}[keyof T]
>[k_1];
},
{
[k_2 in keyof import("zod").baseObjectInputType<T>]: import("zod").baseObjectInputType<T>[k_2];
}
>,
string: (
params?:
| ({
errorMap?: import("zod").ZodErrorMap | undefined;
invalid_type_error?: string | undefined;
required_error?: string | undefined;
description?: string | undefined;
} & {
coerce?: true | undefined;
})
| undefined,
) => import("zod").ZodString;
declare const _default: import("zod").ZodObject<
{
DISCORD_APPLICATION_ID: import("zod").ZodDefault<
import("zod").ZodOptional<import("zod").ZodString>
>;
DISCORD_CLIENT_ID: import("zod").ZodDefault<
import("zod").ZodOptional<import("zod").ZodString>
>;
DISCORD_CLIENT_SECRET: import("zod").ZodDefault<
import("zod").ZodOptional<import("zod").ZodString>
>;
DISCORD_PUBLIC_KEY: import("zod").ZodDefault<
import("zod").ZodOptional<import("zod").ZodString>
>;
DISCORD_TOKENS: import("zod").ZodDefault<
import("zod").ZodOptional<import("zod").ZodString>
>;
},
"strip",
import("zod").ZodTypeAny,
{
DISCORD_APPLICATION_ID: string;
DISCORD_CLIENT_ID: string;
DISCORD_CLIENT_SECRET: string;
DISCORD_PUBLIC_KEY: string;
DISCORD_TOKENS: string;
},
{
DISCORD_APPLICATION_ID?: string | undefined;
DISCORD_CLIENT_ID?: string | undefined;
DISCORD_CLIENT_SECRET?: string | undefined;
DISCORD_PUBLIC_KEY?: string | undefined;
DISCORD_TOKENS?: string | undefined;
}
>;
export default _default;
11 changes: 10 additions & 1 deletion Target/Library/Environment.js
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
(await import("dotenv")).config();const{object:o,string:t}=await import("zod");var a=o({DISCORD_APPLICATION_ID:t().optional().default(""),DISCORD_CLIENT_ID:t().optional().default(""),DISCORD_CLIENT_SECRET:t().optional().default(""),DISCORD_PUBLIC_KEY:t().optional().default(""),DISCORD_TOKENS:t().optional().default("")});export{a as default,o as object,t as string};
(await import("dotenv")).config();
const { object: o, string: t } = await import("zod");
var a = o({
DISCORD_APPLICATION_ID: t().optional().default(""),
DISCORD_CLIENT_ID: t().optional().default(""),
DISCORD_CLIENT_SECRET: t().optional().default(""),
DISCORD_PUBLIC_KEY: t().optional().default(""),
DISCORD_TOKENS: t().optional().default(""),
});
export { a as default, o as object, t as string };
16 changes: 9 additions & 7 deletions Target/Option/DISCORD.d.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
export declare const DISCORD_APPLICATION_ID: string, DISCORD_PUBLIC_KEY: string, DISCORD_TOKENS: string;
export declare const DISCORD_APPLICATION_ID: string,
DISCORD_PUBLIC_KEY: string,
DISCORD_TOKENS: string;
export declare const Tokens: string[];
export type Client = {
events?: Map<string, (...args: string[]) => Promise<void>>;
options?: ClientOptions;
token?: string;
preflight?: (...args: string[]) => Promise<void>;
events?: Map<string, (...args: string[]) => Promise<void>>;
options?: ClientOptions;
token?: string;
preflight?: (...args: string[]) => Promise<void>;
};
export type Flight = {
routes: [];
preflight: () => Promise<void>;
routes: [];
preflight: () => Promise<void>;
};
export declare const Clients: Client[];
declare const _default: Client[];
Expand Down
71 changes: 70 additions & 1 deletion Target/Option/DISCORD.js
Original file line number Diff line number Diff line change
@@ -1 +1,70 @@
import{GatewayIntentBits as s}from"discord.js";const{DISCORD_APPLICATION_ID:l,DISCORD_PUBLIC_KEY:c,DISCORD_TOKENS:i}=(await import("../Library/Environment.js")).default.parse(process.env),g=i.indexOf(",")!==-1?i.split(","):[i],m=[{token:"",events:new Map([["message",async t=>{console.log(t)}]]),options:{intents:[s.GuildMembers,s.GuildMessages,s.Guilds,s.MessageContent]},preflight:async t=>{const e=l;if(!c)throw new Error("The DISCORD_TOKEN environment variable is required.");async function o(a){const n=await fetch(a,{headers:{"Content-Type":"application/json",Authorization:`Bot ${t}`},method:"PUT",body:JSON.stringify([AWW_COMMAND,INVITE_COMMAND])});if(n.ok)console.log("Registered all commands");else{console.error("Error registering commands");const p=await n.text();console.error(p)}return n}async function r(){await o(`https://discord.com/api/v10/applications/${e}/commands`)}await r()}}];var f=m.map((t,e)=>{const o=g[e];return o?t.token=o:console.log(`No token for client: ${e}`),t});export{m as Clients,l as DISCORD_APPLICATION_ID,c as DISCORD_PUBLIC_KEY,i as DISCORD_TOKENS,g as Tokens,f as default};
import { GatewayIntentBits as s } from "discord.js";
const {
DISCORD_APPLICATION_ID: l,
DISCORD_PUBLIC_KEY: c,
DISCORD_TOKENS: i,
} = (await import("../Library/Environment.js")).default.parse(process.env),
g = i.indexOf(",") !== -1 ? i.split(",") : [i],
m = [
{
token: "",
events: new Map([
[
"message",
async (t) => {
console.log(t);
},
],
]),
options: {
intents: [
s.GuildMembers,
s.GuildMessages,
s.Guilds,
s.MessageContent,
],
},
preflight: async (t) => {
const e = l;
if (!c)
throw new Error(
"The DISCORD_TOKEN environment variable is required.",
);
async function o(a) {
const n = await fetch(a, {
headers: {
"Content-Type": "application/json",
Authorization: `Bot ${t}`,
},
method: "PUT",
body: JSON.stringify([AWW_COMMAND, INVITE_COMMAND]),
});
if (n.ok) console.log("Registered all commands");
else {
console.error("Error registering commands");
const p = await n.text();
console.error(p);
}
return n;
}
async function r() {
await o(
`https://discord.com/api/v10/applications/${e}/commands`,
);
}
await r();
},
},
];
var f = m.map((t, e) => {
const o = g[e];
return o ? (t.token = o) : console.log(`No token for client: ${e}`), t;
});
export {
m as Clients,
l as DISCORD_APPLICATION_ID,
c as DISCORD_PUBLIC_KEY,
i as DISCORD_TOKENS,
g as Tokens,
f as default,
};

0 comments on commit 76f2c7b

Please sign in to comment.