From 0b7dc15a4cdfbc5a0c6a22c416dc1d0d37f177c8 Mon Sep 17 00:00:00 2001 From: Thierry Gameiro Date: Thu, 22 Apr 2021 02:44:54 +0200 Subject: [PATCH] settings set prefix --- cogs/dice.py | 26 ++----------------------- cogs/john.py | 4 ---- cogs/owner.py | 44 ++++++++++++++++++++++++++++++++++++++++++ cogs/settings.py | 38 ++++++++---------------------------- cogs/utils/__init__.py | 2 +- cogs/utils/_help.py | 28 +++++++++++++++++++++------ config.json | 1 + 7 files changed, 78 insertions(+), 65 deletions(-) create mode 100644 cogs/owner.py diff --git a/cogs/dice.py b/cogs/dice.py index d9eb121..26fb038 100644 --- a/cogs/dice.py +++ b/cogs/dice.py @@ -3,29 +3,7 @@ import numpy as np import re -from cogs.utils import HelperCommand - - -TITLE = "**Roll a random dice**" -DESCRIPTION_COMMAND = """ - Roll one six sided die. - $d 1d6 - - Roll two four sided die. - $d 2d4 - - Roll one -101 to 150 sided die. - $d 1d[-101:150] - - Add a one six sided die and a eight sided die (all display). - $d 1d6 + 1d8 -v - - Minus a one six sided die and a eight sided die (only output). - $d 1d6 - 1d8 - - Add 6 at a one sided die. - $d 1d6 + 6 - """ +from cogs.utils import HelperCommand, TITLE_DICE, DESCRIPTION_COMMAND_DICE class Dice(commands.Cog, HelperCommand): @@ -62,7 +40,7 @@ async def d(self, ctx, *args): return if len(args) < 1 or ('help' in args): - await ctx.channel.send(embed=self.help(title=TITLE, description_command=DESCRIPTION_COMMAND)) + await ctx.channel.send(embed=self.help(title=TITLE_DICE, description_command=DESCRIPTION_COMMAND_DICE)) return values = [] diff --git a/cogs/john.py b/cogs/john.py index ae58b3d..5588dc1 100644 --- a/cogs/john.py +++ b/cogs/john.py @@ -6,10 +6,6 @@ class John(commands.Cog): def __init__(self, bot): self.bot = bot - @commands.command(name='hello') - async def say_hello(self, ctx): - await ctx.channel.send(f'Hello {ctx.author.name}') - @commands.Cog.listener() async def on_message(self, message): if message.author.id == self.bot.user.id: diff --git a/cogs/owner.py b/cogs/owner.py new file mode 100644 index 0000000..71d378b --- /dev/null +++ b/cogs/owner.py @@ -0,0 +1,44 @@ +import discord +from discord.ext import commands + + + +class Owner(commands.Cog): + def __init__(self, bot): + self.bot = bot + self.path = 'cogs.' + + @commands.command(name="load", hidden=True) + @commands.is_owner() + async def load(self, ctx, *, cog: str): + try: + self.bot.load_extension(self.path + cog) + except Exception as e: + await ctx.send(f"**`ERROR: {e}`**") + else: + await ctx.send("**`SUCCESS`**") + + @commands.command(name="unload", hidden=True) + @commands.is_owner() + async def unload(self, ctx, *, cog: str): + print(cog) + try: + self.bot.unload_extension(self.path + cog) + except Exception as e: + await ctx.send(f"**`ERROR: {e}`**") + else: + await ctx.send("**`SUCCESS`**") + + @commands.command(name="reload", hidden=True) + @commands.is_owner() + async def reload(self, ctx, *, cog: str): + try: + self.bot.unload_extension(self.path + cog) + self.bot.load_extension(self.path + cog) + except Exception as e: + await ctx.send(f"**`ERROR: {e}`**") + else: + await ctx.send("**`SUCCESS`**") + +def setup(bot): + bot.add_cog(Owner(bot)) \ No newline at end of file diff --git a/cogs/settings.py b/cogs/settings.py index 7561886..37e3c09 100644 --- a/cogs/settings.py +++ b/cogs/settings.py @@ -6,39 +6,17 @@ class Settings(commands.Cog): def __init__(self, bot): self.bot = bot - self.path = 'cogs.' - @commands.command(name="load", hidden=True) - @commands.is_owner() - async def load(self, ctx, *, cog: str): - try: - self.bot.load_extension(self.path + cog) - except Exception as e: - await ctx.send(f"**`ERROR: {e}`**") - else: - await ctx.send("**`SUCCESS`**") + @commands.command(name='hello') + async def say_hello(self, ctx): + await ctx.channel.send(f'Hello {ctx.author.name}') - @commands.command(name="unload", hidden=True) - @commands.is_owner() - async def unload(self, ctx, *, cog: str): - print(cog) - try: - self.bot.unload_extension(self.path + cog) - except Exception as e: - await ctx.send(f"**`ERROR: {e}`**") - else: - await ctx.send("**`SUCCESS`**") - @commands.command(name="reload", hidden=True) - @commands.is_owner() - async def reload(self, ctx, *, cog: str): - try: - self.bot.unload_extension(self.path + cog) - self.bot.load_extension(self.path + cog) - except Exception as e: - await ctx.send(f"**`ERROR: {e}`**") - else: - await ctx.send("**`SUCCESS`**") + @commands.has_permissions(administrator=True) + @commands.command(name='set_prefix') + async def set_prefix(self, ctx, *, new_prefix: str): + self.bot.command_prefix = new_prefix + await ctx.send(f'Prefix has been set to `{new_prefix}`.') def setup(bot): bot.add_cog(Settings(bot)) \ No newline at end of file diff --git a/cogs/utils/__init__.py b/cogs/utils/__init__.py index 596c374..364de96 100644 --- a/cogs/utils/__init__.py +++ b/cogs/utils/__init__.py @@ -1,4 +1,4 @@ from ._ufd import REF_ATK, DEFAULT_EXCLUDE_OVERALL_STATS, DEFAULT_STATS, UltimateFD from ._poll import EMOJI -from ._help import HelperCommand, TITLE_UFD, DESCRIPTION_COMMAND_UFD, TITLE_POLL, DESCRIPTION_COMMAND_POLL +from ._help import HelperCommand, TITLE_UFD, DESCRIPTION_COMMAND_UFD, TITLE_POLL, DESCRIPTION_COMMAND_POLL, TITLE_DICE, DESCRIPTION_COMMAND_DICE from ._args import ParseArgs \ No newline at end of file diff --git a/cogs/utils/_help.py b/cogs/utils/_help.py index 14a4356..2171e8a 100644 --- a/cogs/utils/_help.py +++ b/cogs/utils/_help.py @@ -6,6 +6,25 @@ config_arg = json.load(f)["command_prefix"] +REF_COLOR = {'dice': '#8B0000'} + +TITLE_DICE = "**Roll a random dice**" +DESCRIPTION_COMMAND_DICE = f""" + Roll one six sided die. + ```{config_arg}d 1d6``` + Roll two four sided die. + ```{config_arg}d 2d4``` + Roll one -101 to 150 sided die. + ```{config_arg}d 1d[-101:150]``` + Add a one six sided die and a eight sided die (all display). + ```{config_arg}d 1d6 + 1d8 -v``` + Minus a one six sided die and a eight sided die (only output). + ```{config_arg}d 1d6 - 1d8``` + Add 6 at a one sided die. + ```{config_arg}d 1d6 + 6``` + """ + + TITLE_UFD = "**Ultimate frame data**" DESCRIPTION_COMMAND_UFD = f""" Get all characters name with -l option (show links) @@ -15,17 +34,14 @@ TITLE_POLL = "**Create a poll**" DESCRIPTION_COMMAND_POLL = f""" Create a simple poll. - {config_arg}poll Kenshuri is a troll? - + ```{config_arg}poll Kenshuri is a troll?``` For advanced polls use the folowing syntax: - {config_arg}poll {{title}} [Option1] [Option2] [Option 3] ... - - Note: options are limited at 21. + ```{config_arg}poll {{title}} [Option1] [Option2] [Option 3] ...``` + *Note: options are limited at 21.* """ - class HelperCommand: def __init__(self): pass diff --git a/config.json b/config.json index d424c77..f5613ee 100644 --- a/config.json +++ b/config.json @@ -6,6 +6,7 @@ "cogs.john", "cogs.poll", "cogs.ufd", + "cogs.owner", "cogs.settings" ] } \ No newline at end of file