mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-01 12:36:08 +00:00
feat: soundboard shorter
This commit is contained in:
parent
7e55ba9e3c
commit
2c9d199c7d
@ -48,6 +48,7 @@ import type {
|
||||
RESTPostAPIChannelWebhookResult,
|
||||
RESTPostAPIGuildForumThreadsJSONBody,
|
||||
RESTPostAPIPollExpireResult,
|
||||
RESTPostAPISendSoundboardSound,
|
||||
RESTPutAPIChannelMessageReactionResult,
|
||||
RESTPutAPIChannelPermissionJSONBody,
|
||||
RESTPutAPIChannelPermissionResult,
|
||||
@ -199,6 +200,9 @@ export interface ChannelRoutes {
|
||||
post(args?: RestArgumentsNoBody): Promise<RESTPostAPIPollExpireResult>;
|
||||
};
|
||||
};
|
||||
'send-soundboard-sound': {
|
||||
post(args: RestArguments<RESTPostAPISendSoundboardSound>): Promise<never>;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -43,6 +43,7 @@ import type {
|
||||
RESTGetAPIGuildScheduledEventUsersResult,
|
||||
RESTGetAPIGuildScheduledEventsQuery,
|
||||
RESTGetAPIGuildScheduledEventsResult,
|
||||
RESTGetAPIGuildSoundboardSoundsResult,
|
||||
RESTGetAPIGuildStickerResult,
|
||||
RESTGetAPIGuildStickersResult,
|
||||
RESTGetAPIGuildTemplatesResult,
|
||||
@ -74,6 +75,8 @@ import type {
|
||||
RESTPatchAPIGuildRoleResult,
|
||||
RESTPatchAPIGuildScheduledEventJSONBody,
|
||||
RESTPatchAPIGuildScheduledEventResult,
|
||||
RESTPatchAPIGuildSoundboardSound,
|
||||
RESTPatchAPIGuildSoundboardSoundResult,
|
||||
RESTPatchAPIGuildStickerJSONBody,
|
||||
RESTPatchAPIGuildStickerResult,
|
||||
RESTPatchAPIGuildTemplateJSONBody,
|
||||
@ -100,6 +103,8 @@ import type {
|
||||
RESTPostAPIGuildRoleResult,
|
||||
RESTPostAPIGuildScheduledEventJSONBody,
|
||||
RESTPostAPIGuildScheduledEventResult,
|
||||
RESTPostAPIGuildSoundboardSound,
|
||||
RESTPostAPIGuildSoundboardSoundResult,
|
||||
RESTPostAPIGuildStickerFormDataBody,
|
||||
RESTPostAPIGuildStickerResult,
|
||||
RESTPostAPIGuildTemplatesJSONBody,
|
||||
@ -346,6 +351,19 @@ export interface GuildRoutes {
|
||||
delete(args?: RestArgumentsNoBody): Promise<RESTDeleteAPIGuildTemplateResult>;
|
||||
};
|
||||
};
|
||||
'soundboard-sounds': {
|
||||
get(args?: RestArgumentsNoBody): Promise<RESTGetAPIGuildSoundboardSoundsResult>;
|
||||
post(args: RestArguments<RESTPostAPIGuildSoundboardSound>): Promise<RESTPostAPIGuildSoundboardSoundResult>;
|
||||
(
|
||||
id: string,
|
||||
): {
|
||||
get(args?: RestArgumentsNoBody): Promise<RESTPostAPIGuildSoundboardSoundResult>;
|
||||
patch(
|
||||
args?: RestArguments<RESTPatchAPIGuildSoundboardSound>,
|
||||
): Promise<RESTPatchAPIGuildSoundboardSoundResult>;
|
||||
delete(args?: RestArgumentsNoBody): Promise<never>;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
@ -4,12 +4,12 @@ import type { GatewayRoutes } from './gateway';
|
||||
import type { GuildRoutes } from './guilds';
|
||||
import type { InteractionRoutes } from './interactions';
|
||||
import type { InviteRoutes } from './invites';
|
||||
import type { SoundboardRoutes } from './soundboard';
|
||||
import type { StageInstanceRoutes } from './stage-instances';
|
||||
import type { StickerRoutes } from './stickers';
|
||||
import type { UserRoutes } from './users';
|
||||
import type { VoiceRoutes } from './voice';
|
||||
import type { WebhookRoutes } from './webhooks';
|
||||
export type { SoundboardRoutes } from './soundboard';
|
||||
|
||||
export * from './cdn';
|
||||
|
||||
@ -24,4 +24,5 @@ export interface APIRoutes
|
||||
StickerRoutes,
|
||||
UserRoutes,
|
||||
VoiceRoutes,
|
||||
WebhookRoutes {}
|
||||
WebhookRoutes,
|
||||
SoundboardRoutes {}
|
||||
|
@ -1,36 +1,8 @@
|
||||
import type {
|
||||
RESTGetAPIDefaultsSoundboardSoundsResult,
|
||||
RESTGetAPIGuildSoundboardSoundsResult,
|
||||
RESTPatchAPIGuildSoundboardSound,
|
||||
RESTPatchAPIGuildSoundboardSoundResult,
|
||||
RESTPostAPIGuildSoundboardSound,
|
||||
RESTPostAPIGuildSoundboardSoundResult,
|
||||
RESTPostAPISendSoundboardSound,
|
||||
} from '../../types';
|
||||
import type { RestArguments, RestArgumentsNoBody } from '../api';
|
||||
import type { RESTGetAPIDefaultsSoundboardSoundsResult } from '../../types';
|
||||
import type { RestArgumentsNoBody } from '../api';
|
||||
|
||||
export interface SoundboardRoutes {
|
||||
channels(id: string): {
|
||||
'send-soundboard-sound': {
|
||||
post(args: RestArguments<RESTPostAPISendSoundboardSound>): Promise<never>;
|
||||
};
|
||||
};
|
||||
'soundboard-default-sounds': {
|
||||
get(args?: RestArgumentsNoBody): Promise<RESTGetAPIDefaultsSoundboardSoundsResult>;
|
||||
};
|
||||
guilds(id: string): {
|
||||
get(args?: RestArgumentsNoBody): Promise<RESTGetAPIGuildSoundboardSoundsResult>;
|
||||
'soundboard-sounds': {
|
||||
post(
|
||||
args: RestArguments<RESTPostAPIGuildSoundboardSound>,
|
||||
): Promise<RESTPostAPIGuildSoundboardSoundResult | undefined>;
|
||||
(
|
||||
id: string,
|
||||
): {
|
||||
get(args?: RestArgumentsNoBody): Promise<RESTPostAPIGuildSoundboardSoundResult>;
|
||||
patch(args?: RestArguments<RESTPatchAPIGuildSoundboardSound>): Promise<RESTPatchAPIGuildSoundboardSoundResult>;
|
||||
delete(args?: RestArgumentsNoBody): Promise<never>;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
@ -43,6 +43,7 @@ import { promises } from 'node:fs';
|
||||
import { isBufferLike } from '../api/utils/utils';
|
||||
import { HandleCommand } from '../commands/handle';
|
||||
import { BanShorter } from '../common/shorters/bans';
|
||||
import { SoundboardShorter } from '../common/shorters/soundboard';
|
||||
import { VoiceStateShorter } from '../common/shorters/voiceStates';
|
||||
import type { Awaitable, DeepPartial, IntentStrings, OmitInsert, PermissionStrings, When } from '../common/types/util';
|
||||
import type { ComponentCommand, ComponentContext, ModalCommand, ModalContext } from '../components';
|
||||
@ -78,6 +79,7 @@ export class BaseClient {
|
||||
bans = new BanShorter(this);
|
||||
interactions = new InteractionShorter(this);
|
||||
voiceStates = new VoiceStateShorter(this);
|
||||
soundboards = new SoundboardShorter(this);
|
||||
|
||||
debugger?: Logger;
|
||||
|
||||
|
42
src/common/shorters/soundboard.ts
Normal file
42
src/common/shorters/soundboard.ts
Normal file
@ -0,0 +1,42 @@
|
||||
import type {
|
||||
RESTPatchAPIGuildSoundboardSound,
|
||||
RESTPostAPIGuildSoundboardSound,
|
||||
RESTPostAPISendSoundboardSound,
|
||||
} from '../../types';
|
||||
import { BaseShorter } from './base';
|
||||
|
||||
export class SoundboardShorter extends BaseShorter {
|
||||
getDefaults() {
|
||||
return this.client.proxy['soundboard-default-sounds'].get();
|
||||
}
|
||||
|
||||
send(channelId: string, body: RESTPostAPISendSoundboardSound) {
|
||||
return this.client.proxy.channels(channelId)['send-soundboard-sound'].post({
|
||||
body,
|
||||
});
|
||||
}
|
||||
|
||||
list(guildId: string) {
|
||||
return this.client.proxy.guilds(guildId)['soundboard-sounds'].get();
|
||||
}
|
||||
|
||||
get(guildId: string, soundID: string) {
|
||||
return this.client.proxy.guilds(guildId)['soundboard-sounds'](soundID).get();
|
||||
}
|
||||
|
||||
create(guildId: string, body: RESTPostAPIGuildSoundboardSound) {
|
||||
return this.client.proxy.guilds(guildId)['soundboard-sounds'].post({
|
||||
body,
|
||||
});
|
||||
}
|
||||
|
||||
edit(guildId: string, soundID: string, body: RESTPatchAPIGuildSoundboardSound) {
|
||||
return this.client.proxy.guilds(guildId)['soundboard-sounds'](soundID).patch({
|
||||
body,
|
||||
});
|
||||
}
|
||||
|
||||
delete(guildId: string, soundID: string, reason?: string) {
|
||||
return this.client.proxy.guilds(guildId)['soundboard-sounds'](soundID).delete({ reason });
|
||||
}
|
||||
}
|
@ -215,7 +215,7 @@ export class EventHandler extends BaseHandler {
|
||||
t: name,
|
||||
d: packet,
|
||||
} as GatewayDispatchPayload);
|
||||
await Event.run(hook, client, shardId);
|
||||
await (Event.run as any)(hook, client, shardId);
|
||||
} catch (e) {
|
||||
await this.onFail(name, e);
|
||||
}
|
||||
@ -236,8 +236,7 @@ export class EventHandler extends BaseHandler {
|
||||
this.logger.debug(`executed a custom event [${name}]`, Event.data.once ? 'once' : '');
|
||||
|
||||
await Promise.all([
|
||||
// @ts-expect-error
|
||||
Event.run(...args, this.client),
|
||||
(Event.run as any)(...args, this.client),
|
||||
// @ts-expect-error
|
||||
this.client.collectors.run(name, args, this.client),
|
||||
]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user