Skip to content

Commit 090021e

Browse files
Techbot121Meta Construct
authored andcommitted
use custom activities
1 parent 182b605 commit 090021e

File tree

2 files changed

+36
-25
lines changed

2 files changed

+36
-25
lines changed

app/services/discord/modules/shitposting.ts

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ export default async (bot: DiscordBot) => {
240240
posting = false;
241241
};
242242

243-
const getRandomStatus = async () => {
243+
const getRandomActivity = async () => {
244244
const validActivities = [
245245
{ type: 0, ctx: ["playing"] },
246246
{
@@ -249,6 +249,7 @@ export default async (bot: DiscordBot) => {
249249
},
250250
{ type: 2, ctx: ["listening to", "hearing", "following"] },
251251
{ type: 3, ctx: ["watching", "looking at", "observing", "following", "noticing"] },
252+
{ type: 4, ctx: "custom" },
252253
{ type: 5, ctx: ["competing in", "participate in", "take part in", "play in"] },
253254
];
254255

@@ -258,28 +259,35 @@ export default async (bot: DiscordBot) => {
258259

259260
const prefix = selection.ctx[(Math.random() * selection.ctx.length) | 0];
260261

261-
const sentence = await (
262-
await bot.container.getService("Markov")
263-
).generate(prefix, {
264-
continuation: false,
265-
});
266-
267-
if (sentence) {
268-
const split = prefix.split(" ");
269-
let joint = "";
270-
if (split.length > 1 && selection.type !== 2 && selection.type !== 5) {
271-
joint = ` ${split.at(-1)}`;
272-
}
262+
if (prefix !== "custom") {
263+
const sentence = await (
264+
await bot.container.getService("Markov")
265+
).generate(prefix, {
266+
continuation: false,
267+
});
268+
269+
if (sentence) {
270+
const split = prefix.split(" ");
271+
let joint = "";
272+
if (split.length > 1 && selection.type !== 2 && selection.type !== 5) {
273+
joint = ` ${split.at(-1)}`;
274+
}
273275

274-
const maxLength = 127 - joint.length;
276+
const maxLength = 127 - joint.length;
275277

276-
status =
277-
sentence.length > maxLength
278-
? joint + sentence.substring(0, 120) + "..."
279-
: joint + sentence;
278+
status =
279+
sentence.length > maxLength
280+
? joint + sentence.substring(0, 120) + "..."
281+
: joint + sentence;
282+
}
280283
}
284+
const state = (await (await bot.container.getService("Markov")).generate()) ?? "wtf";
281285

282-
lastSetActivity = { name: status, type: selection.type } as Discord.ActivitiesOptions;
286+
lastSetActivity = {
287+
name: status,
288+
state,
289+
type: selection.type,
290+
} as Discord.ActivitiesOptions;
283291

284292
return lastSetActivity;
285293
};
@@ -289,7 +297,7 @@ export default async (bot: DiscordBot) => {
289297
// });
290298

291299
bot.discord.once("ready", async client => {
292-
bot.setActivity(undefined, await getRandomStatus());
300+
bot.setActivity(undefined, await getRandomActivity());
293301

294302
if (lastMsgs.length === 0) {
295303
const lastmsg = bot.getTextChannel(bot.config.channels.chat)?.lastMessage;
@@ -323,7 +331,7 @@ export default async (bot: DiscordBot) => {
323331
replied = false;
324332
}
325333
if (now - lastActivityChange > ACTIVITY_CHANGE_INTERVAL) {
326-
bot.setActivity(undefined, await getRandomStatus());
334+
bot.setActivity(undefined, await getRandomActivity());
327335
lastActivityChange = now;
328336
}
329337
lastMsgs.splice(0, lastMsgs.length - 1); // delete lastmsg cache

app/services/gamebridge/payloads/StatusPayload.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ export default class StatusPayload extends Payload {
118118
? {
119119
activities: [
120120
{
121-
name: `${count} player${count !== 1 ? "s" : ""} ${
121+
name: `${count === 1 ? "a" : count} player${count !== 1 ? "s" : ""} ${
122122
getRandomActivity(gamemodeName) ?? ""
123123
}`,
124124
type: 3,
@@ -136,16 +136,19 @@ export default class StatusPayload extends Payload {
136136
if (current_countdown) {
137137
presence.activities = [
138138
{
139-
name: `${current_countdown.text} in ${current_countdown.time} second${
139+
name: "countdown",
140+
state: `${current_countdown.text} in ${current_countdown.time} second${
140141
current_countdown.time > 1 ? "s" : ""
141142
}`,
142-
type: 3,
143+
type: 4,
143144
},
144145
];
145146
}
146147

147148
if (current_defcon !== 5) {
148-
presence.activities = [{ name: "DEFCON " + current_defcon, type: 5 }];
149+
presence.activities = [
150+
{ name: "oh no", state: "DEFCON " + current_defcon, type: 5 },
151+
];
149152
}
150153
discord.user.setPresence(presence);
151154
}

0 commit comments

Comments
 (0)