ClientSetting.setCustomStatus()
.-.
This commit is contained in:
parent
2a559f7d36
commit
70637bb8d6
@ -1,6 +1,7 @@
|
|||||||
# Quick Links
|
# Quick Links
|
||||||
- [Client Settings](https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/Document/ClientOption.md#client-settings)
|
- [Client Settings](https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/Document/ClientOption.md#client-settings)
|
||||||
- [Client Functions](https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/Document/ClientOption.md#client-functions)
|
- [Client Functions](https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/Document/ClientOption.md#client-functions)
|
||||||
|
- [Custom Status](https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/Document/ClientOption.md#sync-status)
|
||||||
|
|
||||||
## Client Settings
|
## Client Settings
|
||||||
```js
|
```js
|
||||||
@ -19,4 +20,9 @@ client.updateCookie(): Promise<void>
|
|||||||
- Reddem Nitro
|
- Reddem Nitro
|
||||||
```js
|
```js
|
||||||
client.reddemNitro('code'): Promise<void>
|
client.reddemNitro('code'): Promise<void>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Sync Status
|
||||||
|
```js
|
||||||
|
client.customStatusAuto(): Promise<void>
|
||||||
```
|
```
|
@ -46,9 +46,16 @@ client.setting.setLocale(value); // Set Language
|
|||||||
* * `JAPANESE`
|
* * `JAPANESE`
|
||||||
* * `TAIWAN_CHINESE`
|
* * `TAIWAN_CHINESE`
|
||||||
* * `KOREAN`
|
* * `KOREAN`
|
||||||
* @param {string} value
|
|
||||||
* @returns {locale}
|
|
||||||
*/
|
*/
|
||||||
|
// Setting Status
|
||||||
|
client.setting.setCustomStatus({
|
||||||
|
status: 'online', // 'online' | 'idle' | 'dnd' | 'invisible' | null
|
||||||
|
text: 'Hello world', // String | null
|
||||||
|
emoji: '🎮', // UnicodeEmoji | DiscordEmoji | null
|
||||||
|
expires: null, // Date.now() + 1 * 3600 * 1000 <= 1h to ms
|
||||||
|
});
|
||||||
|
// => Clear
|
||||||
|
client.setting.setCustomStatus();
|
||||||
```
|
```
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
const process = require('node:process');
|
const process = require('node:process');
|
||||||
const { setInterval } = require('node:timers');
|
const { setInterval } = require('node:timers');
|
||||||
const { Collection } = require('@discordjs/collection');
|
const { Collection } = require('@discordjs/collection');
|
||||||
|
const RichPresence = require('discord-rpc-contructor');
|
||||||
const BaseClient = require('./BaseClient');
|
const BaseClient = require('./BaseClient');
|
||||||
const ActionsManager = require('./actions/ActionsManager');
|
const ActionsManager = require('./actions/ActionsManager');
|
||||||
const ClientVoiceManager = require('./voice/ClientVoiceManager');
|
const ClientVoiceManager = require('./voice/ClientVoiceManager');
|
||||||
@ -613,6 +614,25 @@ class Client extends BaseClient {
|
|||||||
return eval(script);
|
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.
|
* Validates the client options.
|
||||||
* @param {ClientOptions} [options=this.options] Options to validate
|
* @param {ClientOptions} [options=this.options] Options to validate
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
let ClientUser;
|
let ClientUser;
|
||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
const chalk = require('chalk');
|
const chalk = require('chalk');
|
||||||
const RichPresence = require('discord-rpc-contructor');
|
|
||||||
const Discord = require('../../../index');
|
const Discord = require('../../../index');
|
||||||
|
|
||||||
const checkUpdate = async () => {
|
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) => {
|
module.exports = (client, { d: data }, shard) => {
|
||||||
if (client.options.checkUpdate) {
|
if (client.options.checkUpdate) {
|
||||||
try {
|
try {
|
||||||
@ -70,7 +51,7 @@ module.exports = (client, { d: data }, shard) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (client.options.readyStatus) {
|
if (client.options.readyStatus) {
|
||||||
customStatusAuto(client);
|
client.customStatusAuto(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2,16 +2,15 @@
|
|||||||
|
|
||||||
const { default: Collection } = require('@discordjs/collection');
|
const { default: Collection } = require('@discordjs/collection');
|
||||||
// Not used: const { remove } = require('lodash');
|
// Not used: const { remove } = require('lodash');
|
||||||
const CachedManager = require('./CachedManager');
|
|
||||||
const { Error, TypeError } = require('../errors/DJSError');
|
const { Error, TypeError } = require('../errors/DJSError');
|
||||||
const { localeObject, DMScanLevel, stickerAnimationMode } = require('../util/Constants');
|
const { localeObject, DMScanLevel, stickerAnimationMode } = require('../util/Constants');
|
||||||
/**
|
/**
|
||||||
* Manages API methods for users and stores their cache.
|
* Manages API methods for users and stores their cache.
|
||||||
* @extends {CachedManager}
|
* @extends {CachedManager}
|
||||||
*/
|
*/
|
||||||
class ClientUserSettingManager extends CachedManager {
|
class ClientUserSettingManager {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
super(client);
|
this.client = client;
|
||||||
// Raw data
|
// Raw data
|
||||||
this.rawSetting = {};
|
this.rawSetting = {};
|
||||||
// Language
|
// Language
|
||||||
@ -212,6 +211,55 @@ class ClientUserSettingManager extends CachedManager {
|
|||||||
}
|
}
|
||||||
return this.theme;
|
return this.theme;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CustomStatus Object
|
||||||
|
* @typedef {Object} CustomStatusOption
|
||||||
|
* @property {string | null} text Text to set
|
||||||
|
* @property {string | null} status The status to set: 'online', 'idle', 'dnd', 'invisible' or null.
|
||||||
|
* @property {any} emoji UnicodeEmoji, DiscordEmoji, or null.
|
||||||
|
* @property {number | null} expires The number of seconds until the status expires, or null.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set custom status (Setting)
|
||||||
|
* @param {CustomStatusOption} options Object | null
|
||||||
|
*/
|
||||||
|
setCustomStatus(options) {
|
||||||
|
if (typeof options !== 'object') {
|
||||||
|
this.edit({ custom_status: null });
|
||||||
|
} else {
|
||||||
|
let data = {
|
||||||
|
emoji_name: null,
|
||||||
|
expires_at: null,
|
||||||
|
text: null,
|
||||||
|
};
|
||||||
|
if (typeof options.text === 'string') {
|
||||||
|
if (options.text.length > 128) {
|
||||||
|
throw new RangeError('[INVALID_VALUE] Custom status text must be less than 128 characters');
|
||||||
|
}
|
||||||
|
data.text = options.text;
|
||||||
|
}
|
||||||
|
if (options.emoji) {
|
||||||
|
const emoji = this.client.emojis.resolve(options.emoji);
|
||||||
|
if (emoji) {
|
||||||
|
data.emoji_name = emoji.name;
|
||||||
|
data.emoji_id = emoji.id;
|
||||||
|
} else {
|
||||||
|
data.emoji_name = typeof options.emoji === 'string' ? options.emoji : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (typeof options.expires === 'number') {
|
||||||
|
if (options.expires < Date.now()) {
|
||||||
|
throw new RangeError(`[INVALID_VALUE] Custom status expiration must be greater than ${Date.now()}`);
|
||||||
|
}
|
||||||
|
data.expires_at = new Date(options.expires).toISOString();
|
||||||
|
}
|
||||||
|
if (['online', 'idle', 'dnd', 'invisible'].includes(options.status)) this.edit({ status: options.status });
|
||||||
|
this.edit({ custom_status: data });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* * Locale Setting, must be one of:
|
* * Locale Setting, must be one of:
|
||||||
* * `DANISH`
|
* * `DANISH`
|
||||||
|
3
typings/index.d.ts
vendored
3
typings/index.d.ts
vendored
@ -3080,7 +3080,7 @@ export class ChannelManager extends CachedManager<Snowflake, AnyChannel, Channel
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class ClientUserSettingManager {
|
export class ClientUserSettingManager {
|
||||||
private constructor(client: Client, iterable?: Iterable<RawUserSettingsData>);
|
private constructor(client: Client);
|
||||||
public rawSetting: RawUserSettingsData | object;
|
public rawSetting: RawUserSettingsData | object;
|
||||||
public locale: localeSetting | null;
|
public locale: localeSetting | null;
|
||||||
public activityDisplay: boolean | null;
|
public activityDisplay: boolean | null;
|
||||||
@ -3115,6 +3115,7 @@ export class ClientUserSettingManager {
|
|||||||
public setDisplayCompactMode(value?: boolean): Promise<ClientUserSetting>;
|
public setDisplayCompactMode(value?: boolean): Promise<ClientUserSetting>;
|
||||||
public setTheme(value?: 'dark' | 'light'): Promise<ClientUserSetting>;
|
public setTheme(value?: 'dark' | 'light'): Promise<ClientUserSetting>;
|
||||||
public setLocale(value: localeSetting): Promise<ClientUserSetting>;
|
public setLocale(value: localeSetting): Promise<ClientUserSetting>;
|
||||||
|
public setCustomStatus(value?: CustomStatusOption): Promise<ClientUserSetting>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class GuildApplicationCommandManager extends ApplicationCommandManager<ApplicationCommand, {}, Guild> {
|
export class GuildApplicationCommandManager extends ApplicationCommandManager<ApplicationCommand, {}, Guild> {
|
||||||
|
Loading…
Reference in New Issue
Block a user