mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-01 20:46:08 +00:00
Formatting
This commit is contained in:
parent
b178357553
commit
f547099b5b
@ -70,8 +70,9 @@ session.start();
|
||||
- Avoid sharing state between classes
|
||||
|
||||
### Compatibility (bun)
|
||||
|
||||
**⚠️ DISCLAIMER:** since bun is unestable I highly recommend running biscuit on node!
|
||||
|
||||
- We got the library running on EndeavourOS but it spams the ready event multiple times
|
||||
- We got the library running on Arch/Artix Linux but breaks when sending fetch requests
|
||||
- We got the library running on WSL (Ubuntu) without any trouble
|
||||
|
||||
|
@ -58,7 +58,13 @@ import Integration from "./structures/Integration.ts";
|
||||
import Guild from "./structures/guilds/Guild.ts";
|
||||
import InteractionFactory from "./structures/interactions/InteractionFactory.ts";
|
||||
import { InviteCreate, NewInviteCreate } from "./structures/Invite.ts";
|
||||
import { MessageReactionAdd, MessageReactionRemove, MessageReactionRemoveAll, MessageReactionRemoveEmoji, NewMessageReactionAdd } from "./structures/MessageReaction.ts";
|
||||
import {
|
||||
MessageReactionAdd,
|
||||
MessageReactionRemove,
|
||||
MessageReactionRemoveAll,
|
||||
MessageReactionRemoveEmoji,
|
||||
NewMessageReactionAdd,
|
||||
} from "./structures/MessageReaction.ts";
|
||||
|
||||
export type RawHandler<T> = (...args: [Session, number, T]) => void;
|
||||
export type Handler<T extends unknown[]> = (...args: T) => unknown;
|
||||
|
@ -348,8 +348,11 @@ export function GUILD_APPLICATION_COMMANDS_PERMISSIONS(appId: Snowflake, guildId
|
||||
return `/applications/${appId}/guilds/${guildId}/commands/permissions`;
|
||||
}
|
||||
|
||||
|
||||
export function APPLICATION_COMMANDS_LOCALIZATIONS(appId: Snowflake, commandId: Snowflake, withLocalizations?: boolean) {
|
||||
export function APPLICATION_COMMANDS_LOCALIZATIONS(
|
||||
appId: Snowflake,
|
||||
commandId: Snowflake,
|
||||
withLocalizations?: boolean,
|
||||
) {
|
||||
let url = `/applications/${appId}/commands/${commandId}?`;
|
||||
|
||||
if (withLocalizations !== undefined) {
|
||||
@ -359,7 +362,12 @@ export function APPLICATION_COMMANDS_LOCALIZATIONS(appId: Snowflake, commandId:
|
||||
return url;
|
||||
}
|
||||
|
||||
export function GUILD_APPLICATION_COMMANDS_LOCALIZATIONS(appId: Snowflake, guildId: Snowflake, commandId: Snowflake, withLocalizations?: boolean) {
|
||||
export function GUILD_APPLICATION_COMMANDS_LOCALIZATIONS(
|
||||
appId: Snowflake,
|
||||
guildId: Snowflake,
|
||||
commandId: Snowflake,
|
||||
withLocalizations?: boolean,
|
||||
) {
|
||||
let url = `/applications/${appId}/guilds/${guildId}/commands/${commandId}?`;
|
||||
|
||||
if (withLocalizations !== undefined) {
|
||||
|
@ -1,13 +1,13 @@
|
||||
import type {
|
||||
ApplicationCommandPermissionTypes,
|
||||
AtLeastOne,
|
||||
Localization,
|
||||
DiscordApplicationCommand,
|
||||
DiscordApplicationCommandOption,
|
||||
DiscordGuildApplicationCommandPermissions,
|
||||
DiscordGetGatewayBot,
|
||||
DiscordGuildApplicationCommandPermissions,
|
||||
GatewayBot,
|
||||
GatewayIntents,
|
||||
Localization,
|
||||
} from "../discordeno/mod.ts";
|
||||
|
||||
import type { DiscordGatewayPayload, Shard } from "../discordeno/mod.ts";
|
||||
@ -17,7 +17,12 @@ import type { PermissionResolvable } from "./structures/Permissions.ts";
|
||||
import { Permissions } from "./structures/Permissions.ts";
|
||||
import { Snowflake } from "./Snowflake.ts";
|
||||
import { EventEmitter } from "./util/EventEmmiter.ts";
|
||||
import { ApplicationCommandTypes, createGatewayManager, createRestManager, getBotIdFromToken } from "../discordeno/mod.ts";
|
||||
import {
|
||||
ApplicationCommandTypes,
|
||||
createGatewayManager,
|
||||
createRestManager,
|
||||
getBotIdFromToken,
|
||||
} from "../discordeno/mod.ts";
|
||||
|
||||
import * as Routes from "./Routes.ts";
|
||||
import * as Actions from "./Actions.ts";
|
||||
@ -28,28 +33,28 @@ export type DiscordRawEventHandler = (shard: Shard, data: DiscordGatewayPayload)
|
||||
|
||||
/**
|
||||
* @link https://discord.com/developers/docs/interactions/application-commands#endpoints-json-params
|
||||
* */
|
||||
*/
|
||||
export interface CreateApplicationCommand {
|
||||
name: string;
|
||||
nameLocalizations?: Localization;
|
||||
description: string;
|
||||
descriptionLocalizations?: Localization;
|
||||
type?: ApplicationCommandTypes;
|
||||
options?: DiscordApplicationCommandOption[];
|
||||
defaultMemberPermissions?: PermissionResolvable;
|
||||
dmPermission?: boolean;
|
||||
name: string;
|
||||
nameLocalizations?: Localization;
|
||||
description: string;
|
||||
descriptionLocalizations?: Localization;
|
||||
type?: ApplicationCommandTypes;
|
||||
options?: DiscordApplicationCommandOption[];
|
||||
defaultMemberPermissions?: PermissionResolvable;
|
||||
dmPermission?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* @link https://discord.com/developers/docs/interactions/application-commands#endpoints-json-params
|
||||
* */
|
||||
*/
|
||||
export interface CreateContextApplicationCommand extends Omit<CreateApplicationCommand, "options"> {
|
||||
type: ApplicationCommandTypes.Message | ApplicationCommandTypes.User;
|
||||
type: ApplicationCommandTypes.Message | ApplicationCommandTypes.User;
|
||||
}
|
||||
|
||||
/**
|
||||
* @link https://discord.com/developers/docs/interactions/application-commands#endpoints-query-string-params
|
||||
* */
|
||||
*/
|
||||
export interface GetApplicationCommand {
|
||||
guildId?: Snowflake;
|
||||
withLocalizations?: boolean;
|
||||
@ -61,7 +66,7 @@ export interface UpsertApplicationCommands extends CreateApplicationCommand {
|
||||
|
||||
/**
|
||||
* @link https://discord.com/developers/docs/interactions/application-commands#edit-application-command-permissions
|
||||
* */
|
||||
*/
|
||||
export interface ApplicationCommandPermissions {
|
||||
id: Snowflake;
|
||||
type: ApplicationCommandPermissionTypes;
|
||||
@ -70,11 +75,11 @@ export interface ApplicationCommandPermissions {
|
||||
|
||||
/**
|
||||
* @link https://discord.com/developers/docs/interactions/application-commands#edit-application-command-permissions
|
||||
* */
|
||||
*/
|
||||
export interface ApplicationCommandPermissions {
|
||||
id: Snowflake;
|
||||
type: ApplicationCommandPermissionTypes;
|
||||
permission: boolean;
|
||||
id: Snowflake;
|
||||
type: ApplicationCommandPermissionTypes;
|
||||
permission: boolean;
|
||||
}
|
||||
|
||||
// END INTERACTIONS
|
||||
@ -189,22 +194,24 @@ export class Session extends EventEmitter {
|
||||
guildId
|
||||
? Routes.GUILD_APPLICATION_COMMANDS(this.applicationId, guildId)
|
||||
: Routes.APPLICATION_COMMANDS(this.applicationId),
|
||||
this.isContextApplicationCommand(options) ? {
|
||||
name: options.name,
|
||||
name_localizations: options.nameLocalizations,
|
||||
type: options.type,
|
||||
} : {
|
||||
name: options.name,
|
||||
name_localizations: options.nameLocalizations,
|
||||
description: options.description,
|
||||
description_localizations: options.descriptionLocalizations,
|
||||
type: options.type,
|
||||
options: options.options,
|
||||
default_member_permissions: options.defaultMemberPermissions
|
||||
? new Permissions(options.defaultMemberPermissions).bitfield.toString()
|
||||
: undefined,
|
||||
dm_permission: options.dmPermission,
|
||||
},
|
||||
this.isContextApplicationCommand(options)
|
||||
? {
|
||||
name: options.name,
|
||||
name_localizations: options.nameLocalizations,
|
||||
type: options.type,
|
||||
}
|
||||
: {
|
||||
name: options.name,
|
||||
name_localizations: options.nameLocalizations,
|
||||
description: options.description,
|
||||
description_localizations: options.descriptionLocalizations,
|
||||
type: options.type,
|
||||
options: options.options,
|
||||
default_member_permissions: options.defaultMemberPermissions
|
||||
? new Permissions(options.defaultMemberPermissions).bitfield.toString()
|
||||
: undefined,
|
||||
dm_permission: options.dmPermission,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@ -232,8 +239,8 @@ export class Session extends EventEmitter {
|
||||
permissions: options,
|
||||
},
|
||||
{
|
||||
headers: { authorization: `Bearer ${bearerToken}` }
|
||||
}
|
||||
headers: { authorization: `Bearer ${bearerToken}` },
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@ -279,10 +286,12 @@ export class Session extends EventEmitter {
|
||||
guildId
|
||||
? Routes.GUILD_APPLICATION_COMMANDS(this.applicationId, guildId)
|
||||
: Routes.APPLICATION_COMMANDS(this.applicationId, id),
|
||||
this.isContextApplicationCommand(options) ? {
|
||||
this.isContextApplicationCommand(options)
|
||||
? {
|
||||
name: options.name,
|
||||
type: options.type,
|
||||
} : {
|
||||
}
|
||||
: {
|
||||
name: options.name,
|
||||
description: options.description,
|
||||
type: options.type,
|
||||
@ -291,22 +300,28 @@ export class Session extends EventEmitter {
|
||||
);
|
||||
}
|
||||
|
||||
upsertApplicationCommands(options: Array<UpsertApplicationCommands | CreateContextApplicationCommand>, guildId?: Snowflake) {
|
||||
upsertApplicationCommands(
|
||||
options: Array<UpsertApplicationCommands | CreateContextApplicationCommand>,
|
||||
guildId?: Snowflake,
|
||||
) {
|
||||
return this.rest.runMethod<DiscordApplicationCommand[]>(
|
||||
this.rest,
|
||||
"PUT",
|
||||
guildId
|
||||
? Routes.GUILD_APPLICATION_COMMANDS(this.applicationId, guildId)
|
||||
: Routes.APPLICATION_COMMANDS(this.applicationId),
|
||||
options.map((o) => this.isContextApplicationCommand(o) ? {
|
||||
name: o.name,
|
||||
type: o.type,
|
||||
} : {
|
||||
name: o.name,
|
||||
description: o.description,
|
||||
type: o.type,
|
||||
options: o.options,
|
||||
}
|
||||
options.map((o) =>
|
||||
this.isContextApplicationCommand(o)
|
||||
? {
|
||||
name: o.name,
|
||||
type: o.type,
|
||||
}
|
||||
: {
|
||||
name: o.name,
|
||||
description: o.description,
|
||||
type: o.type,
|
||||
options: o.options,
|
||||
}
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ export type ComponentBuilder =
|
||||
| SelectMenuBuilder
|
||||
| ButtonBuilder;
|
||||
|
||||
/***
|
||||
/** *
|
||||
* Utility type
|
||||
*/
|
||||
export type ComponentEmoji = {
|
||||
|
@ -7,7 +7,7 @@ import * as Routes from "../Routes.ts";
|
||||
/**
|
||||
* A member that comes from a thread
|
||||
* @link https://discord.com/developers/docs/resources/channel#thread-member-object
|
||||
* **/
|
||||
* * */
|
||||
export class ThreadMember implements Model {
|
||||
constructor(session: Session, data: DiscordThreadMember) {
|
||||
this.session = session;
|
||||
|
@ -499,13 +499,13 @@ export class Guild extends BaseGuild implements Model {
|
||||
};
|
||||
}
|
||||
|
||||
/***
|
||||
/** *
|
||||
* Makes the bot leave the guild
|
||||
*/
|
||||
async leave() {
|
||||
}
|
||||
|
||||
/***
|
||||
/** *
|
||||
* Deletes a guild
|
||||
*/
|
||||
async delete() {
|
||||
@ -579,9 +579,8 @@ export class Guild extends BaseGuild implements Model {
|
||||
splash: "splashURL" in options
|
||||
? options.splashURL || urlToBase64(options.splashURL!)
|
||||
: options.splashHash || Util.iconBigintToHash(options.iconHash!),
|
||||
banner: "bannerURL" in options
|
||||
? options.bannerURL || urlToBase64(options.bannerURL!)
|
||||
: options.bannerHash || Util.iconBigintToHash(options.bannerHash!),
|
||||
banner: "bannerURL" in options ? options.bannerURL || urlToBase64(options.bannerURL!)
|
||||
: options.bannerHash || Util.iconBigintToHash(options.bannerHash!),
|
||||
discovery_splash: "discoverySplashURL" in options
|
||||
? options.discoverySplashURL || urlToBase64(options.discoverySplashURL!)
|
||||
: options.discoverySplashHash || Util.iconBigintToHash(options.discoverySplashHash!),
|
||||
|
@ -2,7 +2,7 @@ import type { Model } from "../Base.ts";
|
||||
import type { Snowflake } from "../../Snowflake.ts";
|
||||
import type { Session } from "../../Session.ts";
|
||||
import type { DiscordInteraction, InteractionTypes } from "../../../discordeno/mod.ts";
|
||||
import type { InteractionResponse, InteractionApplicationCommandCallbackData } from "./CommandInteraction.ts";
|
||||
import type { InteractionApplicationCommandCallbackData, InteractionResponse } from "./CommandInteraction.ts";
|
||||
import { MessageComponentTypes } from "../../../discordeno/mod.ts";
|
||||
import CommandInteraction from "./CommandInteraction.ts";
|
||||
import BaseInteraction from "./BaseInteraction.ts";
|
||||
|
Loading…
x
Reference in New Issue
Block a user