From 19cb227dc92cd61b3f3a4542422d0747d5d800ce Mon Sep 17 00:00:00 2001 From: Alexander <49165798+alxndr-stlz@users.noreply.github.com> Date: Fri, 8 Aug 2025 15:49:52 +0200 Subject: [PATCH 1/2] removed axios and switched to Client rest --- index.js | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/index.js b/index.js index 226dfb3..16bb77f 100644 --- a/index.js +++ b/index.js @@ -1,23 +1,14 @@ // noinspection ExceptionCaughtLocallyJS,JSUnusedGlobalSymbols -const axios = require('axios'); const {PermissionsBitField} = require('discord.js'); class VibeSync { /** * @param {Client} Client - * @param {Object} [options] - * @param {string} [options.baseURL] - * @param {number} [options.timeout] */ - constructor(Client, options = {}) { + constructor(Client) { if (!Client?.token) throw new Error('Bot-Token is missing. Please provide a valid Discord bot client with a token.'); this.Client = Client; - this.api = axios.create({ - baseURL: options.baseURL || 'https://discord.com/api/v10', - headers: {Authorization: `Bot ${Client.token}`}, - timeout: options.timeout || 7000, - }); } /** @@ -42,12 +33,15 @@ class VibeSync { async setVoiceStatus(channelId, status = '') { await this._checkPermissions(channelId); try { - const response = await this.api.put(`/channels/${channelId}/voice-status`, {status}); - if (![200, 204].includes(response.status)) throw new Error(`Unexpected status code: ${response.status}`); + const response = await this.Client.rest.put(`/channels/${channelId}/voice-status`, {body: {status}}); + if (!response.ok) { + const errorData = await response.json(); + throw new Error(`API Error: ${errorData.message || 'Unexpected error'}`); + } return {success: true}; } catch (error) { console.error('API Fehler:', error); - throw new Error(error.response?.data?.message ? `API Error: ${error.response.data.message}` : error.request ? 'No response from API.' : `Request Error: ${error.message}`); + throw new Error(error?.message || 'Unbekannter Fehler bei der API-Anfrage.'); } } From dee45113c823748e444d873ecfd6598099f60103 Mon Sep 17 00:00:00 2001 From: Alexander <49165798+alxndr-stlz@users.noreply.github.com> Date: Fri, 8 Aug 2025 16:54:59 +0200 Subject: [PATCH 2/2] language fix --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 16bb77f..6d52069 100644 --- a/index.js +++ b/index.js @@ -41,7 +41,7 @@ class VibeSync { return {success: true}; } catch (error) { console.error('API Fehler:', error); - throw new Error(error?.message || 'Unbekannter Fehler bei der API-Anfrage.'); + throw new Error(error?.message || 'Unexpected error while setting voice status'); } }