using comma for multiples channel

This commit is contained in:
Mylloon 2021-07-27 16:16:10 +02:00
parent e4478be463
commit 8ee24fe256
3 changed files with 6 additions and 3 deletions

View file

@ -18,7 +18,7 @@ Open `.env` and insert the following fields:
|----------------|-----------------------------------------------------------------------------------------------------------|
| `ACCESS_TOKEN` | Access token you can take [here](https://twitchtokengenerator.com/) (be sure you selected Bot Chat Token) |
| `PREFIX` | Prefix you want to use for your bot |
| `CHANNEL` | The name of the your Twitch channel you want the bot to run at |
| `CHANNEL` | The name of the your Twitch channel you want the bot to run at (separate by comma) |
| `DISCORD` | Link to your discord server |
Start Bot:

View file

@ -5,7 +5,7 @@ from utils.utils import load
class Bot(commands.Bot):
def __init__(self):
self.keys = load(["ACCESS_TOKEN", "PREFIX", "CHANNEL"])
super().__init__(token=self.keys["ACCESS_TOKEN"], prefix=self.keys["PREFIX"], initial_channels=[f'{self.keys["CHANNEL"]}'])
super().__init__(token=self.keys["ACCESS_TOKEN"], prefix=self.keys["PREFIX"], initial_channels=self.keys["CHANNEL"])
async def event_ready(self):
print(f"Logged in as {self.nick}")

View file

@ -8,7 +8,10 @@ def load(variables):
load_dotenv()
for var in variables:
try:
keys[var] = environ[var]
res = environ[var]
if var == "CHANNEL": # create a list
res = res.split(',')
keys[var] = res
except KeyError:
print(f"Please set the environment variable {var} (.env file supported)")
exit(1)