mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-03 21:46:08 +00:00
88 lines
2.1 KiB
TypeScript
88 lines
2.1 KiB
TypeScript
import type { Model } from './base';
|
|
import type { Snowflake } from '../snowflakes';
|
|
import type { Session } from '../biscuit';
|
|
import type {
|
|
DiscordIntegration,
|
|
IntegrationExpireBehaviors,
|
|
} from '@biscuitland/api-types';
|
|
import { User } from './user';
|
|
|
|
export type IntegrationTypes = 'twitch' | 'youtube' | 'discord';
|
|
|
|
export interface IntegrationAccount {
|
|
id: Snowflake;
|
|
name: string;
|
|
}
|
|
|
|
export interface IntegrationApplication {
|
|
id: Snowflake;
|
|
name: string;
|
|
icon?: string;
|
|
description: string;
|
|
bot?: User;
|
|
}
|
|
|
|
export class Integration implements Model {
|
|
constructor(
|
|
session: Session,
|
|
data: DiscordIntegration & { guild_id?: Snowflake }
|
|
) {
|
|
this.id = data.id;
|
|
this.session = session;
|
|
|
|
data.guild_id ? (this.guildId = data.guild_id) : null;
|
|
|
|
this.name = data.name;
|
|
this.type = data.type;
|
|
this.enabled = !!data.enabled;
|
|
this.syncing = !!data.syncing;
|
|
this.roleId = data.role_id;
|
|
this.enableEmoticons = !!data.enable_emoticons;
|
|
this.expireBehavior = data.expire_behavior;
|
|
this.expireGracePeriod = data.expire_grace_period;
|
|
this.syncedAt = data.synced_at;
|
|
this.subscriberCount = data.subscriber_count;
|
|
this.revoked = !!data.revoked;
|
|
|
|
this.user = data.user ? new User(session, data.user) : undefined;
|
|
this.account = {
|
|
id: data.account.id,
|
|
name: data.account.name,
|
|
};
|
|
|
|
if (data.application) {
|
|
this.application = {
|
|
id: data.application.id,
|
|
name: data.application.name,
|
|
icon: data.application.icon ? data.application.icon : undefined,
|
|
description: data.application.description,
|
|
bot: data.application.bot
|
|
? new User(session, data.application.bot)
|
|
: undefined,
|
|
};
|
|
}
|
|
}
|
|
|
|
readonly session: Session;
|
|
id: Snowflake;
|
|
guildId?: Snowflake;
|
|
|
|
name: string;
|
|
type: IntegrationTypes;
|
|
enabled?: boolean;
|
|
syncing?: boolean;
|
|
roleId?: string;
|
|
enableEmoticons?: boolean;
|
|
expireBehavior?: IntegrationExpireBehaviors;
|
|
expireGracePeriod?: number;
|
|
syncedAt?: string;
|
|
subscriberCount?: number;
|
|
revoked?: boolean;
|
|
|
|
user?: User;
|
|
account: IntegrationAccount;
|
|
application?: IntegrationApplication;
|
|
}
|
|
|
|
export default Integration;
|