-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
38 lines (34 loc) · 1.2 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const axios = require('axios');
class VibeSync {
/**
* @param {Client} BotDevu
*/
constructor(BotDevu) {
this.BotDevu = BotDevu;
}
/**
* @param {String} ChannelId
* @param {String} status
* @returns {Promise<void>}
*/
async setVoiceStatus(ChannelId, status) {
try {
const response = await axios.put(
`https://discord.com/api/v10/channels/${ChannelId}/voice-status`,
{ status: status.length > 0 ? status : 'Default Status' },
{ headers: { Authorization: `Bot ${this.BotDevu.token}` } }
);
console.log(`Voice channel status updated successfully`);
} catch (error) {
if (error.response) {
console.error(`API Error (${error.response.status}): ${error.response.data.message}`);
} else if (error.request) {
console.error('No response received from API');
} else {
console.error(`Request Setup Error: ${error.message}`);
}
throw new Error(`An error occurred: ${error.message}`);
}
}
}
module.exports = { VibeSync };