From 7c58f5a97abf9ac5e7353940b0ddc50a585d9066 Mon Sep 17 00:00:00 2001 From: stolenvw Date: Sat, 10 Apr 2021 15:28:44 -0400 Subject: Major rewrite, Added optional commands for displaying V+ config settings --- optional/pluscmds.py | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 optional/pluscmds.py (limited to 'optional/pluscmds.py') diff --git a/optional/pluscmds.py b/optional/pluscmds.py new file mode 100644 index 0000000..6c91147 --- /dev/null +++ b/optional/pluscmds.py @@ -0,0 +1,70 @@ +import discord, typing +from discord.ext import commands + +class Plus(commands.Cog): + """ + Plus commands + """ + + def __init__(self, bot): + self.bot = bot + + @commands.command(name='vplus', + brief="Plus settings", + help="Shows Plus mod settings. \n Available arg: enabled, disabled, section name \n Enabled: Shows enabled sections. \n Disabled: Shows disabled sections. \n Section Name: Shows settings for that section.", + usage="", + ) + async def vplus(self, ctx, arg: typing.Optional[str] = 'help'): + ldrembed = discord.Embed(title="Valheim Plus Settings " + arg + "", color=0x33a163) + botsql = self.bot.get_cog('BotSQL') + mycursor = await botsql.get_cursor() + if arg == "help": + ldrembed.add_field(name="{}vplus enabled".format(self.bot.command_prefix), + value="Shows list of enabled sections.\n Example: `{}vplus enabled`".format(self.bot.command_prefix), + inline=True) + ldrembed.add_field(name="{}vplus disabled".format(self.bot.command_prefix), + value="Shows list of disabled sections.\n Example: `{}vplus disabled`".format(self.bot.command_prefix), + inline=True) + ldrembed.add_field(name="{}vplus
".format(self.bot.command_prefix), + value="Shows setting for section.\n Example: `{}vplus Fermenter`".format(self.bot.command_prefix), + inline=True) + elif arg == "enabled": + sql = """SELECT section FROM vplus WHERE enabled = 'true' AND option1 = '0'""" + mycursor.execute(sql) + Info = mycursor.fetchall() + row_count = mycursor.rowcount + vcount = 0 + for ind in Info: + if vcount == 1: + description = description + '\n' + ind[0] + else: + description = ind[0] + vcount = 1 + ldrembed = discord.Embed(title="Valheim Plus Settings " + arg + "", description="" + description + "", color=0x33a163) + elif arg == "disabled": + sql = """SELECT section FROM vplus WHERE enabled = 'false' AND option1 = '0'""" + mycursor.execute(sql) + Info = mycursor.fetchall() + row_count = mycursor.rowcount + vcount = 0 + for ind in Info: + if vcount == 1: + description = description + '\n' + ind[0] + else: + description = ind[0] + vcount = 1 + ldrembed = discord.Embed(title="Valheim Plus Settings " + arg + "", description="" + description + "", color=0x33a163) + else: + sql = """SELECT option1, settings FROM vplus WHERE section = '%s' AND option1 != '0'""" % (arg) + mycursor.execute(sql) + Info = mycursor.fetchall() + row_count = mycursor.rowcount + for ind in Info: + ldrembed.add_field(name="{}".format(ind[0]), + value="{}".format(ind[1]), + inline=False) + mycursor.close() + await ctx.send(embed=ldrembed) + +def setup(bot): + bot.add_cog(Plus(bot)) -- cgit v1.2.3-70-g09d2