Handling testing exception in the cog for now
This commit is contained in:
parent
edaa480aef
commit
ce1077bcd9
3
bot.py
3
bot.py
|
@ -3,7 +3,6 @@
|
||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from cogs.utils import config
|
from cogs.utils import config
|
||||||
import traceback
|
|
||||||
|
|
||||||
extensions = ['cogs.interaction',
|
extensions = ['cogs.interaction',
|
||||||
'cogs.core',
|
'cogs.core',
|
||||||
|
@ -64,8 +63,6 @@ async def on_command_error(error, ctx):
|
||||||
await bot.send_message(ctx.message.channel, fmt)
|
await bot.send_message(ctx.message.channel, fmt)
|
||||||
else:
|
else:
|
||||||
fmt = 'An error occurred while processing this request: ```py\n{}: {}\n```'
|
fmt = 'An error occurred while processing this request: ```py\n{}: {}\n```'
|
||||||
#await bot.send_message(ctx.message.channel,str(traceback.format_exc()))
|
|
||||||
traceback.print_exc(file=open("/home/phxntx5/public_html/Bonfire/bot_error","a"))
|
|
||||||
await bot.send_message(ctx.message.channel, fmt.format(type(error).__name__, error))
|
await bot.send_message(ctx.message.channel, fmt.format(type(error).__name__, error))
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
52
cogs/mod.py
52
cogs/mod.py
|
@ -92,34 +92,36 @@ class Mod:
|
||||||
@perms.command(name="add", aliases=["setup,create"], pass_context=True)
|
@perms.command(name="add", aliases=["setup,create"], pass_context=True)
|
||||||
@commands.has_permissions(manage_server=True)
|
@commands.has_permissions(manage_server=True)
|
||||||
async def add_perms(self, ctx, command: str, permissions: str):
|
async def add_perms(self, ctx, command: str, permissions: str):
|
||||||
for checks in self.bot.commands.get(command).checks:
|
try:
|
||||||
if "isOwner" == checks.__name__:
|
for checks in self.bot.commands.get(command).checks:
|
||||||
await self.bot.say("This command cannot have custom permissions setup!")
|
if "isOwner" == checks.__name__:
|
||||||
return
|
await self.bot.say("This command cannot have custom permissions setup!")
|
||||||
|
return
|
||||||
if getattr(discord.Permissions, permissions, None) is None and not permissions.lower() == "none":
|
|
||||||
await self.bot.say("{} does not appear to be a valid permission! Valid permissions are: ```{}```"
|
if getattr(discord.Permissions, permissions, None) is None and not permissions.lower() == "none":
|
||||||
.format(permissions, "\n".join(valid_perms)))
|
await self.bot.say("{} does not appear to be a valid permission! Valid permissions are: ```{}```"
|
||||||
else:
|
.format(permissions, "\n".join(valid_perms)))
|
||||||
cursor = config.getCursor()
|
|
||||||
cursor.execute('use {}'.format(config.db_default))
|
|
||||||
cursor.execute("show tables like %s", (ctx.message.server.id,))
|
|
||||||
result = cursor.fetchone()
|
|
||||||
if result is None:
|
|
||||||
#Server's data doesn't exist yet, need to create it
|
|
||||||
sql = "create table `{}` (`command` varchar(32) not null,`perms` varchar(32) not null,"
|
|
||||||
"primary key (`command`)) engine=InnoDB default charset=utf8 collate=utf8_bin"
|
|
||||||
cursor.execute(sql.format(ctx.message.server.id))
|
|
||||||
cursor.execute("insert into {} (command, perms) values({}, {})",(ctx.message.server.id,command,perms))
|
|
||||||
else:
|
else:
|
||||||
cursor.execute("select perms from %s where command=%s",(ctx.message.server.id,command))
|
cursor = config.getCursor()
|
||||||
if cursor.fetchone() is None:
|
cursor.execute('use {}'.format(config.db_default))
|
||||||
|
cursor.execute("show tables like %s", (ctx.message.server.id,))
|
||||||
|
result = cursor.fetchone()
|
||||||
|
if result is None:
|
||||||
|
#Server's data doesn't exist yet, need to create it
|
||||||
|
sql = "create table `{}` (`command` varchar(32) not null,`perms` varchar(32) not null,"
|
||||||
|
"primary key (`command`)) engine=InnoDB default charset=utf8 collate=utf8_bin"
|
||||||
|
cursor.execute(sql.format(ctx.message.server.id))
|
||||||
cursor.execute("insert into {} (command, perms) values({}, {})",(ctx.message.server.id,command,perms))
|
cursor.execute("insert into {} (command, perms) values({}, {})",(ctx.message.server.id,command,perms))
|
||||||
else:
|
else:
|
||||||
cursor.execute("update %s set perms=%s where command=%s",(ctx.message.server.id,perms,command))
|
cursor.execute("select perms from %s where command=%s",(ctx.message.server.id,command))
|
||||||
|
if cursor.fetchone() is None:
|
||||||
config.closeConnection()
|
cursor.execute("insert into {} (command, perms) values({}, {})",(ctx.message.server.id,command,perms))
|
||||||
|
else:
|
||||||
|
cursor.execute("update %s set perms=%s where command=%s",(ctx.message.server.id,perms,command))
|
||||||
|
|
||||||
|
config.closeConnection()
|
||||||
|
except:
|
||||||
|
traceback.print_exc(file=open("/home/phxntx5/public_html/Bonfire/bot_error","a"))
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
def setup(bot):
|
||||||
|
|
Loading…
Reference in a new issue