noot
All checks were successful
commit-tag / commit-tag-image (map[context:./migrations file:./migrations/Dockerfile name:migrations]) (push) Successful in 18s
commit-tag / commit-tag-image (map[context:./ts file:./ts/Dockerfile name:ts]) (push) Successful in 50s

This commit is contained in:
a 2025-03-02 21:56:43 -06:00
parent 31d0f75eef
commit 59921dd2cb
No known key found for this signature in database
GPG Key ID: 2F22877AA4DFDADB
3 changed files with 59 additions and 4 deletions

View File

@ -12,8 +12,9 @@ export async function update_wynn_items() {
}
const parsed = WApiV3ItemDatabase(ans.data)
if(parsed instanceof ArkErrors){
console.log(parsed[0].problem)
console.log(parsed[0].path)
console.log(parsed[0].data)
throw parsed
}
// iterate over all items with their names
for(const [name, item] of Object.entries(parsed)){
}
}

View File

@ -0,0 +1,54 @@
import { Bot } from "#/bot";
import {c} from "#/di"
import { InteractionResponse, InteractionResponseTypes, InteractionCallbackOptions, InteractionCallbackData, InteractionTypes, MessageFlags } from "discordeno";
interface InteractionRef {
id: string
token: string
type: InteractionTypes
acknowledged?: boolean
}
// from https://github.com/discordeno/discordeno/blob/21.0.0/packages/bot/src/transformers/interaction.ts#L33
export const reply_to_interaction = async (props: {
ref: InteractionRef
response: InteractionCallbackData | string
options?: InteractionCallbackOptions & {isPrivate?: boolean}
}) => {
const bot = await c.getAsync(Bot);
const {
ref,
response,
options,
} = props;
let data: InteractionCallbackData
let type: InteractionResponseTypes = InteractionResponseTypes.ChannelMessageWithSource
if (typeof response === 'string') {
data = {content: response}
} else {
data = response
if(data.title) {
type = InteractionResponseTypes.Modal
}
}
if(ref.type === InteractionTypes.ApplicationCommandAutocomplete) {
type = InteractionResponseTypes.ApplicationCommandAutocompleteResult
}
if (type === InteractionResponseTypes.ChannelMessageWithSource && options?.isPrivate) {
data.flags = MessageFlags.Ephemeral
}
if(ref.acknowledged) {
return await bot.helpers.sendFollowupMessage(ref.token,data)
}
if(ref.type === InteractionTypes.ModalSubmit && type === InteractionResponseTypes.Modal) {
throw new Error('Cannot send a modal response to a modal')
}
return await bot.helpers.sendInteractionResponse(ref.id, ref.token,
{ type, data }, { withResponse: options?.withResponse })
}