Rewrite getRouteDescriptions, fix message route not appearing in openapi spec
This commit is contained in:
@@ -482,3 +482,27 @@ export enum ChannelPermissionOverwriteType {
|
||||
member = 1,
|
||||
group = 2,
|
||||
}
|
||||
|
||||
export function isTextChannel(type: ChannelType): boolean {
|
||||
switch (type) {
|
||||
case ChannelType.GUILD_STORE:
|
||||
case ChannelType.GUILD_VOICE:
|
||||
case ChannelType.GUILD_STAGE_VOICE:
|
||||
case ChannelType.GUILD_CATEGORY:
|
||||
case ChannelType.GUILD_FORUM:
|
||||
case ChannelType.DIRECTORY:
|
||||
throw new HTTPError("not a text channel", 400);
|
||||
case ChannelType.DM:
|
||||
case ChannelType.GROUP_DM:
|
||||
case ChannelType.GUILD_NEWS:
|
||||
case ChannelType.GUILD_NEWS_THREAD:
|
||||
case ChannelType.GUILD_PUBLIC_THREAD:
|
||||
case ChannelType.GUILD_PRIVATE_THREAD:
|
||||
case ChannelType.GUILD_TEXT:
|
||||
case ChannelType.ENCRYPTED:
|
||||
case ChannelType.ENCRYPTED_THREAD:
|
||||
return true;
|
||||
default:
|
||||
throw new HTTPError("unimplemented", 400);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import { HTTPError } from "lambert-server";
|
||||
import { Config } from "./Config";
|
||||
import { TenorGif } from "..";
|
||||
|
||||
export function parseGifResult(result: TenorGif) {
|
||||
return {
|
||||
id: result.id,
|
||||
title: result.title,
|
||||
url: result.itemurl,
|
||||
src: result.media[0].mp4.url,
|
||||
gif_src: result.media[0].gif.url,
|
||||
width: result.media[0].mp4.dims[0],
|
||||
height: result.media[0].mp4.dims[1],
|
||||
preview: result.media[0].mp4.preview,
|
||||
};
|
||||
}
|
||||
|
||||
export function getGifApiKey() {
|
||||
const { enabled, provider, apiKey } = Config.get().gif;
|
||||
if (!enabled) throw new HTTPError(`Gifs are disabled`);
|
||||
if (provider !== "tenor" || !apiKey)
|
||||
throw new HTTPError(`${provider} gif provider not supported`);
|
||||
|
||||
return apiKey;
|
||||
}
|
||||
@@ -41,3 +41,4 @@ export * from "./String";
|
||||
export * from "./Token";
|
||||
export * from "./TraverseDirectory";
|
||||
export * from "./WebAuthn";
|
||||
export * from "./Gifs";
|
||||
|
||||
Reference in New Issue
Block a user