✨ Even more converting to slash commands
This commit is contained in:
@ -1,8 +1,18 @@
|
||||
import discord, string
|
||||
import discord, string, json
|
||||
from discord.ext import commands
|
||||
from discord_slash import cog_ext
|
||||
|
||||
from funcs import cap
|
||||
from utils import Options
|
||||
|
||||
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
|
||||
|
||||
class SwCog(commands.Cog):
|
||||
|
||||
@ -11,37 +21,43 @@ class SwCog(commands.Cog):
|
||||
self.client = client
|
||||
|
||||
# Rolls star wars dice
|
||||
@cog_ext.cog_slash()
|
||||
async def swroll(self, ctx, dice = ""):
|
||||
@cog_ext.cog_slash(**params["starWarsRoll"])
|
||||
async def starWarsRoll(self, ctx, dice = ""):
|
||||
command = cap(dice)
|
||||
newMessage = self.client.swroll.parseRoll("#"+str(ctx.message.author.id),command)
|
||||
newMessage = self.client.swroll.parseRoll("#"+str(ctx.author.id),command)
|
||||
messageList = newMessage.split("\n")
|
||||
for messageItem in messageList:
|
||||
await ctx.send(messageItem)
|
||||
await ctx.send(messageList[0])
|
||||
if len(messageList) > 1:
|
||||
for messageItem in messageList[1:]:
|
||||
await ctx.channel.send(messageItem)
|
||||
|
||||
# Controls destiny points
|
||||
@cog_ext.cog_slash()
|
||||
async def swd(self, ctx, *, content):
|
||||
newMessage = self.client.swdestiny.parseDestiny("#"+str(ctx.message.author.id),content)
|
||||
@cog_ext.cog_slash(**params["starWarsDestiny"])
|
||||
async def starWarsDestiny(self, ctx, parameters = ""):
|
||||
newMessage = self.client.swdestiny.parseDestiny("#"+str(ctx.author.id),parameters)
|
||||
messageList = newMessage.split("\n")
|
||||
for messageItem in messageList:
|
||||
await ctx.send(messageItem)
|
||||
await ctx.send(messageList[0])
|
||||
if len(messageList) > 1:
|
||||
for messageItem in messageList[1:]:
|
||||
await ctx.channel.send(messageItem)
|
||||
|
||||
# Rolls for critical injuries
|
||||
@cog_ext.cog_slash()
|
||||
async def swcrit(self, ctx, arg : int = 0):
|
||||
newMessage = self.client.swroll.critRoll(int(arg))
|
||||
@cog_ext.cog_slash(**params["starWarsCrit"])
|
||||
async def starWarsCrit(self, ctx, severity : int = 0):
|
||||
newMessage = self.client.swroll.critRoll(int(severity))
|
||||
|
||||
messageList = newMessage.split("\n")
|
||||
for messageItem in messageList:
|
||||
await ctx.send(messageItem)
|
||||
await ctx.send(messageList[0])
|
||||
if len(messageList) > 1:
|
||||
for messageItem in messageList[1:]:
|
||||
await ctx.channel.send(messageItem)
|
||||
|
||||
# Accesses and changes character sheet data with the parseChar function
|
||||
# from funcs/swfuncs/swchar.py
|
||||
@cog_ext.cog_slash()
|
||||
async def swchar(self, ctx, *, content = ""):
|
||||
command = string.capwords(content.replace("+","+ ").replace("-","- ").replace(",",", "))
|
||||
title, desc = self.client.swchar.parseChar("#"+str(ctx.message.author.id),command)
|
||||
@cog_ext.cog_slash(**params["starWarsCharacter"])
|
||||
async def starWarsCharacter(self, ctx, parameters = ""):
|
||||
command = string.capwords(parameters.replace("+","+ ").replace("-","- ").replace(",",", "))
|
||||
title, desc = self.client.swchar.parseChar("#"+str(ctx.author.id),command)
|
||||
if title != "":
|
||||
em1 = discord.Embed(title = title, description = desc, colour=0xDEADBF)
|
||||
await ctx.send(embed = em1)
|
||||
|
Reference in New Issue
Block a user