Skip to content

Delete all Messages in Channel? #1187

Answered by 42atomys
heatdream asked this question in Q&A
Discussion options

You must be logged in to vote

Hello, that is possible with the endpoint DeleteBulkMessage (https://discord.com/developers/docs/resources/channel#bulk-delete-messages)

session.ChannelMessagesBulkDelete(channelID string, messages []string)

But limited to 100 messages per request. If this is a big channel (basically messages > 100), the best solution is to duplicate channel and delete the full channel.

Example:

s, _ := discordgo.New()
s.Open()

ch, err := s.Channel(channelID)
if err != nil {
	panic(err)
}
if _, err = s.ChannelDelete(channelID); err != nil {
	panic(err)
}

s.GuildChannelCreateComplex(guildID, discordgo.GuildChannelCreateData{
	Name: ch.Name,
	Type: ch.Type,
	Topic: ch.Topic,
	Bitrate: ch.Bitrate,
	UserLimit

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by heatdream
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants