查找和删除 Discord webhook 消息
Find and delete Discord webhook message
我正在使用 Discord webhook 发送信息,这些信息稍后可能会失效,因此我希望能够将其删除。为此,我使用这些端点:
首先我发出 post 发送消息的请求:
POST /webhooks/{webhook.id}/{webhook.token}
然后我想发出删除请求以再次删除该消息:
DELETE /webhooks/{webhook.id}/{webhook.token}/messages/{message.id}
但是我没有要删除的消息的 ID,因为没有对第一个 POST 请求给出任何响应,该请求始终是空的 204 响应。是否可以获取消息id?
如有任何帮助,我们将不胜感激。
根据 this reddit post:
If you need to reference a message ID of a webhook message you sent, you can add ?wait=true to the end of the URL which will give you the message data (including the ID) instead of a 204 (No Content) when you don't include the query parameter.
因此,如果您像这样向 url 发送正常的 POST 请求:POST /webhooks/{webhook.id}/{webhook.token}
,请在其末尾添加 ?wait=true
。然后你会得到这样的数据:
{
"id": "MESSAGEID",
"type": 0,
"content": "This is a test",
"channel_id": "CHANNELID",
"author": {
"bot": true,
"id": "AUTHORID",
"username": "USERNAME",
"avatar": "AVATARID",
"discriminator": "0000"
},
"attachments": [],
"embeds": [],
"mentions": [],
"mention_roles": [],
"pinned": false,
"mention_everyone": false,
"tts": false,
"timestamp": "2021-11-13T18:10:24.412000+00:00",
"edited_timestamp": null,
"flags": 0,
"components": [],
"webhook_id": "WEBHOOKID"
}
我正在使用 Discord webhook 发送信息,这些信息稍后可能会失效,因此我希望能够将其删除。为此,我使用这些端点:
首先我发出 post 发送消息的请求:
POST /webhooks/{webhook.id}/{webhook.token}
然后我想发出删除请求以再次删除该消息:
DELETE /webhooks/{webhook.id}/{webhook.token}/messages/{message.id}
但是我没有要删除的消息的 ID,因为没有对第一个 POST 请求给出任何响应,该请求始终是空的 204 响应。是否可以获取消息id?
如有任何帮助,我们将不胜感激。
根据 this reddit post:
If you need to reference a message ID of a webhook message you sent, you can add ?wait=true to the end of the URL which will give you the message data (including the ID) instead of a 204 (No Content) when you don't include the query parameter.
因此,如果您像这样向 url 发送正常的 POST 请求:POST /webhooks/{webhook.id}/{webhook.token}
,请在其末尾添加 ?wait=true
。然后你会得到这样的数据:
{
"id": "MESSAGEID",
"type": 0,
"content": "This is a test",
"channel_id": "CHANNELID",
"author": {
"bot": true,
"id": "AUTHORID",
"username": "USERNAME",
"avatar": "AVATARID",
"discriminator": "0000"
},
"attachments": [],
"embeds": [],
"mentions": [],
"mention_roles": [],
"pinned": false,
"mention_everyone": false,
"tts": false,
"timestamp": "2021-11-13T18:10:24.412000+00:00",
"edited_timestamp": null,
"flags": 0,
"components": [],
"webhook_id": "WEBHOOKID"
}