go-twitch/api/moderation/delete_chat_messages.go

51 lines
1.5 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package moderation
import (
"context"
"net/http"
"net/url"
"github.com/google/go-querystring/query"
)
type DeleteChatMessagesParams struct {
// The ID of the broadcaster that owns the chat room to remove messages from.
BroadcasterID string `url:"broadcaster_id"`
// The ID of the broadcaster or a user that has permission to moderate the broadcasters chat room.
// This ID must match the user ID in the user access token.
ModeratorID string `url:"moderator_id"`
// The ID of the message to remove. The id tag in the PRIVMSG tag contains the messages ID. Restrictions:
//
// - The message must have been created within the last 6 hours.
//
// - The message must not belong to the broadcaster.
//
// - The message must not belong to another moderator.
//
// If not specified, the request removes all messages in the broadcasters chat room.
MessageID *string `url:"message_id,omitempty"`
}
// Removes a single chat message or all chat messages from the broadcasters chat room.
//
// Requires a user access token that includes the moderator:manage:chat_messages scope.
func (m *Moderation) DeleteChatMessages(ctx context.Context, params *DeleteChatMessagesParams) error {
v, _ := query.Values(params)
endpoint := m.baseUrl.ResolveReference(&url.URL{Path: "moderation/chat", RawQuery: v.Encode()})
req, err := http.NewRequestWithContext(ctx, http.MethodDelete, endpoint.String(), nil)
if err != nil {
return err
}
res, err := m.client.Do(req)
if err != nil {
return err
}
defer res.Body.Close()
return nil
}