refactor: make use of destructuring for Constants (#1942)

This commit is contained in:
SpaceEEC
2017-09-16 20:31:36 +02:00
committed by Crawl
parent 25ece1882b
commit ec4c98704f
66 changed files with 262 additions and 262 deletions

View File

@@ -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: