mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-02 21:16:09 +00:00
fix: fmt
This commit is contained in:
parent
c1c358a411
commit
22b27c0874
@ -16,6 +16,8 @@ import type {
|
||||
DiscordIntegration,
|
||||
DiscordIntegrationDelete,
|
||||
DiscordInteraction,
|
||||
DiscordInviteCreate,
|
||||
DiscordInviteDelete,
|
||||
DiscordMemberWithUser,
|
||||
DiscordMessage,
|
||||
DiscordMessageDelete,
|
||||
@ -25,15 +27,15 @@ import type {
|
||||
DiscordMessageReactionRemoveEmoji,
|
||||
DiscordReady,
|
||||
DiscordRole,
|
||||
DiscordScheduledEvent,
|
||||
DiscordScheduledEventUserAdd,
|
||||
DiscordScheduledEventUserRemove,
|
||||
// DiscordThreadMemberUpdate,
|
||||
// DiscordThreadMembersUpdate,
|
||||
DiscordThreadListSync,
|
||||
DiscordTypingStart,
|
||||
DiscordUser,
|
||||
DiscordWebhookUpdate,
|
||||
DiscordInviteCreate,
|
||||
DiscordInviteDelete,
|
||||
DiscordScheduledEvent
|
||||
} from "../discordeno/mod.ts";
|
||||
|
||||
import type { Snowflake } from "./Snowflake.ts";
|
||||
@ -43,7 +45,7 @@ import type { Interaction } from "./structures/interactions/InteractionFactory.t
|
||||
import { AutoModerationRule } from "./structures/AutoModerationRule.ts";
|
||||
import { AutoModerationExecution } from "./structures/AutoModerationExecution.ts";
|
||||
import { type Channel, ChannelFactory, GuildChannel, ThreadChannel } from "./structures/channels.ts";
|
||||
import { StageInstance, type DiscordStageInstance } from "./structures/StageInstance.ts";
|
||||
import { type DiscordStageInstance, StageInstance } from "./structures/StageInstance.ts";
|
||||
import { ScheduledEvent } from "./structures/GuildScheduledEvent.ts";
|
||||
|
||||
import ThreadMember from "./structures/ThreadMember.ts";
|
||||
@ -53,7 +55,7 @@ import User from "./structures/User.ts";
|
||||
import Integration from "./structures/Integration.ts";
|
||||
import Guild from "./structures/guilds/Guild.ts";
|
||||
import InteractionFactory from "./structures/interactions/InteractionFactory.ts";
|
||||
import { NewInviteCreate, InviteCreate } from "./structures/Invite.ts";
|
||||
import { InviteCreate, NewInviteCreate } from "./structures/Invite.ts";
|
||||
|
||||
export type RawHandler<T> = (...args: [Session, number, T]) => void;
|
||||
export type Handler<T extends unknown[]> = (...args: T) => unknown;
|
||||
@ -282,35 +284,59 @@ export const MESSAGE_REACTION_REMOVE_EMOJI: RawHandler<DiscordMessageReactionRem
|
||||
|
||||
export const INVITE_CREATE: RawHandler<DiscordInviteCreate> = (session, _shardId, invite) => {
|
||||
session.emit("inviteCreate", NewInviteCreate(session, invite));
|
||||
}
|
||||
};
|
||||
|
||||
export const INVITE_DELETE: RawHandler<DiscordInviteDelete> = (session, _shardId, data) => {
|
||||
session.emit("inviteDelete", { channelId: data.channel_id, guildId: data.guild_id, code: data.code });
|
||||
}
|
||||
};
|
||||
|
||||
export const STAGE_INSTANCE_CREATE: RawHandler<DiscordStageInstance> = (session, _shardId, payload) => {
|
||||
export const STAGE_INSTANCE_CREATE: RawHandler<DiscordStageInstance> = (session, _shardId, payload) => {
|
||||
session.emit("stageInstanceCreate", new StageInstance(session, payload));
|
||||
};
|
||||
|
||||
export const STAGE_INSTANCE_UPDATE: RawHandler<DiscordStageInstance> = (session, _shardId, payload) => {
|
||||
export const STAGE_INSTANCE_UPDATE: RawHandler<DiscordStageInstance> = (session, _shardId, payload) => {
|
||||
session.emit("stageInstanceUpdate", new StageInstance(session, payload));
|
||||
};
|
||||
|
||||
export const STAGE_INSTANCE_DELETE: RawHandler<DiscordStageInstance> = (session, _shardId, payload) => {
|
||||
export const STAGE_INSTANCE_DELETE: RawHandler<DiscordStageInstance> = (session, _shardId, payload) => {
|
||||
session.emit("stageInstanceDelete", new StageInstance(session, payload));
|
||||
};
|
||||
|
||||
export const GUILD_SCHEDULED_EVENT_CREATE: RawHandler<DiscordScheduledEvent> = (session, _shardId, payload) => {
|
||||
session.emit("guildScheduledEventCreate", new ScheduledEvent(session, payload))
|
||||
}
|
||||
session.emit("guildScheduledEventCreate", new ScheduledEvent(session, payload));
|
||||
};
|
||||
|
||||
export const GUILD_SCHEDULED_EVENT_UPDATE: RawHandler<DiscordScheduledEvent> = (session, _shardId, payload) => {
|
||||
session.emit("guildScheduledEventUpdate", new ScheduledEvent(session, payload))
|
||||
}
|
||||
session.emit("guildScheduledEventUpdate", new ScheduledEvent(session, payload));
|
||||
};
|
||||
|
||||
export const GUILD_SCHEDULED_EVENT_DELETE: RawHandler<DiscordScheduledEvent> = (session, _shardId, payload) => {
|
||||
session.emit("guildScheduledEventDelete", new ScheduledEvent(session, payload))
|
||||
}
|
||||
session.emit("guildScheduledEventDelete", new ScheduledEvent(session, payload));
|
||||
};
|
||||
|
||||
export const GUILD_SCHEDULED_EVENT_USER_ADD: RawHandler<DiscordScheduledEventUserAdd> = (
|
||||
session,
|
||||
_shardId,
|
||||
payload,
|
||||
) => {
|
||||
session.emit("guildScheduledEventUserAdd", {
|
||||
scheduledEventId: payload.guild_scheduled_event_id,
|
||||
userId: payload.user_id,
|
||||
guildId: payload.guild_id,
|
||||
});
|
||||
};
|
||||
|
||||
export const GUILD_SCHEDULED_EVENT_USER_REMOVE: RawHandler<DiscordScheduledEventUserRemove> = (
|
||||
session,
|
||||
_shardId,
|
||||
payload,
|
||||
) => {
|
||||
session.emit("guildScheduledEventUserRemove", {
|
||||
scheduledEventId: payload.guild_scheduled_event_id,
|
||||
userId: payload.user_id,
|
||||
guildId: payload.guild_id,
|
||||
});
|
||||
};
|
||||
|
||||
export const raw: RawHandler<unknown> = (session, shardId, data) => {
|
||||
session.emit("raw", data, shardId);
|
||||
@ -369,6 +395,8 @@ export interface Events {
|
||||
"guildScheduledEventCreate": Handler<[ScheduledEvent]>;
|
||||
"guildScheduledEventUpdate": Handler<[ScheduledEvent]>;
|
||||
"guildScheduledEventDelete": Handler<[ScheduledEvent]>;
|
||||
"guildScheduledEventUserAdd": Handler<[{scheduledEventId: Snowflake, userId: Snowflake, guildId: Snowflake}]>
|
||||
"guildScheduledEventUserRemove": Handler<[{scheduledEventId: Snowflake, userId: Snowflake, guildId: Snowflake}]>
|
||||
"raw": Handler<[unknown, number]>;
|
||||
"webhooksUpdate": Handler<[{ guildId: Snowflake, channelId: Snowflake }]>;
|
||||
"userUpdate": Handler<[User]>;
|
||||
|
@ -1,107 +1,106 @@
|
||||
import { Model } from "./Base.ts";
|
||||
import type { Snowflake } from "../Snowflake.ts";
|
||||
import type { Session } from "../Session.ts";
|
||||
import {
|
||||
DiscordApplication,
|
||||
TeamMembershipStates,
|
||||
DiscordInstallParams,
|
||||
DiscordUser,
|
||||
DiscordTeam
|
||||
} from "../../discordeno/mod.ts";
|
||||
import User from "./User.ts";
|
||||
|
||||
type SummaryDeprecated = ""
|
||||
|
||||
export interface Team {
|
||||
/** a hash of the image of the team's icon */
|
||||
icon?: string;
|
||||
/** the unique id of the team */
|
||||
id: string;
|
||||
/** the members of the team */
|
||||
members: TeamMember[];
|
||||
/** user id of the current team owner */
|
||||
ownerUserId: string;
|
||||
/** team name */
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface TeamMember {
|
||||
/** the user's membership state on the team */
|
||||
membershipState: TeamMembershipStates;
|
||||
permissions: "*"[];
|
||||
|
||||
teamId: string;
|
||||
|
||||
user: Partial<User> & Pick<User, "avatarHash" | "discriminator" | "id" | "username">
|
||||
}
|
||||
|
||||
// NewTeam create a new Team object for discord applications
|
||||
export function NewTeam(session: Session, data: DiscordTeam): Team {
|
||||
return {
|
||||
icon: data.icon ? data.icon : undefined,
|
||||
id: data.id,
|
||||
members: data.members.map(member => {
|
||||
return {
|
||||
membershipState: member.membership_state,
|
||||
permissions: member.permissions,
|
||||
teamId: member.team_id,
|
||||
user: new User(session, member.user)
|
||||
}
|
||||
}),
|
||||
ownerUserId: data.owner_user_id,
|
||||
name: data.name,
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @link https://discord.com/developers/docs/resources/application#application-object
|
||||
*/
|
||||
export class Application implements Model {
|
||||
|
||||
constructor(session: Session, data: DiscordApplication) {
|
||||
this.id = data.id;
|
||||
this.session = session;
|
||||
|
||||
this.name = data.name;
|
||||
this.icon = data.icon || undefined;
|
||||
this.description = data.description;
|
||||
this.rpcOrigins = data.rpc_origins;
|
||||
this.botPublic = data.bot_public;
|
||||
this.botRequireCodeGrant = data.bot_require_code_grant;
|
||||
this.termsOfServiceURL = data.terms_of_service_url;
|
||||
this.privacyPolicyURL = data.privacy_policy_url;
|
||||
this.owner = data.owner ? new User(session, data.owner as DiscordUser) : undefined;
|
||||
this.summary = "";
|
||||
this.verifyKey = data.verify_key;
|
||||
this.team = data.team ? NewTeam(session, data.team) : undefined;
|
||||
this.guildId = data.guild_id;
|
||||
this.coverImage = data.cover_image;
|
||||
this.tags = data.tags;
|
||||
this.installParams = data.install_params;
|
||||
this.customInstallURL = data.custom_install_url;
|
||||
}
|
||||
|
||||
readonly session: Session;
|
||||
id: Snowflake;
|
||||
name: string;
|
||||
icon?: string;
|
||||
description: string;
|
||||
rpcOrigins?: string[];
|
||||
botPublic: boolean;
|
||||
botRequireCodeGrant: boolean;
|
||||
termsOfServiceURL?: string;
|
||||
privacyPolicyURL?: string;
|
||||
owner?: Partial<User>;
|
||||
summary: SummaryDeprecated;
|
||||
verifyKey: string;
|
||||
team?: Team;
|
||||
guildId?: Snowflake;
|
||||
primarySkuId?: Snowflake;
|
||||
slug?: string;
|
||||
coverImage?: string;
|
||||
flags?: number;
|
||||
tags?: string[];
|
||||
installParams?: DiscordInstallParams;
|
||||
customInstallURL?: string;
|
||||
}
|
||||
|
||||
export default Application;
|
||||
import { Model } from "./Base.ts";
|
||||
import type { Snowflake } from "../Snowflake.ts";
|
||||
import type { Session } from "../Session.ts";
|
||||
import {
|
||||
DiscordApplication,
|
||||
DiscordInstallParams,
|
||||
DiscordTeam,
|
||||
DiscordUser,
|
||||
TeamMembershipStates,
|
||||
} from "../../discordeno/mod.ts";
|
||||
import User from "./User.ts";
|
||||
|
||||
type SummaryDeprecated = "";
|
||||
|
||||
export interface Team {
|
||||
/** a hash of the image of the team's icon */
|
||||
icon?: string;
|
||||
/** the unique id of the team */
|
||||
id: string;
|
||||
/** the members of the team */
|
||||
members: TeamMember[];
|
||||
/** user id of the current team owner */
|
||||
ownerUserId: string;
|
||||
/** team name */
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface TeamMember {
|
||||
/** the user's membership state on the team */
|
||||
membershipState: TeamMembershipStates;
|
||||
permissions: "*"[];
|
||||
|
||||
teamId: string;
|
||||
|
||||
user: Partial<User> & Pick<User, "avatarHash" | "discriminator" | "id" | "username">;
|
||||
}
|
||||
|
||||
// NewTeam create a new Team object for discord applications
|
||||
export function NewTeam(session: Session, data: DiscordTeam): Team {
|
||||
return {
|
||||
icon: data.icon ? data.icon : undefined,
|
||||
id: data.id,
|
||||
members: data.members.map((member) => {
|
||||
return {
|
||||
membershipState: member.membership_state,
|
||||
permissions: member.permissions,
|
||||
teamId: member.team_id,
|
||||
user: new User(session, member.user),
|
||||
};
|
||||
}),
|
||||
ownerUserId: data.owner_user_id,
|
||||
name: data.name,
|
||||
};
|
||||
}
|
||||
/**
|
||||
* @link https://discord.com/developers/docs/resources/application#application-object
|
||||
*/
|
||||
export class Application implements Model {
|
||||
constructor(session: Session, data: DiscordApplication) {
|
||||
this.id = data.id;
|
||||
this.session = session;
|
||||
|
||||
this.name = data.name;
|
||||
this.icon = data.icon || undefined;
|
||||
this.description = data.description;
|
||||
this.rpcOrigins = data.rpc_origins;
|
||||
this.botPublic = data.bot_public;
|
||||
this.botRequireCodeGrant = data.bot_require_code_grant;
|
||||
this.termsOfServiceURL = data.terms_of_service_url;
|
||||
this.privacyPolicyURL = data.privacy_policy_url;
|
||||
this.owner = data.owner ? new User(session, data.owner as DiscordUser) : undefined;
|
||||
this.summary = "";
|
||||
this.verifyKey = data.verify_key;
|
||||
this.team = data.team ? NewTeam(session, data.team) : undefined;
|
||||
this.guildId = data.guild_id;
|
||||
this.coverImage = data.cover_image;
|
||||
this.tags = data.tags;
|
||||
this.installParams = data.install_params;
|
||||
this.customInstallURL = data.custom_install_url;
|
||||
}
|
||||
|
||||
readonly session: Session;
|
||||
id: Snowflake;
|
||||
name: string;
|
||||
icon?: string;
|
||||
description: string;
|
||||
rpcOrigins?: string[];
|
||||
botPublic: boolean;
|
||||
botRequireCodeGrant: boolean;
|
||||
termsOfServiceURL?: string;
|
||||
privacyPolicyURL?: string;
|
||||
owner?: Partial<User>;
|
||||
summary: SummaryDeprecated;
|
||||
verifyKey: string;
|
||||
team?: Team;
|
||||
guildId?: Snowflake;
|
||||
primarySkuId?: Snowflake;
|
||||
slug?: string;
|
||||
coverImage?: string;
|
||||
flags?: number;
|
||||
tags?: string[];
|
||||
installParams?: DiscordInstallParams;
|
||||
customInstallURL?: string;
|
||||
}
|
||||
|
||||
export default Application;
|
||||
|
@ -4,9 +4,9 @@ import type { Session } from "../Session.ts";
|
||||
import { PrivacyLevels } from "./StageInstance.ts";
|
||||
import type {
|
||||
DiscordScheduledEvent,
|
||||
ScheduledEventStatus,
|
||||
DiscordScheduledEventEntityMetadata,
|
||||
ScheduledEventEntityType,
|
||||
DiscordScheduledEventEntityMetadata
|
||||
ScheduledEventStatus,
|
||||
} from "../../discordeno/mod.ts";
|
||||
import User from "./User.ts";
|
||||
|
||||
@ -45,5 +45,4 @@ export class ScheduledEvent implements Model {
|
||||
creator?: User;
|
||||
userCount?: number;
|
||||
image?: string;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,15 @@
|
||||
import type { Session } from "../Session.ts";
|
||||
import type { Snowflake } from "../Snowflake.ts";
|
||||
import type {
|
||||
DiscordApplication,
|
||||
DiscordChannel,
|
||||
DiscordInvite,
|
||||
DiscordInviteCreate,
|
||||
DiscordMemberWithUser,
|
||||
DiscordScheduledEventEntityMetadata,
|
||||
ScheduledEventEntityType,
|
||||
ScheduledEventPrivacyLevel,
|
||||
ScheduledEventStatus,
|
||||
DiscordApplication,
|
||||
DiscordInviteCreate
|
||||
} from "../../discordeno/mod.ts";
|
||||
import { TargetTypes } from "../../discordeno/mod.ts";
|
||||
import { GuildChannel } from "./channels.ts";
|
||||
@ -75,10 +75,12 @@ export function NewInviteCreate(session: Session, invite: DiscordInviteCreate):
|
||||
maxUses: invite.max_uses,
|
||||
targetType: invite.target_type,
|
||||
targetUser: invite.target_user ? new User(session, invite.target_user) : undefined,
|
||||
targetApplication: invite.target_application ? new Application(session, invite.target_application as DiscordApplication) : undefined,
|
||||
targetApplication: invite.target_application
|
||||
? new Application(session, invite.target_application as DiscordApplication)
|
||||
: undefined,
|
||||
temporary: invite.temporary,
|
||||
uses: invite.uses
|
||||
}
|
||||
uses: invite.uses,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
@ -95,9 +97,11 @@ export class Invite {
|
||||
this.expiresAt = data.expires_at ? Number.parseInt(data.expires_at) : undefined;
|
||||
this.inviter = data.inviter ? new User(session, data.inviter) : undefined;
|
||||
this.targetUser = data.target_user ? new User(session, data.target_user) : undefined;
|
||||
this.targetApplication = data.target_application ? new Application(session, data.target_application as DiscordApplication) : undefined;
|
||||
this.targetApplication = data.target_application
|
||||
? new Application(session, data.target_application as DiscordApplication)
|
||||
: undefined;
|
||||
this.targetType = data.target_type;
|
||||
|
||||
|
||||
if (data.channel) {
|
||||
const guildId = (data.guild && data.guild?.id) ? data.guild.id : "";
|
||||
this.channel = new GuildChannel(session, data.channel as DiscordChannel, guildId);
|
||||
@ -157,7 +161,7 @@ export class Invite {
|
||||
channel?: Partial<GuildChannel>;
|
||||
stageInstance?: InviteStageInstance;
|
||||
guildScheduledEvent?: InviteScheduledEvent;
|
||||
targetApplication?: Partial<Application>
|
||||
targetApplication?: Partial<Application>;
|
||||
|
||||
async delete(): Promise<Invite> {
|
||||
await Guild.prototype.deleteInvite.call(this.guild, this.code);
|
||||
|
Loading…
x
Reference in New Issue
Block a user