Skip to content

Commit

Permalink
feat: 3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
leomotors committed Oct 12, 2023
1 parent f7c957f commit 59b5f4f
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 9 deletions.
4 changes: 4 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ SKITTLE_NEE=
VLADIMIR=
WESSUWAN=
CAPPUCHINO=
EMU=
EMU_TARGET=
EMU_GUILD=
EMU_STICKER=
Binary file modified bun.lockb
Binary file not shown.
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bots-gulag",
"version": "2.1.0",
"version": "3.0.0",
"description": "Bots",
"repository": "https://github.com/CarelessDev/bots-gulag",
"type": "module",
Expand All @@ -15,17 +15,17 @@
"chalk": "5.3.0",
"cocoa-discord": "3.1.0",
"discord.js": "14.13.0",
"zod": "3.22.2"
"zod": "3.22.4"
},
"devDependencies": {
"@leomotors/config": "0.11.0",
"@trivago/prettier-plugin-sort-imports": "4.2.0",
"@typescript-eslint/eslint-plugin": "6.7.2",
"@typescript-eslint/parser": "6.7.2",
"eslint": "8.50.0",
"@typescript-eslint/eslint-plugin": "6.7.5",
"@typescript-eslint/parser": "6.7.5",
"eslint": "8.51.0",
"eslint-config-prettier": "9.0.0",
"eslint-plugin-import": "2.28.1",
"eslint-plugin-prettier": "5.0.0",
"eslint-plugin-prettier": "5.0.1",
"eslint-plugin-sort-destructure-keys": "1.5.0",
"prettier": "3.0.3",
"typescript": "5.2.2"
Expand Down
4 changes: 4 additions & 0 deletions src/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ const environmentSchema = z.object({
VLADIMIR: z.string().min(10),
WESSUWAN: z.string().min(10),
CAPPUCHINO: z.string().min(10),
EMU: z.string().min(10),
EMU_TARGET: z.string().min(10),
EMU_GUILD: z.string().min(10),
EMU_STICKER: z.string().min(10),
});

export const environment = environmentSchema.parse(process.env);
40 changes: 37 additions & 3 deletions src/slave.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const slaves: Parameters<typeof buildSlave>[] = [
[
"Skittle 姉ちゃん",
environment.SKITTLE_NEE,
new CocoaIntent(),
{
type: ActivityType.Listening,
name: "Gochiusa OST",
Expand All @@ -20,6 +21,11 @@ export const slaves: Parameters<typeof buildSlave>[] = [
[
"Comrade Vladimir",
environment.VLADIMIR,
new CocoaIntent()
.useGuild()
.useGuildMessage()
.useDirectMessage()
.useReadMessage(),
{
type: ActivityType.Watching,
name: "Comrade",
Expand All @@ -34,6 +40,7 @@ export const slaves: Parameters<typeof buildSlave>[] = [
[
"ท้าวเวสสุวรรณ",
environment.WESSUWAN,
new CocoaIntent(),
{
type: ActivityType.Playing,
name: "With Other Gods",
Expand All @@ -42,18 +49,47 @@ export const slaves: Parameters<typeof buildSlave>[] = [
[
"チノお姉ちゃん",
environment.CAPPUCHINO,
new CocoaIntent(),
{
type: ActivityType.Watching,
name: "Chinoflix",
},
],
[
"鳳えむ",
environment.EMU,
new CocoaIntent().useGuild().useGuildMessage().useReadMessage(),
{
type: ActivityType.Streaming,
name: "Asahina Senpai, Wonderhoy!",
url: "https://www.youtube.com/watch?v=2p1R7btCf_Q&t=32",
},
async (msg: Message) => {
if (msg.author.bot || msg.author.id !== environment.EMU_TARGET) return;

if (Math.random() < 0.01) {
const guild =
msg.client.guilds.cache.get(environment.EMU_GUILD) ??
(await msg.client.guilds.fetch(environment.EMU_GUILD));

const sticker =
guild.stickers.cache.get(environment.EMU_STICKER) ??
(await guild.stickers.fetch(environment.EMU_STICKER));

await msg.reply({
stickers: [sticker],
});
}
},
],
];

export const clients = slaves.map((slave) => buildSlave(...slave));

export function buildSlave(
name: string,
token: string | undefined,
intents: CocoaIntent,
activity?: ActivityOptions,
onMessage?: (message: Message) => Promise<void>,
) {
Expand All @@ -62,9 +98,7 @@ export function buildSlave(
return;
}

const client = new Client(
new CocoaIntent().useGuild().useGuildMessage().useReadMessage(),
);
const client = new Client(intents);
client.on("ready", (cli) => {
console.log(chalk.green(`Slave ${name} is ready as ${cli.user.tag}!`));
if (onMessage) {
Expand Down

0 comments on commit 59b5f4f

Please sign in to comment.