Getting Error no response from twitch

My bot works on default messages like hi in chat but when i try to ban someone it gives me the error no response from twitch

client.on('message', ( channel, context, message, self) => {
const lowercaseMessage = message.toLowerCase();
for (const blockedWord of blockedWords) {
    if (lowercaseMessage.includes(blockedWord)) {
        client.ban(channel,context.username, "Inappropriate language detected")
        .catch((err) => {
            console.error('Error timing out user:', err);
        });

Commands over IRC have been deprecated for over a year now, https://discuss.dev.twitch.com/t/deprecation-of-chat-commands-through-irc/40486.

If you want to ban a user, you’ll need to use the Ban User API endpoint. Same with most other commands that were previously handled through IRC they’re now done through the API.

Ok thanks that i understand but is there an example that i can follow for nodejs how to implement this?

assuming usage of fetch

        let url = new URL('https://api.twitch.tv/helix/moderation/bans');
        url.search = new URLSearchParams([
            ['broadcaster_id', broadcaster_id],
            ['moderator_id', this._userId]
        ]).toString();

        let ban_user_response = await fetch(
            url,
            {
                method: 'POST',
                headers: {
                    'Client-ID': this.client_id,
                    'Authorization': `Bearer ${this.access_token}`,
                    'Content-Type': 'application/json'
                },
                body: JSON.stringify({
                  data: {
                      user_id,
                      duration: duration,
                      reason
                  }
              })
            }
        );

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.