-
Notifications
You must be signed in to change notification settings - Fork 10
/
index.js
657 lines (550 loc) · 23.7 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
const express = require('express');
const fs = require('fs');
const YAML = require('yaml');
const tmi = require('tmi.js');
const axios = require('axios').default;
const open = require('open');
const Twitch = require('./twitchcontroller');
const pack = require('./package.json');
let spotifyRefreshToken = '';
let spotifyAccessToken = '';
let voteskipTimeout;
const client_id = process.env.SPOTIFY_CLIENT_ID;
const client_secret = process.env.SPOTIFY_CLIENT_SECRET;
const twitchOauthTokenRefunds = process.env.TWITCH_OAUTH_TOKEN_REFUNDS;
const twitchClientId = process.env.TWITCH_CLIENT_ID;
const twitchOauthToken = process.env.TWITCH_OAUTH_TOKEN;
const channelPointsUsageType = 'channel_points';
const commandUsageType = 'command';
const bitsUsageType = 'bits';
const defaultRewardId = 'xxx-xxx-xxx-xxx';
const displayNameTag = 'display-name';
const streamer = 'streamer';
const mod = 'mod';
const vip = 'vip';
const sub = 'sub';
const everyone = 'everyone';
const spotifyShareUrlBase = 'https://open.spotify.com';
const spotifyShareUrlMaker = `${spotifyShareUrlBase}/track/`;
const spotifyShareUrlMakerRegex = `${spotifyShareUrlBase}/(?:.*)?track/[^\\s]+`;
const spotifyShareUriMaker = 'spotify:track:';
const chatbotConfig = setupYamlConfigs();
const expressPort = chatbotConfig.express_port;
const cooldownDuration = chatbotConfig.cooldown_duration * 1000;
const usersOnCooldown = new Set();
const usersHaveSkipped = new Set();
const volMin = 0;
const volMax = 100;
const clamp = (num, volMin, volMax) => Math.min(Math.max(num, volMin), volMax);
// CHECK FOR UPDATES
axios.get("https://api.github.com/repos/KumoKairo/Spotify-Twitch-Song-Requests/releases/latest")
.then(r => {
if (r.data.tag_name !== pack.version) {
console.log(`An update is available at ${r.data.html_url}`);
}
}, () => console.log("Failed to check for updates."));
// TWITCH SETUP
const twitchAPI = new Twitch();
twitchAPI.init(chatbotConfig, twitchOauthTokenRefunds, twitchClientId).then(() => chatbotConfig.custom_reward_id = twitchAPI.reward_id);
const validTypes = [channelPointsUsageType, commandUsageType, bitsUsageType]
if(!validTypes.some(type => chatbotConfig.usage_types.includes(type))) {
console.log(`Usage type is neither '${channelPointsUsageType}', '${commandUsageType}' nor '${bitsUsageType}', app will not work. Edit your settings in the 'spotipack_config.yaml' file`);
}
const redirectUri = `http://localhost:${expressPort}/callback`;
const client = new tmi.Client({
connection: {
secure: true,
reconnect: true
},
identity: {
username: chatbotConfig.user_name,
password: twitchOauthToken
},
channels: [ chatbotConfig.channel_name ]
});
client.connect().catch(console.error);
console.log(`Logged in as ${chatbotConfig.user_name}. Working on channel '${chatbotConfig.channel_name}'`);
client.on('message', async (channel, tags, message, self) => {
if(self) return;
let messageToLower = message.toLowerCase();
if(chatbotConfig.usage_types.includes(commandUsageType)
&& chatbotConfig.command_alias.includes(messageToLower.split(" ")[0])
&& isUserEligible(channel, tags, chatbotConfig.command_user_level)) {
let args = messageToLower.split(" ")[1];
if (!args) {
client.say(chatbotConfig.channel_name, `${tags[displayNameTag]}, usage: !songrequest song-link (Spotify -> Share -> Copy Song Link)`);
} else {
await handleSongRequest(channel, tags[displayNameTag], message, tags, true);
}
} else if (chatbotConfig.allow_volume_set && messageToLower.split(" ")[0] == '!volume') {
let args = messageToLower.split(" ")[1];
if (!args) {
await handleGetVolume(channel, tags);
} else {
await handleSetVolume(channel, tags, args);
}
}
else if (messageToLower === chatbotConfig.skip_alias) {
await handleSkipSong(channel, tags);
}
else if (chatbotConfig.use_song_command && messageToLower === '!song') {
await handleTrackName(channel);
}
else if (chatbotConfig.use_queue_command && messageToLower === '!queue') {
await handleQueue(channel);
}
else if (chatbotConfig.allow_vote_skip && messageToLower === '!voteskip' ) {
await handleVoteSkip(channel, tags[displayNameTag]);
}
});
client.on('redeem', async (channel, username, rewardType, tags, message) => {
log(`Reward ID: ${rewardType}`);
if(chatbotConfig.usage_types.includes(channelPointsUsageType) && rewardType === chatbotConfig.custom_reward_id) {
let result = await handleSongRequest(channel, tags[displayNameTag], message, false);
if(!result) {
if (await twitchAPI.refundPoints()) {
console.log(`${username} redeemed a song request that couldn't be completed. It was refunded automatically.`);
} else {
console.log(`${username} redeemed a song request that couldn't be completed. It could not be refunded automatically.`);
}
}
}
});
// Extracted for easier debugging without spending actual bits (can be called from client.on('message'))
let onCheer = async (channel, state, message) => {
let bitsParse = parseInt(state.bits);
let bits = isNaN(bitsParse) ? 0 : bitsParse;
if(chatbotConfig.usage_types.includes(bitsUsageType)) {
let use_exact_amount = chatbotConfig.use_exact_amount_of_bits;
if(use_exact_amount && bits == chatbotConfig.minimum_requred_bits || !use_exact_amount && bits >= chatbotConfig.minimum_requred_bits) {
let username = state[displayNameTag];
// afaik, bit redeems include the word "bits" which can mess up the search query.
// we disassemble the phrase, remove anything with 'cheerX' where X is any number or digit
// not likely that a lot of songs contain word 'Cheer15' in their names
message = message.split(' ').filter(w => !(w.includes('cheer') && /\d/.test(w))).join(' ');
let result = await handleSongRequest(channel, username, message, true);
if(!result) {
console.log(`${username} tried cheering for the song request, but it failed (broken link or something). You will have to add it manually`);
}
}
}
}
client.on('cheer', onCheer);
let parseActualSongUrlFromBigMessage = (message) => {
const regex = new RegExp(spotifyShareUrlMakerRegex);
let match = message.match(regex);
if (match !== null) {
return match[0];
} else {
return null;
}
}
let parseActualSongUriFromBigMessage = (message) => {
const regex = new RegExp(`${spotifyShareUriMaker}[^\\s]+`);
let match = message.match(regex);
if (match !== null) {
spotifyIdToUrl = spotifyShareUrlMaker + match[0].split(':')[2];
return spotifyIdToUrl;
} else {
return null;
}
}
let handleTrackName = async (channel) => {
try {
await printTrackName(channel);
} catch (error) {
// Token expired
if(error?.response?.data?.error?.status === 401) {
await refreshAccessToken();
await printTrackName(channel);
} else {
client.say(chatbotConfig.channel_name, 'Seems like no music is playing right now');
}
}
}
let handleQueue = async (channel) => {
try {
await printQueue(channel);
} catch (error) {
// Token expired
if(error?.response?.data?.error?.status === 401) {
await refreshAccessToken();
await printQueue(channel);
} else {
client.say(chatbotConfig.channel_name, `Seems like no music is playing right now`);
}
}
}
let handleVoteSkip = async (channel, username) => {
if (!usersHaveSkipped.has(username)) {
startOrProgressVoteskip(channel);
usersHaveSkipped.add(username);
console.log(`${username} voted to skip the current song (${usersHaveSkipped.size}/${chatbotConfig.required_vote_skip})!`);
client.say(channel, `${username} voted to skip the current song (${usersHaveSkipped.size}/${chatbotConfig.required_vote_skip})!`);
}
if (usersHaveSkipped.size >= chatbotConfig.required_vote_skip) {
usersHaveSkipped.clear();
clearTimeout(voteskipTimeout);
console.log(`Chat has skipped ${await getCurrentTrackName(channel)} (${chatbotConfig.required_vote_skip}/${chatbotConfig.required_vote_skip})!`);
client.say(channel, `Chat has skipped ${await getCurrentTrackName(channel)} (${chatbotConfig.required_vote_skip}/${chatbotConfig.required_vote_skip})!`);
let spotifyHeaders = getSpotifyHeaders();
res = await axios.post('https://api.spotify.com/v1/me/player/next', {}, { headers: spotifyHeaders });
}
}
let printTrackName = async (channel) => {
let spotifyHeaders = getSpotifyHeaders();
let res = await axios.get('https://api.spotify.com/v1/me/player/currently-playing', {
headers: spotifyHeaders
});
let trackId = res.data.item.id;
let trackInfo = await getTrackInfo(trackId);
let trackName = trackInfo.name;
let trackLink = res.data.item.external_urls.spotify;
let artists = trackInfo.artists.map(artist => artist.name).join(', ');
client.say(channel, `▶️ ${artists} - ${trackName} -> ${trackLink}`);
}
let getCurrentTrackName = async (channel) => {
let spotifyHeaders = getSpotifyHeaders();
let res = await axios.get('https://api.spotify.com/v1/me/player/currently-playing', {
headers: spotifyHeaders
});
let trackId = res.data.item.id;
let trackInfo = await getTrackInfo(trackId);
let trackName = trackInfo.name;
return trackName;
}
let printQueue = async (channel) => {
let spotifyHeaders = getSpotifyHeaders();
let res = await axios.get('https://api.spotify.com/v1/me/player/queue', {
headers: spotifyHeaders
});
if (!res.data?.currently_playing || !res.data?.queue){
client.say(channel, 'Nothing in the queue.')
}
else {
let songIndex = 1;
let concatQueue = '';
let queueDepthIndex = chatbotConfig.queue_display_depth;
res.data.queue?.every(qItem => {
let trackName = qItem.name;
let artists = qItem.artists[0].name;
concatQueue += `• ${songIndex}) ${artists} - ${trackName} `;
queueDepthIndex--;
songIndex++;
// using 'every' to loop instead of 'foreach' allows us to break out of a loop like this
// so we can keep it
if (queueDepthIndex <= 0) {
return false;
}
else {
return true;
}
})
client.say(channel, `▶️ Next ${chatbotConfig.queue_display_depth} songs: ${concatQueue}`);
}
}
let handleSongRequest = async (channel, username, message, tags) => {
let validatedSongId = await validateSongRequest(message, channel);
if(!validatedSongId) {
client.say(channel, chatbotConfig.song_not_found);
return false;
} else if (chatbotConfig.use_cooldown && !usersOnCooldown.has(username)) {
usersOnCooldown.add(username);
setTimeout(() => {
usersOnCooldown.delete(username)
}, cooldownDuration);
} else if (chatbotConfig.use_cooldown) {
client.say(channel, `${username}, Please wait before requesting another song.`);
return false;
}
return await addValidatedSongToQueue(validatedSongId, channel, username, tags);
}
let addValidatedSongToQueue = async (songId, channel, callerUsername, tags) => {
try {
await addSongToQueue(songId, channel, callerUsername, tags);
} catch (error) {
// Token expired
if(error?.response?.data?.error?.status === 401) {
await refreshAccessToken();
await addSongToQueue(songId, channel, callerUsername, tags);
}
// No action was received from the Spotify user recently, need to print a message to make them poke Spotify
if(error?.response?.data?.error?.status === 404) {
client.say(channel, `Hey, ${channel}! You forgot to actually use Spotify this time. Please open it and play some music, then I will be able to add songs to the queue`);
return false;
}
if(error?.response?.data?.error?.status === 400) {
client.say(channel, chatbotConfig.song_not_found);
return false;
}
if(error?.response?.status === 403) {
client.say(channel, `It looks like Spotify doesn't want you to use it for some reason. Check the console for details.`);
console.log(`Spotify doesn't allow requesting songs because: ${error.response.data.error.message}`);
return false;
}
else {
console.log('ERROR WHILE REACHING SPOTIFY');
console.log(error?.response?.data);
console.log(error?.response?.status);
return false;
}
}
return true;
}
let searchTrackID = async (searchString) => {
// Excluding command aliases from the query string
chatbotConfig.command_alias.forEach(alias => {
searchString = searchString.replace(alias, '');
});
let spotifyHeaders = getSpotifyHeaders();
searchString = searchString.replace(/-/, ' ');
searchString = searchString.replace(/ by /, ' ');
searchString = encodeURIComponent(searchString);
const searchResponse = await axios.get(`https://api.spotify.com/v1/search?q=${searchString}&type=track`, {
headers: spotifyHeaders
});
let trackId = searchResponse.data.tracks.items[0]?.id;
if (chatbotConfig.blocked_tracks.includes(trackId)) {
return false;
} else {
return trackId;
}
}
let validateSongRequest = async (message, channel) => {
// If it contains a link, just use it as is
if (parseActualSongUrlFromBigMessage(message)) {
return await getTrackId(parseActualSongUrlFromBigMessage(message));
} else if (parseActualSongUriFromBigMessage(message)) {
return await getTrackId(parseActualSongUriFromBigMessage(message));
} else {
try {
return await searchTrackID(message);
} catch (error) {
// Token expired
if(error?.response?.data?.error?.status === 401) {
await refreshAccessToken();
await validateSongRequest(message, channel);
} else {
return false;
}
}
}
}
let getTrackId = (url) => {
let trackId = url.split('/').pop().split('?')[0];
if (chatbotConfig.blocked_tracks.includes(trackId)) {
return false;
} else {
return trackId;
}
}
let getTrackInfo = async (trackId) => {
let spotifyHeaders = getSpotifyHeaders();
let trackInfo = await axios.get(`https://api.spotify.com/v1/tracks/${trackId}`, {
headers: spotifyHeaders
});
return trackInfo.data;
}
let addSongToQueue = async (songId, channel, callerUsername, tags) => {
let spotifyHeaders = getSpotifyHeaders();
let trackInfo = await getTrackInfo(songId);
let trackName = trackInfo.name;
let artists = trackInfo.artists.map(artist => artist.name).join(', ');
let uri = trackInfo.uri;
let duration = trackInfo.duration_ms / 1000;
let eligible = isUserEligible(channel, tags, chatbotConfig.ignore_max_length);
if (duration > chatbotConfig.max_duration && !eligible) {
client.say(channel, `${trackName} is too long. The max duration is ${chatbotConfig.max_duration} seconds`);
return;
}
let res = await axios.post(`https://api.spotify.com/v1/me/player/queue?uri=${uri}`, {}, {headers: spotifyHeaders});
let trackParams = {
artists: artists,
trackName: trackName,
username: callerUsername
}
client.say(channel, handleMessageQueries(chatbotConfig.added_to_queue_messages, trackParams));
}
let refreshAccessToken = async () => {
const params = new URLSearchParams();
params.append('refresh_token', spotifyRefreshToken);
params.append('grant_type', 'refresh_token');
params.append('redirect_uri', `http://localhost:${expressPort}/callback`);
try {
let res = await axios.post('https://accounts.spotify.com/api/token', params, {
headers: {
'Content-Type':'application/x-www-form-urlencoded',
'Authorization': 'Basic ' + Buffer.from(client_id + ':' + client_secret).toString('base64')
}
});
spotifyAccessToken = res.data.access_token;
} catch (error) {
console.log(`Error refreshing token: ${error.message}`);
}
}
function getSpotifyHeaders() {
return {
'Authorization': `Bearer ${spotifyAccessToken}`
};
}
// SPOTIFY CONNECTIONG STUFF
let app = express();
app.get('/login', (req, res) => {
const scope = 'user-modify-playback-state user-read-playback-state user-read-currently-playing';
const authParams = new URLSearchParams();
authParams.append('response_type', 'code');
authParams.append('client_id', client_id);
authParams.append('redirect_uri', redirectUri);
authParams.append('scope', scope);
res.redirect(`https://accounts.spotify.com/authorize?${authParams}`);
});
app.get('/callback', async (req, res) => {
let code = req.query.code || null;
if (!code) {
// Print error
return;
}
const params = new URLSearchParams();
params.append('code', code);
params.append('redirect_uri', redirectUri);
params.append('grant_type', 'authorization_code');
const config = {
headers: {
'Authorization': 'Basic ' + Buffer.from(client_id + ':' + client_secret).toString('base64'),
'Content-Type':'application/x-www-form-urlencoded'
}
};
let tokenResponse = await axios.post('https://accounts.spotify.com/api/token', params, config);
if (!tokenResponse.statusCode === 200) {
// Print error
return;
}
spotifyAccessToken = tokenResponse.data.access_token;
spotifyRefreshToken = tokenResponse.data.refresh_token;
res.send('Tokens refreshed successfully. You can close this tab');
});
app.listen(expressPort);
console.log(`App is running. Visit http://localhost:${expressPort}/login to refresh the tokens if the page didn't open automatically`);
open(`http://localhost:${expressPort}/login`);
function setupYamlConfigs () {
const configFile = fs.readFileSync('spotipack_config.yaml', 'utf8');
let fileConfig = YAML.parse(configFile);
fileConfig = checkIfSetupIsCorrect(fileConfig);
return fileConfig;
}
function startOrProgressVoteskip(channel) {
if (usersHaveSkipped.size > 0) {
clearTimeout(voteskipTimeout);
}
voteskipTimeout = setTimeout(function() {resetVoteskip(channel)}, chatbotConfig.voteskip_timeout * 1000);
}
function resetVoteskip(channel) {
client.say(channel, `Voteskip has timed out... No song will be skipped at this time! catJAM`);
usersHaveSkipped.clear();
}
function checkIfSetupIsCorrect(fileConfig) {
if (fileConfig.usage_types.includes(channelPointsUsageType) && fileConfig.custom_reward_id === defaultRewardId) {
console.log(`!ERROR!: You have included 'channel_points' in 'usage_types', but didn't provide a custom Reward ID. Refer to the manual to get the Reward ID value, or change the usage type`);
}
// check if we have any aliases if we are using commands
if (fileConfig.usage_types.includes(commandUsageType) && fileConfig.command_alias.length === 0) {
console.log(`!ERROR!: You have included 'command' in 'usage_types', but didn't provide any command aliases. Please add an alias to be able to request songs`);
}
else {
for (let i = 0; i < fileConfig.command_alias.length - 1; i++) {
fileConfig.command_alias[i] = fileConfig.command_alias[i].toLowerCase();
}
}
return fileConfig;
}
function handleMessageQueries (messages, params) {
let newMessage = messages[Math.floor(Math.random() * messages.length)];
if (params.username) {
newMessage = newMessage.replace('$(username)', params.username);
}
if (params.trackName) {
newMessage = newMessage.replace('$(trackName)', params.trackName);
}
if (params.artists) {
newMessage = newMessage.replace('$(artists)', params.artists);
}
return newMessage;
}
function log(message) {
if(chatbotConfig.logs) {
console.log(message);
}
}
function isUserEligible(channel, tags, rolesArray) {
// If the user is the streamer
let userEligible = tags.badges?.broadcaster === '1';
// Or if it's a mod
userEligible |= rolesArray.includes(mod) && tags.mod;
// Or if it's a VIP
userEligible |= rolesArray.includes(vip) && tags.badges?.vip === '1';
// Or if it's a subscriber
userEligible |= rolesArray.includes(sub) && tags['badge-info']?.subscriber;
// Or if the tag is set to "everyone"
userEligible |= rolesArray.includes(everyone);
return userEligible > 0;
}
async function handleSkipSong(channel, tags) {
try {
let eligible = isUserEligible(channel, tags, chatbotConfig.skip_user_level);
if(eligible) {
client.say(channel, `${tags[displayNameTag]} skipped ${await getCurrentTrackName(channel)}!`);
console.log(`${tags[displayNameTag]} skipped ${await getCurrentTrackName(channel)}!`);
let spotifyHeaders = getSpotifyHeaders();
res = await axios.post('https://api.spotify.com/v1/me/player/next', null, { headers: spotifyHeaders });
}
} catch (error) {
console.log(error);
// Skipping the error for now, let the users spam it
// 403 error of not having premium is the same as with the request,
// ^ TODO get one place to handle common Spotify error codes
}
}
async function handleGetVolume(channel, tags) {
try {
let eligible = isUserEligible(channel, tags, chatbotConfig.volume_set_level);
if(eligible) {
let spotifyHeaders = getSpotifyHeaders();
res = await axios.get('https://api.spotify.com/v1/me/player', { headers: spotifyHeaders });
let currVolume = res.data.device.volume_percent;
console.log(`${tags[displayNameTag]}, the current volume is ${currVolume.toString()}!`);
client.say(channel, `${tags[displayNameTag]}, the current volume is ${currVolume.toString()}!`);
}
} catch (error) {
console.log(error);
// Skipping the error for now, let the users spam it
// 403 error of not having premium is the same as with the request,
// ^ TODO get one place to handle common Spotify error codes
}
}
async function handleSetVolume(channel, tags, arg) {
try {
let eligible = isUserEligible(channel, tags, chatbotConfig.volume_set_level);
if(eligible) {
let number = 0;
try {
number = Number(arg);
number = clamp(number, volMin, volMax);
} catch (error) {
console.log(error);
client.say(channel, `${tags[displayNameTag]}, a number between 0 and 100 is required.`);
return;
}
let spotifyHeaders = getSpotifyHeaders();
//courtesy of greav
res = await axios.put('https://api.spotify.com/v1/me/player/volume', null, { headers: spotifyHeaders, params:{volume_percent: number} });
console.log(`${tags[displayNameTag]} has set the current volume to ${number.toString()}!`);
client.say(channel, `${tags[displayNameTag]} has set the current volume to ${number.toString()}!`);
}
} catch (error) {
console.log(error);
client.say(channel, `There was a problem setting the volume`);
// Skipping the error for now, let the users spam it
// 403 error of not having premium is the same as with the request,
// ^ TODO get one place to handle common Spotify error codes
}
}