【问题标题】:Delete all messages from a channel using Discord使用 Discord 从频道中删除所有消息
【发布时间】:2021-05-14 14:45:41
【问题描述】:

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

一次只删除1条消息,我想清除所有 我可以使用哪个命令来做到这一点?

【问题讨论】:

  • 如果我没记错的话,你一次只能删除 100 个。如果要删除“所有内容”,则需要不断获取新批次的消息ID

标签: go discord


【解决方案1】:

编辑 正如评论者所说,您可以看到这一次只会删除源代码中的 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) {
   ...
}

【讨论】:

    猜你喜欢
    • 2021-06-30
    • 2020-06-23
    • 2020-12-23
    • 1970-01-01
    • 2020-10-01
    • 2018-09-07
    • 2021-10-18
    • 2018-05-16
    • 2018-06-29
    相关资源
    最近更新 更多