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