Add bulk delete
This commit is contained in:
parent
719c0d230c
commit
042e9166fd
|
@ -559,6 +559,15 @@ func (bot *botInstance) processEventMsg(ctx context.Context, msg *GatewayMessage
|
|||
}
|
||||
case "MESSAGE_DELETE":
|
||||
bot.messageDelete(ctx, MessageDeleteFromMap(msg.Data))
|
||||
case "MESSAGE_BULK_DELETE":
|
||||
bulkDelete := MessageBulkDeleteFromMap(msg.Data)
|
||||
for _, id := range bulkDelete.IDs {
|
||||
bot.messageDelete(ctx, MessageDelete{
|
||||
ID: id,
|
||||
ChannelID: bulkDelete.ChannelID,
|
||||
GuildID: bulkDelete.GuildID,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
@ -127,6 +127,29 @@ func MessageDeleteFromMap(m interface{}) MessageDelete {
|
|||
}
|
||||
}
|
||||
|
||||
// https://discord.com/developers/docs/topics/gateway#message-delete
|
||||
type MessageBulkDelete struct {
|
||||
IDs []string `json:"ids"`
|
||||
ChannelID string `json:"channel_id"`
|
||||
GuildID string `json:"guild_id"`
|
||||
}
|
||||
|
||||
func MessageBulkDeleteFromMap(m interface{}) MessageBulkDelete {
|
||||
mmap := m.(map[string]interface{})
|
||||
|
||||
iids := mmap["ids"].([]interface{})
|
||||
ids := make([]string, len(iids))
|
||||
for i, iid := range iids {
|
||||
ids[i] = iid.(string)
|
||||
}
|
||||
|
||||
return MessageBulkDelete{
|
||||
IDs: ids,
|
||||
ChannelID: mmap["channel_id"].(string),
|
||||
GuildID: maybeString(mmap, "guild_id"),
|
||||
}
|
||||
}
|
||||
|
||||
type ChannelType int
|
||||
|
||||
// https://discord.com/developers/docs/resources/channel#channel-object-channel-types
|
||||
|
|
|
@ -16,7 +16,7 @@ stuff we need to worry about:
|
|||
- ryan used to post everything in #projects for some reason
|
||||
|
||||
|
||||
real-time stuff:
|
||||
✔ real-time stuff:
|
||||
✔ - on new showcase message
|
||||
- always save the lightweight record
|
||||
- if we have permission, create a snippet
|
||||
|
@ -24,10 +24,11 @@ real-time stuff:
|
|||
- re-save the lightweight record and content as if it was new
|
||||
- create snippet, unconditionally???? (bug??)
|
||||
- update snippet contents if the edit makes sense
|
||||
- on delete
|
||||
✔ - on delete
|
||||
- delete snippet if the user so desires
|
||||
- delete the message records
|
||||
|
||||
✔ - on bulk delete
|
||||
- same stuff
|
||||
|
||||
background stuff:
|
||||
- watch mode
|
||||
|
|
Loading…
Reference in New Issue