feat(*): use enums for consistency and speed (#5843)

Co-authored-by: Antonio Román <kyradiscord@gmail.com>
This commit is contained in:
Shubham Parihar
2021-06-15 17:03:31 +05:30
committed by GitHub
parent 671436cbb8
commit f7eeccba4b
9 changed files with 100 additions and 69 deletions

View File

@@ -13,7 +13,7 @@ const {
ChannelTypes,
Events,
VerificationLevels,
DefaultMessageNotifications,
DefaultMessageNotificationLevels,
ExplicitContentFilterLevels,
} = require('../util/Constants');
const DataResolver = require('../util/DataResolver');
@@ -168,14 +168,14 @@ class GuildManager extends BaseManager {
} = {},
) {
icon = await DataResolver.resolveImage(icon);
if (typeof verificationLevel !== 'undefined' && typeof verificationLevel !== 'number') {
verificationLevel = VerificationLevels.indexOf(verificationLevel);
if (typeof verificationLevel === 'string') {
verificationLevel = VerificationLevels[verificationLevel];
}
if (typeof defaultMessageNotifications !== 'undefined' && typeof defaultMessageNotifications !== 'number') {
defaultMessageNotifications = DefaultMessageNotifications.indexOf(defaultMessageNotifications);
if (typeof defaultMessageNotifications === 'string') {
defaultMessageNotifications = DefaultMessageNotificationLevels[defaultMessageNotifications];
}
if (typeof explicitContentFilter !== 'undefined' && typeof explicitContentFilter !== 'number') {
explicitContentFilter = ExplicitContentFilterLevels.indexOf(explicitContentFilter);
if (typeof explicitContentFilter === 'string') {
explicitContentFilter = ExplicitContentFilterLevels[explicitContentFilter];
}
for (const channel of channels) {
if (channel.type) channel.type = ChannelTypes[channel.type.toUpperCase()];