Add Delete()

This commit is contained in:
cryox-dev 2023-12-13 14:30:01 +13:00 committed by GitHub
parent 56e7bd01ca
commit 103b33f77d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -94,6 +94,23 @@ func (t *Transmitter) Edit(channelID string, messageID string, params *discordgo
return nil
}
// Delete will delete a message from a channel, if possible.
func (t *Transmitter) Delete(channelID string, messageID string) error {
wh := t.getWebhook(channelID)
if wh == nil {
return ErrWebhookNotFound
}
uri := discordgo.EndpointWebhookToken(wh.ID, wh.Token) + "/messages/" + messageID
_, err := t.session.RequestWithBucketID("DELETE", uri, nil, discordgo.EndpointWebhookToken("", ""))
if err != nil {
return fmt.Errorf("delete failed: %w", err)
}
return nil
}
// HasWebhook checks whether the transmitter is using a particular webhook.
func (t *Transmitter) HasWebhook(id string) bool {
t.mutex.RLock()