Merge branch 'develop' into fix-33

This commit is contained in:
Christer Warén 2021-09-09 13:03:46 +03:00
commit e08c20aa3d
49 changed files with 186 additions and 168 deletions

View File

@ -4,4 +4,4 @@
datastore datastore
Dockerfile Dockerfile
LICENSE LICENSE
README.md README.md

View File

@ -1,2 +1,2 @@
DISCORD_TOKEN= DISCORD_TOKEN=
RADIOX_STATIONSLISTURL=https://gitea.cwinfo.org/cwchristerw/radio/raw/branch/master/playlist.json RADIOX_STATIONSLISTURL=https://gitea.cwinfo.org/cwchristerw/radio/raw/branch/master/playlist.json

View File

@ -16,4 +16,4 @@ updates:
interval: "daily" interval: "daily"
target-branch: "develop" target-branch: "develop"
labels: labels:
- "dependencies" - "dependencies"

2
.github/labeler.yml vendored
View File

@ -4,4 +4,4 @@ dependencies:
documentation: documentation:
- README.md - README.md
- LICENSE - LICENSE
- .env_example - .env_example

View File

@ -16,4 +16,4 @@ jobs:
with: with:
install: true install: true
- name: Build - name: Build
run: docker build . # will run buildx run: docker build . # will run buildx

View File

@ -14,4 +14,4 @@ jobs:
- uses: actions/labeler@v3 - uses: actions/labeler@v3
with: with:
repo-token: "${{ secrets.GITHUB_TOKEN }}" repo-token: "${{ secrets.GITHUB_TOKEN }}"
sync-labels: true sync-labels: true

3
.gitignore vendored
View File

@ -1,6 +1,5 @@
datastore/ datastore/
node_modules/ node_modules/
npm-debug.log npm-debug.log
.vscode/
.env .env
build/ build/

6
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,6 @@
{
"files.trimTrailingWhitespace": true,
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
"editor.renderFinalNewline": false
}

View File

@ -14,4 +14,4 @@ RUN npm install
RUN npm run build RUN npm run build
CMD [ "npm", "start" ] CMD [ "npm", "start" ]

106
package-lock.json generated
View File

@ -13,7 +13,7 @@
"@discordjs/opus": "^0.6.0", "@discordjs/opus": "^0.6.0",
"@discordjs/rest": "^0.1.1-canary.0", "@discordjs/rest": "^0.1.1-canary.0",
"@discordjs/voice": "^0.6.0", "@discordjs/voice": "^0.6.0",
"discord-api-types": "^0.22.0", "discord-api-types": "^0.23.1",
"discord.js": "^13.1.0", "discord.js": "^13.1.0",
"dotenv": "^10.0.0", "dotenv": "^10.0.0",
"libsodium-wrappers": "^0.7.9", "libsodium-wrappers": "^0.7.9",
@ -21,7 +21,7 @@
"path": "^0.12.7" "path": "^0.12.7"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^16.7.13", "@types/node": "^16.9.0",
"@types/ws": "^7.4.7", "@types/ws": "^7.4.7",
"@typescript-eslint/eslint-plugin": "^4.31.0", "@typescript-eslint/eslint-plugin": "^4.31.0",
"@typescript-eslint/parser": "^4.31.0", "@typescript-eslint/parser": "^4.31.0",
@ -180,6 +180,14 @@
"npm": ">=7.0.0" "npm": ">=7.0.0"
} }
}, },
"node_modules/@discordjs/builders/node_modules/discord-api-types": {
"version": "0.22.0",
"resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.22.0.tgz",
"integrity": "sha512-l8yD/2zRbZItUQpy7ZxBJwaLX/Bs2TGaCthRppk8Sw24LOIWg12t9JEreezPoYD0SQcC2htNNo27kYEpYW/Srg==",
"engines": {
"node": ">=12"
}
},
"node_modules/@discordjs/collection": { "node_modules/@discordjs/collection": {
"version": "0.2.1", "version": "0.2.1",
"resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-0.2.1.tgz", "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-0.2.1.tgz",
@ -259,6 +267,14 @@
"node": ">=16.0.0" "node": ">=16.0.0"
} }
}, },
"node_modules/@discordjs/rest/node_modules/discord-api-types": {
"version": "0.22.0",
"resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.22.0.tgz",
"integrity": "sha512-l8yD/2zRbZItUQpy7ZxBJwaLX/Bs2TGaCthRppk8Sw24LOIWg12t9JEreezPoYD0SQcC2htNNo27kYEpYW/Srg==",
"engines": {
"node": ">=12"
}
},
"node_modules/@discordjs/rest/node_modules/node-fetch": { "node_modules/@discordjs/rest/node_modules/node-fetch": {
"version": "2.6.2", "version": "2.6.2",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.2.tgz", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.2.tgz",
@ -297,6 +313,14 @@
"node": ">=12.0.0" "node": ">=12.0.0"
} }
}, },
"node_modules/@discordjs/voice/node_modules/discord-api-types": {
"version": "0.22.0",
"resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.22.0.tgz",
"integrity": "sha512-l8yD/2zRbZItUQpy7ZxBJwaLX/Bs2TGaCthRppk8Sw24LOIWg12t9JEreezPoYD0SQcC2htNNo27kYEpYW/Srg==",
"engines": {
"node": ">=12"
}
},
"node_modules/@discordjs/voice/node_modules/node-addon-api": { "node_modules/@discordjs/voice/node_modules/node-addon-api": {
"version": "3.2.1", "version": "3.2.1",
"resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-3.2.1.tgz", "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-3.2.1.tgz",
@ -476,9 +500,9 @@
"dev": true "dev": true
}, },
"node_modules/@types/node": { "node_modules/@types/node": {
"version": "16.7.13", "version": "16.9.0",
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.7.13.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-16.9.0.tgz",
"integrity": "sha512-pLUPDn+YG3FYEt/pHI74HmnJOWzeR+tOIQzUx93pi9M7D8OE7PSLr97HboXwk5F+JS+TLtWuzCOW97AHjmOXXA==" "integrity": "sha512-nmP+VR4oT0pJUPFbKE4SXj3Yb4Q/kz3M9dSAO1GGMebRKWHQxLfDNmU/yh3xxCJha3N60nQ/JwXWwOE/ZSEVag=="
}, },
"node_modules/@types/ws": { "node_modules/@types/ws": {
"version": "7.4.7", "version": "7.4.7",
@ -1309,9 +1333,9 @@
} }
}, },
"node_modules/discord-api-types": { "node_modules/discord-api-types": {
"version": "0.22.0", "version": "0.23.1",
"resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.22.0.tgz", "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.23.1.tgz",
"integrity": "sha512-l8yD/2zRbZItUQpy7ZxBJwaLX/Bs2TGaCthRppk8Sw24LOIWg12t9JEreezPoYD0SQcC2htNNo27kYEpYW/Srg==", "integrity": "sha512-igWmn+45mzXRWNEPU25I/pr8MwxHb767wAr51oy3VRLRcTlp5ADBbrBR0lq3SA1Rfw3MtM4TQu1xo3kxscfVdQ==",
"engines": { "engines": {
"node": ">=12" "node": ">=12"
} }
@ -1351,6 +1375,14 @@
"npm": ">=7.0.0" "npm": ">=7.0.0"
} }
}, },
"node_modules/discord.js/node_modules/discord-api-types": {
"version": "0.22.0",
"resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.22.0.tgz",
"integrity": "sha512-l8yD/2zRbZItUQpy7ZxBJwaLX/Bs2TGaCthRppk8Sw24LOIWg12t9JEreezPoYD0SQcC2htNNo27kYEpYW/Srg==",
"engines": {
"node": ">=12"
}
},
"node_modules/discord.js/node_modules/node-fetch": { "node_modules/discord.js/node_modules/node-fetch": {
"version": "2.6.2", "version": "2.6.2",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.2.tgz", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.2.tgz",
@ -2897,9 +2929,9 @@
} }
}, },
"node_modules/prettier": { "node_modules/prettier": {
"version": "2.3.2", "version": "2.4.0",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.3.2.tgz", "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.4.0.tgz",
"integrity": "sha512-lnJzDfJ66zkMy58OL5/NY5zp70S7Nz6KqcKkXYzn2tMVrNxvbqaBpg7H3qHaLxCJ5lNMsGuM8+ohS7cZrthdLQ==", "integrity": "sha512-DsEPLY1dE5HF3BxCRBmD4uYZ+5DCbvatnolqTqcxEgKVZnL2kUfyu7b8pPQ5+hTBkdhU9SLUmK0/pHb07RE4WQ==",
"dev": true, "dev": true,
"bin": { "bin": {
"prettier": "bin-prettier.js" "prettier": "bin-prettier.js"
@ -3943,9 +3975,9 @@
} }
}, },
"node_modules/ws": { "node_modules/ws": {
"version": "7.5.4", "version": "7.5.5",
"resolved": "https://registry.npmjs.org/ws/-/ws-7.5.4.tgz", "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.5.tgz",
"integrity": "sha512-zP9z6GXm6zC27YtspwH99T3qTG7bBFv2VIkeHstMLrLlDJuzA7tQ5ls3OJ1hOGGCzTQPniNJoHXIAOS0Jljohg==", "integrity": "sha512-BAkMFcAzl8as1G/hArkxOxq3G7pjUqQ3gzYbLL0/5zNkph70e+lCoxBGnm6AW1+/aiNeV4fnKqZ8m4GZewmH2w==",
"engines": { "engines": {
"node": ">=8.3.0" "node": ">=8.3.0"
}, },
@ -4096,6 +4128,13 @@
"ow": "^0.27.0", "ow": "^0.27.0",
"ts-mixer": "^6.0.0", "ts-mixer": "^6.0.0",
"tslib": "^2.3.1" "tslib": "^2.3.1"
},
"dependencies": {
"discord-api-types": {
"version": "0.22.0",
"resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.22.0.tgz",
"integrity": "sha512-l8yD/2zRbZItUQpy7ZxBJwaLX/Bs2TGaCthRppk8Sw24LOIWg12t9JEreezPoYD0SQcC2htNNo27kYEpYW/Srg=="
}
} }
}, },
"@discordjs/collection": { "@discordjs/collection": {
@ -4160,6 +4199,11 @@
"tslib": "^2.3.0" "tslib": "^2.3.0"
}, },
"dependencies": { "dependencies": {
"discord-api-types": {
"version": "0.22.0",
"resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.22.0.tgz",
"integrity": "sha512-l8yD/2zRbZItUQpy7ZxBJwaLX/Bs2TGaCthRppk8Sw24LOIWg12t9JEreezPoYD0SQcC2htNNo27kYEpYW/Srg=="
},
"node-fetch": { "node-fetch": {
"version": "2.6.2", "version": "2.6.2",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.2.tgz", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.2.tgz",
@ -4190,6 +4234,11 @@
"node-addon-api": "^3.2.1" "node-addon-api": "^3.2.1"
} }
}, },
"discord-api-types": {
"version": "0.22.0",
"resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.22.0.tgz",
"integrity": "sha512-l8yD/2zRbZItUQpy7ZxBJwaLX/Bs2TGaCthRppk8Sw24LOIWg12t9JEreezPoYD0SQcC2htNNo27kYEpYW/Srg=="
},
"node-addon-api": { "node-addon-api": {
"version": "3.2.1", "version": "3.2.1",
"resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-3.2.1.tgz", "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-3.2.1.tgz",
@ -4320,9 +4369,9 @@
"dev": true "dev": true
}, },
"@types/node": { "@types/node": {
"version": "16.7.13", "version": "16.9.0",
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.7.13.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-16.9.0.tgz",
"integrity": "sha512-pLUPDn+YG3FYEt/pHI74HmnJOWzeR+tOIQzUx93pi9M7D8OE7PSLr97HboXwk5F+JS+TLtWuzCOW97AHjmOXXA==" "integrity": "sha512-nmP+VR4oT0pJUPFbKE4SXj3Yb4Q/kz3M9dSAO1GGMebRKWHQxLfDNmU/yh3xxCJha3N60nQ/JwXWwOE/ZSEVag=="
}, },
"@types/ws": { "@types/ws": {
"version": "7.4.7", "version": "7.4.7",
@ -4918,9 +4967,9 @@
} }
}, },
"discord-api-types": { "discord-api-types": {
"version": "0.22.0", "version": "0.23.1",
"resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.22.0.tgz", "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.23.1.tgz",
"integrity": "sha512-l8yD/2zRbZItUQpy7ZxBJwaLX/Bs2TGaCthRppk8Sw24LOIWg12t9JEreezPoYD0SQcC2htNNo27kYEpYW/Srg==" "integrity": "sha512-igWmn+45mzXRWNEPU25I/pr8MwxHb767wAr51oy3VRLRcTlp5ADBbrBR0lq3SA1Rfw3MtM4TQu1xo3kxscfVdQ=="
}, },
"discord.js": { "discord.js": {
"version": "13.1.0", "version": "13.1.0",
@ -4949,6 +4998,11 @@
"tslib": "^2.3.0" "tslib": "^2.3.0"
} }
}, },
"discord-api-types": {
"version": "0.22.0",
"resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.22.0.tgz",
"integrity": "sha512-l8yD/2zRbZItUQpy7ZxBJwaLX/Bs2TGaCthRppk8Sw24LOIWg12t9JEreezPoYD0SQcC2htNNo27kYEpYW/Srg=="
},
"node-fetch": { "node-fetch": {
"version": "2.6.2", "version": "2.6.2",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.2.tgz", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.2.tgz",
@ -6123,9 +6177,9 @@
"dev": true "dev": true
}, },
"prettier": { "prettier": {
"version": "2.3.2", "version": "2.4.0",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.3.2.tgz", "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.4.0.tgz",
"integrity": "sha512-lnJzDfJ66zkMy58OL5/NY5zp70S7Nz6KqcKkXYzn2tMVrNxvbqaBpg7H3qHaLxCJ5lNMsGuM8+ohS7cZrthdLQ==", "integrity": "sha512-DsEPLY1dE5HF3BxCRBmD4uYZ+5DCbvatnolqTqcxEgKVZnL2kUfyu7b8pPQ5+hTBkdhU9SLUmK0/pHb07RE4WQ==",
"dev": true "dev": true
}, },
"prettier-linter-helpers": { "prettier-linter-helpers": {
@ -6890,9 +6944,9 @@
} }
}, },
"ws": { "ws": {
"version": "7.5.4", "version": "7.5.5",
"resolved": "https://registry.npmjs.org/ws/-/ws-7.5.4.tgz", "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.5.tgz",
"integrity": "sha512-zP9z6GXm6zC27YtspwH99T3qTG7bBFv2VIkeHstMLrLlDJuzA7tQ5ls3OJ1hOGGCzTQPniNJoHXIAOS0Jljohg==", "integrity": "sha512-BAkMFcAzl8as1G/hArkxOxq3G7pjUqQ3gzYbLL0/5zNkph70e+lCoxBGnm6AW1+/aiNeV4fnKqZ8m4GZewmH2w==",
"requires": {} "requires": {}
}, },
"xdg-basedir": { "xdg-basedir": {

View File

@ -22,7 +22,7 @@
"@discordjs/opus": "^0.6.0", "@discordjs/opus": "^0.6.0",
"@discordjs/rest": "^0.1.1-canary.0", "@discordjs/rest": "^0.1.1-canary.0",
"@discordjs/voice": "^0.6.0", "@discordjs/voice": "^0.6.0",
"discord-api-types": "^0.22.0", "discord-api-types": "^0.23.1",
"discord.js": "^13.1.0", "discord.js": "^13.1.0",
"dotenv": "^10.0.0", "dotenv": "^10.0.0",
"libsodium-wrappers": "^0.7.9", "libsodium-wrappers": "^0.7.9",
@ -30,7 +30,7 @@
"path": "^0.12.7" "path": "^0.12.7"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^16.7.13", "@types/node": "^16.9.0",
"@types/ws": "^7.4.7", "@types/ws": "^7.4.7",
"@typescript-eslint/eslint-plugin": "^4.31.0", "@typescript-eslint/eslint-plugin": "^4.31.0",
"@typescript-eslint/parser": "^4.31.0", "@typescript-eslint/parser": "^4.31.0",
@ -48,4 +48,4 @@
"node": ">=16.8.0", "node": ">=16.8.0",
"npm": ">=7.0.0" "npm": ">=7.0.0"
} }
} }

View File

@ -73,11 +73,11 @@ class RadioClient extends Client {
this.on("interactionCreate", interaction => { this.on("interactionCreate", interaction => {
require(`${events}interactionCreate`).execute(this, interaction); require(`${events}interactionCreate`).execute(this, interaction);
}); });
this.on("voiceStateUpdate", (oldState, newState) => { this.on("voiceStateUpdate", (oldState, newState) => {
require(`${events}voiceStateUpdate`).execute(this, oldState, newState); require(`${events}voiceStateUpdate`).execute(this, oldState, newState);
}); });
process.on('SIGINT', () => { process.on('SIGINT', () => {
require(`${events}SIGINT`).execute(this); require(`${events}SIGINT`).execute(this);
}); });
@ -89,7 +89,11 @@ class RadioClient extends Client {
process.on('uncaughtException', (error) => { process.on('uncaughtException', (error) => {
require(`${events}uncaughtException`).execute(this, error); require(`${events}uncaughtException`).execute(this, error);
}); });
process.on('exit', () => {
this.funcs.logger("Bot", "Stopping");
});
this.on("error", error => { this.on("error", error => {
console.error(error); console.error(error);
}); });
@ -98,4 +102,4 @@ class RadioClient extends Client {
} }
} }
export default RadioClient export default RadioClient

View File

@ -15,7 +15,7 @@ module.exports = {
command.data = new SlashCommandBuilder() command.data = new SlashCommandBuilder()
.setName(command.name) .setName(command.name)
.setDescription(command.description); .setDescription(command.description);
command.data = command.data.toJSON(); command.data = command.data.toJSON();
if(command.options) { if(command.options) {
command.options.forEach(function(option) { command.options.forEach(function(option) {
@ -67,4 +67,4 @@ module.exports = {
} }
})(); })();
} }
} }

View File

@ -23,4 +23,4 @@ module.exports = {
ephemeral: true ephemeral: true
}); });
} }
}; };

View File

@ -26,7 +26,7 @@ module.exports = {
.setDescription(message.helpDescription) .setDescription(message.helpDescription)
.setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png') .setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png')
.setFooter(client.messages.footerText, "https://cdn.discordapp.com/emojis/" + client.messageEmojis["eximiabots"].replace(/[^0-9]+/g, '')); .setFooter(client.messages.footerText, "https://cdn.discordapp.com/emojis/" + client.messageEmojis["eximiabots"].replace(/[^0-9]+/g, ''));
interaction.reply({ interaction.reply({
embeds: [embed], embeds: [embed],
ephemeral: true ephemeral: true

View File

@ -19,4 +19,4 @@ module.exports = {
ephemeral: true ephemeral: true
}); });
} }
}; };

View File

@ -13,9 +13,9 @@ module.exports = {
ephemeral: true ephemeral: true
}); });
} }
const radio = client.radio.get(interaction.guild.id); const radio = client.radio.get(interaction.guild.id);
if(radio){ if(radio){
client.funcs.listStations(client, interaction); client.funcs.listStations(client, interaction);
} else { } else {
@ -39,4 +39,4 @@ module.exports = {
}); });
} }
} }
}; };

View File

@ -61,7 +61,7 @@ module.exports = {
value: "9" value: "9"
} }
); );
const menu = new Discord.MessageActionRow() const menu = new Discord.MessageActionRow()
.addComponents( .addComponents(
new Discord.MessageSelectMenu() new Discord.MessageSelectMenu()
@ -85,7 +85,7 @@ module.exports = {
.setColor(client.config.embedColor) .setColor(client.config.embedColor)
.setDescription(options.find(option => option.value == action).label) .setDescription(options.find(option => option.value == action).label)
.setFooter(client.messages.footerText, "https://cdn.discordapp.com/emojis/" + client.messageEmojis["eximiabots"].replace(/[^0-9]+/g, '')); .setFooter(client.messages.footerText, "https://cdn.discordapp.com/emojis/" + client.messageEmojis["eximiabots"].replace(/[^0-9]+/g, ''));
interaction.reply({ interaction.reply({
embeds: [embed], embeds: [embed],
ephemeral: true ephemeral: true
@ -117,7 +117,7 @@ module.exports = {
client.stations = await fetch(client.config.stationslistUrl) client.stations = await fetch(client.config.stationslistUrl)
.then(client.funcs.checkFetchStatus) .then(client.funcs.checkFetchStatus)
.then(response => response.json()); .then(response => response.json());
client.funcs.logger('Stations', 'Successfully fetched list'); client.funcs.logger('Stations', 'Successfully fetched list');
} catch (error) { } catch (error) {
client.funcs.logger('Stations', 'Fetching list failed'); client.funcs.logger('Stations', 'Fetching list failed');
@ -133,46 +133,5 @@ module.exports = {
} }
/*
if(!client.stations) {
message.errorToGetPlaylist = client.messages.errorToGetPlaylist.replace("%client.config.supportGuild%", client.config.supportGuild);
return interaction.reply(client.messageEmojis["error"] + message.errorToGetPlaylist);
}
let currentRadios = client.radio.keys();
let radio = currentRadios.next();
let stoppedRadios = "";
client.user.setStatus('dnd');
while (!radio.done) {
let currentRadio = client.radio.get(radio.value);
currentRadio.guild = client.datastore.getEntry(radio.value).guild;
if(currentRadio){
client.funcs.statisticsUpdate(client, currentRadio.guild, currentRadio);
currentRadio.connection?.destroy();
currentRadio.audioPlayer?.stop();
currentRadio.message?.delete();
client.radio.delete(radio.value);
stoppedRadios += "-" + radio.value + ": " + currentRadio.guild.name + "\n";
}
radio = currentRadios.next();
}
const embed = new Discord.MessageEmbed()
.setTitle(client.messages.maintenanceTitle)
.setThumbnail("https://cdn.discordapp.com/emojis/" + client.messageEmojis["maintenance"].replace(/[^0-9]+/g, ''))
.setColor(client.config.embedColor)
.setDescription("Stopped all radios" + "\n" + stoppedRadios)
.setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png')
.setFooter(client.messages.footerText, "https://cdn.discordapp.com/emojis/" + client.messageEmojis["eximiabots"].replace(/[^0-9]+/g, ''));
interaction.reply({
embeds: [embed],
ephemeral: true
});*/
} }
}; };

View File

@ -5,7 +5,7 @@ module.exports = {
async execute(interaction, client, command) { async execute(interaction, client, command) {
if (client.funcs.check(client, interaction, command)) { if (client.funcs.check(client, interaction, command)) {
const radio = client.radio.get(interaction.guild.id); const radio = client.radio.get(interaction.guild.id);
let index = client.stations.findIndex(station => station.name == radio.station.name) + 1; let index = client.stations.findIndex(station => station.name == radio.station.name) + 1;
if(index == client.stations.length) index = 0; if(index == client.stations.length) index = 0;
@ -20,7 +20,7 @@ module.exports = {
client.funcs.statisticsUpdate(client, interaction.guild, radio); client.funcs.statisticsUpdate(client, interaction.guild, radio);
radio.audioPlayer.stop(); radio.audioPlayer.stop();
let date = new Date(); let date = new Date();
radio.station = station; radio.station = station;
radio.textChannel = interaction.channel; radio.textChannel = interaction.channel;
@ -36,4 +36,4 @@ module.exports = {
} }
} }
} }

View File

@ -25,11 +25,11 @@ module.exports = {
.setDescription(message.nowplayingDescription) .setDescription(message.nowplayingDescription)
.setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png') .setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png')
.setFooter(client.messages.footerText, "https://cdn.discordapp.com/emojis/" + client.messageEmojis["eximiabots"].replace(/[^0-9]+/g, '')); .setFooter(client.messages.footerText, "https://cdn.discordapp.com/emojis/" + client.messageEmojis["eximiabots"].replace(/[^0-9]+/g, ''));
interaction.reply({ interaction.reply({
embeds: [embed], embeds: [embed],
ephemeral: true ephemeral: true
}); });
} }
} }
}; };

View File

@ -90,7 +90,7 @@ module.exports = {
if (radio) { if (radio) {
client.funcs.statisticsUpdate(client, interaction.guild, radio); client.funcs.statisticsUpdate(client, interaction.guild, radio);
radio.audioPlayer.stop(); radio.audioPlayer.stop();
let date = new Date(); let date = new Date();
radio.station = station; radio.station = station;
radio.textChannel = interaction.channel; radio.textChannel = interaction.channel;
@ -141,4 +141,4 @@ module.exports = {
}); });
} }
} }
}; };

View File

@ -20,12 +20,12 @@ module.exports = {
client.funcs.statisticsUpdate(client, interaction.guild, radio); client.funcs.statisticsUpdate(client, interaction.guild, radio);
radio.audioPlayer.stop(); radio.audioPlayer.stop();
let date = new Date(); let date = new Date();
radio.station = station; radio.station = station;
radio.textChannel = interaction.channel; radio.textChannel = interaction.channel;
radio.startTime = date.getTime(); radio.startTime = date.getTime();
if(interaction.isCommand()) { if(interaction.isCommand()) {
client.funcs.play(interaction, interaction.guild, client, url); client.funcs.play(interaction, interaction.guild, client, url);
} }
@ -36,4 +36,4 @@ module.exports = {
} }
} }
} }

View File

@ -11,7 +11,7 @@ module.exports = {
let currentGuild = client.datastore.getEntry(interaction.guild.id); let currentGuild = client.datastore.getEntry(interaction.guild.id);
let global = client.datastore.getEntry("global"); let global = client.datastore.getEntry("global");
let statistics = ""; let statistics = "";
if(!client.stations) { if(!client.stations) {
message.errorToGetPlaylist = client.messages.errorToGetPlaylist.replace("%client.config.supportGuild%", client.config.supportGuild); message.errorToGetPlaylist = client.messages.errorToGetPlaylist.replace("%client.config.supportGuild%", client.config.supportGuild);
return interaction.reply({ return interaction.reply({
@ -35,7 +35,7 @@ module.exports = {
} }
}); });
} }
const embed = new Discord.MessageEmbed() const embed = new Discord.MessageEmbed()
.setTitle(client.messages.statisticsTitle) .setTitle(client.messages.statisticsTitle)
.setThumbnail("https://cdn.discordapp.com/emojis/" + client.messageEmojis["statistics"].replace(/[^0-9]+/g, '')) .setThumbnail("https://cdn.discordapp.com/emojis/" + client.messageEmojis["statistics"].replace(/[^0-9]+/g, ''))
@ -49,4 +49,4 @@ module.exports = {
ephemeral: true ephemeral: true
}); });
} }
}; };

View File

@ -28,4 +28,4 @@ module.exports = {
}); });
} }
}; };

View File

@ -38,4 +38,4 @@ module.exports = {
}); });
} }
} }
}; };

View File

@ -6,7 +6,7 @@ module.exports = class {
this.map = new Map(); this.map = new Map();
this.loadData(); this.loadData();
} }
loadData() { loadData() {
const dir = path.join(path.dirname(__dirname), '../datastore'); const dir = path.join(path.dirname(__dirname), '../datastore');
if (!fs.existsSync(dir)) { if (!fs.existsSync(dir)) {
@ -33,7 +33,7 @@ module.exports = class {
var statistics = {}; var statistics = {};
if(!client.stations) return; if(!client.stations) return;
let calculation = guilds.next(); let calculation = guilds.next();
while (!calculation.done) { while (!calculation.done) {
@ -47,7 +47,7 @@ module.exports = class {
statistics[stations[station].name].time = 0; statistics[stations[station].name].time = 0;
statistics[stations[station].name].used = 0; statistics[stations[station].name].used = 0;
} }
statistics[stations[station].name].time = parseInt(statistics[stations[station].name].time)+parseInt(currentGuild.statistics[stations[station].name].time); statistics[stations[station].name].time = parseInt(statistics[stations[station].name].time)+parseInt(currentGuild.statistics[stations[station].name].time);
statistics[stations[station].name].used = parseInt(statistics[stations[station].name].used)+parseInt(currentGuild.statistics[stations[station].name].used); statistics[stations[station].name].used = parseInt(statistics[stations[station].name].used)+parseInt(currentGuild.statistics[stations[station].name].used);
} }
@ -84,26 +84,26 @@ module.exports = class {
this.map.set(id, newData); this.map.set(id, newData);
this.saveEntry(id, newData); this.saveEntry(id, newData);
} }
getEntry(id){ getEntry(id){
return this.map.get(id); return this.map.get(id);
} }
updateEntry(guild, newData) { updateEntry(guild, newData) {
newData.guild.name = guild.name; newData.guild.name = guild.name;
let date = new Date(); let date = new Date();
newData.updated = date.toISOString().substring(0, 10) newData.updated = date.toISOString().substring(0, 10)
this.map.set(guild.id, newData); this.map.set(guild.id, newData);
this.saveEntry(guild.id, newData); this.saveEntry(guild.id, newData);
//this.showEntry(this.getEntry(guild.id)); //this.showEntry(this.getEntry(guild.id));
} }
showEntry(data){ showEntry(data){
console.log(data); console.log(data);
} }
createTestFile () { createTestFile () {
let newData = { let newData = {
"guild": { "guild": {
@ -120,10 +120,10 @@ module.exports = class {
} }
} }
this.updateEntry(newData.guild, newData); this.updateEntry(newData.guild, newData);
} }
saveEntry(file, data) { saveEntry(file, data) {
data = JSON.stringify(data, null, 4); data = JSON.stringify(data, null, 4);

View File

@ -39,4 +39,4 @@ module.exports = {
} }
} }
} }
} }

View File

@ -3,16 +3,12 @@ module.exports = {
execute(client) { execute(client) {
client.user.setStatus('dnd'); client.user.setStatus('dnd');
console.log("\n");
client.funcs.logger("Bot", "Closing");
console.log("\n");
client.funcs.saveRadios(client); client.funcs.saveRadios(client);
setInterval(() => { setInterval(() => {
if(client.radio.size == 0){ if(client.radio.size == 0){
process.exit(); process.exit();
} }
}, 500); }, 500);
} }
} }

View File

@ -3,4 +3,4 @@ module.exports = {
execute(client) { execute(client) {
process.emit('SIGINT'); process.emit('SIGINT');
} }
} }

View File

@ -4,7 +4,7 @@ module.exports = {
const permissions = interaction.channel.permissionsFor(interaction.client.user); const permissions = interaction.channel.permissionsFor(interaction.client.user);
if (!permissions.has('VIEW_CHANNEL')) return; if (!permissions.has('VIEW_CHANNEL')) return;
if (!permissions.has('EMBED_LINKS')) return interaction.reply({ if (!permissions.has('EMBED_LINKS')) return interaction.reply({
content: client.messages.noPermsEmbed, content: client.messages.noPermsEmbed,
ephemeral: true ephemeral: true
@ -14,7 +14,7 @@ module.exports = {
const commandName = interaction.commandName; const commandName = interaction.commandName;
const command = client.commands.get(commandName); const command = client.commands.get(commandName);
if (!command) return; if (!command) return;
try { try {
command.execute(interaction, client); command.execute(interaction, client);
} catch (error) { } catch (error) {

View File

@ -16,7 +16,7 @@ module.exports = {
} else { } else {
return; return;
} }
const args = message.content.slice(prefix.length).split(' '); const args = message.content.slice(prefix.length).split(' ');
if (!message.content.startsWith(prefix)) return; if (!message.content.startsWith(prefix)) return;
if (!args[0]) return; if (!args[0]) return;
@ -30,7 +30,7 @@ module.exports = {
let newMessage = {}; let newMessage = {};
newMessage.messageCommandsDeprecatedTitle = client.messages.messageCommandsDeprecatedTitle.replace("%client.user.username%", client.user.username); newMessage.messageCommandsDeprecatedTitle = client.messages.messageCommandsDeprecatedTitle.replace("%client.user.username%", client.user.username);
const embed = new Discord.MessageEmbed() const embed = new Discord.MessageEmbed()
.setTitle(newMessage.messageCommandsDeprecatedTitle) .setTitle(newMessage.messageCommandsDeprecatedTitle)
.setThumbnail("https://cdn.discordapp.com/emojis/" + client.messageEmojis["logo"].replace(/[^0-9]+/g, '')) .setThumbnail("https://cdn.discordapp.com/emojis/" + client.messageEmojis["logo"].replace(/[^0-9]+/g, ''))
@ -55,4 +55,4 @@ module.exports = {
console.error(error); console.error(error);
} }
} }
} }

View File

@ -7,4 +7,4 @@ module.exports = {
if(msg.id != radio.message.id) return; if(msg.id != radio.message.id) return;
radio.message = null; radio.message = null;
} }
} }

View File

@ -22,7 +22,7 @@ module.exports = {
/*DEVELOPERS*/ /*DEVELOPERS*/
client.funcs.logger('Developers'); client.funcs.logger('Developers');
client.developers = ""; client.developers = "";
let user = ""; let user = "";
for (let i = 0; i < client.config.devId.length; i++) { for (let i = 0; i < client.config.devId.length; i++) {
@ -54,7 +54,7 @@ module.exports = {
client.funcs.logger('Stations', 'Fetching list failed'); client.funcs.logger('Stations', 'Fetching list failed');
console.error(error + "\n"); console.error(error + "\n");
} }
setInterval(async () => { setInterval(async () => {
try { try {
client.funcs.logger('Stations', 'Started fetching list ' + client.config.stationslistUrl); client.funcs.logger('Stations', 'Started fetching list ' + client.config.stationslistUrl);
@ -72,7 +72,7 @@ module.exports = {
if(!client.stations) { if(!client.stations) {
client.user.setStatus('dnd'); client.user.setStatus('dnd');
} }
/*GUILDS*/ /*GUILDS*/
client.funcs.logger('Guilds', 'Started fetching list'); client.funcs.logger('Guilds', 'Started fetching list');
@ -84,7 +84,7 @@ module.exports = {
console.log("\n"); console.log("\n");
client.funcs.logger('Guilds', 'Successfully fetched list'); client.funcs.logger('Guilds', 'Successfully fetched list');
/*STATISTICS*/ /*STATISTICS*/
client.datastore.calculateGlobal(client); client.datastore.calculateGlobal(client);
@ -100,4 +100,4 @@ module.exports = {
}, 5000); }, 5000);
} }
} }

View File

@ -4,4 +4,4 @@ module.exports = {
console.log(error.stack); console.log(error.stack);
process.emit('SIGINT'); process.emit('SIGINT');
} }
} }

View File

@ -4,4 +4,4 @@ module.exports = function (response) {
} else { } else {
throw new Error(response.status + " " + response.statusText); throw new Error(response.status + " " + response.statusText);
} }
} }

View File

@ -7,4 +7,4 @@ module.exports = function (devList, authorID){
} }
}); });
return response; return response;
} }

View File

@ -30,4 +30,4 @@ module.exports = function (client, interaction){
components: [menu], components: [menu],
ephemeral: true ephemeral: true
}); });
} }

View File

@ -7,4 +7,4 @@ module.exports = function loadState(client, guild){
data.state = {}; data.state = {};
client.datastore.updateEntry(guild, data); client.datastore.updateEntry(guild, data);
return state; return state;
} }

View File

@ -2,4 +2,4 @@ module.exports = function (area, text){
let date = new Date(); let date = new Date();
console.log('[' + area + '] ' + date.toISOString()); console.log('[' + area + '] ' + date.toISOString());
if(text) console.log(text + '\n'); if(text) console.log(text + '\n');
} }

View File

@ -9,4 +9,4 @@ module.exports = function msToTime(duration) {
: +hours > 0 : +hours > 0
? `${+hours < 10 ? `0${hours}` : hours}:${+minutes < 10 ? `0${minutes}` : minutes}:${+seconds < 10 ? `0${seconds}` : seconds}` ? `${+hours < 10 ? `0${hours}` : hours}:${+minutes < 10 ? `0${minutes}` : minutes}:${+seconds < 10 ? `0${seconds}` : seconds}`
: `${+minutes < 10 ? `0${minutes}` : minutes}:${+seconds < 10 ? `0${seconds}` : seconds}`; : `${+minutes < 10 ? `0${minutes}` : minutes}:${+seconds < 10 ? `0${seconds}` : seconds}`;
} }

View File

@ -47,7 +47,7 @@ module.exports = async function play(interaction, guild, client, url) {
.addField(client.messages.nowplayingTitle, message.nowplayingDescription, true) .addField(client.messages.nowplayingTitle, message.nowplayingDescription, true)
.setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png') .setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png')
.setFooter(client.messages.footerText, "https://cdn.discordapp.com/emojis/" + client.messageEmojis["eximiabots"].replace(/[^0-9]+/g, '')); .setFooter(client.messages.footerText, "https://cdn.discordapp.com/emojis/" + client.messageEmojis["eximiabots"].replace(/[^0-9]+/g, ''));
const buttons = new Discord.MessageActionRow() const buttons = new Discord.MessageActionRow()
.addComponents( .addComponents(
new Discord.MessageButton() new Discord.MessageButton()
@ -87,10 +87,10 @@ module.exports = async function play(interaction, guild, client, url) {
} }
message.play = client.messages.play.replace("%radio.station.name%", radio.station.name); message.play = client.messages.play.replace("%radio.station.name%", radio.station.name);
interaction?.reply({ interaction?.reply({
content: client.messageEmojis["play"] + message.play, content: client.messageEmojis["play"] + message.play,
ephemeral: true ephemeral: true
}); });
} }

View File

@ -43,7 +43,7 @@ module.exports = async function restoreRadios(client, guilds) {
construct.connection = connection; construct.connection = connection;
let date = new Date(); let date = new Date();
construct.startTime = date.getTime(); construct.startTime = date.getTime();
client.funcs.play(null, guild, client, url, Discord); client.funcs.play(null, guild, client, url, Discord);
client.datastore.checkEntry(guild.id); client.datastore.checkEntry(guild.id);
@ -59,4 +59,4 @@ module.exports = async function restoreRadios(client, guilds) {
console.log(error); console.log(error);
} }
}); });
} }

View File

@ -1,11 +1,11 @@
module.exports = function saveRadios(client) { module.exports = function saveRadios(client) {
let currentRadios = client.radio.keys(); let currentRadios = client.radio.keys();
let radio = currentRadios.next(); let radio = currentRadios.next();
while (!radio.done) { while (!radio.done) {
let currentRadio = client.radio.get(radio.value); let currentRadio = client.radio.get(radio.value);
currentRadio.guild = client.datastore.getEntry(radio.value).guild; currentRadio.guild = client.datastore.getEntry(radio.value).guild;
if (currentRadio) { if (currentRadio) {
client.funcs.statisticsUpdate(client, currentRadio.guild, currentRadio); client.funcs.statisticsUpdate(client, currentRadio.guild, currentRadio);
client.funcs.saveState(client, currentRadio.guild, currentRadio); client.funcs.saveState(client, currentRadio.guild, currentRadio);
@ -14,7 +14,7 @@ module.exports = function saveRadios(client) {
currentRadio.message?.delete(); currentRadio.message?.delete();
client.radio.delete(radio.value); client.radio.delete(radio.value);
} }
radio = currentRadios.next(); radio = currentRadios.next();
} }
} }

View File

@ -1,6 +1,6 @@
module.exports = function saveState(client, guild, radio){ module.exports = function saveState(client, guild, radio){
client.datastore.checkEntry(guild.id); client.datastore.checkEntry(guild.id);
let date = new Date(); let date = new Date();
let data = client.datastore.getEntry(guild.id); let data = client.datastore.getEntry(guild.id);
@ -15,4 +15,4 @@ module.exports = function saveState(client, guild, radio){
data.state.station.owner = radio.station.owner; data.state.station.owner = radio.station.owner;
client.datastore.updateEntry(guild, data); client.datastore.updateEntry(guild, data);
} }

View File

@ -59,4 +59,4 @@ module.exports = function searchStation(key, client) {
} }
} }
return highestProbabilityStation; return highestProbabilityStation;
} }

View File

@ -1,22 +1,22 @@
module.exports = function statisticsUpdate(client, guild, radio) { module.exports = function statisticsUpdate(client, guild, radio) {
client.datastore.checkEntry(guild.id); client.datastore.checkEntry(guild.id);
radio.datastore = client.datastore.getEntry(guild.id); radio.datastore = client.datastore.getEntry(guild.id);
if(!radio.datastore.statistics[radio.station.name]){ if(!radio.datastore.statistics[radio.station.name]){
radio.datastore.statistics[radio.station.name] = {}; radio.datastore.statistics[radio.station.name] = {};
radio.datastore.statistics[radio.station.name].time = 0; radio.datastore.statistics[radio.station.name].time = 0;
radio.datastore.statistics[radio.station.name].used = 0; radio.datastore.statistics[radio.station.name].used = 0;
client.datastore.updateEntry(guild, radio.datastore); client.datastore.updateEntry(guild, radio.datastore);
} }
let date = new Date(); let date = new Date();
radio.currentTime = date.getTime(); radio.currentTime = date.getTime();
radio.playTime = parseInt(radio.currentTime)-parseInt(radio.startTime); radio.playTime = parseInt(radio.currentTime)-parseInt(radio.startTime);
radio.datastore.statistics[radio.station.name].time = parseInt(radio.datastore.statistics[radio.station.name].time)+parseInt(radio.playTime); radio.datastore.statistics[radio.station.name].time = parseInt(radio.datastore.statistics[radio.station.name].time)+parseInt(radio.playTime);
radio.datastore.statistics[radio.station.name].used = parseInt(radio.datastore.statistics[radio.station.name].used)+1; radio.datastore.statistics[radio.station.name].used = parseInt(radio.datastore.statistics[radio.station.name].used)+1;
client.datastore.updateEntry(guild, radio.datastore); client.datastore.updateEntry(guild, radio.datastore);
client.datastore.calculateGlobal(client); client.datastore.calculateGlobal(client);
} }

View File

@ -37,4 +37,4 @@ module.exports = {
errorStationURL: "Station can't be URL", errorStationURL: "Station can't be URL",
messageCommandsDeprecatedTitle: "%client.user.username%", messageCommandsDeprecatedTitle: "%client.user.username%",
messageCommandsDeprecatedDescription: "We recommend you to reauthorize our bot by clicking the invite link down below, because Discord is planning to remove message content from verified bots [Read More](https://support-dev.discord.com/hc/en-us/articles/4404772028055)" + "\n\n" + "**Invite Bot**" + "\n" + "https://wgi.fi/radiox_invite" + "\n\n" + "This bot now supports slash commands, you should start using them instead. Type / into the message box and select the bot you wish to use. Remember to be careful as there are a few bugs here and there on Discord." + "\n\n" + "We will remove this deprecation message in March of 2022 when RadioX 1.0.0 is released." messageCommandsDeprecatedDescription: "We recommend you to reauthorize our bot by clicking the invite link down below, because Discord is planning to remove message content from verified bots [Read More](https://support-dev.discord.com/hc/en-us/articles/4404772028055)" + "\n\n" + "**Invite Bot**" + "\n" + "https://wgi.fi/radiox_invite" + "\n\n" + "This bot now supports slash commands, you should start using them instead. Type / into the message box and select the bot you wish to use. Remember to be careful as there are a few bugs here and there on Discord." + "\n\n" + "We will remove this deprecation message in March of 2022 when RadioX 1.0.0 is released."
}; };

View File

@ -1,3 +1,3 @@
export interface command { } export interface command { }
export interface radio {} export interface radio {}

View File

@ -23,4 +23,4 @@ module.exports = {
version: process.env.RADIOX_VERSION || process.env.npm_package_version, version: process.env.RADIOX_VERSION || process.env.npm_package_version,
debug: process.env.DEBUG_MODE || false debug: process.env.DEBUG_MODE || false
} }