commit
d3ed30ce17
4 changed files with 38 additions and 33 deletions
3
mod.ts
3
mod.ts
|
@ -46,7 +46,8 @@ export { UsersManager } from './src/managers/users.ts'
|
||||||
export { InviteManager } from './src/managers/invites.ts'
|
export { InviteManager } from './src/managers/invites.ts'
|
||||||
export { Application } from './src/structures/application.ts'
|
export { Application } from './src/structures/application.ts'
|
||||||
// export { ImageURL } from './src/structures/cdn.ts'
|
// export { ImageURL } from './src/structures/cdn.ts'
|
||||||
export { Channel } from './src/structures/channel.ts'
|
export { Channel, GuildChannel } from './src/structures/channel.ts'
|
||||||
|
export type { EditOverwriteOptions } from './src/structures/channel.ts'
|
||||||
export { DMChannel } from './src/structures/dmChannel.ts'
|
export { DMChannel } from './src/structures/dmChannel.ts'
|
||||||
export { Embed } from './src/structures/embed.ts'
|
export { Embed } from './src/structures/embed.ts'
|
||||||
export { Emoji } from './src/structures/emoji.ts'
|
export { Emoji } from './src/structures/emoji.ts'
|
||||||
|
|
|
@ -38,6 +38,13 @@ export class Channel extends SnowflakeBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface EditOverwriteOptions {
|
||||||
|
/** Allow Override Type */
|
||||||
|
allow?: OverrideType
|
||||||
|
/** Deny Override Type */
|
||||||
|
deny?: OverrideType
|
||||||
|
}
|
||||||
|
|
||||||
export class GuildChannel extends Channel {
|
export class GuildChannel extends Channel {
|
||||||
guildID: string
|
guildID: string
|
||||||
name: string
|
name: string
|
||||||
|
@ -74,7 +81,7 @@ export class GuildChannel extends Channel {
|
||||||
const stringToObject =
|
const stringToObject =
|
||||||
typeof target === 'string'
|
typeof target === 'string'
|
||||||
? (await this.guild.members.get(target)) ??
|
? (await this.guild.members.get(target)) ??
|
||||||
(await this.guild.roles.get(target))
|
(await this.guild.roles.get(target))
|
||||||
: target
|
: target
|
||||||
|
|
||||||
if (stringToObject === undefined) {
|
if (stringToObject === undefined) {
|
||||||
|
@ -121,7 +128,7 @@ export class GuildChannel extends Channel {
|
||||||
const stringToObject =
|
const stringToObject =
|
||||||
typeof target === 'string'
|
typeof target === 'string'
|
||||||
? (await this.guild.members.get(target)) ??
|
? (await this.guild.members.get(target)) ??
|
||||||
(await this.guild.roles.get(target))
|
(await this.guild.roles.get(target))
|
||||||
: target
|
: target
|
||||||
|
|
||||||
if (stringToObject === undefined) {
|
if (stringToObject === undefined) {
|
||||||
|
@ -193,8 +200,8 @@ export class GuildChannel extends Channel {
|
||||||
overwrite.id instanceof Role
|
overwrite.id instanceof Role
|
||||||
? 0
|
? 0
|
||||||
: overwrite.id instanceof Member
|
: overwrite.id instanceof Member
|
||||||
? 1
|
? 1
|
||||||
: overwrite.type
|
: overwrite.type
|
||||||
if (type === undefined) {
|
if (type === undefined) {
|
||||||
throw new Error('Overwrite type is undefined.')
|
throw new Error('Overwrite type is undefined.')
|
||||||
}
|
}
|
||||||
|
@ -226,8 +233,8 @@ export class GuildChannel extends Channel {
|
||||||
overwrite.id instanceof Role
|
overwrite.id instanceof Role
|
||||||
? 0
|
? 0
|
||||||
: overwrite.id instanceof Member
|
: overwrite.id instanceof Member
|
||||||
? 1
|
? 1
|
||||||
: overwrite.type
|
: overwrite.type
|
||||||
if (type === undefined) {
|
if (type === undefined) {
|
||||||
throw new Error('Overwrite type is undefined.')
|
throw new Error('Overwrite type is undefined.')
|
||||||
}
|
}
|
||||||
|
@ -257,12 +264,9 @@ export class GuildChannel extends Channel {
|
||||||
async editOverwrite(
|
async editOverwrite(
|
||||||
overwrite: OverwriteAsArg,
|
overwrite: OverwriteAsArg,
|
||||||
{
|
{
|
||||||
overriteAllow = OverrideType.ADD,
|
allow: overwriteAllow = OverrideType.ADD,
|
||||||
overriteDeny = OverrideType.ADD
|
deny: overwriteDeny = OverrideType.ADD
|
||||||
}: {
|
}: EditOverwriteOptions
|
||||||
overriteAllow?: OverrideType
|
|
||||||
overriteDeny?: OverrideType
|
|
||||||
}
|
|
||||||
): Promise<GuildChannels> {
|
): Promise<GuildChannels> {
|
||||||
const id = typeof overwrite.id === 'string' ? overwrite.id : overwrite.id.id
|
const id = typeof overwrite.id === 'string' ? overwrite.id : overwrite.id.id
|
||||||
const index = this.permissionOverwrites.findIndex((e) => e.id === id)
|
const index = this.permissionOverwrites.findIndex((e) => e.id === id)
|
||||||
|
@ -274,9 +278,9 @@ export class GuildChannel extends Channel {
|
||||||
|
|
||||||
if (
|
if (
|
||||||
overwrite.allow !== undefined &&
|
overwrite.allow !== undefined &&
|
||||||
overriteAllow !== OverrideType.REPLACE
|
overwriteAllow !== OverrideType.REPLACE
|
||||||
) {
|
) {
|
||||||
switch (overriteAllow) {
|
switch (overwriteAllow) {
|
||||||
case OverrideType.ADD: {
|
case OverrideType.ADD: {
|
||||||
const originalAllow = new Permissions(overwrites[index].allow)
|
const originalAllow = new Permissions(overwrites[index].allow)
|
||||||
const newAllow = new Permissions(overwrite.allow)
|
const newAllow = new Permissions(overwrite.allow)
|
||||||
|
@ -299,8 +303,8 @@ export class GuildChannel extends Channel {
|
||||||
: overwrite.allow?.toJSON() ?? overwrites[index].allow
|
: overwrite.allow?.toJSON() ?? overwrites[index].allow
|
||||||
}
|
}
|
||||||
|
|
||||||
if (overwrite.deny !== undefined && overriteDeny !== OverrideType.REPLACE) {
|
if (overwrite.deny !== undefined && overwriteDeny !== OverrideType.REPLACE) {
|
||||||
switch (overriteDeny) {
|
switch (overwriteDeny) {
|
||||||
case OverrideType.ADD: {
|
case OverrideType.ADD: {
|
||||||
const originalDeny = new Permissions(overwrites[index].deny)
|
const originalDeny = new Permissions(overwrites[index].deny)
|
||||||
const newDeny = new Permissions(overwrite.deny)
|
const newDeny = new Permissions(overwrite.deny)
|
||||||
|
@ -327,8 +331,8 @@ export class GuildChannel extends Channel {
|
||||||
overwrite.id instanceof Role
|
overwrite.id instanceof Role
|
||||||
? 0
|
? 0
|
||||||
: overwrite.id instanceof Member
|
: overwrite.id instanceof Member
|
||||||
? 1
|
? 1
|
||||||
: overwrite.type
|
: overwrite.type
|
||||||
if (type === undefined) {
|
if (type === undefined) {
|
||||||
throw new Error('Overwrite type is undefined.')
|
throw new Error('Overwrite type is undefined.')
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,12 +74,12 @@ client.on('messageCreate', async (msg: Message) => {
|
||||||
const guilds = await msg.client.guilds.collection()
|
const guilds = await msg.client.guilds.collection()
|
||||||
msg.channel.send(
|
msg.channel.send(
|
||||||
'Guild List:\n' +
|
'Guild List:\n' +
|
||||||
(guilds
|
(guilds
|
||||||
.array()
|
.array()
|
||||||
.map((c: Guild, i: number) => {
|
.map((c: Guild, i: number) => {
|
||||||
return `${i + 1}. ${c.name} - ${c.memberCount} members`
|
return `${i + 1}. ${c.name} - ${c.memberCount} members`
|
||||||
})
|
})
|
||||||
.join('\n') as string)
|
.join('\n') as string)
|
||||||
)
|
)
|
||||||
} else if (msg.content === '!roles') {
|
} else if (msg.content === '!roles') {
|
||||||
const col = await msg.guild?.roles.collection()
|
const col = await msg.guild?.roles.collection()
|
||||||
|
@ -246,7 +246,7 @@ client.on('messageCreate', async (msg: Message) => {
|
||||||
allow: Permissions.DEFAULT.toString()
|
allow: Permissions.DEFAULT.toString()
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
overriteAllow: OverrideType.REMOVE
|
allow: OverrideType.REMOVE
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
msg.channel.send(`Done!`)
|
msg.channel.send(`Done!`)
|
||||||
|
|
|
@ -28,7 +28,7 @@ export interface GuildChannelPayload extends ChannelPayload {
|
||||||
|
|
||||||
export interface GuildTextBasedChannelPayload
|
export interface GuildTextBasedChannelPayload
|
||||||
extends TextChannelPayload,
|
extends TextChannelPayload,
|
||||||
GuildChannelPayload {
|
GuildChannelPayload {
|
||||||
topic?: string
|
topic?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ export interface GuildTextChannelPayload extends GuildTextBasedChannelPayload {
|
||||||
rate_limit_per_user: number
|
rate_limit_per_user: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GuildNewsChannelPayload extends GuildTextBasedChannelPayload {}
|
export interface GuildNewsChannelPayload extends GuildTextBasedChannelPayload { }
|
||||||
|
|
||||||
export interface GuildVoiceChannelPayload extends GuildChannelPayload {
|
export interface GuildVoiceChannelPayload extends GuildChannelPayload {
|
||||||
bitrate: string
|
bitrate: string
|
||||||
|
@ -55,7 +55,7 @@ export interface GroupDMChannelPayload extends DMChannelPayload {
|
||||||
|
|
||||||
export interface GuildCategoryChannelPayload
|
export interface GuildCategoryChannelPayload
|
||||||
extends ChannelPayload,
|
extends ChannelPayload,
|
||||||
GuildChannelPayload {}
|
GuildChannelPayload { }
|
||||||
|
|
||||||
export interface ModifyChannelPayload {
|
export interface ModifyChannelPayload {
|
||||||
name?: string
|
name?: string
|
||||||
|
@ -66,7 +66,7 @@ export interface ModifyChannelPayload {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ModifyGuildCategoryChannelPayload
|
export interface ModifyGuildCategoryChannelPayload
|
||||||
extends ModifyChannelPayload {}
|
extends ModifyChannelPayload { }
|
||||||
|
|
||||||
export interface ModifyGuildTextBasedChannelPayload
|
export interface ModifyGuildTextBasedChannelPayload
|
||||||
extends ModifyChannelPayload {
|
extends ModifyChannelPayload {
|
||||||
|
@ -80,7 +80,7 @@ export interface ModifyGuildTextChannelPayload
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ModifyGuildNewsChannelPayload
|
export interface ModifyGuildNewsChannelPayload
|
||||||
extends ModifyGuildTextBasedChannelPayload {}
|
extends ModifyGuildTextBasedChannelPayload { }
|
||||||
|
|
||||||
export interface ModifyVoiceChannelPayload extends ModifyChannelPayload {
|
export interface ModifyVoiceChannelPayload extends ModifyChannelPayload {
|
||||||
bitrate?: number | null
|
bitrate?: number | null
|
||||||
|
@ -95,7 +95,7 @@ export interface ModifyChannelOption {
|
||||||
nsfw?: boolean | null
|
nsfw?: boolean | null
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ModifyGuildCategoryChannelOption extends ModifyChannelOption {}
|
export interface ModifyGuildCategoryChannelOption extends ModifyChannelOption { }
|
||||||
|
|
||||||
export interface ModifyGuildTextBasedChannelOption extends ModifyChannelOption {
|
export interface ModifyGuildTextBasedChannelOption extends ModifyChannelOption {
|
||||||
type?: number
|
type?: number
|
||||||
|
@ -108,7 +108,7 @@ export interface ModifyGuildTextChannelOption
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ModifyGuildNewsChannelOption
|
export interface ModifyGuildNewsChannelOption
|
||||||
extends ModifyGuildTextBasedChannelOption {}
|
extends ModifyGuildTextBasedChannelOption { }
|
||||||
|
|
||||||
export interface ModifyVoiceChannelOption extends ModifyChannelOption {
|
export interface ModifyVoiceChannelOption extends ModifyChannelOption {
|
||||||
bitrate?: number | null
|
bitrate?: number | null
|
||||||
|
|
Loading…
Reference in a new issue