🧹 Cleaned up starwars funcs
This commit is contained in:
@ -2,16 +2,9 @@ import discord, string, json
|
||||
from discord.ext import commands
|
||||
from discord_slash import cog_ext
|
||||
|
||||
from utils import Options, cap
|
||||
from utils import getParams
|
||||
|
||||
with open("resources/slashParameters.json", "r") as f:
|
||||
params = json.load(f)
|
||||
|
||||
options = Options()
|
||||
|
||||
if options.testing:
|
||||
for p in params:
|
||||
params[p]["guild_ids"] = options.guildIds
|
||||
params = getParams()
|
||||
|
||||
class starWarsCog(commands.Cog):
|
||||
|
||||
@ -22,46 +15,23 @@ class starWarsCog(commands.Cog):
|
||||
# Rolls star wars dice
|
||||
@cog_ext.cog_slash(**params["starWarsRoll"])
|
||||
async def starWarsRoll(self, ctx, dice = ""):
|
||||
command = cap(dice)
|
||||
newMessage = self.bot.starWars.roll.parseRoll("#"+str(ctx.author.id),command)
|
||||
messageList = newMessage.split("\n")
|
||||
await ctx.send(messageList[0])
|
||||
if len(messageList) > 1:
|
||||
for messageItem in messageList[1:]:
|
||||
await ctx.channel.send(messageItem)
|
||||
await self.bot.starWars.roll.parseRoll(ctx, dice)
|
||||
|
||||
# Controls destiny points
|
||||
@cog_ext.cog_slash(**params["starWarsDestiny"])
|
||||
async def starWarsDestiny(self, ctx, parameters = ""):
|
||||
newMessage = self.bot.starWars.destiny.parseDestiny("#"+str(ctx.author.id),parameters)
|
||||
messageList = newMessage.split("\n")
|
||||
await ctx.send(messageList[0])
|
||||
if len(messageList) > 1:
|
||||
for messageItem in messageList[1:]:
|
||||
await ctx.channel.send(messageItem)
|
||||
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):
|
||||
newMessage = self.bot.starWars.roll.critRoll(int(severity))
|
||||
|
||||
messageList = newMessage.split("\n")
|
||||
await ctx.send(messageList[0])
|
||||
if len(messageList) > 1:
|
||||
for messageItem in messageList[1:]:
|
||||
await ctx.channel.send(messageItem)
|
||||
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 = ""):
|
||||
command = string.capwords(parameters.replace("+","+ ").replace("-","- ").replace(",",", "))
|
||||
title, desc = self.bot.starWars.character.parseChar("#"+str(ctx.author.id),command)
|
||||
if title != "":
|
||||
em1 = discord.Embed(title = title, description = desc, colour=0xDEADBF)
|
||||
await ctx.send(embed = em1)
|
||||
else:
|
||||
await ctx.send(desc)
|
||||
await self.bot.starWars.character.parseChar(ctx, parameters)
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(starWarsCog(bot))
|
Reference in New Issue
Block a user