Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
238 changes: 238 additions & 0 deletions commands.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,238 @@
import discord
from utils import CONFIG, save_config, is_bot_owner
from discord.ext import commands


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

# ✅ Toggle Debug Mode
@tree.command(name="toggle_debug", description="Toggle debug mode")
async def toggle_debug(interaction: discord.Interaction) -> None:
if not is_bot_owner(interaction):
await interaction.response.send_message(
"❌ You do not have permission.", ephemeral=True
)
return

CONFIG["debug"] = not CONFIG.get("debug", False)
save_config()

await interaction.response.send_message(
f"✅ Debug mode {'enabled' if CONFIG['debug'] else 'disabled'}."
)

# ✅ Set Refresh Time
@tree.command(name="set_refresh_time", description="Set bot refresh time")
async def set_refresh_time(interaction: discord.Interaction, seconds: int) -> None:
if not is_bot_owner(interaction):
await interaction.response.send_message(
"❌ You do not have permission.", ephemeral=True
)
return

CONFIG["refresh_time"] = seconds
save_config()

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

# ✅ Set Game TTL
@tree.command(name="set_game_ttl", description="Set game timeout duration")
async def set_game_ttl(interaction: discord.Interaction, seconds: int) -> None:
if not is_bot_owner(interaction):
await interaction.response.send_message(
"❌ You do not have permission.", ephemeral=True
)
return

CONFIG["game_ttl"] = seconds
save_config()

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

# ✅ Add Game Type
@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:
if not is_bot_owner(interaction):
await interaction.response.send_message(
"❌ You do not have permission.", ephemeral=True
)
return

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

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

# ✅ Set Discord Channel ID
@tree.command(name="set_channel", description="Set the bot's Discord channel")
async def set_channel(
interaction: discord.Interaction, channel: discord.TextChannel
) -> None:
if not is_bot_owner(interaction):
await interaction.response.send_message(
"❌ You do not have permission.", ephemeral=True
)
return

CONFIG["discord_channel_id"] = channel.id
save_config()

await interaction.response.send_message(
f"✅ Discord channel set to {channel.mention}."
)

# ✅ Add a Bot Owner
@tree.command(name="add_bot_owner", description="Add a bot owner by user ID")
async def add_bot_owner(interaction: discord.Interaction, user_id: int) -> None:
if not is_bot_owner(interaction):
await interaction.response.send_message(
"❌ You do not have permission.", ephemeral=True
)
return

CONFIG["bot_owners"].append(user_id)
save_config()

await interaction.response.send_message(
f"✅ User with ID `{user_id}` added as a bot owner."
)

# ✅ Remove a Bot Owner
@tree.command(name="remove_bot_owner", description="Remove a bot owner by user ID")
async def remove_bot_owner(interaction: discord.Interaction, user_id: int) -> None:
if not is_bot_owner(interaction):
await interaction.response.send_message(
"❌ You do not have permission.", ephemeral=True
)
return

if user_id in CONFIG["bot_owners"]:
CONFIG["bot_owners"].remove(user_id)
save_config()
await interaction.response.send_message(
f"✅ Removed user with ID `{user_id}` from bot owners."
)
else:
await interaction.response.send_message(
f"⚠ User with ID `{user_id}` is not a bot owner.", ephemeral=True
)

# ✅ Add Difficulty
@tree.command(name="add_difficulty", description="Add a new difficulty level")
async def add_difficulty(interaction: discord.Interaction, difficulty: str) -> None:
if not is_bot_owner(interaction):
await interaction.response.send_message(
"❌ You do not have permission.", ephemeral=True
)
return

CONFIG["difficulties"].append(difficulty)
save_config()

await interaction.response.send_message(f"✅ Added difficulty: `{difficulty}`.")

# ✅ Remove Difficulty
@tree.command(name="remove_difficulty", description="Remove a difficulty level")
async def remove_difficulty(
interaction: discord.Interaction, difficulty: str
) -> None:
if not is_bot_owner(interaction):
await interaction.response.send_message(
"❌ You do not have permission.", ephemeral=True
)
return

if difficulty in CONFIG["difficulties"]:
CONFIG["difficulties"].remove(difficulty)
save_config()
await interaction.response.send_message(
f"✅ Removed difficulty: `{difficulty}`."
)
else:
await interaction.response.send_message(
f"⚠ Difficulty `{difficulty}` not found.", ephemeral=True
)

# ✅ Set Tick Rate
@tree.command(name="set_tick_rate", description="Set a tick rate")
async def set_tick_rate(
interaction: discord.Interaction, rate: int, name: str
) -> None:
if not is_bot_owner(interaction):
await interaction.response.send_message(
"❌ You do not have permission.", ephemeral=True
)
return

CONFIG["tick_rates"][str(rate)] = name
save_config()

await interaction.response.send_message(
f"✅ Set tick rate `{rate}` to `{name}`."
)

# ✅ Remove Tick Rate
@tree.command(name="remove_tick_rate", description="Remove a tick rate")
async def remove_tick_rate(interaction: discord.Interaction, rate: int) -> None:
if not is_bot_owner(interaction):
await interaction.response.send_message(
"❌ You do not have permission.", ephemeral=True
)
return

rate_str = str(rate)
if rate_str in CONFIG["tick_rates"]:
del CONFIG["tick_rates"][rate_str]
save_config()
await interaction.response.send_message(f"✅ Removed tick rate `{rate}`.")
else:
await interaction.response.send_message(
f"⚠ Tick rate `{rate}` not found.", ephemeral=True
)

# ✅ Add Game Option
@tree.command(name="add_game_option", description="Add a new game option")
async def add_game_option(
interaction: discord.Interaction, key: str, value: str
) -> None:
if not is_bot_owner(interaction):
await interaction.response.send_message(
"❌ You do not have permission.", ephemeral=True
)
return

CONFIG["game_options"][key] = value
save_config()

await interaction.response.send_message(
f"✅ Added game option: `{key}` - {value}"
)

# ✅ Remove Game Option
@tree.command(name="remove_game_option", description="Remove a game option")
async def remove_game_option(interaction: discord.Interaction, key: str) -> None:
if not is_bot_owner(interaction):
await interaction.response.send_message(
"❌ You do not have permission.", ephemeral=True
)
return

if key in CONFIG["game_options"]:
del CONFIG["game_options"][key]
save_config()
await interaction.response.send_message(f"✅ Removed game option `{key}`.")
else:
await interaction.response.send_message(
f"⚠ Game option `{key}` not found.", ephemeral=True
)

await client.tree.sync()
40 changes: 40 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"debug": false,
"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",
"theo_quest": "Theo Quest",
"cow_quest": "Cow Quest",
"friendly_fire": "Friendly Fire"
}
}
Loading