📝 Cogs and utils

Improved code style and added comments and docstrings to cogs and utils.
This commit is contained in:
NikolajDanger
2021-04-15 15:16:56 +02:00
parent 35b2446a10
commit 43f26ec383
11 changed files with 725 additions and 255 deletions

View File

@ -1,37 +1,40 @@
import discord, string, json
"""Contains the StarWarsCog, which deals with Star Wars commands."""
from discord.ext import commands
from discord_slash import cog_ext
from utils import getParams
from utils import getParams # pylint: disable=import-error
params = getParams()
class starWarsCog(commands.Cog):
class StarWarsCog(commands.Cog):
"""Contains the Star Wars commands."""
def __init__(self, bot):
"""Runs star wars commands."""
"""Initialize the cog."""
self.bot = bot
# Rolls star wars dice
@cog_ext.cog_slash(**params["starWarsRoll"])
async def starWarsRoll(self, ctx, dice = ""):
async def starWarsRoll(self, ctx, dice=""):
"""Roll Star Wars dice."""
await self.bot.starWars.roll.parseRoll(ctx, dice)
# Controls destiny points
@cog_ext.cog_slash(**params["starWarsDestiny"])
async def starWarsDestiny(self, ctx, parameters = ""):
async def starWarsDestiny(self, ctx, parameters=""):
"""Control Star Wars destiny points."""
await self.bot.starWars.destiny.parseDestiny(ctx, parameters)
# Rolls for critical injuries
@cog_ext.cog_slash(**params["starWarsCrit"])
async def starWarsCrit(self, ctx, severity : int = 0):
async def starWarsCrit(self, ctx, severity: int = 0):
"""Roll for critical injuries."""
await self.bot.starWars.roll.critRoll(ctx, severity)
# Accesses and changes character sheet data with the parseChar function
# from funcs/starWarsFuncs/starWarsCharacter.py
@cog_ext.cog_slash(**params["starWarsCharacter"])
async def starWarsCharacter(self, ctx, parameters = ""):
async def starWarsCharacter(self, ctx, parameters=""):
"""Access and change Star Wars character sheet data."""
await self.bot.starWars.character.parseChar(ctx, parameters)
def setup(bot):
bot.add_cog(starWarsCog(bot))
"""Add the cog to the bot."""
bot.add_cog(StarWarsCog(bot))