Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dump config override #15

Merged
merged 5 commits into from
Feb 28, 2023
Merged
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
10 changes: 10 additions & 0 deletions override.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,16 @@ async def config(self, ctx: discord.Interaction):
await ctx.followup.send("Sent config.")
logging.info("Config sent.")

@app_commands.command(name="dumpconfig", description="Deletes all data from config")
@app_commands.check(is_owner)
async def dump_config(self, ctx: discord.Interaction, confirm: bool):
"""Dump config of bot"""
if confirm:
self._config.dump()
await ctx.response.send_message("Configuration dumped.\n**Prepare for unforeseen consequences.**")
return
await ctx.response.send_message("Dump aborted.")

async def setup(bot: commands.Bot):
"""Setup function for the cog."""
await bot.add_cog(Overrides(bot, Config(bot)))
7 changes: 6 additions & 1 deletion variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from discord.ext import commands

#v[major].[minor].[release].[build]
VERSION = "v0.0.2.4a"
VERSION = "v0.0.2.4b"
PROG_DIR = os.path.dirname(os.path.realpath(__file__))

intents = discord.Intents.default()
Expand Down Expand Up @@ -55,6 +55,11 @@ def update(self) -> None:
json.dump(self._config,config_f,indent=4)
config_f.truncate()

def dump(self) -> None:
'''Wipes everything but guild id from config'''
self._config = {'guild_id': self._config['guild_id']}
self.update()

@property
def guild(self) -> discord.Guild:
'''Returns the guild object'''
Expand Down