使用 Discord 从频道中删除所有消息

时间:2021-02-10 20:59:19

标签: go discord

我正在尝试使用 discord bot 从频道中删除所有消息,但我发现的唯一删除消息的命令是 s.ChannelMessageDelete(m.ChannelID, m.ID)

它一次只删除 1 条消息,我想清除所有 我可以使用哪个命令来执行此操作?

1 个答案:

答案 0 :(得分:0)

EDIT 正如评论者所指出的,您可以看到这一次只会删除源代码中的 100 条消息。如果要删除所有消息,则必须以 100 条消息为单位调用此函数。

the source codedocs,您可以使用 ChannelMessagesBulkDelete

// ChannelMessagesBulkDelete bulk deletes the messages from the channel for the provided messageIDs.
// If only one messageID is in the slice call channelMessageDelete function.
// If the slice is empty do nothing.
// channelID : The ID of the channel for the messages to delete.
// messages  : The IDs of the messages to be deleted. A slice of string IDs. A maximum of 100 messages.
func (s *Session) ChannelMessagesBulkDelete(channelID string, messages []string) (err error) {
   ...
}