diff --git a/CONFIGURATION.md b/CONFIGURATION.md
index 49bde6d4..6ed5c960 100644
--- a/CONFIGURATION.md
+++ b/CONFIGURATION.md
@@ -11,6 +11,13 @@
"warning": "Orange",
"error": "DarkRed"
},
+ "status": {
+ "presence": "online",
+ "activityType": "Listening",
+ "name": "music",
+ "url": "",
+ "showVersion": true
+ },
"defaultLocaleCode": "en",
"disableAd": false,
"supportServer": "https://discord.gg/",
@@ -77,6 +84,11 @@
| `applicationId` | Your application ID. Typically the same as your [bot's user ID](https://support.discord.com/hc/en-us/articles/206346498-Where-can-I-find-my-User-Server-Message-ID-).
Alternatively, you can get it from the [Discord Developer Portal](https://discord.com/developers/applications). | ✅ | |
| `clientSecret` | Your client secret. You can get it from the [Discord Developer Portal](https://discord.com/developers/applications) under `OAuth2 > General`. | ✅ | |
| `colors` | The colors used for embeds. Valid values are available [here](https://discord.js.org/#/docs/discord.js/main/typedef/ColorResolvable). | ✅ | |
+| `status.presence` | The presence. Valid values are `online`, `idle`, `dnd`, and `invisible`. | ✅ | `6.10.0` |
+| `status.activityType` | The activity type. Valid values are `Playing`, `Streaming`, `Listening`, `Watching`, and `Competing`. | ✅ | `6.10.0` |
+| `status.name` | The activity name. | ✅ | `6.10.0` |
+| `status.url` | The activity URL. Only used if `status.activityType` is `Streaming`. | ❌ | `6.10.0` |
+| `status.showVersion` | Whether to show the version in the status. | ❌ | `6.10.0` |
| `defaultLocaleCode` | The default locale code. Valid values are available in the `locales` folder.
**Note:** This is used for all logs, slash command descriptions (at the time of deployment), and for all guilds without a language set in `/settings`. | ✅ | |
| `disableAd` | Whether to disable the ad in the `info` command (Sponsor Us button).
**Note:** Please do not disable the ad unless you really need to. Sponsors help keep the development of ZPTXDev projects going. Consider sponsoring us if you need to disable the ad! | ❌ | |
| `supportServer` | The support server invite link. This is used in the `info` command (Support Server button) and some messages in the event of an error. | ❌ | `6.6.0` |
diff --git a/settings.example.json b/settings.example.json
index def6bb52..15d0c4af 100644
--- a/settings.example.json
+++ b/settings.example.json
@@ -8,6 +8,13 @@
"warning": "Orange",
"error": "DarkRed"
},
+ "status": {
+ "presence": "online",
+ "activityType": "Listening",
+ "name": "music",
+ "url": "",
+ "showVersion": true
+ },
"defaultLocaleCode": "en",
"disableAd": false,
"supportServer": "https://discord.gg/",
diff --git a/src/events/ready.ts b/src/events/ready.ts
index 39bdd2eb..00bb0c1c 100644
--- a/src/events/ready.ts
+++ b/src/events/ready.ts
@@ -2,6 +2,7 @@ import type { QuaverClient } from '#src/lib/util/common.d.js';
import { logger } from '#src/lib/util/common.js';
import { settings } from '#src/lib/util/settings.js';
import { version } from '#src/lib/util/version.js';
+import type { PresenceStatusData } from 'discord.js';
import { ActivityType } from 'discord.js';
export default {
@@ -42,8 +43,52 @@ export default {
label: 'Quaver',
});
}
- client.user.setActivity(`music | ${version}`, {
- type: ActivityType.Listening,
+ let activityType:
+ | ActivityType.Playing
+ | ActivityType.Streaming
+ | ActivityType.Listening
+ | ActivityType.Watching
+ | ActivityType.Competing;
+ switch (settings.status.activityType.toLowerCase()) {
+ case 'streaming':
+ activityType = ActivityType.Streaming;
+ break;
+ case 'listening':
+ activityType = ActivityType.Listening;
+ break;
+ case 'watching':
+ activityType = ActivityType.Watching;
+ break;
+ case 'competing':
+ activityType = ActivityType.Competing;
+ break;
+ default:
+ activityType = ActivityType.Playing;
+ break;
+ }
+ let presence: PresenceStatusData = 'online';
+ if (
+ ['online', 'idle', 'dnd', 'invisible'].includes(
+ settings.status.presence.toLowerCase(),
+ )
+ ) {
+ presence =
+ settings.status.presence.toLowerCase() as PresenceStatusData;
+ }
+ client.user.setPresence({
+ status: presence,
+ activities: [
+ {
+ name: `${settings.status.name}${
+ settings.status.showVersion ? ` | ${version}` : ''
+ }`,
+ type: activityType,
+ url:
+ settings.status.url === ''
+ ? undefined
+ : settings.status.url,
+ },
+ ],
});
client.music.connect(client.user.id);
await client.application.commands.fetch();
diff --git a/src/events/shardResume.ts b/src/events/shardResume.ts
index 4f4aff9c..ecb714e5 100644
--- a/src/events/shardResume.ts
+++ b/src/events/shardResume.ts
@@ -1,5 +1,7 @@
import { logger } from '#src/lib/util/common.js';
+import { settings } from '#src/lib/util/settings.js';
import { version } from '#src/lib/util/version.js';
+import type { PresenceStatusData } from 'discord.js';
import { ActivityType } from 'discord.js';
export default {
@@ -7,8 +9,52 @@ export default {
once: false,
async execute(): Promise {
const { bot } = await import('#src/main.js');
- bot.user.setActivity(`music | ${version}`, {
- type: ActivityType.Listening,
+ let activityType:
+ | ActivityType.Playing
+ | ActivityType.Streaming
+ | ActivityType.Listening
+ | ActivityType.Watching
+ | ActivityType.Competing;
+ switch (settings.status.activityType.toLowerCase()) {
+ case 'streaming':
+ activityType = ActivityType.Streaming;
+ break;
+ case 'listening':
+ activityType = ActivityType.Listening;
+ break;
+ case 'watching':
+ activityType = ActivityType.Watching;
+ break;
+ case 'competing':
+ activityType = ActivityType.Competing;
+ break;
+ default:
+ activityType = ActivityType.Playing;
+ break;
+ }
+ let presence: PresenceStatusData = 'online';
+ if (
+ ['online', 'idle', 'dnd', 'invisible'].includes(
+ settings.status.presence.toLowerCase(),
+ )
+ ) {
+ presence =
+ settings.status.presence.toLowerCase() as PresenceStatusData;
+ }
+ bot.user.setPresence({
+ status: presence,
+ activities: [
+ {
+ name: `${settings.status.name}${
+ settings.status.showVersion ? ` | ${version}` : ''
+ }`,
+ type: activityType,
+ url:
+ settings.status.url === ''
+ ? undefined
+ : settings.status.url,
+ },
+ ],
});
logger.info({ message: 'Reconnected.', label: 'Discord' });
},
diff --git a/src/lib/util/settings.d.ts b/src/lib/util/settings.d.ts
index e44f8e93..d66b8338 100644
--- a/src/lib/util/settings.d.ts
+++ b/src/lib/util/settings.d.ts
@@ -6,6 +6,7 @@ export type SettingsObject = {
applicationId?: Snowflake;
clientSecret?: string;
colors?: ColorsSettingsObject;
+ status?: StatusSettingsObject;
defaultLocaleCode?: string;
developerMode?: boolean;
disableAd?: boolean;
@@ -26,6 +27,14 @@ export type ColorsSettingsObject = {
error?: ColorResolvable;
};
+export type StatusSettingsObject = {
+ presence?: string;
+ activityType?: string;
+ name?: string;
+ url?: string;
+ showVersion?: boolean;
+};
+
export type DatabaseSettingsObject = {
protocol?: string;
path?: string;