Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cleaned up project structure and extension setup
- Loading branch information
Showing
23 changed files
with
329 additions
and
272 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from discord.ext import commands | ||
import logging | ||
from ruamel import yaml | ||
import os | ||
from functools import wraps | ||
from .context import Context | ||
|
||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class Bot(commands.Bot): | ||
def __init__(self, *args, **kwargs): | ||
super(Bot, self).__init__(*args, **kwargs) | ||
|
||
with open(os.path.dirname(__file__) + '/translations/strings.yml', 'r', encoding='utf-8') as stream: | ||
try: | ||
_string_translations = yaml.load(stream, Loader=yaml.Loader) | ||
except yaml.YAMLError as exc: | ||
logger.error(exc) | ||
|
||
async def on_message(self, message): | ||
ctx = await self.get_context(message, cls=Context) | ||
await self.invoke(ctx) | ||
|
||
@property | ||
def string_translations(self): | ||
return Bot._string_translations | ||
|
||
@staticmethod | ||
def prime_feature(f: callable) -> callable: | ||
@wraps(f) | ||
async def wrapper(ctx, *args, **kwargs): | ||
if not ctx.is_prime(): | ||
await ctx.send(ctx.translate("this is a prime feature")) | ||
else: | ||
await f(ctx, *args, *kwargs) | ||
|
||
return wrapper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,21 @@ | ||
from .config import config | ||
from .ticket import ticket | ||
from .tickets import tickets | ||
from .response import response | ||
from .help import help_messages | ||
from .outlaw import outlaw | ||
from .statistics import statistics | ||
from .blacklist import blacklist | ||
from .report import report | ||
|
||
|
||
def setup(bot): | ||
from .config import config | ||
from .ticket import ticket | ||
from .tickets import tickets | ||
from .response import response | ||
from .help import help_messages | ||
from .outlaw import outlaw | ||
from .statistics import statistics | ||
from .blacklist import blacklist | ||
from .report import report | ||
bot.add_command(config) | ||
bot.add_command(ticket) | ||
bot.add_command(tickets) | ||
bot.add_command(response) | ||
bot.add_command(help_messages) | ||
bot.add_command(outlaw) | ||
bot.add_command(statistics) | ||
bot.add_command(blacklist) | ||
bot.add_command(report) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.