diff --git a/src/client/doAutoChangePresence.ts b/src/client/doAutoChangePresence.ts new file mode 100644 index 00000000..383ff587 --- /dev/null +++ b/src/client/doAutoChangePresence.ts @@ -0,0 +1,45 @@ +/** + * Copyright (C) 2021-2022 PythonCoderAS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +import { sample } from "lodash"; + +import { AutoUser } from "../orm/autoUser"; +import HealthScreeningBotClient from "./extraClient"; + +export default async function doAutoChangePresence( + client: HealthScreeningBotClient +): Promise { + const guildSize = client.guilds.cache.size; + const registeredPeople = await AutoUser.count(); + + const presences: string[] = [ + "Generating Health Screenings", + `In ${guildSize} servers`, + `Generating for ${registeredPeople} people!`, + "/generate name:walkthrough for walkthrough of commands!", + "Report a bug with /report_bug!", + "Use /set to set optional configuration info!", + "can i put ma balls on ya jaws", + "Run /stats for cool stats about the bot!", + "Check out your profile with /profile!", + "Have an idea? Suggest it with /suggest!", + ]; + + // We only need to set the name. + await client.user!.setPresence({ activities: [{ name: sample(presences) }] }); + + setTimeout(() => doAutoChangePresence(client), 300000); +} diff --git a/src/client/extraClient.ts b/src/client/extraClient.ts index 49cc3985..1e53f1ec 100644 --- a/src/client/extraClient.ts +++ b/src/client/extraClient.ts @@ -56,6 +56,7 @@ import runFunctionAndLogError from "../utils/logError/runAndLog"; import { ItemType } from "../utils/multiMessage"; import postToGithub from "../utils/postToGithub"; import { Command } from "./command"; +import doAutoChangePresence from "./doAutoChangePresence"; import doAutoLoop from "./doAutoLoop"; import commandInteraction from "./interactions/commandInteraction"; import commandInteractionAutocomplete from "./interactions/commandInteractionAutocomplete"; @@ -203,6 +204,10 @@ export default class HealthScreeningBotClient extends Client { () => doAutoLoop(this, logChannel), "onReady::doAutoLoop" ), + runFunctionAndLogError( + () => doAutoChangePresence(this), + "onReady::doAutoChangePresence" + ), ]); } }