summaryrefslogtreecommitdiff
path: root/optional
diff options
context:
space:
mode:
authorstolenvw <stolenvw@hotmail.com>2021-04-15 18:54:05 -0400
committerstolenvw <stolenvw@hotmail.com>2021-04-15 18:54:05 -0400
commitc5e6a213d5eda8b2122b8858ed53dc55a5537c9c (patch)
tree9ea74712c87217505dfde8bab0399ace34291ee1 /optional
parent68e8f975c2cade235a0f2bdb2edfb20a467fc2b6 (diff)
Added role check for commands, so you can set what roles users need to use a command.
Set commands to only work in the LOGCHAN_ID channel if not owner. Owner can use commands in any channel.
Diffstat (limited to 'optional')
-rw-r--r--optional/pluscmds.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/optional/pluscmds.py b/optional/pluscmds.py
index 6c91147..3343568 100644
--- a/optional/pluscmds.py
+++ b/optional/pluscmds.py
@@ -1,4 +1,4 @@
-import discord, typing
+import discord, typing, config
from discord.ext import commands
class Plus(commands.Cog):
@@ -9,11 +9,17 @@ class Plus(commands.Cog):
def __init__(self, bot):
self.bot = bot
+ async def chancheck(ctx):
+ if ctx.channel.id == config.LOGCHAN_ID or commands.is_owner():
+ return True
+
@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="<arg>",
)
+ @commands.has_any_role(config.VPLUS_CMD)
+ @commands.check(chancheck)
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')
@@ -66,5 +72,18 @@ class Plus(commands.Cog):
mycursor.close()
await ctx.send(embed=ldrembed)
+ @vplus.error
+ async def vplus_error_handler(self, ctx, error):
+ if isinstance(error, commands.MissingAnyRole):
+ if config.USEDEBUGCHAN == True:
+ bugchan = self.bot.get_channel(config.BUGCHANNEL_ID)
+ bugerror = discord.Embed(title=":sos: **ERROR** :sos:", description='**{}** Tried to use command: **{}**\n{}'.format(ctx.author, ctx.command, error), color=0xFF001E)
+ await bugchan.send(embed=bugerror)
+ if isinstance(error, commands.CheckFailure):
+ if config.USEDEBUGCHAN == True:
+ bugchan = self.bot.get_channel(config.BUGCHANNEL_ID)
+ bugerror = discord.Embed(title=":sos: **ERROR** :sos:", description='**{}** Tried to use command: **{}**\nIn channel **#{}**'.format(ctx.author, ctx.command, ctx.channel), color=0xFF001E)
+ await bugchan.send(embed=bugerror)
+
def setup(bot):
bot.add_cog(Plus(bot))