mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-03 05:26:07 +00:00
fix(channels): permissionOverwrites (#75)
* fix(Message): delete() params * fix
This commit is contained in:
parent
d2c984d31a
commit
c50e8d72c8
@ -391,7 +391,7 @@ export class Message implements Model {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** deletes this message */
|
/** deletes this message */
|
||||||
async delete({ reason }: { reason: string }): Promise<Message> {
|
async delete(reason?: string): Promise<Message> {
|
||||||
await this.session.rest.runMethod<undefined>(
|
await this.session.rest.runMethod<undefined>(
|
||||||
this.session.rest,
|
this.session.rest,
|
||||||
'DELETE',
|
'DELETE',
|
||||||
|
@ -12,6 +12,7 @@ import {
|
|||||||
DiscordInviteMetadata,
|
DiscordInviteMetadata,
|
||||||
DiscordListArchivedThreads,
|
DiscordListArchivedThreads,
|
||||||
DiscordMessage,
|
DiscordMessage,
|
||||||
|
DiscordOverwrite,
|
||||||
DiscordThreadMember,
|
DiscordThreadMember,
|
||||||
DiscordWebhook,
|
DiscordWebhook,
|
||||||
GatewayOpcodes,
|
GatewayOpcodes,
|
||||||
@ -30,7 +31,7 @@ import Invite from './Invite.ts';
|
|||||||
import Webhook from './Webhook.ts';
|
import Webhook from './Webhook.ts';
|
||||||
import User from './User.ts';
|
import User from './User.ts';
|
||||||
import ThreadMember from './ThreadMember.ts';
|
import ThreadMember from './ThreadMember.ts';
|
||||||
import Permissions, { PermissionResolvable } from "./Permissions.ts";
|
import Permissions from './Permissions.ts';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract class that represents the base for creating a new channel.
|
* Abstract class that represents the base for creating a new channel.
|
||||||
@ -90,7 +91,7 @@ export abstract class BaseChannel implements Model {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a category channel.
|
* Represents a category channel.
|
||||||
*/
|
*/
|
||||||
export class CategoryChannel extends BaseChannel {
|
export class CategoryChannel extends BaseChannel {
|
||||||
@ -104,18 +105,9 @@ export class CategoryChannel extends BaseChannel {
|
|||||||
this.position = data.position ? data.position : undefined;
|
this.position = data.position ? data.position : undefined;
|
||||||
this.parentId = data.parent_id ? data.parent_id : undefined;
|
this.parentId = data.parent_id ? data.parent_id : undefined;
|
||||||
|
|
||||||
this.permissionOverwrites = [] as PermissionsOverwrites[];
|
this.permissionOverwrites = data.permission_overwrites
|
||||||
// TODO: improve this and test
|
? ChannelFactory.permissionOverwrites(data.permission_overwrites)
|
||||||
if (data.permission_overwrites && data.permission_overwrites.length > 0) {
|
: [];
|
||||||
data.permission_overwrites.forEach(v => {
|
|
||||||
this.permissionOverwrites.push({
|
|
||||||
id: v.id,
|
|
||||||
type: v.type,
|
|
||||||
allow: new Permissions(parseInt(v.allow as string) as PermissionResolvable),
|
|
||||||
deny: new Permissions(parseInt(v.deny as string) as PermissionResolvable),
|
|
||||||
} as PermissionsOverwrites);
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
id: Snowflake;
|
id: Snowflake;
|
||||||
@ -246,7 +238,6 @@ export class TextChannel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fetchPins makes an asynchronous request and gets the current channel pins.
|
* fetchPins makes an asynchronous request and gets the current channel pins.
|
||||||
* @returns A promise that resolves with an array of Message objects.
|
* @returns A promise that resolves with an array of Message objects.
|
||||||
@ -525,6 +516,9 @@ export class GuildChannel extends BaseChannel implements Model {
|
|||||||
this.position = data.position;
|
this.position = data.position;
|
||||||
data.topic ? this.topic = data.topic : null;
|
data.topic ? this.topic = data.topic : null;
|
||||||
data.parent_id ? this.parentId = data.parent_id : undefined;
|
data.parent_id ? this.parentId = data.parent_id : undefined;
|
||||||
|
this.permissionOverwrites = data.permission_overwrites
|
||||||
|
? ChannelFactory.permissionOverwrites(data.permission_overwrites)
|
||||||
|
: [];
|
||||||
}
|
}
|
||||||
|
|
||||||
override type: Exclude<ChannelTypes, ChannelTypes.DM | ChannelTypes.GroupDm>;
|
override type: Exclude<ChannelTypes, ChannelTypes.DM | ChannelTypes.GroupDm>;
|
||||||
@ -532,6 +526,7 @@ export class GuildChannel extends BaseChannel implements Model {
|
|||||||
topic?: string;
|
topic?: string;
|
||||||
position?: number;
|
position?: number;
|
||||||
parentId?: Snowflake;
|
parentId?: Snowflake;
|
||||||
|
permissionOverwrites: PermissionsOverwrites[];
|
||||||
|
|
||||||
async fetchInvites(): Promise<Invite[]> {
|
async fetchInvites(): Promise<Invite[]> {
|
||||||
const invites = await this.session.rest.runMethod<DiscordInviteMetadata[]>(
|
const invites = await this.session.rest.runMethod<DiscordInviteMetadata[]>(
|
||||||
@ -916,4 +911,15 @@ export class ChannelFactory {
|
|||||||
throw new Error('Channel was not implemented');
|
throw new Error('Channel was not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static permissionOverwrites(overwrites: DiscordOverwrite[]): PermissionsOverwrites[] {
|
||||||
|
return overwrites.map((v) => {
|
||||||
|
return {
|
||||||
|
id: v.id,
|
||||||
|
type: v.type,
|
||||||
|
allow: new Permissions(parseInt(v.allow!)),
|
||||||
|
deny: new Permissions(parseInt(v.deny!)),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user