Skip to content
This repository has been archived by the owner on Nov 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #37 from ExpressHermes/update-dockerfile
Browse files Browse the repository at this point in the history
Updated docker-compose and Dockerfile
  • Loading branch information
codeperfectplus authored Nov 1, 2022
2 parents b9c3dc3 + f3c1a77 commit 1e4f3ec
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ FROM python:3.9

WORKDIR /app

COPY requirements /app/requirements
COPY requirements.txt /app/requirements.txt

RUN pip install -r requirements.txt
COPY . /app

RUN start.sh
RUN bash start_server.sh
25 changes: 22 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,33 @@ Invite **Cybel** into your server

#### Run with Docker

Documentation is in progress
1. Create .env file in root directory and add the following variables. Sample env file is [here](/.env.sample)

```bash
DISCORD_TOKEN=Discord bot token [get it from here](https://discord.com/developers/applications)
WEATHER_API_KEY=OpenWeatherMap API key [get it from here](https://openweathermap.org/api)
DATABASE_URL=postgres://username:password@localhost:5432/database_name
```

2. Run the docker-compose command to run the bot

```bash
docker compose up -d
```

3. See the docker logs

```bash
docker compose logs -f
```


#### Run locally

1. Create .evn file in root directory and add the following variables. Sample Env file is [here](/.env.sample)
1. Create .env file in root directory and add the following variables. Sample env file is [here](/.env.sample)

```bash
DISCORD_TOKEN: Discord bot token [get it from here](https://discord.com/developers/applications)
DISCORD_TOKEN=Discord bot token [get it from here](https://discord.com/developers/applications)
WEATHER_API_KEY= OpenWeatherMap API key [get it from here](https://openweathermap.org/api)
DATABASE_URL=postgres://username:password@localhost:5432/database_name
```
Expand Down
11 changes: 8 additions & 3 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
'NSFW Commands': 'src.cogs.nsfwCommands',
'Fun Commands': 'src.cogs.funCommands',
'Utility Commands': 'src.cogs.utilityCommands',
'Music Commands': 'src.cogs.musicCommands', # FIXME: add music commands in future update
# FIXME: add music commands in future update
'Music Commands': 'src.cogs.musicCommands',
'Owner Commands': 'src.cogs.ownerCommands',
'Testing Commands': 'src.cogs.testingCommands',
'Error Handler': 'src.cogs.errorHandler',
Expand All @@ -59,5 +60,9 @@ async def load_cogs(cog_dict: dict):


if __name__ == '__main__':
asyncio.run(load_cogs(cog_dict=cog_dict))
bot.run(DISCORD_TOKEN, log_level=logging.DEBUG if args.debug else logging.INFO)
try:
asyncio.run(load_cogs(cog_dict=cog_dict))
bot.run(DISCORD_TOKEN,
log_level=logging.DEBUG if args.debug else logging.INFO)
except Exception as e:
logging.error('Error while running bot: {}'.format(e))
14 changes: 10 additions & 4 deletions src/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
encoding="utf-8",
datefmt='%d/%m/%Y %I:%M:%S %p',
handlers=[
logging.FileHandler(os.path.join(root_dir, 'logs', 'bot.log')),
logging.FileHandler(os.path.join(
root_dir, 'logs', 'bot.log')),
logging.StreamHandler()])

logging.info(f'Discord Version : {discord.__version__}')
Expand All @@ -42,8 +43,12 @@ def get_environment_variable(key: str):
if value is not None:
logging.info('Loading... {}'.format(key))
return value
except Exception:
logging.critical('{} is not found in environment variable.'.format(key))
else:
logging.error(
'{} is not found in environment variable.'.format(key))
except Exception as e:
logging.critical(
'Error while reading environment variables: {}'.format(e))


DISCORD_TOKEN = get_environment_variable('DISCORD_TOKEN')
Expand Down Expand Up @@ -81,7 +86,8 @@ def create_embed(ctx=None, title=None, description="", color=None):
embed (discord.Embed): The embed created
"""
embed = discord.Embed(title=title, description=description, color=color)
embed.set_thumbnail(url="https://cdn.discordapp.com/attachments/831943037936467985/835036938326638622/cybel.png")
embed.set_thumbnail(
url="https://cdn.discordapp.com/attachments/831943037936467985/835036938326638622/cybel.png")
if ctx is not None:
embed.set_author(name=ctx.author.name)
return embed

0 comments on commit 1e4f3ec

Please sign in to comment.