Compare commits

..

No commits in common. "master" and "0.5.3" have entirely different histories.

37 changed files with 3285 additions and 1262 deletions

View File

@ -1,5 +1,5 @@
DISCORD_TOKEN= DISCORD_TOKEN=
RADIOX_STATIONSLISTURL=https://eximiabots.waren.io/radiox/stations.json RADIOX_STATIONSLISTURL=https://git.cwinfo.net/cwchristerw/radio/raw/branch/master/playlist.json
DEV_MODE=false DEV_MODE=false
DEBUG_MODE=false DEBUG_MODE=false
STREAMER_MODE=manual STREAMER_MODE=manual

4
.github/labeler.yml vendored
View File

@ -1,11 +1,7 @@
dependencies: dependencies:
- changed-files:
- any-glob-to-any-file:
- package-lock.json - package-lock.json
documentation: documentation:
- changed-files:
- any-glob-to-any-file:
- README.md - README.md
- SECURITY.md - SECURITY.md
- CONTRIBUTING.md - CONTRIBUTING.md

View File

@ -43,7 +43,7 @@ jobs:
# Initializes the CodeQL tools for scanning. # Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL - name: Initialize CodeQL
uses: github/codeql-action/init@v3 uses: github/codeql-action/init@v2
with: with:
languages: ${{ matrix.language }} languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file. # If you wish to specify custom queries, you can do so here or in a config file.
@ -54,7 +54,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below) # If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild - name: Autobuild
uses: github/codeql-action/autobuild@v3 uses: github/codeql-action/autobuild@v2
# Command-line programs to run using the OS shell. # Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl # 📚 https://git.io/JvXDl
@ -68,4 +68,4 @@ jobs:
# make release # make release
- name: Perform CodeQL Analysis - name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3 uses: github/codeql-action/analyze@v2

View File

@ -14,7 +14,7 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Setup Docker Buildx - name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3.9.0 uses: docker/setup-buildx-action@v3.0.0
id: buildx id: buildx
with: with:
install: true install: true

View File

@ -11,7 +11,7 @@ jobs:
pull-requests: write pull-requests: write
steps: steps:
- uses: actions/labeler@v5 - uses: actions/labeler@v4
with: with:
repo-token: "${{ secrets.GITHUB_TOKEN }}" repo-token: "${{ secrets.GITHUB_TOKEN }}"
sync-labels: true sync-labels: true

View File

@ -1,644 +0,0 @@
# CHANGELOG
## 0.5.9 (23.2.2025)
Patch Release
- Updating code, because Discord.js has deprecated few options previously used.
**Package**
- Dependencies Update
**Contributors:**
[cwchristerw](<https://github.com/cwchristerw>)
## 0.5.8 (30.9.2024)
Patch Release
**Package**
- Dependencies Update
**Documentation**
- Update radio stations list address and repo in README.md
- Fix versions 0.5.5-0.5.7 release years in CHANGELOG.md
**Contributors:**
[cwchristerw](<https://github.com/cwchristerw>)
## 0.5.7 (19.6.2024)
Patch Release
**Package**
- Dependencies Update
**Contributors:**
[cwchristerw](<https://github.com/cwchristerw>)
## 0.5.6 (8.6.2024)
Patch Release
**Package**
- Dependencies Update
**Documentation**
- Add CHANGELOG.md
**Contributors:**
[cwchristerw](<https://github.com/cwchristerw>)
## 0.5.5 (30.4.2024)
Patch Release
- Avoid refreshing player too often to keep in Discord API quotas.
**Package**
- Dependencies Update
**Miscellaneous:**
- Dockerfile: Use "docker.io/library/node:20-alpine" as upstream to image.
**Documentation**
- Use Podman in instructions.
__**Contributors:**__
[cwchristerw](<https://github.com/cwchristerw>)
## 0.5.4 (21.12.2023)
Patch Release
- Update new stationlistUrl address
- Change player interval to every 10 seconds in Play function
- Handle application commands better in commands.ts
- Handle DiscordAPIError: unknown interaction in uncaughtException event
- Remove audioPlayer maxMissedFrames in Streamer class
- Remove Bug command
- Remove Invite command
**Package**
- Dependencies Update
**Miscellaneous:**
- Dockerfile
- Github Workflow: Labeler (update)
**Docs**
- .env_example Update
__**Contributors:**__
[cwchristerw](<https://github.com/cwchristerw>)
## 0.5.3 (29.11.2023)
Patch Release
- Add duration to Play command
- Add RadioPlay playlist support to track info
- Remove Now Playing command
**Package**
- Dependencies Update
- Typescript Typings
__**Contributors:**__
[cwchristerw](<https://github.com/cwchristerw>)
## 0.5.2 (23.11.2023)
Patch Release
- Display track info in play and nowplaying commands
- Fix idling audioPlayer
**Package**
- Update Dependencies
- Typescript Typings
**Docs**
- Update supported versions list in SECURITY.md
__**Contributors:**__
[cwchristerw](<https://github.com/cwchristerw>)
## 0.5.1 (13.7.2023)
Patch Release
**Package**
- Update Dependencies
__**Contributors:**__
[cwchristerw](<https://github.com/cwchristerw>)
## 0.5.0 (9.6.2023)
Minor Release
- Create event listeners once in Streamer class.
- Limit commands in maintenance mode.
- Remove unnecessary await in Play command.
- Replace multiple forEach loop to for...of loops.
- Move events and funcs from RadioClient to events.ts and funcs.ts respectively.
- Remove execute functions in events and commands.ts.
- Move emojis into messages.ts.
- Fallback missing version into version 0.0.0.
- Change em dash to dash in Stations class.
- Remove messageCreate event and deprecation messages.
- Converted codebase to Typescript
**Package**
- NodeJS 18
- Use lockfileVersion 3
- Remove node-fetch dependency
- Update Dependencies
**Documentation**
- Removed version 0.4.x support in Security Policy
**Miscellaneous:**
- Dockerfile
__**Contributors:**__
[cwchristerw](<https://github.com/cwchristerw>)
## 0.4.3 (4.6.2023)
Patch Release
**Package**
- Update Dependencies
***Miscellaneous:***
- Github Workflow: Docker Build & TypeScript Build (update)
__**Contributors:**__
[cwchristerw](<https://github.com/cwchristerw>)
## 0.4.2 (24.5.2023)
Patch Release
- Fix Status command
- Replaced SelectMenuBuilder (deprecated) with StringSelectMenuBuilder (Discord.js)
**Package**
- Update Dependencies
__**Contributors:**__
[cwchristerw](<https://github.com/cwchristerw>)
## 0.4.1 (29.11.2022)
Patch Release
**Package**
- Update Dependencies
__**Contributors:**__
[cwchristerw](<https://github.com/cwchristerw>)
## 0.4.0 (19.7.2022)
Minor Release
**Package**
- Update Dependencies
**Docs**
- Improviding Docker instructions in README.md
__**Contributors:**__
[cwchristerw](<https://github.com/cwchristerw>)
## 0.3.20 (7.4.2022)
Patch Release
- Added dashboard link to Statistics command. Preparations to [#24](<https://github.com/warengroup/eximiabots-radiox/issues/24>)
- Minor changes in Ready event and Stations class.
- Fixed multiple bugs [#286](<https://github.com/warengroup/eximiabots-radiox/issues/286>), [#284](<https://github.com/warengroup/eximiabots-radiox/issues/284>), [#283](<https://github.com/warengroup/eximiabots-radiox/issues/283>), [#227](<https://github.com/warengroup/eximiabots-radiox/issues/227>).
**Package**
- Update Dependencies
***Miscellaneous:***
- Github Workflow: Dependabot Auto-Merge (update)
**Docs**
- Improviding Docker instructions in README.md
__**Contributors:**__
[cwchristerw](<https://github.com/cwchristerw>)
## 0.3.19 (26.2.2022)
Patch Release
**Package**
- Update Dependencies
***Miscellaneous:***
- Github Workflow: Docker Build & TypeScript Build (update)
__**Contributors:**__
[cwchristerw](<https://github.com/cwchristerw>)
## 0.3.18 (26.2.2022)
Patch Release
***Miscellaneous:***
- Github Workflow: Dependabot Auto-Merge (update)
__**Contributors:**__
[cwchristerw](<https://github.com/cwchristerw>)
## 0.3.17 (26.2.2022)
Patch Release
**Package**
- Update Dependencies
***Miscellaneous:***
- Github Workflow: Dependabot Auto-Merge (update)
__**Contributors:**__
[cwchristerw](<https://github.com/cwchristerw>)
## 0.3.16 (24.2.2022)
Patch Release
**Package**
- Update Dependencies
***Miscellaneous:***
- Github Workflow: Dependabot Auto-Merge (update)
**Docs**
- Update year in LICENSE
__**Contributors:**__
[cwchristerw](<https://github.com/cwchristerw>)
## 0.3.15 (21.2.2022)
Patch Release
**Package**
- Updated Dependencies
***Miscellaneous:***
- Github Workflow: CodeQL Analyze (update)
- Github Workflow: Dependabot Auto-Merge (new)
__**Contributors:**__
[cwchristerw](<https://github.com/cwchristerw>)
## 0.3.14 (1.2.2022)
Patch Release
**Package**
- Updated Dependencies
***Miscellaneous:***
- Github Workflow: Typescript Build (updated)
__**Contributors:**__
[cwchristerw](<https://github.com/cwchristerw>)
## 0.3.13 (21.12.2021)
Patch Release
- Listen function will use play to restart playing station when streamerMode is manual and audioPlayer has no subscribers in Streamer class
- Prevent bot restarting when uncaughtException event is caused by "DiscordAPIError - Unknown interaction" in uncaughtException event.
- Remove Discord.js voice audioResource event listeners in Streamer class
**Package**
- Updated Dependencies
***Miscellaneous:***
- Github Workflow: Typescript Build (updated)
__**Contributors:**__
[cwchristerw](<https://github.com/cwchristerw>)
## 0.3.12 (30.11.2021)
Patch Release
- Add removal feature when station isn't working in Stations class
- Add direct type to search function in Stations class
- Add validation to station at restore function in Radio class
- Add manual mode at play function in Streamer class
- Update audioPlayer idle event in Streamer class
- Update fetch function in Stations class
- Change stationsListURL
- Move previous search function to text type at search function in Stations class
**Package**
- Updated Dependencies
__**Contributors:**__
[cwchristerw](<https://github.com/cwchristerw>)
## 0.3.11 (18.9.2021)
Patch Release
- Catch errors inside loadEntry method in Datastore class
- Fix memory leak bug in Streamer class
- Dont delete first streamer when refreshing streamers in Streamer class
- Fix maintenance command
__**Contributors:**__
[cwchristerw](<https://github.com/cwchristerw>)
## 0.3.10 (17.9.2021)
Patch Release
- Fix Stations class bug
- Prevent loadState function updating datastore entries everytime
- Streamlined restore method in Radio class with play command
__**Contributors:**__
[cwchristerw](<https://github.com/cwchristerw>)
## 0.3.9 (17.9.2021)
Patch Release
- Move Datastore class into classes folder.
- Add loadEntry method to Datastore class.
- Move calculateGlobal method from Datastore to Statistics class.
- Create Radio, Stations, Streamer, Statistics class.
- Commands are now set into map in commands.js.
- Remove application command options in maintenance command.
- Add Streamer Mode Manual and Streamer Mode Auto to selectMenu in maintenance command.
- Small fixes to next, play and prev command.
- Hide owner when its same as station name in nowplaying command.
- Update fields in status command.
- Delete message when using stop command in different textChannel.
- Small fixes to SIGINT, interactionCreate and ready event.
- Delete radio when no members in voiceChannel with excluding bot users in voiceStateUpdate event.
- Small fixes to check, isDev, listStations and logger function.
- Move checkFetchStatus function to Stations class.
- Delete message and send new message when textChannel has changed in play function.
- Hide owner when its same as station name in play function.
- Move restoreRadios function to Radio class.
- Move saveRadios function to Radio class.
- Move searchStation function to Statistics class.
- Move statisticsUpdate function to Statistics class.
- Update statusFields in messages.
- Rename maintenanceMode in config.
- Add Streamer Mode in config.
- Add Dev Mode in config.
**Package**
- Updated Dependencies
**Docs**
- Add new environment variables to .env_example file.
__**Contributors:**__
[cwchristerw](<https://github.com/cwchristerw>)
## 0.3.8 (10.9.2021)
Patch Release
- Add maintenance mode
- Node-fetch update to 3.0.0 with temporary solution
- Create exit event in Client.ts and added logger.
- Remove logger from SIGINT event
- Handle warnings in event instead of default warnings.
- Add logger to uncaughtException event
- Update login error catcher
**Package**
- Updated Dependencies
***Miscellaneous:***
- VSCode settings
**Docs**
- Contributing Guide CONTRIBUTING.md (new)
- Security Policy SECURITY.md (new)
__**Contributors:**__
[cwchristerw](<https://github.com/cwchristerw>)
## 0.3.7 (7.9.2021)
Patch Release
- Fixed messageCreate event
**Package**
- Updated Dependencies
***Miscellaneous:***
- Github Workflow: Labeler (updated)
__**Contributors:**__
[cwchristerw](<https://github.com/cwchristerw>)
## 0.3.6 (6.9.2021)
Patch Release
- Fixed prev & next command
- Changed forgotten interaction replies to ephemeral in commands.
- Handle uncaughtException event
- Tidied code
**Package**
- Updated Dependencies
***Miscellaneous:***
- Github Workflow: CodeQL Analyze (new), Labeler (new)
**Docs**
- Updated README.md
__**Contributors:**__
[cwchristerw](<https://github.com/cwchristerw>)
## 0.3.5 (6.9.2021)
Patch Release
- Avoid answering interaction that came from channels that bot has no rights to view.
- Hide decimals from global percent in statistics
- Check if there members when restoring radio instead of returning to empty channel and staying alone.
- Simplified listStations function and decided to hide one channel because it has maximum of 25 items in select menu options.
- Show unknown errors more transparently by using console.error function when needed.
- Moved restoreRadios function to funcs folder
- Created saveRadios function
- Updated SIGINT event: Removed code that was there before saveRadios function was separated into function script
- Added more controls to maintenance command
- Fixed play command
__**Contributors:**__
[cwchristerw](<https://github.com/cwchristerw>) & [Vekki000](<https://github.com/Vekki000>)
## 0.3.4 (5.9.2021)
Patch Release
- Created next & prev command
- Fixed typo in bug command code
- Added loggers to Slash Commands creation process
- Tidied code and moved few functions to funcs folder
- Disabled removing commands when bot is going offline
- Removed deprecated code that may have caused bot to restart unintentionally
**Package**
- Updated Dependencies
__**Contributors:**__
[cwchristerw](<https://github.com/cwchristerw>)
## 0.3.3 (4.9.2021)
Patch Release
- Changed few replies to ephemeral in nowplaying command.
- Fixed bug command
__**Contributors:**__
[cwchristerw](<https://github.com/cwchristerw>)
## 0.3.2 (3.9.2021)
Patch Release
- Added station logo to embed thumbnail
- Added empty image to make embeds same size
- Improved mobile user experience by removing unnecessary spaces in messages
- restoreradio.js is now checking that there is stations before continuing.
- Improved Dev bot to remove slash commands during process ending.
***Package:***
- Updated Dependencies
__**Contributors:**__
[cwchristerw](<https://github.com/cwchristerw>)
## 0.3.1 (3.9.2021)
Patch Release
- Added message command deprecation message
- Updated Invite link
- Added messageDelete event
- Edited play message
- Updated logger
- Updated list command
- Gracefully handling process ending when requested (SIGINT & SIGTERM)
- Update startTime when changing stations
- Remove play message when bot is disconnected from voice channel
- Removed references to prefix
- Removed unnecessary comments & messages
- Removed maintenance message in maintenance command because we will automatically resume playing after restart by saving and loading state.
***Package:***
- Updated Dependencies
__**Contributors:**__
[cwchristerw](<https://github.com/cwchristerw>)
## 0.3.0 (31.8.2021)
Minor Release
- Slash Commands
- Removed Message Commands
- Improved logging with new logger function
- Yle X is now searchable
- Ephemeral replies
- New invite link
- Using play command now gives you dropdown menu when no station id or name is given to command.
- Elapsed time is better shown because bot has improved msToTime function.
- New Emojis
- We may utilize new Discord features because bot can now handle new types of interactions.
- Version number in console
***Package:***
- Updated Dependencies
***Miscellaneous:***
- Dockerfile
- Github Workflow: TypeScript Build
__**Contributors:**__
[cwchristerw](<https://github.com/cwchristerw>)
## 0.2.4 (31.8.2021)
Patch Release
Changed voiceAdapterCreator to Discord.js instead of custom adapter. Should fix #26 indefinitely until major changes coming to Discord.js or Discord.js Voice.
__**Contributors:**__
[cwchristerw](<https://github.com/cwchristerw>)
## 0.2.3 (21.8.2021)
Patch Release
- Fixed help command (#28)
- Nulling connection after bot is disconnected
***Package:***
- Updated Dependencies
__**Contributors:**__
[cwchristerw](<https://github.com/cwchristerw>)
## 0.2.2 (21.8.2021)
Patch Release
Fixed #26 in voiceStateUpdate.js
__**Contributors:**__
[cwchristerw](<https://github.com/cwchristerw>)
## 0.2.1 (18.8.2021)
Patch Release
***Package:***
- Updated Dependencies
***Miscellaneous:***
- Dockerfile
- Github Workflow: Docker Build (new)
__**Contributors:**__
[cwchristerw](<https://github.com/cwchristerw>)
## 0.2.0 (8.8.2021)
Minor Release
***Miscellaneous:***
- eslint
- prettier
- Dockerfile
- TypeScript
__**Contributors:**__
[cwchristerw](<https://github.com/cwchristerw>) & [MatteZ02](<https://github.com/MatteZ02>)
## 0.1.0 (15.6.2021)
\-

View File

@ -1,4 +1,4 @@
FROM docker.io/library/node:20-alpine FROM node:18-alpine
#Dependencies #Dependencies
RUN apk add --virtual .build-deps python3 make g++ gcc git RUN apk add --virtual .build-deps python3 make g++ gcc git

View File

@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2020-2025 EximiaBots by Warén Group Copyright (c) 2020-2023 EximiaBots by Warén Group
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@ -1,12 +1,8 @@
# RadioX by EximiaBots # RadioX by EximiaBots
Internet Radio to your Discord guild Internet Radio to your Discord guild
## [Radio Stations List](https://eximiabots.waren.io/radiox/stations.json) ## [Radio Stations List](https://git.cwinfo.net/cwchristerw/radio)
This bot is getting radio stations from our servers. This bot is using Gitea repo to get radio stations from [playlist.json](https://git.cwinfo.net/cwchristerw/radio/raw/branch/master/playlist.json) file. List is currently maintained by Christer Warén. You can use alternative list with same format when using RADIOX_STATIONSLISTURL environment variable.
https://eximiabots.waren.io/radiox/stations.json
List is generated with cwchristerw's [radio](https://git.waren.io/cwchristerw/radio) repo. This list is currently maintained by Christer Warén. You can use alternative list with same format when using RADIOX_STATIONSLISTURL environment variable.
## Docker ## Docker
@ -14,35 +10,36 @@ List is generated with cwchristerw's [radio](https://git.waren.io/cwchristerw/ra
**Production** **Production**
``` ```
podman build -t warengroup/eximiabots-radiox:latest . --pull docker build -t warengroup/eximiabots-radiox:latest . --pull
``` ```
**Beta** **Beta**
``` ```
podman build -t warengroup/eximiabots-radiox:latest-beta . --pull docker build -t warengroup/eximiabots-radiox:latest-beta . --pull
``` ```
**Dev** **Dev**
``` ```
podman build -t warengroup/eximiabots-radiox:latest-dev . --pull docker build -t warengroup/eximiabots-radiox:latest-dev . --pull
``` ```
### 2. Run Container ### 2. Run Container
**Production** **Production**
``` ```
podman run --name radiox -d -e DISCORD_TOKEN= -e STREAMER_MODE=auto -v "$PWD/datastore":/usr/src/app/datastore/ warengroup/eximiabots-radiox:latest docker run --name radiox --net host -d -e DISCORD_TOKEN= -e STREAMER_MODE=auto -v "$PWD/datastore":/usr/src/app/datastore/ warengroup/eximiabots-radiox:latest
``` ```
**Beta** **Beta**
``` ```
podman run --name radiox -d -e DISCORD_TOKEN= -e STREAMER_MODE=auto -v "$PWD/datastore":/usr/src/app/datastore/ warengroup/eximiabots-radiox:latest-beta docker run --name radiox --net host -d -e DISCORD_TOKEN= -e STREAMER_MODE=auto -v "$PWD/datastore":/usr/src/app/datastore/ warengroup/eximiabots-radiox:latest-beta
``` ```
**Dev** **Dev**
``` ```
podman run --rm --name radiox-dev -e DISCORD_TOKEN= -e DEV_MODE=true -v "$PWD":/usr/src/app/ warengroup/eximiabots-radiox:latest-dev docker run --rm --name radiox-dev --net host -e DISCORD_TOKEN= -e DEV_MODE=true -v "$PWD":/usr/src/app/ warengroup/eximiabots-radiox:latest-dev
``` ```
## Join our Discord Server ## Join our Discord Server
https://discord.gg/rRA65Mn https://discord.gg/rRA65Mn

3523
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{ {
"name": "eximiabots-radiox", "name": "eximiabots-radiox",
"version": "0.5.9", "version": "0.5.3",
"description": "Internet Radio to your Discord guild", "description": "Internet Radio to your Discord guild",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
@ -18,18 +18,32 @@
"url": "https://github.com/warengroup/eximiabots-radiox/issues" "url": "https://github.com/warengroup/eximiabots-radiox/issues"
}, },
"dependencies": { "dependencies": {
"@discordjs/voice": "^0.18.0", "@discordjs/builders": "^1.7.0",
"discord.js": "^14.18.0", "@discordjs/opus": "^0.9.0",
"dotenv": "^16.4.7", "@discordjs/rest": "^2.2.0",
"libsodium-wrappers": "^0.7.15", "@discordjs/voice": "^0.16.1",
"discord-api-types": "^0.37.65",
"discord.js": "^14.14.1",
"dotenv": "^16.3.1",
"libsodium-wrappers": "^0.7.13",
"path": "^0.12.7" "path": "^0.12.7"
}, },
"devDependencies": { "devDependencies": {
"rimraf": "^6.0.1", "@types/node": "^20.10.0",
"typescript": "^5.7.3" "@types/ws": "^8.5.9",
"@typescript-eslint/eslint-plugin": "^6.13.1",
"@typescript-eslint/parser": "^6.13.1",
"eslint": "^8.54.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.1",
"prettier": "^3.1.0",
"rimraf": "^5.0.5",
"ts-node": "^10.9.1",
"tsc-watch": "^6.0.4",
"typescript": "^5.2.2"
}, },
"engines": { "engines": {
"node": ">=20.0.0", "node": ">=18.16.0",
"npm": ">=10.0.0" "npm": ">=8.0.0"
} }
} }

View File

@ -42,7 +42,7 @@ export default class RadioClient extends Client {
console.log('RadioX ' + this.config.version); console.log('RadioX ' + this.config.version);
console.log('Internet Radio to your Discord guild'); console.log('Internet Radio to your Discord guild');
console.log('(c)2020-2024 EximiaBots by Warén Group'); console.log('(c)2020-2022 EximiaBots by Warén Group');
console.log(''); console.log('');
this.funcs.logger("Bot", "Starting"); this.funcs.logger("Bot", "Starting");

View File

@ -76,7 +76,7 @@ export default class Datastore {
return this.map.get(id); return this.map.get(id);
} }
updateEntry(guild: Guild | { id: string, name?: string }, newData: datastore) { updateEntry(guild: Guild | { id: string, name: string }, newData: datastore) {
newData.guild.name = guild.name; newData.guild.name = guild.name;
let date = new Date(); let date = new Date();

View File

@ -1,20 +1,20 @@
import { Collection, GuildMember, Message, Guild, OAuth2Guild, TextBasedChannel, VoiceBasedChannel, VoiceChannel } from "discord.js"; import { Collection, GuildMember, Message, OAuth2Guild, TextBasedChannel, VoiceBasedChannel, VoiceChannel } from "discord.js";
import { DiscordGatewayAdapterCreator, getVoiceConnection, joinVoiceChannel, VoiceConnection } from "@discordjs/voice"; import { getVoiceConnection, joinVoiceChannel, VoiceConnection } from "@discordjs/voice";
import RadioClient from "../../Client"; import RadioClient from "../../Client";
import { station } from "./Stations"; import { station } from "./Stations";
import { datastore } from "./Datastore"; import { datastore } from "./Datastore";
export interface radio { export interface radio {
textChannel: TextBasedChannel | null, textChannel: TextBasedChannel | undefined | null,
voiceChannel: VoiceBasedChannel | null, voiceChannel: VoiceBasedChannel | undefined,
connection: VoiceConnection | undefined, connection: VoiceConnection | null,
message: Message | null, message: Message | null,
station: station, station: station,
datastore?: datastore, datastore?: datastore,
currentTime?: number, currentTime?: number,
startTime: number, startTime: number,
playTime?: number, playTime?: number,
guild?: Guild | { id: string, name?: string } guild?: any
} }
export interface state { export interface state {
@ -78,11 +78,10 @@ export default class Radio extends Map<string, radio> {
const construct: radio = { const construct: radio = {
textChannel: client.channels.cache.get(state.channels.text) as TextBasedChannel, textChannel: client.channels.cache.get(state.channels.text) as TextBasedChannel,
voiceChannel: client.channels.cache.get(state.channels.voice) as VoiceBasedChannel, voiceChannel: client.channels.cache.get(state.channels.voice) as VoiceBasedChannel,
connection: undefined, connection: null,
message: null, message: null,
station: station, station: station,
startTime: date.getTime(), startTime: date.getTime()
guild: guild
}; };
this.set(guild.id, construct); this.set(guild.id, construct);
@ -92,7 +91,7 @@ export default class Radio extends Map<string, radio> {
joinVoiceChannel({ joinVoiceChannel({
channelId: voiceChannel.id, channelId: voiceChannel.id,
guildId: voiceChannel.guild.id, guildId: voiceChannel.guild.id,
adapterCreator: voiceChannel.guild.voiceAdapterCreator as DiscordGatewayAdapterCreator adapterCreator: voiceChannel.guild.voiceAdapterCreator
}); });
construct.connection = connection; construct.connection = connection;

View File

@ -1,4 +1,4 @@
import { Guild, OAuth2Guild } from "discord.js"; import { Guild } from "discord.js";
import RadioClient from "../../Client"; import RadioClient from "../../Client";
import { radio } from "./Radio"; import { radio } from "./Radio";
@ -18,7 +18,7 @@ export default class Statistics {
this.map = new Map(); this.map = new Map();
} }
update(client: RadioClient, guild: Guild | { id: string, name?: string } | undefined, radio: radio) { update(client: RadioClient, guild: Guild | null, radio: radio) {
if(!guild) return; if(!guild) return;
client.datastore?.checkEntry(guild.id); client.datastore?.checkEntry(guild.id);

View File

@ -51,13 +51,15 @@ export default class Streamer {
if(this.mode == "auto"){ if(this.mode == "auto"){
audioPlayer = createAudioPlayer({ audioPlayer = createAudioPlayer({
behaviors: { behaviors: {
noSubscriber: NoSubscriberBehavior.Play noSubscriber: NoSubscriberBehavior.Play,
maxMissedFrames: Math.round(5000 / 20),
} }
}); });
} else { } else {
audioPlayer = createAudioPlayer({ audioPlayer = createAudioPlayer({
behaviors: { behaviors: {
noSubscriber: NoSubscriberBehavior.Stop noSubscriber: NoSubscriberBehavior.Stop,
maxMissedFrames: Math.round(5000 / 20),
} }
}); });
} }

View File

@ -1,6 +1,8 @@
import { ApplicationCommand, ApplicationCommandManager, BaseGuild, Guild, GuildApplicationCommandManager, OAuth2Guild, Snowflake } from "discord.js"; import { Snowflake } from "discord.js";
import RadioClient from "../Client"; import RadioClient from "../Client";
import bug from "./commands/bug";
import help from "./commands/help"; import help from "./commands/help";
import invite from "./commands/invite";
import list from "./commands/list"; import list from "./commands/list";
import maintenance from "./commands/maintenance"; import maintenance from "./commands/maintenance";
import next from "./commands/next"; import next from "./commands/next";
@ -19,17 +21,35 @@ export interface command {
} }
export default async function commands(client: RadioClient) { export default async function commands(client: RadioClient) {
const commands1 : command[] = [ help, list, maintenance, next, play, prev, statistics, status, stop ]; const commands : command[] = [ bug, help, invite, list, maintenance, next, play, prev, statistics, status, stop ];
const commands2 = await client.application?.commands.fetch();
for(const command of commands1){ for(const command of commands){
client.commands.set(command.name, command); client.commands.set(command.name, command);
} }
if(!client.application) return;
client.funcs.logger('Application Commands', 'Started refreshing application (/) commands.'); client.funcs.logger('Application Commands', 'Started refreshing application (/) commands.');
if(commands1){ if(client.config.devMode){
for(const command of commands1){ client.application.commands.set([]);
await client.application?.commands.create({ for(const command of commands){
let guilds = await client.guilds.fetch();
guilds.forEach(async (guild: { id: Snowflake; name: string; }) => {
try {
if(!client.application) return;
await client.application.commands.create({
name: command.name,
description: command.description,
options: command.options || []
}, guild.id);
client.funcs.logger('Application Commands', 'Guild: ' + guild.id + " (" + guild.name + ") \n" + 'Command: ' + command.name);
} catch(DiscordAPIError) {
client.funcs.logger('Application Commands', 'Guild: ' + guild.id + " (" + guild.name + ") [FAILED] \n" + 'Command: ' + command.name);
}
});
}
} else {
for(const command of commands){
await client.application.commands.create({
name: command.name, name: command.name,
description: command.description, description: command.description,
options: command.options || [] options: command.options || []
@ -37,24 +57,15 @@ export default async function commands(client: RadioClient) {
client.funcs.logger('Application Commands', 'Command: ' + command.name); client.funcs.logger('Application Commands', 'Command: ' + command.name);
} }
}
if(commands2){
commands2.forEach(async command2 => {
if(commands1.findIndex((command1) => command1.name == command2.name) == -1){
await client.application?.commands.delete(command2.id);
}
});
}
let guilds = await client.guilds.fetch(); let guilds = await client.guilds.fetch();
guilds.forEach(async (guild: Guild | OAuth2Guild) => { guilds.forEach(async (guild: { id: Snowflake; }) => {
try { try {
if(!client.application) return; if(!client.application) return;
await client.application.commands.set([], guild.id); await client.application.commands.set([], guild.id);
} catch (DiscordAPIError){ } catch (DiscordAPIError){
} }
}); });
}
client.funcs.logger('Application Commands', 'Successfully reloaded application (/) commands.' + "\n"); client.funcs.logger('Application Commands', 'Successfully reloaded application (/) commands.' + "\n");
} }

View File

@ -0,0 +1,34 @@
import { ChatInputCommandInteraction, EmbedBuilder } from "discord.js";
import RadioClient from "../../Client";
export default {
name: 'bug',
description: 'Report a bug',
category: 'info',
async execute(interaction: ChatInputCommandInteraction, client: RadioClient) {
if(!client.user) return interaction.reply({
content: client.messages.emojis["error"] + client.messages.maintenance,
ephemeral: true
});
const embed = new EmbedBuilder()
.setTitle(client.messages.replace(client.messages.bugTitle, {
"%client.user.username%": client.user.username
}))
.setThumbnail("https://cdn.discordapp.com/emojis/" + client.messages.emojis["logo"].replace(/[^0-9]+/g, ''))
.setColor(client.config.embedColor)
.setDescription(client.messages.replace(client.messages.bugDescription, {
"%client.config.supportGuild%": client.config.supportGuild
}))
.setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png')
.setFooter({
text: client.messages.footerText,
iconURL: "https://cdn.discordapp.com/emojis/" + client.messages.emojis["eximiabots"].replace(/[^0-9]+/g, '')
});
interaction.reply({
embeds: [embed],
ephemeral: true
});
}
};

View File

@ -10,15 +10,26 @@ export default {
if(!client.user) return interaction.reply({ if(!client.user) return interaction.reply({
content: client.messages.emojis["error"] + client.messages.maintenance, content: client.messages.emojis["error"] + client.messages.maintenance,
flags: 'Ephemeral' ephemeral: true
}); });
const categories: string[] = [];
for (let i = 0; i < client.commands.size; i++) {
if (!categories.includes([...client.commands.values()][i].category)) categories.push([...client.commands.values()][i].category);
}
let commands = '';
for (let i = 0; i < categories.length; i++) {
commands += `**» ${categories[i].toUpperCase()}**\n${client.commands.filter(x => x.category === categories[i]).map((x: command) => `\`${x.name}\``).join(', ')}\n`;
}
const embed = new EmbedBuilder() const embed = new EmbedBuilder()
.setTitle(client.messages.helpTitle) .setTitle(client.messages.replace(client.messages.helpTitle, {
"%client.user.username%": client.user.username
}))
.setThumbnail("https://cdn.discordapp.com/emojis/" + client.messages.emojis["logo"].replace(/[^0-9]+/g, '')) .setThumbnail("https://cdn.discordapp.com/emojis/" + client.messages.emojis["logo"].replace(/[^0-9]+/g, ''))
.setColor(client.config.embedColor) .setColor(client.config.embedColor)
.setDescription(client.messages.replace(client.messages.helpDescription, { .setDescription(client.messages.replace(client.messages.helpDescription, {
"%client.config.supportGuild%": client.config.supportGuild "%commands%": commands
})) }))
.setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png') .setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png')
.setFooter({ .setFooter({
@ -28,7 +39,7 @@ export default {
interaction.reply({ interaction.reply({
embeds: [embed], embeds: [embed],
flags: 'Ephemeral' ephemeral: true
}); });
} }
}; };

View File

@ -0,0 +1,32 @@
import { ChatInputCommandInteraction, EmbedBuilder } from "discord.js";
import RadioClient from "../../Client";
export default {
name: 'invite',
description: 'Invite Bot',
category: 'info',
execute(interaction: ChatInputCommandInteraction, client: RadioClient) {
if(!client.user) return interaction.reply({
content: client.messages.emojis["error"] + client.messages.maintenance,
ephemeral: true
});
const embed = new EmbedBuilder()
.setTitle(client.messages.replace(client.messages.inviteTitle, {
"%client.user.username%": client.user.username
}))
.setColor(client.config.embedColor)
.setURL("https://discord.com/api/oauth2/authorize?client_id=" + client.user.id + "&permissions=2184465408&scope=applications.commands%20bot") //View Channels, Send Messages, Embed Links, Use External Emojis, Use Slash Commands, Connect, Speak, Use Voice Activity
.setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png')
.setFooter({
text: client.messages.footerText,
iconURL: "https://cdn.discordapp.com/emojis/" + client.messages.emojis["eximiabots"].replace(/[^0-9]+/g, '')
});
interaction.reply({
embeds: [embed],
ephemeral: true
});
}
};

View File

@ -14,7 +14,7 @@ export default {
if(client.config.maintenanceMode){ if(client.config.maintenanceMode){
return interaction.reply({ return interaction.reply({
content: client.messages.emojis["error"] + client.messages.maintenance, content: client.messages.emojis["error"] + client.messages.maintenance,
flags: 'Ephemeral' ephemeral: true
}); });
} }
@ -37,7 +37,7 @@ export default {
content: client.messages.emojis["error"] + client.messages.replace(client.messages.errorToGetPlaylist, { content: client.messages.emojis["error"] + client.messages.replace(client.messages.errorToGetPlaylist, {
"%client.config.supportGuild%": client.config.supportGuild "%client.config.supportGuild%": client.config.supportGuild
}), }),
flags: 'Ephemeral' ephemeral: true
}); });
} }
@ -65,7 +65,7 @@ export default {
interaction.reply({ interaction.reply({
embeds: [embed], embeds: [embed],
flags: 'Ephemeral' ephemeral: true
}); });
} }
} }

View File

@ -11,7 +11,7 @@ export default {
if(!client.funcs.isDev(client.config.devIDs, interaction.user.id)) return interaction.reply({ if(!client.funcs.isDev(client.config.devIDs, interaction.user.id)) return interaction.reply({
content: client.messages.emojis["error"] + client.messages.notAllowed, content: client.messages.emojis["error"] + client.messages.notAllowed,
flags: 'Ephemeral' ephemeral: true
}); });
let action : number | string | null = null; let action : number | string | null = null;
@ -107,7 +107,7 @@ export default {
return interaction.reply({ return interaction.reply({
content: "**" + client.messages.maintenanceTitle + "**", content: "**" + client.messages.maintenanceTitle + "**",
components: [menu], components: [menu],
flags: 'Ephemeral' ephemeral: true
}); });
} }
@ -124,7 +124,7 @@ export default {
interaction.reply({ interaction.reply({
embeds: [embed], embeds: [embed],
flags: 'Ephemeral' ephemeral: true
}); });
let guilds = await client.guilds.fetch(); let guilds = await client.guilds.fetch();

View File

@ -16,7 +16,7 @@ export default {
if(client.config.maintenanceMode){ if(client.config.maintenanceMode){
return interaction.reply({ return interaction.reply({
content: client.messages.emojis["error"] + client.messages.maintenance, content: client.messages.emojis["error"] + client.messages.maintenance,
flags: 'Ephemeral' ephemeral: true
}); });
} }
@ -25,7 +25,7 @@ export default {
content: client.messages.emojis["error"] + client.messages.replace(client.messages.errorToGetPlaylist, { content: client.messages.emojis["error"] + client.messages.replace(client.messages.errorToGetPlaylist, {
"%client.config.supportGuild%": client.config.supportGuild "%client.config.supportGuild%": client.config.supportGuild
}), }),
flags: 'Ephemeral' ephemeral: true
}); });
} }
@ -36,7 +36,7 @@ export default {
if(!station) return interaction.reply({ if(!station) return interaction.reply({
content: client.messages.emojis["error"] + client.messages.noSearchResults, content: client.messages.emojis["error"] + client.messages.noSearchResults,
flags: 'Ephemeral' ephemeral: true
}); });
client.statistics?.update(client, interaction.guild, radio); client.statistics?.update(client, interaction.guild, radio);

View File

@ -1,5 +1,5 @@
import { ApplicationCommandOptionType, ChatInputCommandInteraction, GuildMember, PermissionFlagsBits, StringSelectMenuInteraction } from "discord.js"; import { ApplicationCommandOptionType, ChatInputCommandInteraction, GuildMember, PermissionFlagsBits, StringSelectMenuInteraction } from "discord.js";
import { DiscordGatewayAdapterCreator, getVoiceConnection, joinVoiceChannel } from "@discordjs/voice"; import { getVoiceConnection, joinVoiceChannel } from "@discordjs/voice";
import RadioClient from "../../Client"; import RadioClient from "../../Client";
import { radio } from "../classes/Radio" import { radio } from "../classes/Radio"
@ -18,7 +18,7 @@ export default {
if(client.config.maintenanceMode){ if(client.config.maintenanceMode){
return interaction.reply({ return interaction.reply({
content: client.messages.emojis["error"] + client.messages.maintenance, content: client.messages.emojis["error"] + client.messages.maintenance,
flags: 'Ephemeral' ephemeral: true
}); });
} }
@ -27,7 +27,7 @@ export default {
content: client.messages.emojis["error"] + client.messages.replace(client.messages.errorToGetPlaylist, { content: client.messages.emojis["error"] + client.messages.replace(client.messages.errorToGetPlaylist, {
"%client.config.supportGuild%": client.config.supportGuild "%client.config.supportGuild%": client.config.supportGuild
}), }),
flags: 'Ephemeral' ephemeral: true
}); });
} }
@ -52,32 +52,32 @@ export default {
if (!voiceChannel) return interaction.reply({ if (!voiceChannel) return interaction.reply({
content: client.messages.emojis["error"] + client.messages.noVoiceChannel, content: client.messages.emojis["error"] + client.messages.noVoiceChannel,
flags: 'Ephemeral' ephemeral: true
}); });
if (radio) { if (radio) {
if (voiceChannel !== radio.voiceChannel) return interaction.reply({ if (voiceChannel !== radio.voiceChannel) return interaction.reply({
content: client.messages.emojis["error"] + client.messages.wrongVoiceChannel, content: client.messages.emojis["error"] + client.messages.wrongVoiceChannel,
flags: 'Ephemeral' ephemeral: true
}); });
} }
if (!query) return interaction.reply({ if (!query) return interaction.reply({
content: client.messages.noQuery, content: client.messages.noQuery,
flags: 'Ephemeral' ephemeral: true
}); });
const permissions = voiceChannel.permissionsFor(interaction.client.user); const permissions = voiceChannel.permissionsFor(interaction.client.user);
if (!permissions?.has(PermissionFlagsBits.Connect)) { if (!permissions?.has(PermissionFlagsBits.Connect)) {
return interaction.reply({ return interaction.reply({
content: client.messages.emojis["error"] + client.messages.noPermsConnect, content: client.messages.emojis["error"] + client.messages.noPermsConnect,
flags: 'Ephemeral' ephemeral: true
}); });
} }
if (!permissions?.has(PermissionFlagsBits.Speak)) { if (!permissions?.has(PermissionFlagsBits.Speak)) {
return interaction.reply({ return interaction.reply({
content: client.messages.emojis["error"] + client.messages.noPermsSpeak, content: client.messages.emojis["error"] + client.messages.noPermsSpeak,
flags: 'Ephemeral' ephemeral: true
}); });
} }
let station; let station;
@ -87,7 +87,7 @@ export default {
if(number > client.stations.length - 1) { if(number > client.stations.length - 1) {
return interaction.reply({ return interaction.reply({
content: client.messages.emojis["error"] + client.messages.wrongStationNumber, content: client.messages.emojis["error"] + client.messages.wrongStationNumber,
flags: 'Ephemeral' ephemeral: true
}); });
} else { } else {
station = client.stations[number]; station = client.stations[number];
@ -96,7 +96,7 @@ export default {
if(query.length < 3) return interaction.reply({ if(query.length < 3) return interaction.reply({
content: client.messages.emojis["error"] + client.messages.tooShortSearch, content: client.messages.emojis["error"] + client.messages.tooShortSearch,
flags: 'Ephemeral' ephemeral: true
}); });
let type = "text"; let type = "text";
@ -108,7 +108,7 @@ export default {
const sstation = client.stations.search(query, type); const sstation = client.stations.search(query, type);
if (!sstation) return interaction.reply({ if (!sstation) return interaction.reply({
content: client.messages.emojis["error"] + client.messages.noSearchResults, content: client.messages.emojis["error"] + client.messages.noSearchResults,
flags: 'Ephemeral' ephemeral: true
}); });
station = sstation; station = sstation;
} }
@ -129,11 +129,10 @@ export default {
const construct: radio = { const construct: radio = {
textChannel: interaction.channel, textChannel: interaction.channel,
voiceChannel: voiceChannel, voiceChannel: voiceChannel,
connection: undefined, connection: null,
message: null, message: null,
station: station, station: station,
startTime: date.getTime(), startTime: date.getTime()
guild: interaction.guild
}; };
client.radio?.set(interaction.guild?.id, construct); client.radio?.set(interaction.guild?.id, construct);
@ -143,7 +142,7 @@ export default {
joinVoiceChannel({ joinVoiceChannel({
channelId: voiceChannel.id, channelId: voiceChannel.id,
guildId: voiceChannel.guild.id, guildId: voiceChannel.guild.id,
adapterCreator: voiceChannel.guild?.voiceAdapterCreator as DiscordGatewayAdapterCreator adapterCreator: voiceChannel.guild.voiceAdapterCreator
}); });
construct.connection = connection; construct.connection = connection;
let date = new Date(); let date = new Date();
@ -155,7 +154,7 @@ export default {
client.radio?.delete(interaction.guild?.id); client.radio?.delete(interaction.guild?.id);
return interaction.reply({ return interaction.reply({
content: client.messages.emojis["error"] + `An error occured: ${error}`, content: client.messages.emojis["error"] + `An error occured: ${error}`,
flags: 'Ephemeral' ephemeral: true
}); });
} }
} }

View File

@ -16,7 +16,7 @@ export default {
if(client.config.maintenanceMode){ if(client.config.maintenanceMode){
return interaction.reply({ return interaction.reply({
content: client.messages.emojis["error"] + client.messages.maintenance, content: client.messages.emojis["error"] + client.messages.maintenance,
flags: 'Ephemeral' ephemeral: true
}); });
} }
@ -25,7 +25,7 @@ export default {
content: client.messages.emojis["error"] + client.messages.replace(client.messages.errorToGetPlaylist, { content: client.messages.emojis["error"] + client.messages.replace(client.messages.errorToGetPlaylist, {
"%client.config.supportGuild%": client.config.supportGuild "%client.config.supportGuild%": client.config.supportGuild
}), }),
flags: 'Ephemeral' ephemeral: true
}); });
} }
@ -36,7 +36,7 @@ export default {
if(!station) return interaction.reply({ if(!station) return interaction.reply({
content: client.messages.emojis["error"] + client.messages.noSearchResults, content: client.messages.emojis["error"] + client.messages.noSearchResults,
flags: 'Ephemeral' ephemeral: true
}); });
client.statistics?.update(client, interaction.guild, radio); client.statistics?.update(client, interaction.guild, radio);

View File

@ -10,7 +10,7 @@ export default {
if(!interaction.guild) return interaction.reply({ if(!interaction.guild) return interaction.reply({
content: client.messages.emojis["error"] + client.messages.maintenance, content: client.messages.emojis["error"] + client.messages.maintenance,
flags: 'Ephemeral' ephemeral: true
}); });
let currentGuild = client.datastore?.getEntry(interaction.guild.id); let currentGuild = client.datastore?.getEntry(interaction.guild.id);
@ -22,7 +22,7 @@ export default {
content: client.messages.emojis["error"] + client.messages.replace(client.messages.errorToGetPlaylist, { content: client.messages.emojis["error"] + client.messages.replace(client.messages.errorToGetPlaylist, {
"%client.config.supportGuild%": client.config.supportGuild "%client.config.supportGuild%": client.config.supportGuild
}), }),
flags: 'Ephemeral' ephemeral: true
}); });
} }
@ -45,7 +45,7 @@ export default {
interaction.reply({ interaction.reply({
embeds: [embed], embeds: [embed],
flags: 'Ephemeral' ephemeral: true
}); });
} }
}; };

View File

@ -9,7 +9,7 @@ export default {
if(!client.user) return interaction.reply({ if(!client.user) return interaction.reply({
content: client.messages.emojis["error"] + client.messages.maintenance, content: client.messages.emojis["error"] + client.messages.maintenance,
flags: 'Ephemeral' ephemeral: true
}); });
let uptime = client.funcs.msToTime(client.uptime || 0); let uptime = client.funcs.msToTime(client.uptime || 0);
@ -35,7 +35,7 @@ export default {
interaction.reply({ interaction.reply({
embeds: [embed], embeds: [embed],
flags: 'Ephemeral' ephemeral: true
}); });
} }

View File

@ -1,4 +1,4 @@
import { ButtonInteraction, ChannelType, ChatInputCommandInteraction, EmbedBuilder, StringSelectMenuInteraction } from "discord.js"; import { ButtonInteraction, ChatInputCommandInteraction, EmbedBuilder, StringSelectMenuInteraction } from "discord.js";
import RadioClient from "../../Client"; import RadioClient from "../../Client";
import { command } from "../commands"; import { command } from "../commands";
@ -11,7 +11,6 @@ export default {
if(!interaction.guild) return; if(!interaction.guild) return;
const radio = client.radio?.get(interaction.guild?.id); const radio = client.radio?.get(interaction.guild?.id);
if(!radio) return; if(!radio) return;
if(radio.textChannel?.type == ChannelType.DM || radio.textChannel?.type == ChannelType.GroupDM) return;
client.statistics?.update(client, interaction.guild, radio); client.statistics?.update(client, interaction.guild, radio);
radio.connection?.destroy(); radio.connection?.destroy();
client.funcs.logger('Radio', interaction.guild?.id + " / " + 'Stop'); client.funcs.logger('Radio', interaction.guild?.id + " / " + 'Stop');
@ -48,7 +47,7 @@ export default {
interaction.reply({ interaction.reply({
content: client.messages.emojis["stop"] + client.messages.stop, content: client.messages.emojis["stop"] + client.messages.stop,
flags: 'Ephemeral' ephemeral: true
}); });
} }
} }

View File

@ -3,15 +3,16 @@ import RadioClient from "../../Client";
export default function interactionCreate(client: RadioClient, interaction: Interaction) { export default function interactionCreate(client: RadioClient, interaction: Interaction) {
if(!(interaction.isButton()) && !(interaction.isChatInputCommand()) && !(interaction.isStringSelectMenu())) return; if(!(interaction.isButton()) && !(interaction.isChatInputCommand()) && !(interaction.isStringSelectMenu())) return;
if(interaction.channel?.type == ChannelType.DM || interaction.channel?.type == ChannelType.GroupDM) return;
if(interaction.channel?.type != ChannelType.DM){
const permissions = interaction.channel?.permissionsFor(interaction.client.user); const permissions = interaction.channel?.permissionsFor(interaction.client.user);
if (!permissions?.has(PermissionFlagsBits.ViewChannel)) return; if (!permissions?.has(PermissionFlagsBits.ViewChannel)) return;
if (!permissions?.has(PermissionFlagsBits.EmbedLinks)) return interaction.reply({ if (!permissions?.has(PermissionFlagsBits.EmbedLinks)) return interaction.reply({
content: client.messages.emojis["error"] + client.messages.noPermsEmbed, content: client.messages.emojis["error"] + client.messages.noPermsEmbed,
flags: 'Ephemeral' ephemeral: true
}); });
}
if(interaction.isChatInputCommand()){ if(interaction.isChatInputCommand()){
const commandName = interaction.commandName; const commandName = interaction.commandName;
@ -23,7 +24,7 @@ export default function interactionCreate(client: RadioClient, interaction: Inte
} catch (error) { } catch (error) {
interaction.reply({ interaction.reply({
content: client.messages.emojis["error"] + client.messages.runningCommandFailed, content: client.messages.emojis["error"] + client.messages.runningCommandFailed,
flags: 'Ephemeral' ephemeral: true
}); });
console.error(error); console.error(error);
} }
@ -37,7 +38,7 @@ export default function interactionCreate(client: RadioClient, interaction: Inte
} catch (error) { } catch (error) {
interaction.reply({ interaction.reply({
content: client.messages.emojis["error"] + client.messages.runningCommandFailed, content: client.messages.emojis["error"] + client.messages.runningCommandFailed,
flags: 'Ephemeral' ephemeral: true
}); });
console.error(error); console.error(error);
} }

View File

@ -5,6 +5,6 @@ export default function uncaughtException(client: RadioClient, error: Error) {
console.log(error.stack); console.log(error.stack);
console.log(''); console.log('');
if(error.name == "DiscordAPIError[10062]" && error.message == "Unknown interaction") return; if(error.name == "DiscordAPIError" && error.message == "Unknown interaction") return;
process.emit('SIGINT'); process.emit('SIGINT');
} }

View File

@ -1,6 +1,9 @@
import { GuildMember, PermissionFlagsBits, VoiceState } from "discord.js"; import { GuildMember, PermissionFlagsBits, VoiceState } from "discord.js";
import RadioClient from "../../Client"; import RadioClient from "../../Client";
import { DiscordGatewayAdapterCreator, getVoiceConnection, joinVoiceChannel } from "@discordjs/voice"; const {
getVoiceConnection,
joinVoiceChannel
} = require("@discordjs/voice");
export default async function voiceStateUpdate(client: RadioClient, oldState: VoiceState, newState: VoiceState) { export default async function voiceStateUpdate(client: RadioClient, oldState: VoiceState, newState: VoiceState) {
if (oldState.channel === null) return; if (oldState.channel === null) return;
@ -24,9 +27,9 @@ export default async function voiceStateUpdate(client: RadioClient, oldState: Vo
setTimeout( setTimeout(
async () => ( async () => (
radio.connection = joinVoiceChannel({ radio.connection = joinVoiceChannel({
channelId: oldState.channel?.id as string, channelId: oldState.channel?.id,
guildId: oldState.channel?.guild.id as string, guildId: oldState.channel?.guild.id,
adapterCreator: oldState.channel?.guild.voiceAdapterCreator as DiscordGatewayAdapterCreator adapterCreator: oldState.channel?.guild.voiceAdapterCreator
}) })
), ),
1000 1000

View File

@ -11,14 +11,14 @@ export default function check(client: RadioClient, interaction: ButtonInteractio
content: client.messages.emojis["error"] + client.messages.replace(client.messages.errorToGetPlaylist, { content: client.messages.emojis["error"] + client.messages.replace(client.messages.errorToGetPlaylist, {
"%client.config.supportGuild%": client.config.supportGuild "%client.config.supportGuild%": client.config.supportGuild
}), }),
flags: 'Ephemeral' ephemeral: true
}); });
return false; return false;
} }
if (!radio) { if (!radio) {
interaction.reply({ interaction.reply({
content: client.messages.emojis["error"] + client.messages.notPlaying, content: client.messages.emojis["error"] + client.messages.notPlaying,
flags: 'Ephemeral' ephemeral: true
}); });
return false; return false;
} }
@ -26,7 +26,7 @@ export default function check(client: RadioClient, interaction: ButtonInteractio
if (interaction.member instanceof GuildMember && interaction.member?.voice.channel !== radio.voiceChannel) { if (interaction.member instanceof GuildMember && interaction.member?.voice.channel !== radio.voiceChannel) {
interaction.reply({ interaction.reply({
content: client.messages.emojis["error"] + client.messages.wrongVoiceChannel, content: client.messages.emojis["error"] + client.messages.wrongVoiceChannel,
flags: 'Ephemeral' ephemeral: true
}); });
return false; return false;
} }

View File

@ -37,6 +37,6 @@ export default function listStations(client: RadioClient, interaction: ButtonInt
return interaction.reply({ return interaction.reply({
content: '**Select station:**', content: '**Select station:**',
components: [menu], components: [menu],
flags: 'Ephemeral' ephemeral: true
}); });
} }

View File

@ -1,4 +1,4 @@
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, ChannelType, ChatInputCommandInteraction, EmbedBuilder, Guild, OAuth2Guild, StringSelectMenuInteraction } from "discord.js"; import { ActionRowBuilder, ButtonBuilder, ButtonStyle, ChatInputCommandInteraction, EmbedBuilder, Guild, OAuth2Guild, StringSelectMenuInteraction } from "discord.js";
import RadioClient from "../../Client"; import RadioClient from "../../Client";
import { station } from "../classes/Stations"; import { station } from "../classes/Stations";
@ -7,7 +7,6 @@ export default async function play(client: RadioClient, interaction: ChatInputCo
const radio = client.radio?.get(guild.id); const radio = client.radio?.get(guild.id);
if(!radio) return; if(!radio) return;
if(radio.textChannel?.type == ChannelType.DM || radio.textChannel?.type == ChannelType.GroupDM) return;
const audioPlayer = client.streamer?.listen(station); const audioPlayer = client.streamer?.listen(station);
if(!audioPlayer) return; if(!audioPlayer) return;
radio.connection?.subscribe(audioPlayer); radio.connection?.subscribe(audioPlayer);
@ -124,7 +123,7 @@ export default async function play(client: RadioClient, interaction: ChatInputCo
let timer : NodeJS.Timeout = setInterval(async function(){ let timer : NodeJS.Timeout = setInterval(async function(){
const radio = client.radio?.get(guild.id); const radio = client.radio?.get(guild.id);
if(!radio || !oldRadio || radio.station.name != oldRadio.station.name || radio.textChannel?.type == ChannelType.DM || radio.textChannel?.type == ChannelType.GroupDM) { if(!radio || !oldRadio || radio.station.name != oldRadio.station.name) {
return clearInterval(timer); return clearInterval(timer);
} }
@ -206,13 +205,13 @@ export default async function play(client: RadioClient, interaction: ChatInputCo
radio.message = await radio.textChannel?.send({ embeds: [embed], components: [buttons] }) ?? null; radio.message = await radio.textChannel?.send({ embeds: [embed], components: [buttons] }) ?? null;
} }
} }
},30000); },2500);
interaction?.reply({ interaction?.reply({
content: client.messages.emojis["play"] + client.messages.replace(client.messages.play, { content: client.messages.emojis["play"] + client.messages.replace(client.messages.play, {
"%radio.station.name%": radio.station.name "%radio.station.name%": radio.station.name
}), }),
flags: 'Ephemeral' ephemeral: true
}); });
} }

View File

@ -2,8 +2,8 @@ import { Guild } from "discord.js";
import RadioClient from "../../Client"; import RadioClient from "../../Client";
import { radio } from "../classes/Radio"; import { radio } from "../classes/Radio";
export default function saveState(client: RadioClient, guild: Guild | { id: string, name?: string } | undefined, radio: radio){ export default function saveState(client: RadioClient, guild: Guild, radio: radio){
if(!client.datastore || !guild) return; if(!client.datastore) return;
client.datastore.checkEntry(guild.id); client.datastore.checkEntry(guild.id);
let date = new Date(); let date = new Date();

View File

@ -16,8 +16,11 @@ export const messages = {
notPlaying: "There is nothing playing!", notPlaying: "There is nothing playing!",
runningCommandFailed: "Running this command failed!", runningCommandFailed: "Running this command failed!",
noPermsEmbed: "I cannot send embeds (Embed links).", noPermsEmbed: "I cannot send embeds (Embed links).",
helpTitle: "Help", bugTitle: "Found a bug with %client.user.username%?",
helpDescription: "Join to our support server" + "\n" + "%client.config.supportGuild%", bugDescription: "Join the support server" + "\n" + "%client.config.supportGuild%",
helpTitle: "%client.user.username% help:",
helpDescription: "%commands%",
inviteTitle: "Invite %client.user.username% to your Discord server!",
listTitle: "Radio Stations", listTitle: "Radio Stations",
playTitle1: ":radio: Channel", playTitle1: ":radio: Channel",
playDescription1: "__%radio.station.name%__" + "\n" + "%radio.station.owner%", playDescription1: "__%radio.station.name%__" + "\n" + "%radio.station.owner%",

View File

@ -6,7 +6,7 @@ export default {
token: process.env.DISCORD_TOKEN, token: process.env.DISCORD_TOKEN,
//radio stations //radio stations
stationslistUrl: process.env.RADIOX_STATIONSLISTURL || "https://eximiabots.waren.io/radiox/stations.json", stationslistUrl: process.env.RADIOX_STATIONSLISTURL || "https://git.cwinfo.net/cwchristerw/radio/raw/branch/master/playlist.json",
//support //support
supportGuild: "https://discord.gg/rRA65Mn", supportGuild: "https://discord.gg/rRA65Mn",