Skip to content

Commit

Permalink
Merge pull request #112 from Project-Coda/get-max-bitrate
Browse files Browse the repository at this point in the history
Automatically get max bitrate
  • Loading branch information
ikifar2012 authored Jan 18, 2023
2 parents 1dcf001 + 5a6c463 commit 06e1921
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
1 change: 0 additions & 1 deletion env.js.example
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ module.exports = {
openai: '',
customvc:{
channel: '',
bitrate: 96000,
},
releases: {
releases_channel: '',
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "coda-utilities",
"version": "2.5.0",
"version": "2.5.1",
"description": "A general utilities bot for Coda",
"main": "index.js",
"scripts": {
Expand Down
22 changes: 21 additions & 1 deletion utilities/custom-vc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,26 @@ const mariadb = require('../db.js');
const embedcreator = require('../embed.js');
const env = require('../env.js');
collector = false;
// get max bitrate
async function getMaxBitrate() {
// get max bitrate from discord
const guild = global.client.guilds.cache.get(env.discord.guild);
console.log(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;
}
}
async function buttonResponder(interaction) {
const buttonid = interaction.customId;
const userchannel = await checkUser(interaction.user.id);
Expand Down Expand Up @@ -306,7 +326,7 @@ async function Create(newState) {
guild = await global.client.guilds.cache.get(env.discord.guild);
userobject = await guild.members.fetch(userid);
nickname = await userobject.displayName;
vc_bitrate = env.utilities.customvc.bitrate;
vc_bitrate = await getMaxBitrate();
const channel = await member.guild.channels.create({
name: nickname + '\'s Channel',
type: ChannelType.GuildVoice,
Expand Down

0 comments on commit 06e1921

Please sign in to comment.