-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b0fb2c4
commit c9b375e
Showing
5 changed files
with
47 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
const env = require('../env.js'); | ||
const embedcreator = require('../embed.js'); | ||
async function getMaxBitrate() { | ||
// get max bitrate from discord | ||
const guild = await global.client.guilds.cache.get(env.discord.guild); | ||
const maxbitrate = await guild.premiumTier; | ||
// convert to bitrate | ||
if (maxbitrate === 0) { | ||
return 96000; | ||
} | ||
if (maxbitrate === 1) { | ||
return 128000; | ||
} | ||
if (maxbitrate === 2) { | ||
return 256000; | ||
} | ||
if (maxbitrate === 3) { | ||
return 384000; | ||
} | ||
} | ||
// Set bitrate of each channel to max bitrate | ||
async function setBitrate() { | ||
try { | ||
const guild = await global.client.guilds.cache.get(env.discord.guild); | ||
const maxbitrate = await getMaxBitrate(); | ||
const channels = await guild.channels.cache.filter(channel => channel.type === 2 && channel.bitrate !== maxbitrate); | ||
channels.forEach(async channel => { | ||
await channel.setBitrate(maxbitrate); | ||
bitrate = maxbitrate / 1000; | ||
embedcreator.log(`Set bitrate of ${channel} to ${bitrate}kbps`); | ||
}); | ||
} | ||
catch (error) { | ||
console.error(error); | ||
embedcreator.sendError(error); | ||
} | ||
} | ||
module.exports = { | ||
getMaxBitrate, | ||
setBitrate, | ||
}; |