using comma for multiples channel
This commit is contained in:
parent
e4478be463
commit
8ee24fe256
3 changed files with 6 additions and 3 deletions
|
@ -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:
|
||||
|
|
|
@ -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}")
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue