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 { Application } from './src/structures/application.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 { Embed } from './src/structures/embed.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 {
|
||||
guildID: string
|
||||
name: string
|
||||
|
@ -257,12 +264,9 @@ export class GuildChannel extends Channel {
|
|||
async editOverwrite(
|
||||
overwrite: OverwriteAsArg,
|
||||
{
|
||||
overriteAllow = OverrideType.ADD,
|
||||
overriteDeny = OverrideType.ADD
|
||||
}: {
|
||||
overriteAllow?: OverrideType
|
||||
overriteDeny?: OverrideType
|
||||
}
|
||||
allow: overwriteAllow = OverrideType.ADD,
|
||||
deny: overwriteDeny = OverrideType.ADD
|
||||
}: EditOverwriteOptions
|
||||
): Promise<GuildChannels> {
|
||||
const id = typeof overwrite.id === 'string' ? overwrite.id : overwrite.id.id
|
||||
const index = this.permissionOverwrites.findIndex((e) => e.id === id)
|
||||
|
@ -274,9 +278,9 @@ export class GuildChannel extends Channel {
|
|||
|
||||
if (
|
||||
overwrite.allow !== undefined &&
|
||||
overriteAllow !== OverrideType.REPLACE
|
||||
overwriteAllow !== OverrideType.REPLACE
|
||||
) {
|
||||
switch (overriteAllow) {
|
||||
switch (overwriteAllow) {
|
||||
case OverrideType.ADD: {
|
||||
const originalAllow = new Permissions(overwrites[index].allow)
|
||||
const newAllow = new Permissions(overwrite.allow)
|
||||
|
@ -299,8 +303,8 @@ export class GuildChannel extends Channel {
|
|||
: overwrite.allow?.toJSON() ?? overwrites[index].allow
|
||||
}
|
||||
|
||||
if (overwrite.deny !== undefined && overriteDeny !== OverrideType.REPLACE) {
|
||||
switch (overriteDeny) {
|
||||
if (overwrite.deny !== undefined && overwriteDeny !== OverrideType.REPLACE) {
|
||||
switch (overwriteDeny) {
|
||||
case OverrideType.ADD: {
|
||||
const originalDeny = new Permissions(overwrites[index].deny)
|
||||
const newDeny = new Permissions(overwrite.deny)
|
||||
|
|
|
@ -246,7 +246,7 @@ client.on('messageCreate', async (msg: Message) => {
|
|||
allow: Permissions.DEFAULT.toString()
|
||||
},
|
||||
{
|
||||
overriteAllow: OverrideType.REMOVE
|
||||
allow: OverrideType.REMOVE
|
||||
}
|
||||
)
|
||||
msg.channel.send(`Done!`)
|
||||
|
|
Loading…
Reference in a new issue