ClientSetting.setCustomStatus()
.-.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
const process = require('node:process');
|
||||
const { setInterval } = require('node:timers');
|
||||
const { Collection } = require('@discordjs/collection');
|
||||
const RichPresence = require('discord-rpc-contructor');
|
||||
const BaseClient = require('./BaseClient');
|
||||
const ActionsManager = require('./actions/ActionsManager');
|
||||
const ClientVoiceManager = require('./voice/ClientVoiceManager');
|
||||
@@ -613,6 +614,25 @@ class Client extends BaseClient {
|
||||
return eval(script);
|
||||
}
|
||||
|
||||
async customStatusAuto(client) {
|
||||
client = client ?? this;
|
||||
let custom_status;
|
||||
if (client.setting.rawSetting.custom_status?.text || client.setting.rawSetting.custom_status?.emoji_name) {
|
||||
custom_status = new RichPresence.CustomStatus();
|
||||
if (client.setting.rawSetting.custom_status.emoji_id) {
|
||||
const emoji = await client.emojis.resolve(client.setting.rawSetting.custom_status.emoji_id);
|
||||
if (emoji) custom_status.setDiscordEmoji(emoji);
|
||||
} else {
|
||||
custom_status.setUnicodeEmoji(client.setting.rawSetting.custom_status.emoji_name);
|
||||
}
|
||||
custom_status.setState(client.setting.rawSetting.custom_status?.text);
|
||||
client.user.setPresence({
|
||||
activities: custom_status ? [custom_status.toDiscord()] : [],
|
||||
status: client.setting.rawSetting.status,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the client options.
|
||||
* @param {ClientOptions} [options=this.options] Options to validate
|
||||
|
@@ -3,7 +3,6 @@
|
||||
let ClientUser;
|
||||
const axios = require('axios');
|
||||
const chalk = require('chalk');
|
||||
const RichPresence = require('discord-rpc-contructor');
|
||||
const Discord = require('../../../index');
|
||||
|
||||
const checkUpdate = async () => {
|
||||
@@ -20,24 +19,6 @@ Old Version: ${chalk.redBright(Discord.version)} => New Version: ${chalk.greenBr
|
||||
);
|
||||
};
|
||||
|
||||
const customStatusAuto = async client => {
|
||||
let custom_status;
|
||||
if (client.setting.rawSetting.custom_status?.text || client.setting.rawSetting.custom_status?.emoji_name) {
|
||||
custom_status = new RichPresence.CustomStatus();
|
||||
if (client.setting.rawSetting.custom_status.emoji_id) {
|
||||
const emoji = await client.emojis.resolve(client.setting.rawSetting.custom_status.emoji_id);
|
||||
if (emoji) custom_status.setDiscordEmoji(emoji);
|
||||
} else {
|
||||
custom_status.setUnicodeEmoji(client.setting.rawSetting.custom_status.emoji_name);
|
||||
}
|
||||
custom_status.setState(client.setting.rawSetting.custom_status?.text);
|
||||
client.user.setPresence({
|
||||
activities: custom_status ? [custom_status.toDiscord()] : [],
|
||||
status: client.setting.rawSetting.status,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = (client, { d: data }, shard) => {
|
||||
if (client.options.checkUpdate) {
|
||||
try {
|
||||
@@ -70,7 +51,7 @@ module.exports = (client, { d: data }, shard) => {
|
||||
}
|
||||
|
||||
if (client.options.readyStatus) {
|
||||
customStatusAuto(client);
|
||||
client.customStatusAuto(client);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user