Skip to content

Commit

Permalink
remove duplicate status setting on sending a message
Browse files Browse the repository at this point in the history
and don't revert activity (forgot why I did it in the first place)
  • Loading branch information
Techbot121 authored and Meta Construct committed Apr 10, 2024
1 parent 63f2ef0 commit cfb5788
Showing 1 changed file with 0 additions and 5 deletions.
5 changes: 0 additions & 5 deletions app/services/discord/modules/shitposting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ export default async (bot: DiscordBot) => {
db.exec("CREATE TABLE IF NOT EXISTS media_urls (url VARCHAR(255) NOT NULL UNIQUE);");
const now = Date.now();
let lastActivityChange = now;
let lastAPIActivity: Discord.Activity | undefined;
let lastSetActivity: Discord.ActivitiesOptions | undefined;
let lastMsgTime = (data.lastMsgTime = data.lastMsgTime ?? now);
let lastChatTime = now;
Expand Down Expand Up @@ -274,7 +273,6 @@ export default async (bot: DiscordBot) => {

bot.discord.on("presenceUpdate", async (old, now) => {
if (now.userId !== bot.discord.user?.id) return;
lastAPIActivity = now.activities[0];
});

bot.discord.once("ready", async client => {
Expand Down Expand Up @@ -310,13 +308,10 @@ export default async (bot: DiscordBot) => {
});
data.lastMsgTime = lastMsgTime = now;
replied = false;
bot.setActivity(undefined, await getRandomStatus());
}
if (now - lastActivityChange > ACTIVITY_CHANGE_INTERVAL) {
bot.setActivity(undefined, await getRandomStatus());
lastActivityChange = now;
} else if (lastSetActivity?.name !== lastAPIActivity?.name) {
bot.setActivity(undefined, lastSetActivity);
}
lastMsgs.splice(0, lastMsgs.length - 1); // delete lastmsg cache
}, MSG_INTERVAL);
Expand Down

0 comments on commit cfb5788

Please sign in to comment.