stage channel

This commit is contained in:
DjDeveloperr 2021-04-04 16:57:02 +05:30
parent d63d4f4f12
commit 6293a1f940
11 changed files with 105 additions and 8 deletions

4
mod.ts
View File

@ -96,7 +96,7 @@ export { Intents } from './src/utils/intents.ts'
export * from './src/utils/permissions.ts' export * from './src/utils/permissions.ts'
export { UserFlagsManager } from './src/utils/userFlags.ts' export { UserFlagsManager } from './src/utils/userFlags.ts'
export { HarmonyEventEmitter } from './src/utils/events.ts' export { HarmonyEventEmitter } from './src/utils/events.ts'
export type { EveryChannelTypes } from './src/utils/getChannelByType.ts' export type { EveryChannelTypes } from './src/utils/channel.ts'
export * from './src/utils/bitfield.ts' export * from './src/utils/bitfield.ts'
export type { export type {
ActivityGame, ActivityGame,
@ -175,3 +175,5 @@ export type { Dict } from './src/utils/dict.ts'
export * from './src/cache/redis.ts' export * from './src/cache/redis.ts'
export { ColorUtil } from './src/utils/colorutil.ts' export { ColorUtil } from './src/utils/colorutil.ts'
export type { Colors } from './src/utils/colorutil.ts' export type { Colors } from './src/utils/colorutil.ts'
export { StoreChannel } from './src/structures/guildStoreChannel.ts'
export { StageVoiceChannel } from './src/structures/guildStageVoiceChannel.ts'

View File

@ -1,5 +1,5 @@
import type { Gateway, GatewayEventHandler } from '../mod.ts' import type { Gateway, GatewayEventHandler } from '../mod.ts'
import getChannelByType from '../../utils/getChannelByType.ts' import getChannelByType from '../../utils/channel.ts'
import type { import type {
ChannelPayload, ChannelPayload,
GuildChannelPayload GuildChannelPayload

View File

@ -57,7 +57,7 @@ import type { Presence } from '../../structures/presence.ts'
import type { import type {
EveryChannelTypes, EveryChannelTypes,
EveryTextChannelTypes EveryTextChannelTypes
} from '../../utils/getChannelByType.ts' } from '../../utils/channel.ts'
import { interactionCreate } from './interactionCreate.ts' import { interactionCreate } from './interactionCreate.ts'
import type { Interaction } from '../../structures/slash.ts' import type { Interaction } from '../../structures/slash.ts'
import type { CommandContext } from '../../commands/command.ts' import type { CommandContext } from '../../commands/command.ts'

View File

@ -9,7 +9,7 @@ import type {
MessageOptions MessageOptions
} from '../types/channel.ts' } from '../types/channel.ts'
import { CHANNEL } from '../types/endpoint.ts' import { CHANNEL } from '../types/endpoint.ts'
import getChannelByType from '../utils/getChannelByType.ts' import getChannelByType from '../utils/channel.ts'
import { BaseManager } from './base.ts' import { BaseManager } from './base.ts'
export type AllMessageOptions = MessageOptions | Embed export type AllMessageOptions = MessageOptions | Embed

View File

@ -11,7 +11,7 @@ import type {
import { OverrideType } from '../types/channel.ts' import { OverrideType } from '../types/channel.ts'
import { CHANNEL } from '../types/endpoint.ts' import { CHANNEL } from '../types/endpoint.ts'
import type { GuildChannelPayloads, GuildChannels } from '../types/guild.ts' import type { GuildChannelPayloads, GuildChannels } from '../types/guild.ts'
import getChannelByType from '../utils/getChannelByType.ts' import getChannelByType from '../utils/channel.ts'
import { Permissions } from '../utils/permissions.ts' import { Permissions } from '../utils/permissions.ts'
import { SnowflakeBase } from './base.ts' import { SnowflakeBase } from './base.ts'
import type { Guild } from './guild.ts' import type { Guild } from './guild.ts'

View File

@ -0,0 +1,3 @@
import { VoiceChannel } from './guildVoiceChannel.ts'
export class StageVoiceChannel extends VoiceChannel {}

View File

@ -0,0 +1,3 @@
import { GuildChannel } from './channel.ts'
export class StoreChannel extends GuildChannel {}

View File

@ -157,7 +157,8 @@ export enum ChannelTypes {
GROUP_DM = 3, GROUP_DM = 3,
GUILD_CATEGORY = 4, GUILD_CATEGORY = 4,
GUILD_NEWS = 5, GUILD_NEWS = 5,
GUILD_STORE = 6 GUILD_STORE = 6,
GUILD_STAGE_VOICE = 13
} }
export interface MessagePayload { export interface MessagePayload {
@ -336,7 +337,11 @@ export enum MessageTypes {
USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_3 = 11, USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_3 = 11,
CHANNEL_FOLLOW_ADD = 12, CHANNEL_FOLLOW_ADD = 12,
GUILD_DISCOVERY_DISQUALIFIED = 14, GUILD_DISCOVERY_DISQUALIFIED = 14,
GUILD_DISCOVERY_REQUALIFIED = 15 GUILD_DISCOVERY_REQUALIFIED = 15,
GUILD_DISCOVERY_GRACE_PERIOD_INITIAL_WARNING = 16,
GUILD_DISCOVERY_GRACE_PERIOD_FINAL_WARNING = 17,
REPLY = 19,
APPLICATION_COMMAND = 20
} }
export enum MessageActivityTypes { export enum MessageActivityTypes {

View File

@ -32,5 +32,7 @@ export const PermissionFlags: { [key: string]: bigint } = {
MANAGE_ROLES: 1n << 28n, MANAGE_ROLES: 1n << 28n,
MANAGE_WEBHOOKS: 1n << 29n, MANAGE_WEBHOOKS: 1n << 29n,
MANAGE_EMOJIS: 1n << 30n, MANAGE_EMOJIS: 1n << 30n,
USE_SLASH_COMMANDS: 1n << 31n USE_SLASH_COMMANDS: 1n << 31n,
// Might be removed (as PR says)
REQUEST_TO_SPEAK: 0x100000000n
} }

View File

@ -41,6 +41,7 @@ export interface VoiceStatePayload {
self_stream?: boolean self_stream?: boolean
self_video: boolean self_video: boolean
suppress: boolean suppress: boolean
request_to_speak_timestamp: string | null
} }
/** Voice Region Structure */ /** Voice Region Structure */

View File

@ -23,6 +23,8 @@ import { VoiceChannel } from '../structures/guildVoiceChannel.ts'
import { Guild } from '../structures/guild.ts' import { Guild } from '../structures/guild.ts'
import { TextChannel } from '../structures/textChannel.ts' import { TextChannel } from '../structures/textChannel.ts'
import { Channel, GuildChannel } from '../structures/channel.ts' import { Channel, GuildChannel } from '../structures/channel.ts'
import { StoreChannel } from '../structures/guildStoreChannel.ts'
import { StageVoiceChannel } from '../structures/guildStageVoiceChannel.ts'
export type EveryTextChannelTypes = export type EveryTextChannelTypes =
| TextChannel | TextChannel
@ -80,10 +82,22 @@ const getChannelByType = (
data as GuildTextChannelPayload, data as GuildTextChannelPayload,
guild guild
) )
case ChannelTypes.GUILD_STORE:
if (guild === undefined)
throw new Error('No Guild was provided to construct Channel')
return new StoreChannel(client, data as GuildTextChannelPayload, guild)
case ChannelTypes.GUILD_VOICE: case ChannelTypes.GUILD_VOICE:
if (guild === undefined) if (guild === undefined)
throw new Error('No Guild was provided to construct Channel') throw new Error('No Guild was provided to construct Channel')
return new VoiceChannel(client, data as GuildVoiceChannelPayload, guild) return new VoiceChannel(client, data as GuildVoiceChannelPayload, guild)
case ChannelTypes.GUILD_STAGE_VOICE:
if (guild === undefined)
throw new Error('No Guild was provided to construct Channel')
return new StageVoiceChannel(
client,
data as GuildVoiceChannelPayload,
guild
)
case ChannelTypes.DM: case ChannelTypes.DM:
return new DMChannel(client, data as DMChannelPayload) return new DMChannel(client, data as DMChannelPayload)
case ChannelTypes.GROUP_DM: case ChannelTypes.GROUP_DM:
@ -92,3 +106,70 @@ const getChannelByType = (
} }
export default getChannelByType export default getChannelByType
export function isTextChannel(channel: Channel): channel is TextChannel {
return (
channel.type === ChannelTypes.DM ||
channel.type === ChannelTypes.GROUP_DM ||
channel.type === ChannelTypes.GUILD_TEXT ||
channel.type === ChannelTypes.GUILD_NEWS
)
}
export function isDMChannel(channel: Channel): channel is DMChannel {
return channel.type === ChannelTypes.DM
}
export function isGroupDMChannel(channel: Channel): channel is GroupDMChannel {
return channel.type === ChannelTypes.GROUP_DM
}
export function isGuildTextChannel(
channel: Channel
): channel is GuildTextChannel {
return channel.type === ChannelTypes.GUILD_TEXT
}
export function isGuildBasedTextChannel(
channel: Channel
): channel is GuildTextBasedChannel {
return (
channel.type === ChannelTypes.GUILD_TEXT ||
channel.type === ChannelTypes.GUILD_NEWS
)
}
export function isCategoryChannel(
channel: Channel
): channel is CategoryChannel {
return channel.type === ChannelTypes.GUILD_CATEGORY
}
export function isNewsChannel(channel: Channel): channel is NewsChannel {
return channel.type === ChannelTypes.GUILD_NEWS
}
export function isVoiceChannel(channel: Channel): channel is VoiceChannel {
return channel.type === ChannelTypes.GUILD_VOICE
}
export function isStageVoiceChannel(
channel: Channel
): channel is StageVoiceChannel {
return channel.type === ChannelTypes.GUILD_STAGE_VOICE
}
export function isStoreChannel(channel: Channel): channel is StoreChannel {
return channel.type === ChannelTypes.GUILD_STORE
}
export function isGuildChannel(channel: Channel): channel is GuildChannel {
return (
channel.type === ChannelTypes.GUILD_CATEGORY ||
channel.type === ChannelTypes.GUILD_NEWS ||
channel.type === ChannelTypes.GUILD_STORE ||
channel.type === ChannelTypes.GUILD_TEXT ||
channel.type === ChannelTypes.GUILD_VOICE ||
channel.type === ChannelTypes.GUILD_STAGE_VOICE
)
}