跳到主要内容

Discord Webhook 辅助函数

discord_send(webhook_url, content, username, avatar_url) → (success, error)

向 Discord 发送消息并等待确认(5 秒超时)。

  • webhook_url (字符串) - 必须以 https://discord.com/api/webhooks/https://discordapp.com/api/webhooks/ 开头
  • content (字符串) - 消息文本(最多 2000 个字符,不能为空)
  • username (字符串, 可选) - 覆盖 Webhook 用户名(最多 80 个字符,nil 表示默认值)
  • avatar_url (字符串, 可选) - 覆盖 Webhook 头像 (nil 表示默认值)

返回值: success (布尔值), error (字符串|nil)。

discord_send_async(webhook_url, content, username, avatar_url) → boolean

触发后即忘 (Fire-and-forget) 变体。如果已加入队列返回 true,如果验证失败返回 false