Skip to content

Commit

Permalink
refactor: remove emu
Browse files Browse the repository at this point in the history
  • Loading branch information
leomotors committed Dec 6, 2023
1 parent a941e07 commit 78d3df5
Show file tree
Hide file tree
Showing 9 changed files with 8 additions and 147 deletions.
5 changes: 0 additions & 5 deletions .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,3 @@ SKITTLE_NEE=
VLADIMIR=
WESSUWAN=
CAPPUCHINO=
EMU=
EMU_TARGET=
EMU_GUILD=
EMU_STICKER=
EMU_CHANCE=
8 changes: 1 addition & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
# Bots Gulag

Run ~~five~~ six Discord Bots in the same process to make server feels active and not dead.
Run 5 Discord Bots in the same process to make server feels active and not dead.
(It actually dead 💀)

## Feature: Help you win argument by Emu Ootori

![](./images/emudemo.png)

(Address and IP Leak 😱)
Binary file modified bun.lockb
Binary file not shown.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bots-gulag",
"version": "3.2.69",
"version": "3.3.0",
"description": "Bots",
"repository": "https://github.com/CarelessDev/bots-gulag",
"type": "module",
Expand All @@ -20,10 +20,10 @@
"devDependencies": {
"@leomotors/config": "0.11.0",
"@trivago/prettier-plugin-sort-imports": "4.3.0",
"@typescript-eslint/eslint-plugin": "6.12.0",
"@typescript-eslint/parser": "6.12.0",
"eslint": "8.54.0",
"eslint-config-prettier": "9.0.0",
"@typescript-eslint/eslint-plugin": "6.13.2",
"@typescript-eslint/parser": "6.13.2",
"eslint": "8.55.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-import": "2.29.0",
"eslint-plugin-prettier": "5.0.1",
"eslint-plugin-sort-destructure-keys": "1.5.0",
Expand Down
3 changes: 1 addition & 2 deletions src/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ import { ActivityType, Client } from "discord.js";

import chalk from "chalk";

import { Emu } from "./commands/emu.js";
import { MaoCommander } from "./commands/index.js";
import { environment } from "./environment.js";
import { clients } from "./slave.js";

const MaoClient = new Client(new CocoaIntent().useGuild());

const center = new SlashCenter(MaoClient, "Global");
center.addModules(new MaoCommander(MaoClient), new Emu());
center.addModules(new MaoCommander(MaoClient));
center.validateCommands();

MaoClient.on("ready", (cli) => {
Expand Down
38 changes: 0 additions & 38 deletions src/commands/emu.ts

This file was deleted.

11 changes: 0 additions & 11 deletions src/emuChance.ts

This file was deleted.

6 changes: 0 additions & 6 deletions src/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ 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),
EMU_CHANCE: z.number().min(0).max(100).default(1),
SKILLISSUE: z.string().min(10),
});

export const environment = environmentSchema.parse(process.env);
74 changes: 1 addition & 73 deletions src/slave.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
import { CocoaIntent } from "cocoa-discord/template";

import {
ActivityOptions,
ActivityType,
Client,
Guild,
Message,
} from "discord.js";
import { ActivityOptions, ActivityType, Client, Message } from "discord.js";

import chalk from "chalk";

import { getEmu } from "./emuChance.js";
import { environment } from "./environment.js";

const RussianChars = "АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ";
Expand Down Expand Up @@ -62,73 +55,8 @@ export const slaves: Parameters<typeof buildSlave>[] = [
name: "Chinoflix",
},
],
[
"鳳えむ",
environment.EMU,
new CocoaIntent().useGuild().useGuildMessage(),
{
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) return;

// Leak IP
if (
msg.author.id === environment.EMU_TARGET &&
msg.guild?.id === environment.EMU_GUILD &&
Math.random() < getEmu() / 100
) {
const sticker = await getSticker(msg.guild, environment.EMU_STICKER);

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

// Skill Issue
if (
msg.guild?.id === environment.EMU_GUILD &&
msg.mentions.has(msg.client.user)
) {
if (
!msg.content
.toLowerCase()
.replaceAll(/\s/g, "")
.includes("skillissue")
)
return;

msg.delete().catch(() => {
console.log(
chalk.red(`Failed to delete skill issue request message`),
);
});

const [reference, sticker] = await Promise.all([
msg.fetchReference(),
getSticker(msg.guild, environment.SKILLISSUE),
]);

if (!reference) return;

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

async function getSticker(guild: Guild, stickerId: string) {
const sticker =
guild.stickers.cache.get(stickerId) ??
(await guild.stickers.fetch(stickerId));

return sticker;
}

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

export function buildSlave(
Expand Down

0 comments on commit 78d3df5

Please sign in to comment.