Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

seyfert

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

seyfert - npm Package Compare versions

Comparing version 1.2.0 to 1.2.1

60

lib/client/httpclient.js

@@ -115,37 +115,39 @@ "use strict";

await (0, oninteractioncreate_1.onInteractionCreate)(this, rawBody, -1, async ({ body, files }) => {
let response;
const headers = {};
if (files) {
response = new FormData();
for (const [index, file] of files.entries()) {
const fileKey = file.key ?? `files[${index}]`;
if ((0, utils_1.isBufferLike)(file.data)) {
let contentType = file.contentType;
if (!contentType) {
const [parsedType] = (0, magic_bytes_js_1.filetypeinfo)(file.data);
if (parsedType) {
contentType =
api_1.OverwrittenMimeTypes[parsedType.mime] ??
parsedType.mime ??
'application/octet-stream';
res.cork(() => {
let response;
const headers = {};
if (files) {
response = new FormData();
for (const [index, file] of files.entries()) {
const fileKey = file.key ?? `files[${index}]`;
if ((0, utils_1.isBufferLike)(file.data)) {
let contentType = file.contentType;
if (!contentType) {
const [parsedType] = (0, magic_bytes_js_1.filetypeinfo)(file.data);
if (parsedType) {
contentType =
api_1.OverwrittenMimeTypes[parsedType.mime] ??
parsedType.mime ??
'application/octet-stream';
}
}
response.append(fileKey, new Blob([file.data], { type: contentType }), file.name);
}
response.append(fileKey, new Blob([file.data], { type: contentType }), file.name);
else {
response.append(fileKey, new Blob([`${file.data}`], { type: file.contentType }), file.name);
}
}
else {
response.append(fileKey, new Blob([`${file.data}`], { type: file.contentType }), file.name);
if (body) {
response.append('payload_json', JSON.stringify(body));
}
}
if (body) {
response.append('payload_json', JSON.stringify(body));
else {
response = body ?? {};
headers['Content-Type'] = 'application/json';
}
}
else {
response = body ?? {};
headers['Content-Type'] = 'application/json';
}
for (const i in headers) {
res.writeHeader(i, headers[i]);
}
return res.end(JSON.stringify(response));
for (const i in headers) {
res.writeHeader(i, headers[i]);
}
return res.end(JSON.stringify(response));
});
});

@@ -152,0 +154,0 @@ break;

import type { ContextMenuCommand, ReturnCache, WebhookMessage } from '../..';
import { type InteractionCreateBodyRequest, type InteractionMessageUpdateBodyRequest, type UnionToTuple, type When } from '../../common';
import { type InteractionCreateBodyRequest, type InteractionMessageUpdateBodyRequest, type UnionToTuple, type When, type ModalCreateBodyRequest } from '../../common';
import { Message, User, type AllChannels, type Guild, type GuildMember, type MessageCommandInteraction, type UserCommandInteraction } from '../../structures';

@@ -24,3 +24,3 @@ import { BaseContext } from '../basecontex';

write<FR extends boolean = false>(body: InteractionCreateBodyRequest, fetchReply?: FR): Promise<When<FR, WebhookMessage, void | WebhookMessage>>;
get modal(): ((body: import("../../common").ModalCreateBodyRequest) => Promise<void>) | ((body: import("../../common").ModalCreateBodyRequest) => Promise<void>);
modal(body: ModalCreateBodyRequest): Promise<void>;
deferReply(ephemeral?: boolean): Promise<void>;

@@ -27,0 +27,0 @@ editResponse(body: InteractionMessageUpdateBodyRequest): Promise<Message>;

@@ -44,4 +44,4 @@ "use strict";

}
get modal() {
return this.interaction.modal;
modal(body) {
return this.interaction.modal(body);
}

@@ -48,0 +48,0 @@ deferReply(ephemeral = false) {

import type { AllChannels, ButtonInteraction, ChannelSelectMenuInteraction, ComponentInteraction, Guild, GuildMember, MentionableSelectMenuInteraction, Message, ReturnCache, RoleSelectMenuInteraction, StringSelectMenuInteraction, UserSelectMenuInteraction, WebhookMessage } from '..';
import type { ExtendContext, UsingClient } from '../commands';
import { BaseContext } from '../commands/basecontex';
import type { InteractionCreateBodyRequest, InteractionMessageUpdateBodyRequest, When } from '../common';
import type { ComponentInteractionMessageUpdate, InteractionCreateBodyRequest, InteractionMessageUpdateBodyRequest, When } from '../common';
export interface ComponentContext<Type extends keyof ComponentCommandInteractionMap> extends BaseContext, ExtendContext {
}
/**
* Represents a context for interacting with components in a Discord bot.
* @template Type - The type of component interaction.
*/
export declare class ComponentContext<Type extends keyof ComponentCommandInteractionMap> extends BaseContext {
readonly client: UsingClient;
interaction: ComponentCommandInteractionMap[Type] | ComponentInteraction;
/**
* Creates a new instance of the ComponentContext class.
* @param client - The UsingClient instance.
* @param interaction - The component interaction object.
*/
constructor(client: UsingClient, interaction: ComponentCommandInteractionMap[Type] | ComponentInteraction);
/**
* Gets the proxy object.
*/
get proxy(): import("..").APIRoutes;
/**
* Gets the language object for the interaction's locale.
*/
get t(): import("..").__InternalParseLocale<import("..").DefaultLocale> & {
get(locale?: string | undefined): import("..").DefaultLocale;
};
/**
* Gets the custom ID of the interaction.
*/
get customId(): string;
get write(): <FR extends boolean = false>(body: Omit<import("discord-api-types/v10").APIInteractionResponseCallbackData, "components" | "embeds"> & import("../common").ResolverProps, fetchReply?: FR | undefined) => Promise<When<FR, WebhookMessage, void>>;
/**
* Writes a response to the interaction.
* @param body - The body of the response.
* @param fetchReply - Whether to fetch the reply or not.
*/
write<FR extends boolean = false>(body: InteractionCreateBodyRequest, fetchReply?: FR): Promise<When<FR, WebhookMessage, void>>;
/**
* Defers the reply to the interaction.
* @param ephemeral - Whether the reply should be ephemeral or not.
*/
deferReply(ephemeral?: boolean): Promise<void>;
get editResponse(): ((body: Omit<import("discord-api-types/v10").RESTPatchAPIWebhookWithTokenMessageJSONBody, "components" | "embeds"> & import("../common").ResolverProps) => Promise<Message>) | ((body: Omit<import("discord-api-types/v10").RESTPatchAPIWebhookWithTokenMessageJSONBody, "components" | "embeds"> & import("../common").ResolverProps) => Promise<Message>) | ((body: Omit<import("discord-api-types/v10").RESTPatchAPIWebhookWithTokenMessageJSONBody, "components" | "embeds"> & import("../common").ResolverProps) => Promise<Message>) | ((body: Omit<import("discord-api-types/v10").RESTPatchAPIWebhookWithTokenMessageJSONBody, "components" | "embeds"> & import("../common").ResolverProps) => Promise<Message>) | ((body: Omit<import("discord-api-types/v10").RESTPatchAPIWebhookWithTokenMessageJSONBody, "components" | "embeds"> & import("../common").ResolverProps) => Promise<Message>) | ((body: Omit<import("discord-api-types/v10").RESTPatchAPIWebhookWithTokenMessageJSONBody, "components" | "embeds"> & import("../common").ResolverProps) => Promise<Message>) | ((body: Omit<import("discord-api-types/v10").RESTPatchAPIWebhookWithTokenMessageJSONBody, "components" | "embeds"> & import("../common").ResolverProps) => Promise<Message>);
get update(): ((data: Omit<import("discord-api-types/v10").APIInteractionResponseCallbackData, "components" | "embeds"> & import("../common").ResolverProps) => Promise<void>) | ((data: Omit<import("discord-api-types/v10").APIInteractionResponseCallbackData, "components" | "embeds"> & import("../common").ResolverProps) => Promise<void>) | ((data: Omit<import("discord-api-types/v10").APIInteractionResponseCallbackData, "components" | "embeds"> & import("../common").ResolverProps) => Promise<void>) | ((data: Omit<import("discord-api-types/v10").APIInteractionResponseCallbackData, "components" | "embeds"> & import("../common").ResolverProps) => Promise<void>) | ((data: Omit<import("discord-api-types/v10").APIInteractionResponseCallbackData, "components" | "embeds"> & import("../common").ResolverProps) => Promise<void>) | ((data: Omit<import("discord-api-types/v10").APIInteractionResponseCallbackData, "components" | "embeds"> & import("../common").ResolverProps) => Promise<void>) | ((data: Omit<import("discord-api-types/v10").APIInteractionResponseCallbackData, "components" | "embeds"> & import("../common").ResolverProps) => Promise<void>);
/**
* Edits the response of the interaction.
* @param body - The updated body of the response.
*/
editResponse(body: InteractionMessageUpdateBodyRequest): Promise<Message>;
/**
* Updates the interaction with new data.
* @param body - The updated body of the interaction.
*/
update(body: ComponentInteractionMessageUpdate): Promise<void>;
/**
* Edits the response or replies to the interaction.
* @param body - The body of the response or updated body of the interaction.
* @param fetchReply - Whether to fetch the reply or not.
*/
editOrReply<FR extends boolean = false>(body: InteractionCreateBodyRequest | InteractionMessageUpdateBodyRequest, fetchReply?: FR): Promise<When<FR, WebhookMessage | Message, void | WebhookMessage | Message>>;
/**
* Deletes the response of the interaction.
* @returns A promise that resolves when the response is deleted.
*/
deleteResponse(): Promise<void | undefined>;
/**
* Gets the channel of the interaction.
* @param mode - The mode to fetch the channel.
* @returns A promise that resolves to the channel.
*/
channel(mode?: 'rest' | 'flow'): Promise<AllChannels>;
channel(mode?: 'cache'): ReturnCache<AllChannels>;
/**
* Gets the bot member in the guild of the interaction.
* @param mode - The mode to fetch the member.
* @returns A promise that resolves to the bot member.
*/
me(mode?: 'rest' | 'flow'): Promise<GuildMember>;
me(mode?: 'cache'): ReturnCache<GuildMember | undefined>;
/**
* Gets the guild of the interaction.
* @param mode - The mode to fetch the guild.
* @returns A promise that resolves to the guild.
*/
guild(mode?: 'rest' | 'flow'): Promise<Guild<'cached' | 'api'> | undefined>;
guild(mode?: 'cache'): ReturnCache<Guild<'cached'> | undefined>;
/**
* Gets the ID of the guild of the interaction.
*/
get guildId(): string | undefined;
/**
* Gets the ID of the channel of the interaction.
*/
get channelId(): string;
/**
* Gets the author of the interaction.
*/
get author(): import("..").User;
/**
* Gets the member of the interaction.
*/
get member(): import("..").InteractionGuildMember | undefined;

@@ -32,0 +103,0 @@ }

@@ -6,5 +6,14 @@ "use strict";

const basecontex_1 = require("../commands/basecontex");
/**
* Represents a context for interacting with components in a Discord bot.
* @template Type - The type of component interaction.
*/
class ComponentContext extends basecontex_1.BaseContext {
client;
interaction;
/**
* Creates a new instance of the ComponentContext class.
* @param client - The UsingClient instance.
* @param interaction - The component interaction object.
*/
constructor(client, interaction) {

@@ -15,26 +24,61 @@ super(client);

}
/**
* Gets the proxy object.
*/
get proxy() {
return this.client.proxy;
}
/**
* Gets the language object for the interaction's locale.
*/
get t() {
return this.client.langs.get(this.interaction?.locale ?? this.client.langs?.defaultLang ?? 'en-US');
}
/**
* Gets the custom ID of the interaction.
*/
get customId() {
return this.interaction.customId;
}
get write() {
return this.interaction.write;
/**
* Writes a response to the interaction.
* @param body - The body of the response.
* @param fetchReply - Whether to fetch the reply or not.
*/
write(body, fetchReply) {
return this.interaction.write(body, fetchReply);
}
/**
* Defers the reply to the interaction.
* @param ephemeral - Whether the reply should be ephemeral or not.
*/
deferReply(ephemeral = false) {
return this.interaction.deferReply(ephemeral ? v10_1.MessageFlags.Ephemeral : undefined);
}
get editResponse() {
return this.interaction.editResponse;
/**
* Edits the response of the interaction.
* @param body - The updated body of the response.
*/
editResponse(body) {
return this.interaction.editResponse(body);
}
get update() {
return this.interaction.update;
/**
* Updates the interaction with new data.
* @param body - The updated body of the interaction.
*/
update(body) {
return this.interaction.update(body);
}
/**
* Edits the response or replies to the interaction.
* @param body - The body of the response or updated body of the interaction.
* @param fetchReply - Whether to fetch the reply or not.
*/
editOrReply(body, fetchReply) {
return this.interaction.editOrReply(body, fetchReply);
}
/**
* Deletes the response of the interaction.
* @returns A promise that resolves when the response is deleted.
*/
deleteResponse() {

@@ -68,11 +112,23 @@ return this.interaction.deleteResponse();

}
/**
* Gets the ID of the guild of the interaction.
*/
get guildId() {
return this.interaction.guildId;
}
/**
* Gets the ID of the channel of the interaction.
*/
get channelId() {
return this.interaction.channelId;
}
/**
* Gets the author of the interaction.
*/
get author() {
return this.interaction.user;
}
/**
* Gets the member of the interaction.
*/
get member() {

@@ -79,0 +135,0 @@ return this.interaction.member;

@@ -13,2 +13,3 @@ import { type APIMessageActionRowComponent } from 'discord-api-types/v10';

export * from './command';
export * from './componentcontext';
/**

@@ -15,0 +16,0 @@ * Return a new component instance based on the component type.

@@ -27,2 +27,3 @@ "use strict";

__exportStar(require("./command"), exports);
__exportStar(require("./componentcontext"), exports);
/**

@@ -29,0 +30,0 @@ * Return a new component instance based on the component type.

@@ -29,3 +29,4 @@ "use strict";

if (!this.avatar) {
return this.rest.cdn.defaultAvatar(Number(this.discriminator));
const avatarIndex = this.discriminator === '0' ? Number(BigInt(this.id) >> 22n) % 6 : Number.parseInt(this.discriminator) % 5;
return this.rest.cdn.defaultAvatar(avatarIndex);
}

@@ -32,0 +33,0 @@ return this.rest.cdn.avatar(this.id, this.avatar, options);

{
"name": "seyfert",
"version": "1.2.0",
"version": "1.2.1",
"description": "The most advanced framework for discord bots",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc