Using REGION_DISCORD variable for voice region

This commit is contained in:
Mylloon 2021-08-06 16:24:37 +02:00
parent 4bd1314b04
commit ae5c27ff79
3 changed files with 11 additions and 3 deletions

View file

@ -1,4 +1,4 @@
# Bot developed with [discord.py](https://github.com/Rapptz/discord.py) (rewrite) - FRENCH # Bot Discord
[![Version](https://img.shields.io/badge/version-1.5-green?style=for-the-badge)](https://gitlab.com/ConfrerieDuKassoulait/KassouBot/-/releases) [![Version](https://img.shields.io/badge/version-1.5-green?style=for-the-badge)](https://gitlab.com/ConfrerieDuKassoulait/KassouBot/-/releases)
[![Build](https://img.shields.io/gitlab/pipeline/ConfrerieDuKassoulait/KassouBot/dev?style=for-the-badge)](https://gitlab.com/ConfrerieDuKassoulait/KassouBot/container_registry) [![Build](https://img.shields.io/gitlab/pipeline/ConfrerieDuKassoulait/KassouBot/dev?style=for-the-badge)](https://gitlab.com/ConfrerieDuKassoulait/KassouBot/container_registry)
@ -23,6 +23,8 @@ docker run -d \
You can add the environment variable `DEACTIVATE` to disable some cogs (separate the cogs with commas and no spaces between). You can add the environment variable `DEACTIVATE` to disable some cogs (separate the cogs with commas and no spaces between).
You can add the environment variable `REGION_DISCORD` to force the Lavalink server to use your voice region.
To find reddit tokens, go to [this site](https://www.reddit.com/prefs/apps) and here are the instructions: ![instructions](https://i.imgur.com/tEzYKDA.png) To find reddit tokens, go to [this site](https://www.reddit.com/prefs/apps) and here are the instructions: ![instructions](https://i.imgur.com/tEzYKDA.png)
*redirection uri (for copy/paste) : http://localhost:8080* *redirection uri (for copy/paste) : http://localhost:8080*
@ -37,8 +39,10 @@ To find Genius token, go to [this site](https://genius.com/api-clients), `login
## __Features__ ## __Features__
- Using [discord.py](https://github.com/Rapptz/discord.py) (rewrite)
- Everything is explained by doing the `help` command. - Everything is explained by doing the `help` command.
- Using SQLite for the database. - Using [SQLite](https://www.sqlite.org/index.html) for the database.
- Using [Lavalink](https://github.com/freyacodes/Lavalink) with a [Wavelink client](https://github.com/PythonistaGuild/Wavelink).
## __Launching locally__ ## __Launching locally__
If you want to run it without Docker, create an .env file to store variables in the root folder (there is an example [here](https://gitlab.com/ConfrerieDuKassoulait/KassouBot/-/blob/main/.envexample)). If you want to run it without Docker, create an .env file to store variables in the root folder (there is an example [here](https://gitlab.com/ConfrerieDuKassoulait/KassouBot/-/blob/main/.envexample)).

View file

@ -3,6 +3,7 @@ from subprocess import Popen, DEVNULL
from wavelink import Client as wClient from wavelink import Client as wClient
from discord.ext import commands from discord.ext import commands
from time import sleep from time import sleep
from utils.core import load
def setup(client): def setup(client):
client.add_cog(Music(client)) client.add_cog(Music(client))
@ -12,6 +13,7 @@ class Music(commands.Cog):
def __init__(self, client): def __init__(self, client):
self.client = client self.client = client
print("Démarrage du serveur Lavalink...", end = " ") print("Démarrage du serveur Lavalink...", end = " ")
self.keys = load(["REGION_DISCORD"])
Popen(['java', '-jar', 'Lavalink.jar'], stdout = DEVNULL) Popen(['java', '-jar', 'Lavalink.jar'], stdout = DEVNULL)
print("Lavalink prêt") print("Lavalink prêt")
@ -29,7 +31,7 @@ class Music(commands.Cog):
rest_uri = "http://127.0.0.1:2333", rest_uri = "http://127.0.0.1:2333",
password = "youshallnotpass", password = "youshallnotpass",
identifier = "PROD", identifier = "PROD",
region = "eu_west") region = self.keys["REGION_DISCORD"])
@commands.command(name='connect') @commands.command(name='connect')
async def connect_(self, ctx, *, channel: discord.VoiceChannel = None): async def connect_(self, ctx, *, channel: discord.VoiceChannel = None):

View file

@ -178,6 +178,8 @@ def load(variables):
except KeyError: except KeyError:
if var == "DEACTIVATE": if var == "DEACTIVATE":
keys[var] = "None" keys[var] = "None"
elif var == "REGION_DISCORD":
keys[var] = "eu_west"
else: else:
print(f"Please set the environment variable {var} (.env file supported)") print(f"Please set the environment variable {var} (.env file supported)")
exit(1) exit(1)