-
Notifications
You must be signed in to change notification settings - Fork 0
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 #8 from doodlebunnyhops/base-player-commands
Base Player Commands
- Loading branch information
Showing
27 changed files
with
1,695 additions
and
227 deletions.
There are no files selected for viewing
File renamed without changes.
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,18 @@ | ||
from discord import app_commands | ||
from discord.ext import commands | ||
|
||
from cogs.game_commands.set import set_group | ||
|
||
class Game(commands.Cog): | ||
def __init__(self, bot): | ||
self.bot = bot | ||
self.commands_to_toggle = ["join", "trick", "treat"] | ||
|
||
game_group = app_commands.Group(name="game",description="Game options and commands") | ||
game_group.add_command(set_group) | ||
|
||
|
||
|
||
|
||
async def setup(bot): | ||
await bot.tree.add_command(Game.game_group) |
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,47 @@ | ||
|
||
import discord | ||
from discord import app_commands | ||
import utils.checks as checks | ||
from db_utils import get_game_settings, set_game_disabled | ||
|
||
from modals.settings import Game | ||
|
||
# Subcommand group for setting (used within the server group) | ||
set_group = app_commands.Group(name="set", description="Set commands") | ||
|
||
@set_group.command(name="settings", description="Update the game settings.") | ||
@checks.check_if_has_permission_or_role() | ||
async def set_game_settings(interaction: discord.Interaction): | ||
modal = Game() | ||
await interaction.response.send_modal(modal) | ||
|
||
|
||
@set_group.command(name="state", description="Enable or disable the game.") | ||
@app_commands.describe( | ||
state="Enable or disable the game." | ||
) | ||
@app_commands.choices(state=[ | ||
app_commands.Choice(name="Enable", value="enable"), | ||
app_commands.Choice(name="Disable", value="disable") | ||
]) | ||
@checks.check_if_has_permission_or_role() | ||
async def set_game_state( interaction: discord.Interaction, state: app_commands.Choice[str]): | ||
guild_id = interaction.guild.id | ||
|
||
# Fetch current settings from the db using db_utils | ||
game_disabled, _, _ = get_game_settings(guild_id) | ||
|
||
# Logic based on the selected option and current game state | ||
if state.value == "enable": | ||
if not game_disabled: | ||
await interaction.response.send_message("The game commands are already enabled.", ephemeral=True) | ||
return | ||
set_game_disabled(guild_id, False) | ||
await interaction.response.send_message("The game commands have been enabled.", ephemeral=True) | ||
|
||
elif state.value == "disable": | ||
if game_disabled: | ||
await interaction.response.send_message("The game commands are already disabled.", ephemeral=True) | ||
return | ||
set_game_disabled(guild_id, True) | ||
await interaction.response.send_message("The game commands have been disabled.", ephemeral=True) |
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
Oops, something went wrong.