noot
This commit is contained in:
parent
31d0f75eef
commit
59921dd2cb
@ -12,8 +12,9 @@ export async function update_wynn_items() {
|
|||||||
}
|
}
|
||||||
const parsed = WApiV3ItemDatabase(ans.data)
|
const parsed = WApiV3ItemDatabase(ans.data)
|
||||||
if(parsed instanceof ArkErrors){
|
if(parsed instanceof ArkErrors){
|
||||||
console.log(parsed[0].problem)
|
throw parsed
|
||||||
console.log(parsed[0].path)
|
}
|
||||||
console.log(parsed[0].data)
|
// iterate over all items with their names
|
||||||
|
for(const [name, item] of Object.entries(parsed)){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
54
ts/src/activities/discord.ts
Normal file
54
ts/src/activities/discord.ts
Normal 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 })
|
||||||
|
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
import {Bot, BotType} from "#/bot"
|
import { Bot, BotType } from "#/bot"
|
||||||
import { ActivityTypes, ApplicationCommandOptionTypes, InteractionTypes } from "discordeno"
|
import { ActivityTypes, ApplicationCommandOptionTypes, InteractionTypes } from "discordeno"
|
||||||
import { InteractionType, MuxHandler, SlashHandler } from "./types"
|
import { InteractionType, MuxHandler, SlashHandler } from "./types"
|
||||||
import { uuid4 } from "@temporalio/workflow"
|
import { uuid4 } from "@temporalio/workflow"
|
||||||
|
Loading…
Reference in New Issue
Block a user