mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-02 21:16:09 +00:00
feat: some changes
This commit is contained in:
parent
aa1aaf6682
commit
373c46471d
1
mod.ts
1
mod.ts
@ -15,3 +15,4 @@ export * from "./structures/TextChannel.ts";
|
||||
export * from "./structures/VoiceChannel.ts";
|
||||
export * from "./structures/ThreadChannel.ts";
|
||||
export * from "./structures/NewsChannel.ts";
|
||||
export * from "./structures/Emoji.ts";
|
||||
|
@ -8,8 +8,8 @@ export abstract class Channel implements Model {
|
||||
this.name = data.name;
|
||||
this.type = data.type;
|
||||
}
|
||||
id: Snowflake;
|
||||
session: Session;
|
||||
readonly id: Snowflake;
|
||||
readonly session: Session;
|
||||
name?: string;
|
||||
type: ChannelTypes;
|
||||
|
||||
|
18
structures/Emoji.ts
Normal file
18
structures/Emoji.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import { Session, DiscordEmoji, Snowflake } from "../mod.ts";
|
||||
|
||||
export class Emoji {
|
||||
constructor(session: Session, data: DiscordEmoji) {
|
||||
this.id = data.id;
|
||||
this.name = data.name;
|
||||
this.animated = !!data.animated;
|
||||
this.available = !!data.available;
|
||||
this.requireColons = !!data.require_colons;
|
||||
this.session = session;
|
||||
}
|
||||
readonly id?: Snowflake;
|
||||
readonly session: Session;
|
||||
name?: string;
|
||||
animated: boolean;
|
||||
available: boolean;
|
||||
requireColons: boolean;
|
||||
}
|
@ -39,7 +39,7 @@ export class Guild extends BaseGuild implements Model {
|
||||
this.defaultMessageNotificationLevel = data.default_message_notifications;
|
||||
this.explicitContentFilterLevel = data.explicit_content_filter;
|
||||
this.members = data.members?.map((member) => new Member(session, { ...member, user: member.user! })) ?? [];
|
||||
this.roles = data.roles.map((role) => new Role(session, this, role));
|
||||
this.roles = data.roles.map((role) => new Role(session, this.id, role));
|
||||
}
|
||||
|
||||
splashHash?: bigint;
|
||||
@ -78,7 +78,7 @@ export class Guild extends BaseGuild implements Model {
|
||||
},
|
||||
);
|
||||
|
||||
return new Role(this.session, this, role);
|
||||
return new Role(this.session, this.id, role);
|
||||
}
|
||||
|
||||
async deleteRole(roleId: Snowflake): Promise<void> {
|
||||
|
@ -2,7 +2,7 @@ import { Channel } from "./Channel.ts";
|
||||
import { Guild } from "./Guild.ts";
|
||||
import { DiscordChannel, Routes, Session, Snowflake } from "../mod.ts";
|
||||
|
||||
export class GuildChannel extends Channel {
|
||||
export abstract class GuildChannel extends Channel {
|
||||
constructor(session: Session, data: DiscordChannel, guildId: Guild["id"]) {
|
||||
super(session, data);
|
||||
this.guildId = guildId;
|
||||
|
15
structures/GuildEmoji.ts
Normal file
15
structures/GuildEmoji.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import { Snowflake, Session, Emoji, DiscordEmoji, User } from "../mod.ts";
|
||||
|
||||
export class GuildEmoji extends Emoji {
|
||||
constructor(session: Session, data: DiscordEmoji, guildId: Snowflake) {
|
||||
super(session, data);
|
||||
this.guildId = guildId;
|
||||
this.roles = data.roles;
|
||||
this.user = data.user ? new User(this.session, data.user) : undefined;
|
||||
this.managed = !!data.managed;
|
||||
}
|
||||
guildId: Snowflake;
|
||||
roles?: Snowflake[];
|
||||
user?: User;
|
||||
managed?: boolean;
|
||||
}
|
@ -1,15 +1,14 @@
|
||||
import type { Model } from "./Base.ts";
|
||||
import type { Session } from "../session/Session.ts";
|
||||
import type { DiscordRole } from "../vendor/external.ts";
|
||||
import { Snowflake } from "../util/Snowflake.ts";
|
||||
import { Snowflake, Routes } from "../mod.ts";
|
||||
import { iconHashToBigInt } from "../util/hash.ts";
|
||||
import { Guild } from "./Guild.ts";
|
||||
|
||||
export class Role implements Model {
|
||||
constructor(session: Session, guild: Guild, data: DiscordRole) {
|
||||
constructor(session: Session, guildId: Snowflake, data: DiscordRole) {
|
||||
this.session = session;
|
||||
this.id = data.id;
|
||||
this.guild = guild;
|
||||
this.guildId = guildId;
|
||||
this.hoist = data.hoist;
|
||||
this.iconHash = data.icon ? iconHashToBigInt(data.icon) : undefined;
|
||||
this.color = data.color;
|
||||
@ -21,7 +20,7 @@ export class Role implements Model {
|
||||
|
||||
session: Session;
|
||||
id: Snowflake;
|
||||
guild: Guild;
|
||||
guildId: Snowflake;
|
||||
hoist: boolean;
|
||||
iconHash?: bigint;
|
||||
color: number;
|
||||
@ -43,12 +42,12 @@ export class Role implements Model {
|
||||
}
|
||||
|
||||
async delete() {
|
||||
await this.guild.deleteRole(this.id);
|
||||
await this.session.rest.runMethod<undefined>(this.session.rest, "DELETE", Routes.GUILD_ROLE(this.guildId, this.id));
|
||||
}
|
||||
|
||||
toString() {
|
||||
switch (this.id) {
|
||||
case this.guild.id:
|
||||
case this.guildId:
|
||||
return "@everyone";
|
||||
default:
|
||||
return `<@&${this.id}>`;
|
||||
|
@ -7,7 +7,7 @@ import { GetMessagesOptions } from "../util/Routes.ts";
|
||||
|
||||
/**
|
||||
* Represents the options object to create an invitation
|
||||
* https://discord.com/developers/docs/resources/channel#create-channel-invite-json-params
|
||||
* @link https://discord.com/developers/docs/resources/channel#create-channel-invite-json-params
|
||||
*/
|
||||
|
||||
export interface DiscordInviteOptions {
|
||||
@ -20,7 +20,7 @@ export interface DiscordInviteOptions {
|
||||
|
||||
/**
|
||||
* Represent the options object to create a Thread Channel
|
||||
* https://discord.com/developers/docs/resources/channel#start-thread-without-message
|
||||
* @link https://discord.com/developers/docs/resources/channel#start-thread-without-message
|
||||
*/
|
||||
|
||||
export interface ThreadCreateOptions {
|
||||
|
@ -3,8 +3,8 @@ import { Guild } from "./Guild.ts";
|
||||
import { DiscordChannel, Session, Snowflake, VideoQualityModes } from "../mod.ts";
|
||||
|
||||
export class VoiceChannel extends GuildChannel {
|
||||
constructor(session: Session, data: DiscordChannel, guild: Guild) {
|
||||
super(session, data, guild);
|
||||
constructor(session: Session, data: DiscordChannel, guildId: Guild["id"]) {
|
||||
super(session, data, guildId);
|
||||
this.bitRate = data.bitrate;
|
||||
this.userLimit = data.user_limit ?? 0;
|
||||
data.rtc_region ? this.rtcRegion = data.rtc_region : undefined;
|
||||
|
Loading…
x
Reference in New Issue
Block a user