Skip to content

Commit

Permalink
settings set prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
Thierry Gameiro authored and Thierry Gameiro committed Apr 22, 2021
1 parent e7fe6cf commit 0b7dc15
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 65 deletions.
26 changes: 2 additions & 24 deletions cogs/dice.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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 = []
Expand Down
4 changes: 0 additions & 4 deletions cogs/john.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
44 changes: 44 additions & 0 deletions cogs/owner.py
Original file line number Diff line number Diff line change
@@ -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))
38 changes: 8 additions & 30 deletions cogs/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
2 changes: 1 addition & 1 deletion cogs/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -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
28 changes: 22 additions & 6 deletions cogs/utils/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"cogs.john",
"cogs.poll",
"cogs.ufd",
"cogs.owner",
"cogs.settings"
]
}

0 comments on commit 0b7dc15

Please sign in to comment.