Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move ChannelType typings to within discord.js module #5015

Closed
MitchTalmadge opened this issue Nov 15, 2020 · 1 comment
Closed

Move ChannelType typings to within discord.js module #5015

MitchTalmadge opened this issue Nov 15, 2020 · 1 comment

Comments

@MitchTalmadge
Copy link

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Eg. I'm always frustrated when [...]

The ChannelType enum typings are declared at the top of typings/index.d.ts, outside of the discord.js module. Thus, they appear at the root of all TypeScript projects which have discord.js in their packages.

Type Definition:

declare enum ChannelType {
text = 0,
dm = 1,
voice = 2,
group = 3,
category = 4,
news = 5,
store = 6,
unknown = 7,
}

For example, if I import discord.js as follows:

import * as Discord from "discord.js";

then I would expect to access ChannelType as such:

let myType = Discord.ChannelType.text;

Instead, ChannelType appears at the root:

let myType = ChannelType.text;

and gives an error at runtime:

ReferenceError: ChannelType is not defined

Describe the ideal solution
A clear and concise description of what you want to happen.

Move ChannelType typings into the discord.js module.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

I need to use this for GuildCreateChannelOptions as seen here:

discord.js/typings/index.d.ts

Lines 2562 to 2565 in b8fd3f6

type?: Exclude<
keyof typeof ChannelType | ChannelType,
'dm' | 'group' | 'unknown' | ChannelType.dm | ChannelType.group | ChannelType.unknown
>;

So for now I just use the any type and assign "text" or "voice" as needed.

Additional context
Add any other context or screenshots about the feature request here.

I've noticed a near duplicate inside Constants:

ChannelTypes: {
TEXT: 0;
DM: 1;
VOICE: 2;
GROUP: 3;
CATEGORY: 4;
NEWS: 5;
STORE: 6;
};

Not sure what to do with this.

@SpaceEEC
Copy link
Member

SpaceEEC commented Jun 10, 2021

As of #5456, you can now access the enum through Discord.Constants.ChannelTypes:

ChannelTypes: typeof ChannelTypes;

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants