mirror of
https://github.com/discordjs/discord.js.git
synced 2024-08-21 05:04:42 +12:00
refactor: use formatters (#9956)
* refactor: use formatters * fix: imports * fix: imports pt.2 --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
parent
1e4ef35436
commit
40726db722
8 changed files with 29 additions and 25 deletions
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
const { channelLink } = require('@discordjs/builders');
|
||||
const { channelLink, channelMention } = require('@discordjs/formatters');
|
||||
const { DiscordSnowflake } = require('@sapphire/snowflake');
|
||||
const { ChannelType, Routes } = require('discord-api-types/v10');
|
||||
const Base = require('./Base');
|
||||
|
@ -89,7 +89,7 @@ class BaseChannel extends Base {
|
|||
* console.log(`Hello from ${channel}!`);
|
||||
*/
|
||||
toString() {
|
||||
return `<#${this.id}>`;
|
||||
return channelMention(this.id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
const { userMention } = require('@discordjs/builders');
|
||||
const { userMention } = require('@discordjs/formatters');
|
||||
const { ChannelType } = require('discord-api-types/v10');
|
||||
const { BaseChannel } = require('./BaseChannel');
|
||||
const TextBasedChannel = require('./interfaces/TextBasedChannel');
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
const process = require('node:process');
|
||||
const { formatEmoji } = require('@discordjs/formatters');
|
||||
const { DiscordSnowflake } = require('@sapphire/snowflake');
|
||||
const Base = require('./Base');
|
||||
|
||||
|
@ -97,7 +98,7 @@ class Emoji extends Base {
|
|||
* reaction.message.channel.send(`The emoji used was: ${reaction.emoji}`);
|
||||
*/
|
||||
toString() {
|
||||
return this.id ? `<${this.animated ? 'a' : ''}:${this.name}:${this.id}>` : this.name;
|
||||
return this.id ? formatEmoji(this.id, this.animated) : this.name;
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
const { messageLink } = require('@discordjs/builders');
|
||||
const { Collection } = require('@discordjs/collection');
|
||||
const { messageLink } = require('@discordjs/formatters');
|
||||
const { DiscordSnowflake } = require('@sapphire/snowflake');
|
||||
const {
|
||||
InteractionType,
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
const { roleMention } = require('@discordjs/formatters');
|
||||
const { DiscordSnowflake } = require('@sapphire/snowflake');
|
||||
const { PermissionFlagsBits } = require('discord-api-types/v10');
|
||||
const Base = require('./Base');
|
||||
|
@ -452,7 +453,7 @@ class Role extends Base {
|
|||
*/
|
||||
toString() {
|
||||
if (this.id === this.guild.id) return '@everyone';
|
||||
return `<@&${this.id}>`;
|
||||
return roleMention(this.id);
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
const { userMention } = require('@discordjs/builders');
|
||||
const { userMention } = require('@discordjs/formatters');
|
||||
const { calculateUserDefaultAvatarIndex } = require('@discordjs/rest');
|
||||
const { DiscordSnowflake } = require('@sapphire/snowflake');
|
||||
const Base = require('./Base');
|
||||
|
|
|
@ -19,7 +19,7 @@ const {
|
|||
TimestampStyles,
|
||||
underscore,
|
||||
userMention,
|
||||
} = require('@discordjs/builders');
|
||||
} = require('@discordjs/formatters');
|
||||
|
||||
/**
|
||||
* Formats an application command name and id into an application command mention.
|
||||
|
|
36
packages/discord.js/typings/index.d.ts
vendored
36
packages/discord.js/typings/index.d.ts
vendored
|
@ -1,19 +1,8 @@
|
|||
import {
|
||||
ActionRowBuilder as BuilderActionRow,
|
||||
MessageActionRowComponentBuilder,
|
||||
blockQuote,
|
||||
bold,
|
||||
ButtonBuilder as BuilderButtonComponent,
|
||||
channelMention,
|
||||
codeBlock,
|
||||
EmbedBuilder as BuildersEmbed,
|
||||
formatEmoji,
|
||||
hideLinkEmbed,
|
||||
hyperlink,
|
||||
inlineCode,
|
||||
italic,
|
||||
quote,
|
||||
roleMention,
|
||||
ChannelSelectMenuBuilder as BuilderChannelSelectMenuComponent,
|
||||
MentionableSelectMenuBuilder as BuilderMentionableSelectMenuComponent,
|
||||
RoleSelectMenuBuilder as BuilderRoleSelectMenuComponent,
|
||||
|
@ -21,12 +10,6 @@ import {
|
|||
UserSelectMenuBuilder as BuilderUserSelectMenuComponent,
|
||||
TextInputBuilder as BuilderTextInputComponent,
|
||||
SelectMenuOptionBuilder as BuildersSelectMenuOption,
|
||||
spoiler,
|
||||
strikethrough,
|
||||
time,
|
||||
TimestampStyles,
|
||||
underscore,
|
||||
userMention,
|
||||
ModalActionRowComponentBuilder,
|
||||
ModalBuilder as BuildersModal,
|
||||
AnyComponentBuilder,
|
||||
|
@ -34,6 +17,25 @@ import {
|
|||
type RestOrArray,
|
||||
ApplicationCommandOptionAllowedChannelTypes,
|
||||
} from '@discordjs/builders';
|
||||
import {
|
||||
blockQuote,
|
||||
bold,
|
||||
channelMention,
|
||||
codeBlock,
|
||||
formatEmoji,
|
||||
hideLinkEmbed,
|
||||
hyperlink,
|
||||
inlineCode,
|
||||
italic,
|
||||
quote,
|
||||
roleMention,
|
||||
spoiler,
|
||||
strikethrough,
|
||||
time,
|
||||
TimestampStyles,
|
||||
underscore,
|
||||
userMention,
|
||||
} from '@discordjs/formatters';
|
||||
import { Awaitable, JSONEncodable } from '@discordjs/util';
|
||||
import { Collection, ReadonlyCollection } from '@discordjs/collection';
|
||||
import { BaseImageURLOptions, ImageURLOptions, RawFile, REST, RESTOptions } from '@discordjs/rest';
|
||||
|
|
Loading…
Reference in a new issue