diff --git a/packages/bot/bot.ts b/packages/bot/bot.ts index fd681dd..e96f86c 100644 --- a/packages/bot/bot.ts +++ b/packages/bot/bot.ts @@ -1,5 +1,6 @@ import { APIApplicationCommandInteraction, APIInteractionResponse, APIMessageComponentInteraction, APIPingInteraction, InteractionResponseType, InteractionType, MessageFlags, RouteBases, Routes } from 'discord-api-types/v9'; import { isJSON } from './utils/isJson'; +import { resolvePartialEmoji } from './utils/resolveEmoji'; import { verify } from './utils/verify'; const respond = (response: APIInteractionResponse) => new Response(JSON.stringify(response), {headers: {'content-type': 'application/json'}}); @@ -42,11 +43,11 @@ export const handleRequest = async(request: Request): Promise => { if (!json) return badFormatting(); const channelId = json.channel; - const message = json.message?.toString(); + let message = json.message?.toString(); let roles = json.roles; if (!channelId) return badFormatting(); - if (!message) return badFormatting(); + if (!message) message = '​'; if (!roles || Object.values(json.roles).filter((role: any) => role.id && role.label).length === 0 || roles.length === 0 || roles.length > 25) return badFormatting(roles.length > 25); roles = roles.map((r: any) => { @@ -88,13 +89,13 @@ export const handleRequest = async(request: Request): Promise => { content: message, components: finalComponents }) - }).catch(() => {}); + }).catch(e => e); return respond({ type: InteractionResponseType.ChannelMessageWithSource, data: { flags: 64, - content: fetched?.ok ? 'Done!' : 'Error, invalid channelId or duplication button ids.' + content: fetched?.ok ? 'Done!' : 'Error, bad channel id/missing permissions.' } }); } else if (interaction.type === InteractionType.MessageComponent) { diff --git a/packages/bot/utils/resolveEmoji.ts b/packages/bot/utils/resolveEmoji.ts index 0eac725..35f8179 100644 --- a/packages/bot/utils/resolveEmoji.ts +++ b/packages/bot/utils/resolveEmoji.ts @@ -2,18 +2,18 @@ * https://github.com/discordjs/discord.js/blob/3c0bbac82fa9988af4a62ff00c66d149fbe6b921/packages/discord.js/src/util/Util.js#L292-L311 */ -const resolvePartialEmoji = (emoji: string) => { - if (!emoji) return null; - if (typeof emoji === 'string') return /^\d{17,19}$/.test(emoji) ? { id: emoji } : parseEmoji(emoji); - const { id, name, animated } = emoji; - if (!id && !name) return null; - return { id, name, animated: Boolean(animated) }; -} +export const resolvePartialEmoji = (emoji: string) => { + if (!emoji) return null; + if (typeof emoji === 'string') return /^\d{17,19}$/.test(emoji) ? { id: emoji } : parseEmoji(emoji); + const { id, name, animated } = emoji; + if (!id && !name) return null; + return { id, name, animated: Boolean(animated) }; +}; -const parseEmoji = (text: string) => { - if (text.includes('%')) text = decodeURIComponent(text); - if (!text.includes(':')) return { animated: false, name: text, id: null }; +export const parseEmoji = (text: string) => { + if (text.includes('%')) text = decodeURIComponent(text); + if (!text.includes(':')) return { animated: false, name: text, id: null }; - const match = text.match(/?/); - return match && { animated: Boolean(match[1]), name: match[2], id: match[3] ?? null }; -} \ No newline at end of file + const match = text.match(/?/); + return match && { animated: Boolean(match[1]), name: match[2], id: match[3] ?? null }; +}; \ No newline at end of file diff --git a/packages/website/pages/index.tsx b/packages/website/pages/index.tsx index ad993e2..b344216 100644 --- a/packages/website/pages/index.tsx +++ b/packages/website/pages/index.tsx @@ -18,7 +18,7 @@ export default function Home() {

Generate


- +