无法与Discord API发送附件或嵌入

发布于 2025-02-12 16:31:59 字数 1647 浏览 0 评论 0原文

我需要有关Discord API中附件的错误的帮助。

它正在响应slash命令的应用程序commandType,但它仅通过内容成功,但没有用内容,而是使用嵌入式和附件。 (我什至不知道如何找到有关此错误的更多信息。)

我不知道有什么问题,并感谢您的帮助。

我正在使用为Deno编辑的DeNo环境,并使用DeNo的DeNo环境。不使用Discord.js。

import {
  APIApplicationCommandInteraction,
  APIInteractionResponse,
  InteractionResponseType,
  APIAttachment,
  APIEmbed
} from "../lib/discord-api-types/payloads/index.ts";

import { Snowflake } from "../lib/discord-api-types/globals.ts";

import { DiscordSnowflake as sf } from "../lib/snowflake/DiscordSnowflake.ts";

export const onApplicationCommand = (
  interaction: APIApplicationCommandInteraction
) => {
  let res: APIInteractionResponse = {
    type: InteractionResponseType.ChannelMessageWithSource,
    data: {
      // Success!!
      content: "hello"

      // Some Error
      // embeds: [
      //   {url: "https://media.valorant-api.com/weaponskinlevels/d6b75f1b-409b-bae9-d378-d3adf04a3ca9/displayicon.png"} as APIEmbed
      // ]

      // Some Error
      // attachments: [
      //   {
      //     id: sf.generate().toString() as Snowflake,
      //     filename: "displayicon.png",
      //     content_type: "image/png",
      //     size: 56056,
      //     url: "https://media.valorant-api.com/weaponskinlevels/d6b75f1b-409b-bae9-d378-d3adf04a3ca9/displayicon.png",
      //     proxy_url: "https://media.valorant-api.com/weaponskinlevels/d6b75f1b-409b-bae9-d378-d3adf04a3ca9/displayicon.png",
      //   } as APIAttachment,
      // ],
    },
  };

  return res;
};

我编辑了Discord-api类型以使用类型定义。 我在github上查找使用附件,但它使用了discord.js,没有帮助。 我不知道发送响应后的不便错误是什么,所以我需要知道如何找出答案。我也不知道该怎么做。

I need help with an error about Attachments in the Discord API.

It is responding to the ApplicationCommandType of the slash command in serverless, but it succeeds with Content only, but not with Content but with embedds and attachments.
(I don't even know how to find out more about this error.)

I have no idea what is wrong and would appreciate your help.

I am using deno environment with discord-api-types edited for deno. discord.js is not used.

import {
  APIApplicationCommandInteraction,
  APIInteractionResponse,
  InteractionResponseType,
  APIAttachment,
  APIEmbed
} from "../lib/discord-api-types/payloads/index.ts";

import { Snowflake } from "../lib/discord-api-types/globals.ts";

import { DiscordSnowflake as sf } from "../lib/snowflake/DiscordSnowflake.ts";

export const onApplicationCommand = (
  interaction: APIApplicationCommandInteraction
) => {
  let res: APIInteractionResponse = {
    type: InteractionResponseType.ChannelMessageWithSource,
    data: {
      // Success!!
      content: "hello"

      // Some Error
      // embeds: [
      //   {url: "https://media.valorant-api.com/weaponskinlevels/d6b75f1b-409b-bae9-d378-d3adf04a3ca9/displayicon.png"} as APIEmbed
      // ]

      // Some Error
      // attachments: [
      //   {
      //     id: sf.generate().toString() as Snowflake,
      //     filename: "displayicon.png",
      //     content_type: "image/png",
      //     size: 56056,
      //     url: "https://media.valorant-api.com/weaponskinlevels/d6b75f1b-409b-bae9-d378-d3adf04a3ca9/displayicon.png",
      //     proxy_url: "https://media.valorant-api.com/weaponskinlevels/d6b75f1b-409b-bae9-d378-d3adf04a3ca9/displayicon.png",
      //   } as APIAttachment,
      // ],
    },
  };

  return res;
};

I edited discord-api-types to use type definitions.
I looked on github for a use of attachment, but it was using discord.js and was not helpful.
I don't know what the discord error is after sending a response, so I need to know how to find out. I couldn't figure out how to do this either.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文