mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 00:23:30 +01:00
fix(Structures): remove Structures (#6027)
This commit is contained in:
@@ -1,6 +1,14 @@
|
||||
'use strict';
|
||||
|
||||
const Base = require('./Base');
|
||||
let CategoryChannel;
|
||||
let DMChannel;
|
||||
let NewsChannel;
|
||||
let StageChannel;
|
||||
let StoreChannel;
|
||||
let TextChannel;
|
||||
let ThreadChannel;
|
||||
let VoiceChannel;
|
||||
const { ChannelTypes, ThreadChannelTypes } = require('../util/Constants');
|
||||
const SnowflakeUtil = require('../util/SnowflakeUtil');
|
||||
|
||||
@@ -120,11 +128,18 @@ class Channel extends Base {
|
||||
}
|
||||
|
||||
static create(client, data, guild) {
|
||||
const Structures = require('../util/Structures');
|
||||
if (!CategoryChannel) CategoryChannel = require('./CategoryChannel');
|
||||
if (!DMChannel) DMChannel = require('./DMChannel');
|
||||
if (!NewsChannel) NewsChannel = require('./NewsChannel');
|
||||
if (!StageChannel) StageChannel = require('./StageChannel');
|
||||
if (!StoreChannel) StoreChannel = require('./StoreChannel');
|
||||
if (!TextChannel) TextChannel = require('./TextChannel');
|
||||
if (!ThreadChannel) ThreadChannel = require('./ThreadChannel');
|
||||
if (!VoiceChannel) VoiceChannel = require('./VoiceChannel');
|
||||
|
||||
let channel;
|
||||
if (!data.guild_id && !guild) {
|
||||
if ((data.recipients && data.type !== ChannelTypes.GROUP) || data.type === ChannelTypes.DM) {
|
||||
const DMChannel = Structures.get('DMChannel');
|
||||
channel = new DMChannel(client, data);
|
||||
} else if (data.type === ChannelTypes.GROUP) {
|
||||
const PartialGroupDMChannel = require('./PartialGroupDMChannel');
|
||||
@@ -136,39 +151,32 @@ class Channel extends Base {
|
||||
if (guild) {
|
||||
switch (data.type) {
|
||||
case ChannelTypes.TEXT: {
|
||||
const TextChannel = Structures.get('TextChannel');
|
||||
channel = new TextChannel(guild, data);
|
||||
break;
|
||||
}
|
||||
case ChannelTypes.VOICE: {
|
||||
const VoiceChannel = Structures.get('VoiceChannel');
|
||||
channel = new VoiceChannel(guild, data);
|
||||
break;
|
||||
}
|
||||
case ChannelTypes.CATEGORY: {
|
||||
const CategoryChannel = Structures.get('CategoryChannel');
|
||||
channel = new CategoryChannel(guild, data);
|
||||
break;
|
||||
}
|
||||
case ChannelTypes.NEWS: {
|
||||
const NewsChannel = Structures.get('NewsChannel');
|
||||
channel = new NewsChannel(guild, data);
|
||||
break;
|
||||
}
|
||||
case ChannelTypes.STORE: {
|
||||
const StoreChannel = Structures.get('StoreChannel');
|
||||
channel = new StoreChannel(guild, data);
|
||||
break;
|
||||
}
|
||||
case ChannelTypes.STAGE: {
|
||||
const StageChannel = Structures.get('StageChannel');
|
||||
channel = new StageChannel(guild, data);
|
||||
break;
|
||||
}
|
||||
case ChannelTypes.NEWS_THREAD:
|
||||
case ChannelTypes.PUBLIC_THREAD:
|
||||
case ChannelTypes.PRIVATE_THREAD: {
|
||||
const ThreadChannel = Structures.get('ThreadChannel');
|
||||
channel = new ThreadChannel(guild, data);
|
||||
channel.parent?.threads.cache.set(channel.id, channel);
|
||||
break;
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
'use strict';
|
||||
|
||||
const User = require('./User');
|
||||
const DataResolver = require('../util/DataResolver');
|
||||
const Structures = require('../util/Structures');
|
||||
|
||||
/**
|
||||
* Represents the logged in client's Discord user.
|
||||
* @extends {User}
|
||||
*/
|
||||
class ClientUser extends Structures.get('User') {
|
||||
class ClientUser extends User {
|
||||
constructor(client, data) {
|
||||
super(client, data);
|
||||
this._typing = new Map();
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
'use strict';
|
||||
|
||||
const Base = require('./Base');
|
||||
const { Presence } = require('./Presence');
|
||||
const VoiceState = require('./VoiceState');
|
||||
const TextBasedChannel = require('./interfaces/TextBasedChannel');
|
||||
const { Error } = require('../errors');
|
||||
const GuildMemberRoleManager = require('../managers/GuildMemberRoleManager');
|
||||
const Permissions = require('../util/Permissions');
|
||||
let Structures;
|
||||
|
||||
/**
|
||||
* Represents a member of a guild on Discord.
|
||||
@@ -130,8 +131,6 @@ class GuildMember extends Base {
|
||||
* @readonly
|
||||
*/
|
||||
get voice() {
|
||||
if (!Structures) Structures = require('../util/Structures');
|
||||
const VoiceState = Structures.get('VoiceState');
|
||||
return this.guild.voiceStates.cache.get(this.id) ?? new VoiceState(this.guild, { user_id: this.id });
|
||||
}
|
||||
|
||||
@@ -159,8 +158,6 @@ class GuildMember extends Base {
|
||||
* @readonly
|
||||
*/
|
||||
get presence() {
|
||||
if (!Structures) Structures = require('../util/Structures');
|
||||
const Presence = Structures.get('Presence');
|
||||
return (
|
||||
this.guild.presences.cache.get(this.id) ??
|
||||
new Presence(this.client, {
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
'use strict';
|
||||
|
||||
const Base = require('./Base');
|
||||
const { Presence } = require('./Presence');
|
||||
const TextBasedChannel = require('./interfaces/TextBasedChannel');
|
||||
const { Error } = require('../errors');
|
||||
const SnowflakeUtil = require('../util/SnowflakeUtil');
|
||||
const UserFlags = require('../util/UserFlags');
|
||||
|
||||
let Structures;
|
||||
|
||||
/**
|
||||
* Represents a user on Discord.
|
||||
* @implements {TextBasedChannel}
|
||||
@@ -153,8 +152,6 @@ class User extends Base {
|
||||
for (const guild of this.client.guilds.cache.values()) {
|
||||
if (guild.presences.cache.has(this.id)) return guild.presences.cache.get(this.id);
|
||||
}
|
||||
if (!Structures) Structures = require('../util/Structures');
|
||||
const Presence = Structures.get('Presence');
|
||||
return new Presence(this.client, { user: { id: this.id } });
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user