mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 16:43:31 +01:00
refactor: make use of destructuring for Constants (#1942)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
const Snowflake = require('../util/Snowflake');
|
||||
const Base = require('./Base');
|
||||
const Constants = require('../util/Constants');
|
||||
const { ChannelTypes } = require('../util/Constants');
|
||||
|
||||
/**
|
||||
* Represents any channel on Discord.
|
||||
@@ -10,7 +10,7 @@ class Channel extends Base {
|
||||
constructor(client, data) {
|
||||
super(client);
|
||||
|
||||
const type = Object.keys(Constants.ChannelTypes)[data.type];
|
||||
const type = Object.keys(ChannelTypes)[data.type];
|
||||
/**
|
||||
* The type of the channel, either:
|
||||
* * `dm` - a DM channel
|
||||
@@ -72,23 +72,22 @@ class Channel extends Base {
|
||||
const VoiceChannel = require('./VoiceChannel');
|
||||
const CategoryChannel = require('./CategoryChannel');
|
||||
const GuildChannel = require('./GuildChannel');
|
||||
const types = Constants.ChannelTypes;
|
||||
let channel;
|
||||
if (data.type === types.DM) {
|
||||
if (data.type === ChannelTypes.DM) {
|
||||
channel = new DMChannel(client, data);
|
||||
} else if (data.type === types.GROUP) {
|
||||
} else if (data.type === ChannelTypes.GROUP) {
|
||||
channel = new GroupDMChannel(client, data);
|
||||
} else {
|
||||
guild = guild || client.guilds.get(data.guild_id);
|
||||
if (guild) {
|
||||
switch (data.type) {
|
||||
case types.TEXT:
|
||||
case ChannelTypes.TEXT:
|
||||
channel = new TextChannel(guild, data);
|
||||
break;
|
||||
case types.VOICE:
|
||||
case ChannelTypes.VOICE:
|
||||
channel = new VoiceChannel(guild, data);
|
||||
break;
|
||||
case types.CATEGORY:
|
||||
case ChannelTypes.CATEGORY:
|
||||
channel = new CategoryChannel(guild, data);
|
||||
break;
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user