Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions commands.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import discord
from utils import load_config, save_config, is_admin
from discord.ext import commands
from typing import Dict, Any

async def setup_commands(client: commands.Bot) -> None:
tree = client.tree

@tree.command(name="set_refresh_time", description="Set bot refresh time")
async def set_refresh_time(interaction: discord.Interaction, seconds: int) -> None:
config = load_config()

if not is_admin(interaction, config):
await interaction.response.send_message("❌ You do not have permission.", ephemeral=True)
return

config["refresh_time"] = seconds
save_config(config)

await interaction.response.send_message(f"✅ Refresh time updated to {seconds} seconds.")

@tree.command(name="set_game_ttl", description="Set game timeout duration")
async def set_game_ttl(interaction: discord.Interaction, seconds: int) -> None:
config = load_config()

if not is_admin(interaction, config):
await interaction.response.send_message("❌ You do not have permission.", ephemeral=True)
return

config["game_ttl"] = seconds
save_config(config)

await interaction.response.send_message(f"✅ Game TTL updated to {seconds} seconds.")

@tree.command(name="add_game_type", description="Add a new game type")
async def add_game_type(interaction: discord.Interaction, code: str, name: str) -> None:
config = load_config()

if not is_admin(interaction, config):
await interaction.response.send_message("❌ You do not have permission.", ephemeral=True)
return

config["game_types"][code.upper()] = name
save_config(config)

await interaction.response.send_message(f"✅ Added game type: `{code.upper()}` - {name}")

await client.tree.sync()
36 changes: 36 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"discord_channel_id": 1061483226767556719,
"refresh_time": 30,
"game_ttl": 120,
"bot_owners": [],
"difficulties": [
"Normal",
"Nightmare",
"Hell"
],
"tick_rates": {
"20": "Normal",
"30": "Fast",
"40": "Faster",
"50": "Fastest"
},
"game_types": {
"DRTL": "DevilutionX (Diablo)",
"DSHR": "DevilutionX (Diablo Shareware)",
"HRTL": "DevilutionX (Hellfire)",
"HSHR": "DevilutionX (Hellfire Shareware)",
"IRON": "sixcy - Ironman",
"MEMD": "DakkDaniels - Middle Earth",
"DRDX": "ikonomov - DiabloX",
"DWKD": "wkdgmr - wkdmod (Diablo)",
"HWKD": "wkdgmr - wkdmod (Hellfire)",
"LTDR": "kphoenix - Lord of Terror (Diablo)",
"LTDS": "kphoenix - Lord of Terror (Diablo Shareware)",
"LTHR": "kphoenix - Lord of Terror (Hellfire)",
"LTHS": "kphoenix - Lord of Terror (Hellfire Shareware)"
},
"game_options": {
"run_in_town": "Run in Town",
"full_quests": "Quests"
}
}
Loading