@shyzg/discord.js-selfbot 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@shyzg/discord.js-selfbot",
4
- "version": "1.0.0",
4
+ "version": "1.0.1",
5
5
  "description": "A user-account (selfbot) fork of discord.js v14 for Node.js.",
6
6
  "scripts": {
7
7
  "test": "node --test --test-force-exit test/*.test.js && pnpm run test:typescript",
@@ -60,7 +60,6 @@
60
60
  "@discordjs/ws": "^2.0.4",
61
61
  "@sapphire/snowflake": "4.0.0",
62
62
  "discord-api-types": "^0.38.60",
63
- "magic-bytes.js": "^1.13.1",
64
63
  "qr": "^0.7.2"
65
64
  },
66
65
  "devDependencies": {
@@ -374,6 +374,7 @@ class Client extends BaseClient {
374
374
  super.destroy();
375
375
 
376
376
  this.sweepers.destroy();
377
+ this.voice.destroy();
377
378
  await this.ws.destroy();
378
379
  this.token = null;
379
380
  this.readyTimestamp = null;
@@ -39,6 +39,13 @@ class ClientVoiceManager {
39
39
  this.adapters.get(payload.guild_id)?.onVoiceStateUpdate(payload);
40
40
  }
41
41
  }
42
+
43
+ destroy() {
44
+ for (const adapter of this.adapters.values()) {
45
+ adapter.destroy();
46
+ }
47
+ this.adapters.clear();
48
+ }
42
49
  }
43
50
 
44
51
  module.exports = ClientVoiceManager;
@@ -148,6 +148,7 @@ class WebSocketManager extends EventEmitter {
148
148
  const invalidToken = new DiscordjsError(ErrorCodes.TokenInvalid);
149
149
  const { ws } = this.client.options;
150
150
  if (this._ws && this._ws.token !== this.client.token) {
151
+ this.client.voice.destroy();
151
152
  await this.destroy();
152
153
  this.client.readyTimestamp = null;
153
154
  this.client.user = null;
package/src/index.js CHANGED
@@ -34,7 +34,6 @@ exports.Collection = require('@discordjs/collection').Collection;
34
34
  exports.Constants = require('./util/Constants');
35
35
  exports.Colors = require('./util/Colors');
36
36
  exports.Events = require('./util/Events');
37
- exports.Formatters = require('./util/Formatters');
38
37
  exports.GuildMemberFlagsBitField = require('./util/GuildMemberFlagsBitField').GuildMemberFlagsBitField;
39
38
  exports.IntentsBitField = require('./util/IntentsBitField');
40
39
  exports.InviteFlagsBitField = require('./util/InviteFlagsBitField.js').InviteFlagsBitField;
@@ -3,6 +3,7 @@
3
3
  const { Collection } = require('@discordjs/collection');
4
4
  const { Routes } = require('discord-api-types/v10');
5
5
  const CachedManager = require('./CachedManager');
6
+ const { DiscordjsTypeError, ErrorCodes } = require('../errors');
6
7
  const AutoModerationRule = require('../structures/AutoModerationRule');
7
8
 
8
9
  /**
@@ -177,6 +178,9 @@ class AutoModerationRuleManager extends CachedManager {
177
178
  { name, eventType, triggerMetadata, actions, enabled, exemptRoles, exemptChannels, reason },
178
179
  ) {
179
180
  const autoModerationRuleId = this.resolveId(autoModerationRule);
181
+ if (!autoModerationRuleId) {
182
+ throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'autoModerationRule', 'AutoModerationRuleResolvable');
183
+ }
180
184
 
181
185
  const data = await this.client.rest.patch(Routes.guildAutoModerationRule(this.guild.id, autoModerationRuleId), {
182
186
  body: {
@@ -285,6 +289,9 @@ class AutoModerationRuleManager extends CachedManager {
285
289
  */
286
290
  async delete(autoModerationRule, reason) {
287
291
  const autoModerationRuleId = this.resolveId(autoModerationRule);
292
+ if (!autoModerationRuleId) {
293
+ throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'autoModerationRule', 'AutoModerationRuleResolvable');
294
+ }
288
295
  await this.client.rest.delete(Routes.guildAutoModerationRule(this.guild.id, autoModerationRuleId), { reason });
289
296
  }
290
297
  }
@@ -153,7 +153,9 @@ class GuildBanManager extends CachedManager {
153
153
  * .catch(console.error);
154
154
  */
155
155
  async create(user, options = {}) {
156
- if (typeof options !== 'object') throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'options', 'object', true);
156
+ if (typeof options !== 'object' || options === null) {
157
+ throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'options', 'object', true);
158
+ }
157
159
  const id = this.client.users.resolveId(user);
158
160
  if (!id) throw new DiscordjsError(ErrorCodes.BanResolveId, true);
159
161
 
@@ -233,7 +235,9 @@ class GuildBanManager extends CachedManager {
233
235
  if (!users || !(Array.isArray(users) || users instanceof Collection)) {
234
236
  throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'users', 'Array or Collection of UserResolvable', true);
235
237
  }
236
- if (typeof options !== 'object') throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'options', 'object', true);
238
+ if (typeof options !== 'object' || options === null) {
239
+ throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'options', 'object', true);
240
+ }
237
241
 
238
242
  const userIds = users.map(user => this.client.users.resolveId(user));
239
243
  if (userIds.length === 0) throw new DiscordjsError(ErrorCodes.BulkBanUsersOptionEmpty);
@@ -652,7 +652,9 @@ class GuildMemberManager extends CachedManager {
652
652
  async addRole(options) {
653
653
  const { user, role, reason } = options;
654
654
  const userId = this.resolveId(user);
655
+ if (!userId) throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'user', 'UserResolvable');
655
656
  const roleId = this.guild.roles.resolveId(role);
657
+ if (!roleId) throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'role', 'RoleResolvable');
656
658
  await this.client.rest.put(Routes.guildMemberRole(this.guild.id, userId, roleId), { reason });
657
659
 
658
660
  return this.resolve(user) ?? this.client.users.resolve(user) ?? userId;
@@ -666,7 +668,9 @@ class GuildMemberManager extends CachedManager {
666
668
  async removeRole(options) {
667
669
  const { user, role, reason } = options;
668
670
  const userId = this.resolveId(user);
671
+ if (!userId) throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'user', 'UserResolvable');
669
672
  const roleId = this.guild.roles.resolveId(role);
673
+ if (!roleId) throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'role', 'RoleResolvable');
670
674
  await this.client.rest.delete(Routes.guildMemberRole(this.guild.id, userId, roleId), { reason });
671
675
 
672
676
  return this.resolve(user) ?? this.client.users.resolve(user) ?? userId;
@@ -84,7 +84,9 @@ class GuildScheduledEventManager extends CachedManager {
84
84
  * @returns {Promise<GuildScheduledEvent>}
85
85
  */
86
86
  async create(options) {
87
- if (typeof options !== 'object') throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'options', 'object', true);
87
+ if (typeof options !== 'object' || options === null) {
88
+ throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'options', 'object', true);
89
+ }
88
90
  let {
89
91
  privacyLevel,
90
92
  entityType,
@@ -206,7 +208,9 @@ class GuildScheduledEventManager extends CachedManager {
206
208
  const guildScheduledEventId = this.resolveId(guildScheduledEvent);
207
209
  if (!guildScheduledEventId) throw new DiscordjsError(ErrorCodes.GuildScheduledEventResolve);
208
210
 
209
- if (typeof options !== 'object') throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'options', 'object', true);
211
+ if (typeof options !== 'object' || options === null) {
212
+ throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'options', 'object', true);
213
+ }
210
214
  let {
211
215
  privacyLevel,
212
216
  entityType,
@@ -1,14 +1,24 @@
1
1
  'use strict';
2
2
 
3
3
  const { Collection } = require('@discordjs/collection');
4
- const { lazy } = require('@discordjs/util');
5
4
  const { Routes } = require('discord-api-types/v10');
6
5
  const CachedManager = require('./CachedManager.js');
7
6
  const { DiscordjsTypeError, ErrorCodes } = require('../errors/index.js');
8
7
  const { SoundboardSound } = require('../structures/SoundboardSound.js');
9
8
  const { resolveBase64, resolveFile } = require('../util/DataResolver.js');
10
9
 
11
- const fileTypeMime = lazy(() => require('magic-bytes.js').filetypemime);
10
+ function sniffSoundMime(data) {
11
+ if (data.length >= 4 && data[0] === 0x4f && data[1] === 0x67 && data[2] === 0x67 && data[3] === 0x53) {
12
+ return 'audio/ogg';
13
+ }
14
+ if (
15
+ (data.length >= 3 && data[0] === 0x49 && data[1] === 0x44 && data[2] === 0x33) ||
16
+ (data.length >= 2 && data[0] === 0xff && (data[1] & 0xe0) === 0xe0)
17
+ ) {
18
+ return 'audio/mpeg';
19
+ }
20
+ return undefined;
21
+ }
12
22
 
13
23
  /**
14
24
  * Manages API methods for Soundboard Sounds and stores their cache.
@@ -87,7 +97,7 @@ class GuildSoundboardSoundManager extends CachedManager {
87
97
  async create({ contentType, emojiId, emojiName, file, name, reason, volume }) {
88
98
  const resolvedFile = await resolveFile(file);
89
99
 
90
- const resolvedContentType = contentType ?? resolvedFile.contentType ?? fileTypeMime()(resolvedFile.data)[0];
100
+ const resolvedContentType = contentType ?? resolvedFile.contentType ?? sniffSoundMime(resolvedFile.data);
91
101
 
92
102
  const sound = resolveBase64(resolvedFile.data, resolvedContentType);
93
103
 
@@ -108,9 +108,10 @@ class GuildStickerManager extends CachedManager {
108
108
  const stickerId = this.resolveId(sticker);
109
109
  if (!stickerId) throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'sticker', 'StickerResolvable');
110
110
 
111
+ const { name, description, tags, reason } = options;
111
112
  const d = await this.client.rest.patch(Routes.guildSticker(this.guild.id, stickerId), {
112
- body: options,
113
- reason: options.reason,
113
+ body: { name, description, tags },
114
+ reason,
114
115
  });
115
116
 
116
117
  const existing = this.cache.get(stickerId);
@@ -327,6 +327,7 @@ class RoleManager extends CachedManager {
327
327
  */
328
328
  async delete(role, reason) {
329
329
  const id = this.resolveId(role);
330
+ if (!id) throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'role', 'RoleResolvable');
330
331
  await this.client.rest.delete(Routes.guildRole(this.guild.id, id), { reason });
331
332
  this.client.actions.GuildRoleDelete.handle({ guild_id: this.guild.id, role_id: id });
332
333
  }
@@ -60,7 +60,9 @@ class StageInstanceManager extends CachedManager {
60
60
  async create(channel, options) {
61
61
  const channelId = this.guild.channels.resolveId(channel);
62
62
  if (!channelId) throw new DiscordjsError(ErrorCodes.StageChannelResolve);
63
- if (typeof options !== 'object') throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'options', 'object', true);
63
+ if (typeof options !== 'object' || options === null) {
64
+ throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'options', 'object', true);
65
+ }
64
66
  const { guildScheduledEvent, topic, privacyLevel, sendStartNotification } = options;
65
67
 
66
68
  const guildScheduledEventId = guildScheduledEvent && this.guild.scheduledEvents.resolveId(guildScheduledEvent);
@@ -121,7 +123,9 @@ class StageInstanceManager extends CachedManager {
121
123
  * .catch(console.error);
122
124
  */
123
125
  async edit(channel, options) {
124
- if (typeof options !== 'object') throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'options', 'object', true);
126
+ if (typeof options !== 'object' || options === null) {
127
+ throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'options', 'object', true);
128
+ }
125
129
  const channelId = this.guild.channels.resolveId(channel);
126
130
  if (!channelId) throw new DiscordjsError(ErrorCodes.StageChannelResolve);
127
131
 
@@ -263,7 +263,7 @@ class Guild extends AnonymousGuild {
263
263
  * The timestamp the client user joined the guild at
264
264
  * @type {number}
265
265
  */
266
- this.joinedTimestamp = Date.parse(data.joined_at);
266
+ this.joinedTimestamp = data.joined_at ? Date.parse(data.joined_at) : null;
267
267
  }
268
268
 
269
269
  if ('default_message_notifications' in data) {
@@ -510,7 +510,7 @@ class Guild extends AnonymousGuild {
510
510
  * @readonly
511
511
  */
512
512
  get joinedAt() {
513
- return new Date(this.joinedTimestamp);
513
+ return this.joinedTimestamp && new Date(this.joinedTimestamp);
514
514
  }
515
515
 
516
516
  /**
@@ -37,8 +37,8 @@ class MessageCollector extends Collector {
37
37
  */
38
38
  this.received = 0;
39
39
 
40
- const bulkDeleteListener = messages => {
41
- for (const message of messages.values()) this.handleDispose(message);
40
+ const bulkDeleteListener = async messages => {
41
+ await Promise.all([...messages.values()].map(message => this.handleDispose(message)));
42
42
  };
43
43
 
44
44
  this._handleChannelDeletion = this._handleChannelDeletion.bind(this);
@@ -154,7 +154,7 @@ class Poll extends Base {
154
154
  * @returns {Promise<Poll>}
155
155
  */
156
156
  async fetch() {
157
- await this.channel.messages.fetch(this.messageId);
157
+ await this.channel.messages.fetch({ message: this.messageId, force: true });
158
158
 
159
159
  return this;
160
160
  }
@@ -111,7 +111,9 @@ class ThreadChannel extends BaseChannel {
111
111
  * created</info>
112
112
  * @type {?number}
113
113
  */
114
- this.archiveTimestamp = Date.parse(data.thread_metadata.archive_timestamp);
114
+ this.archiveTimestamp = data.thread_metadata.archive_timestamp
115
+ ? Date.parse(data.thread_metadata.archive_timestamp)
116
+ : null;
115
117
 
116
118
  if ('create_timestamp' in data.thread_metadata) {
117
119
  // Note: this is needed because we can't assign directly to getters
@@ -108,7 +108,7 @@ class Webhook {
108
108
  * The source guild of the webhook
109
109
  * @type {?(Guild|APIGuild)}
110
110
  */
111
- this.sourceGuild = this.client.guilds?.cache.get(data.source_guild.id) ?? data.source_guild;
111
+ this.sourceGuild = this.client.guilds?.cache.get(data.source_guild?.id) ?? data.source_guild;
112
112
  } else {
113
113
  this.sourceGuild ??= null;
114
114
  }
@@ -279,7 +279,7 @@ class Webhook {
279
279
  * @param {WebhookEditOptions} options Options for editing the webhook
280
280
  * @returns {Promise<Webhook>}
281
281
  */
282
- async edit({ name = this.name, avatar, channel, reason }) {
282
+ async edit({ name = this.name, avatar, channel, reason } = {}) {
283
283
  if (avatar && !(typeof avatar === 'string' && avatar.startsWith('data:'))) {
284
284
  avatar = await resolveImage(avatar);
285
285
  }
@@ -417,7 +417,7 @@ class Sweepers {
417
417
  */
418
418
  _validateProperties(key) {
419
419
  const props = this.options[key];
420
- if (typeof props !== 'object') {
420
+ if (typeof props !== 'object' || props === null) {
421
421
  throw new DiscordjsTypeError(ErrorCodes.InvalidType, `sweepers.${key}`, 'object', true);
422
422
  }
423
423
  if (typeof props.interval !== 'number') {
@@ -16,25 +16,6 @@ import {
16
16
  type RestOrArray,
17
17
  } from '@discordjs/builders';
18
18
  import { Collection, ReadonlyCollection } from '@discordjs/collection';
19
- import {
20
- blockQuote,
21
- bold,
22
- channelMention,
23
- codeBlock,
24
- formatEmoji,
25
- hideLinkEmbed,
26
- hyperlink,
27
- inlineCode,
28
- italic,
29
- quote,
30
- roleMention,
31
- spoiler,
32
- strikethrough,
33
- TimestampStyles,
34
- time,
35
- underscore,
36
- userMention,
37
- } from '@discordjs/formatters';
38
19
  import {
39
20
  BaseImageURLOptions,
40
21
  EmojiURLOptions,
@@ -2843,44 +2824,6 @@ export function transformResolved<Cached extends CacheType>(
2843
2824
  >['resolved'],
2844
2825
  ): CommandInteractionResolvedData<Cached>;
2845
2826
 
2846
- /** @deprecated This class is redundant as all methods of the class can be imported from discord.js directly. */
2847
- export class Formatters extends null {
2848
- /** @deprecated Import this method directly from discord.js instead. */
2849
- public static blockQuote: typeof blockQuote;
2850
- /** @deprecated Import this method directly from discord.js instead. */
2851
- public static bold: typeof bold;
2852
- /** @deprecated Import this method directly from discord.js instead. */
2853
- public static channelMention: typeof channelMention;
2854
- /** @deprecated Import this method directly from discord.js instead. */
2855
- public static codeBlock: typeof codeBlock;
2856
- /** @deprecated Import this method directly from discord.js instead. */
2857
- public static formatEmoji: typeof formatEmoji;
2858
- /** @deprecated Import this method directly from discord.js instead. */
2859
- public static hideLinkEmbed: typeof hideLinkEmbed;
2860
- /** @deprecated Import this method directly from discord.js instead. */
2861
- public static hyperlink: typeof hyperlink;
2862
- /** @deprecated Import this method directly from discord.js instead. */
2863
- public static inlineCode: typeof inlineCode;
2864
- /** @deprecated Import this method directly from discord.js instead. */
2865
- public static italic: typeof italic;
2866
- /** @deprecated Import this method directly from discord.js instead. */
2867
- public static quote: typeof quote;
2868
- /** @deprecated Import this method directly from discord.js instead. */
2869
- public static roleMention: typeof roleMention;
2870
- /** @deprecated Import this method directly from discord.js instead. */
2871
- public static spoiler: typeof spoiler;
2872
- /** @deprecated Import this method directly from discord.js instead. */
2873
- public static strikethrough: typeof strikethrough;
2874
- /** @deprecated Import this method directly from discord.js instead. */
2875
- public static time: typeof time;
2876
- /** @deprecated Import this property directly from discord.js instead. */
2877
- public static TimestampStyles: typeof TimestampStyles;
2878
- /** @deprecated Import this method directly from discord.js instead. */
2879
- public static underscore: typeof underscore;
2880
- /** @deprecated Import this method directly from discord.js instead. */
2881
- public static userMention: typeof userMention;
2882
- }
2883
-
2884
2827
  export type ComponentData =
2885
2828
  | MessageActionRowComponentData
2886
2829
  | ModalActionRowComponentData
@@ -16,25 +16,6 @@ import {
16
16
  type RestOrArray,
17
17
  } from '@discordjs/builders';
18
18
  import { Collection, ReadonlyCollection } from '@discordjs/collection';
19
- import {
20
- blockQuote,
21
- bold,
22
- channelMention,
23
- codeBlock,
24
- formatEmoji,
25
- hideLinkEmbed,
26
- hyperlink,
27
- inlineCode,
28
- italic,
29
- quote,
30
- roleMention,
31
- spoiler,
32
- strikethrough,
33
- TimestampStyles,
34
- time,
35
- underscore,
36
- userMention,
37
- } from '@discordjs/formatters';
38
19
  import {
39
20
  BaseImageURLOptions,
40
21
  EmojiURLOptions,
@@ -2843,44 +2824,6 @@ export function transformResolved<Cached extends CacheType>(
2843
2824
  >['resolved'],
2844
2825
  ): CommandInteractionResolvedData<Cached>;
2845
2826
 
2846
- /** @deprecated This class is redundant as all methods of the class can be imported from discord.js directly. */
2847
- export class Formatters extends null {
2848
- /** @deprecated Import this method directly from discord.js instead. */
2849
- public static blockQuote: typeof blockQuote;
2850
- /** @deprecated Import this method directly from discord.js instead. */
2851
- public static bold: typeof bold;
2852
- /** @deprecated Import this method directly from discord.js instead. */
2853
- public static channelMention: typeof channelMention;
2854
- /** @deprecated Import this method directly from discord.js instead. */
2855
- public static codeBlock: typeof codeBlock;
2856
- /** @deprecated Import this method directly from discord.js instead. */
2857
- public static formatEmoji: typeof formatEmoji;
2858
- /** @deprecated Import this method directly from discord.js instead. */
2859
- public static hideLinkEmbed: typeof hideLinkEmbed;
2860
- /** @deprecated Import this method directly from discord.js instead. */
2861
- public static hyperlink: typeof hyperlink;
2862
- /** @deprecated Import this method directly from discord.js instead. */
2863
- public static inlineCode: typeof inlineCode;
2864
- /** @deprecated Import this method directly from discord.js instead. */
2865
- public static italic: typeof italic;
2866
- /** @deprecated Import this method directly from discord.js instead. */
2867
- public static quote: typeof quote;
2868
- /** @deprecated Import this method directly from discord.js instead. */
2869
- public static roleMention: typeof roleMention;
2870
- /** @deprecated Import this method directly from discord.js instead. */
2871
- public static spoiler: typeof spoiler;
2872
- /** @deprecated Import this method directly from discord.js instead. */
2873
- public static strikethrough: typeof strikethrough;
2874
- /** @deprecated Import this method directly from discord.js instead. */
2875
- public static time: typeof time;
2876
- /** @deprecated Import this property directly from discord.js instead. */
2877
- public static TimestampStyles: typeof TimestampStyles;
2878
- /** @deprecated Import this method directly from discord.js instead. */
2879
- public static underscore: typeof underscore;
2880
- /** @deprecated Import this method directly from discord.js instead. */
2881
- public static userMention: typeof userMention;
2882
- }
2883
-
2884
2827
  export type ComponentData =
2885
2828
  | MessageActionRowComponentData
2886
2829
  | ModalActionRowComponentData
@@ -1,413 +0,0 @@
1
- 'use strict';
2
-
3
- const { deprecate } = require('node:util');
4
- const {
5
- blockQuote,
6
- bold,
7
- channelMention,
8
- codeBlock,
9
- formatEmoji,
10
- hideLinkEmbed,
11
- hyperlink,
12
- inlineCode,
13
- italic,
14
- quote,
15
- roleMention,
16
- spoiler,
17
- strikethrough,
18
- time,
19
- TimestampStyles,
20
- underscore,
21
- userMention,
22
- } = require('@discordjs/formatters');
23
-
24
- /**
25
- * Formats an application command name and id into an application command mention.
26
- * @method chatInputApplicationCommandMention
27
- * @param {string} commandName The name of the application command
28
- * @param {string|Snowflake} subcommandGroupOrSubOrId
29
- * The subcommand group name, subcommand name, or application command id
30
- * @param {string|Snowflake} [subcommandNameOrId] The subcommand name or application command id
31
- * @param {string} [commandId] The id of the application command
32
- * @returns {string}
33
- */
34
-
35
- /**
36
- * Wraps the content inside a code block with an optional language.
37
- * @method codeBlock
38
- * @param {string} contentOrLanguage The language to use or content if a second parameter isn't provided
39
- * @param {string} [content] The content to wrap
40
- * @returns {string}
41
- */
42
-
43
- /**
44
- * Wraps the content inside \`backticks\`, which formats it as inline code.
45
- * @method inlineCode
46
- * @param {string} content The content to wrap
47
- * @returns {string}
48
- */
49
-
50
- /**
51
- * Formats the content into italic text.
52
- * @method italic
53
- * @param {string} content The content to wrap
54
- * @returns {string}
55
- */
56
-
57
- /**
58
- * Formats the content into bold text.
59
- * @method bold
60
- * @param {string} content The content to wrap
61
- * @returns {string}
62
- */
63
-
64
- /**
65
- * Formats the content into underscored text.
66
- * @method underscore
67
- * @param {string} content The content to wrap
68
- * @returns {string}
69
- */
70
-
71
- /**
72
- * Formats the content into strike-through text.
73
- * @method strikethrough
74
- * @param {string} content The content to wrap
75
- * @returns {string}
76
- */
77
-
78
- /**
79
- * Formats the content into a quote.
80
- * <info>This needs to be at the start of the line for Discord to format it.</info>
81
- * @method quote
82
- * @param {string} content The content to wrap
83
- * @returns {string}
84
- */
85
-
86
- /**
87
- * Formats the content into a block quote.
88
- * <info>This needs to be at the start of the line for Discord to format it.</info>
89
- * @method blockQuote
90
- * @param {string} content The content to wrap
91
- * @returns {string}
92
- */
93
-
94
- /**
95
- * Wraps the URL into `<>`, which stops it from embedding.
96
- * @method hideLinkEmbed
97
- * @param {string} content The content to wrap
98
- * @returns {string}
99
- */
100
-
101
- /**
102
- * Formats the content and the URL into a masked URL with an optional title.
103
- * @method hyperlink
104
- * @param {string} content The content to display
105
- * @param {string} url The URL the content links to
106
- * @param {string} [title] The title shown when hovering on the masked link
107
- * @returns {string}
108
- */
109
-
110
- /**
111
- * Formats the content into spoiler text.
112
- * @method spoiler
113
- * @param {string} content The content to spoiler
114
- * @returns {string}
115
- */
116
-
117
- /**
118
- * Formats a user id into a user mention.
119
- * @method userMention
120
- * @param {Snowflake} userId The user id to format
121
- * @returns {string}
122
- */
123
-
124
- /**
125
- * Formats a channel id into a channel mention.
126
- * @method channelMention
127
- * @param {Snowflake} channelId The channel id to format
128
- * @returns {string}
129
- */
130
-
131
- /**
132
- * Formats a role id into a role mention.
133
- * @method roleMention
134
- * @param {Snowflake} roleId The role id to format
135
- * @returns {string}
136
- */
137
-
138
- /**
139
- * Formats an emoji id into a fully qualified emoji identifier.
140
- * @method formatEmoji
141
- * @param {Snowflake} emojiId The emoji id to format
142
- * @param {boolean} [animated=false] Whether the emoji is animated
143
- * @returns {string}
144
- */
145
-
146
- /**
147
- * Formats a channel link for a channel.
148
- * @method channelLink
149
- * @param {Snowflake} channelId The id of the channel
150
- * @param {Snowflake} [guildId] The id of the guild
151
- * @returns {string}
152
- */
153
-
154
- /**
155
- * Formats a message link for a channel.
156
- * @method messageLink
157
- * @param {Snowflake} channelId The id of the channel
158
- * @param {Snowflake} messageId The id of the message
159
- * @param {Snowflake} [guildId] The id of the guild
160
- * @returns {string}
161
- */
162
-
163
- /**
164
- * A message formatting timestamp style, as defined in
165
- * [here](https://discord.com/developers/docs/reference#message-formatting-timestamp-styles).
166
- * * `t` Short time format, consisting of hours and minutes, e.g. 16:20.
167
- * * `T` Long time format, consisting of hours, minutes, and seconds, e.g. 16:20:30.
168
- * * `d` Short date format, consisting of day, month, and year, e.g. 20/04/2021.
169
- * * `D` Long date format, consisting of day, month, and year, e.g. 20 April 2021.
170
- * * `f` Short date-time format, consisting of short date and short time formats, e.g. 20 April 2021 16:20.
171
- * * `F` Long date-time format, consisting of long date and short time formats, e.g. Tuesday, 20 April 2021 16:20.
172
- * * `R` Relative time format, consisting of a relative duration format, e.g. 2 months ago.
173
- * @typedef {string} TimestampStylesString
174
- */
175
-
176
- /**
177
- * Formats a date into a short date-time string.
178
- * @method time
179
- * @param {number|Date} [date] The date to format
180
- * @param {TimestampStylesString} [style] The style to use
181
- * @returns {string}
182
- */
183
-
184
- /**
185
- * Contains various Discord-specific functions for formatting messages.
186
- * @deprecated This class is redundant as all methods of the class can be imported from discord.js directly.
187
- */
188
- class Formatters extends null {
189
- /**
190
- * Formats the content into a block quote.
191
- * <info>This needs to be at the start of the line for Discord to format it.</info>
192
- * @method blockQuote
193
- * @memberof Formatters
194
- * @param {string} content The content to wrap
195
- * @returns {string}
196
- * @deprecated Import this method directly from discord.js instead.
197
- */
198
- static blockQuote = deprecate(
199
- blockQuote,
200
- 'Formatters.blockQuote() is deprecated. Import this method directly from discord.js instead.',
201
- );
202
-
203
- /**
204
- * Formats the content into bold text.
205
- * @method bold
206
- * @memberof Formatters
207
- * @param {string} content The content to wrap
208
- * @returns {string}
209
- * @deprecated Import this method directly from discord.js instead.
210
- */
211
- static bold = deprecate(
212
- bold,
213
- 'Formatters.bold() is deprecated. Import this method directly from discord.js instead.',
214
- );
215
-
216
- /**
217
- * Formats a channel id into a channel mention.
218
- * @method channelMention
219
- * @memberof Formatters
220
- * @param {Snowflake} channelId The channel id to format
221
- * @returns {string}
222
- * @deprecated Import this method directly from discord.js instead.
223
- */
224
- static channelMention = deprecate(
225
- channelMention,
226
- 'Formatters.channelMention() is deprecated. Import this method directly from discord.js instead.',
227
- );
228
-
229
- /**
230
- * Wraps the content inside a code block with an optional language.
231
- * @method codeBlock
232
- * @memberof Formatters
233
- * @param {string} contentOrLanguage The language to use or content if a second parameter isn't provided
234
- * @param {string} [content] The content to wrap
235
- * @returns {string}
236
- * @deprecated Import this method directly from discord.js instead.
237
- */
238
- static codeBlock = deprecate(
239
- codeBlock,
240
- 'Formatters.codeBlock() is deprecated. Import this method directly from discord.js instead.',
241
- );
242
-
243
- /**
244
- * Formats an emoji id into a fully qualified emoji identifier.
245
- * @method formatEmoji
246
- * @memberof Formatters
247
- * @param {string} emojiId The emoji id to format
248
- * @param {boolean} [animated=false] Whether the emoji is animated
249
- * @returns {string}
250
- * @deprecated Import this method directly from discord.js instead.
251
- */
252
- static formatEmoji = deprecate(
253
- formatEmoji,
254
- 'Formatters.formatEmoji() is deprecated. Import this method directly from discord.js instead.',
255
- );
256
-
257
- /**
258
- * Wraps the URL into `<>`, which stops it from embedding.
259
- * @method hideLinkEmbed
260
- * @memberof Formatters
261
- * @param {string} content The content to wrap
262
- * @returns {string}
263
- * @deprecated Import this method directly from discord.js instead.
264
- */
265
- static hideLinkEmbed = deprecate(
266
- hideLinkEmbed,
267
- 'Formatters.hideLinkEmbed() is deprecated. Import this method directly from discord.js instead.',
268
- );
269
-
270
- /**
271
- * Formats the content and the URL into a masked URL with an optional title.
272
- * @method hyperlink
273
- * @memberof Formatters
274
- * @param {string} content The content to display
275
- * @param {string} url The URL the content links to
276
- * @param {string} [title] The title shown when hovering on the masked link
277
- * @returns {string}
278
- * @deprecated Import this method directly from discord.js instead.
279
- */
280
- static hyperlink = deprecate(
281
- hyperlink,
282
- 'Formatters.hyperlink() is deprecated. Import this method directly from discord.js instead.',
283
- );
284
-
285
- /**
286
- * Wraps the content inside \`backticks\`, which formats it as inline code.
287
- * @method inlineCode
288
- * @memberof Formatters
289
- * @param {string} content The content to wrap
290
- * @returns {string}
291
- * @deprecated Import this method directly from discord.js instead.
292
- */
293
- static inlineCode = deprecate(
294
- inlineCode,
295
- 'Formatters.inlineCode() is deprecated. Import this method directly from discord.js instead.',
296
- );
297
-
298
- /**
299
- * Formats the content into italic text.
300
- * @method italic
301
- * @memberof Formatters
302
- * @param {string} content The content to wrap
303
- * @returns {string}
304
- * @deprecated Import this method directly from discord.js instead.
305
- */
306
- static italic = deprecate(
307
- italic,
308
- 'Formatters.italic() is deprecated. Import this method directly from discord.js instead.',
309
- );
310
-
311
- /**
312
- * Formats the content into a quote. This needs to be at the start of the line for Discord to format it.
313
- * @method quote
314
- * @memberof Formatters
315
- * @param {string} content The content to wrap
316
- * @returns {string}
317
- * @deprecated Import this method directly from discord.js instead.
318
- */
319
- static quote = deprecate(
320
- quote,
321
- 'Formatters.quote() is deprecated. Import this method directly from discord.js instead.',
322
- );
323
-
324
- /**
325
- * Formats a role id into a role mention.
326
- * @method roleMention
327
- * @memberof Formatters
328
- * @param {Snowflake} roleId The role id to format
329
- * @returns {string}
330
- * @deprecated Import this method directly from discord.js instead.
331
- */
332
- static roleMention = deprecate(
333
- roleMention,
334
- 'Formatters.roleMention() is deprecated. Import this method directly from discord.js instead.',
335
- );
336
-
337
- /**
338
- * Formats the content into spoiler text.
339
- * @method spoiler
340
- * @memberof Formatters
341
- * @param {string} content The content to spoiler
342
- * @returns {string}
343
- * @deprecated Import this method directly from discord.js instead.
344
- */
345
- static spoiler = deprecate(
346
- spoiler,
347
- 'Formatters.spoiler() is deprecated. Import this method directly from discord.js instead.',
348
- );
349
-
350
- /**
351
- * Formats the content into strike-through text.
352
- * @method strikethrough
353
- * @memberof Formatters
354
- * @param {string} content The content to wrap
355
- * @returns {string}
356
- * @deprecated Import this method directly from discord.js instead.
357
- */
358
- static strikethrough = deprecate(
359
- strikethrough,
360
- 'Formatters.strikethrough() is deprecated. Import this method directly from discord.js instead.',
361
- );
362
-
363
- /**
364
- * Formats a date into a short date-time string.
365
- * @method time
366
- * @memberof Formatters
367
- * @param {number|Date} [date] The date to format
368
- * @param {TimestampStylesString} [style] The style to use
369
- * @returns {string}
370
- * @deprecated Import this method directly from discord.js instead.
371
- */
372
- static time = deprecate(
373
- time,
374
- 'Formatters.time() is deprecated. Import this method directly from discord.js instead.',
375
- );
376
-
377
- /**
378
- * The message formatting timestamp
379
- * [styles](https://discord.com/developers/docs/reference#message-formatting-timestamp-styles) supported by Discord.
380
- * @type {Object<string, TimestampStylesString>}
381
- * @memberof Formatters
382
- * @deprecated Import this property directly from discord.js instead.
383
- */
384
- static TimestampStyles = TimestampStyles;
385
-
386
- /**
387
- * Formats the content into underscored text.
388
- * @method underscore
389
- * @memberof Formatters
390
- * @param {string} content The content to wrap
391
- * @returns {string}
392
- * @deprecated Import this method directly from discord.js instead.
393
- */
394
- static underscore = deprecate(
395
- underscore,
396
- 'Formatters.underscore() is deprecated. Import this method directly from discord.js instead.',
397
- );
398
-
399
- /**
400
- * Formats a user id into a user mention.
401
- * @method userMention
402
- * @memberof Formatters
403
- * @param {Snowflake} userId The user id to format
404
- * @returns {string}
405
- * @deprecated Import this method directly from discord.js instead.
406
- */
407
- static userMention = deprecate(
408
- userMention,
409
- 'Formatters.userMention() is deprecated. Import this method directly from discord.js instead.',
410
- );
411
- }
412
-
413
- module.exports = Formatters;