feat: added option to make joel shut the fuck up
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
import type { Message } from "discord.js";
|
||||
import { config } from "../../core/config";
|
||||
import { createLogger } from "../../core/logger";
|
||||
import { userRepository } from "../../database";
|
||||
|
||||
const logger = createLogger("Features:Mentions");
|
||||
|
||||
@@ -22,8 +23,9 @@ export async function getRandomMemberMention(
|
||||
): Promise<string | null> {
|
||||
try {
|
||||
const members = await message.guild.members.fetch({ limit: 100 });
|
||||
const optedOutUsers = await userRepository.getOptedOutUserIds();
|
||||
|
||||
const excludedSet = new Set(excludedUserIds);
|
||||
const excludedSet = new Set([...excludedUserIds, ...optedOutUsers]);
|
||||
const validMembers = members.filter(
|
||||
(member) => !member.user.bot && !excludedSet.has(member.id)
|
||||
);
|
||||
|
||||
@@ -7,16 +7,18 @@ import { eq } from "drizzle-orm";
|
||||
import type { BotClient } from "../../core/client";
|
||||
import { config } from "../../core/config";
|
||||
import { createLogger } from "../../core/logger";
|
||||
import { db } from "../../database";
|
||||
import { db, userRepository } from "../../database";
|
||||
import { botOptions } from "../../database/schema";
|
||||
import { getAiService } from "../../services/ai";
|
||||
|
||||
const logger = createLogger("Features:Joel:SpontaneousCron");
|
||||
|
||||
const SPONTANEOUS_TOPICS = [
|
||||
"a weird thought",
|
||||
"a funny joke",
|
||||
"a chaotic world update",
|
||||
"an unhinged shower thought",
|
||||
"a completely unsolicited aggressive life advice",
|
||||
"a bizarre threat that makes no sense",
|
||||
"a weirdly specific and insulting observation",
|
||||
"a chaotic question that demands an answer",
|
||||
] as const;
|
||||
|
||||
let timer: ReturnType<typeof setTimeout> | null = null;
|
||||
@@ -151,7 +153,10 @@ function isWritableTextChannel(channel: unknown, client: BotClient): channel is
|
||||
async function getRandomGuildMemberMention(guild: Guild): Promise<string | null> {
|
||||
try {
|
||||
const members = await guild.members.fetch({ limit: 200 });
|
||||
const eligible = members.filter((member) => !member.user.bot);
|
||||
const optedOutUsers = await userRepository.getOptedOutUserIds();
|
||||
const excludedSet = new Set(optedOutUsers);
|
||||
|
||||
const eligible = members.filter((member) => !member.user.bot && !excludedSet.has(member.id));
|
||||
|
||||
const randomMember = eligible.random();
|
||||
if (!randomMember) {
|
||||
@@ -172,12 +177,14 @@ async function generateNonsense(): Promise<string | null> {
|
||||
|
||||
const response = await ai.generateResponse(
|
||||
`Write one short Discord message containing ${topic}.`,
|
||||
`You are Joel posting an unsolicited random message.
|
||||
`You are Joel, an unhinged, aggressive, and chaotic Discord bot. You are randomly pinging a user to say something completely unsolicited.
|
||||
Rules:
|
||||
- Mention nothing about being an AI
|
||||
- 1-2 sentences, max 220 characters
|
||||
- Funny or absurd tone
|
||||
- No lists, no hashtags`
|
||||
- The message should make the user think "wtf did he just say?"
|
||||
- Be aggressive, insulting, or bizarrely threatening, but in a humorous, absurd way (not extremely fucked up or genuinely disturbing).
|
||||
- Use your signature unhinged personality (swearing is fine, but keep it funny).
|
||||
- Mention nothing about being an AI.
|
||||
- 1-2 sentences, max 220 characters.
|
||||
- No lists, no hashtags, no greetings.`
|
||||
);
|
||||
|
||||
const text = response.text.trim().replace(/\s+/g, " ");
|
||||
|
||||
Reference in New Issue
Block a user