Writing variables to a file to check on an error
This commit is contained in:
parent
48a753cf26
commit
4f6e1b7ea5
|
@ -1,7 +1,6 @@
|
|||
from discord.ext import commands
|
||||
from .utils import config
|
||||
from .utils import checks
|
||||
import discord
|
||||
import subprocess
|
||||
import urllib.parse
|
||||
import urllib.request
|
||||
|
|
24
cogs/mod.py
24
cogs/mod.py
|
@ -2,16 +2,19 @@ from discord.ext import commands
|
|||
from .utils import checks
|
||||
from .utils import config
|
||||
import pymysql
|
||||
import traceback
|
||||
import discord
|
||||
|
||||
valid_perms = ['kick_members', 'ban_members', 'administrator', 'manage_channels', 'manage_server', 'read_messages',
|
||||
'send_messages','send_tts_messages','manage_messages','embed_links','attach_files','read_message_history',
|
||||
'mention_everyone','connect','speak','mute_members','deafen_members','move_members','use_voice_activation',
|
||||
'send_messages', 'send_tts_messages', 'manage_messages', 'embed_links', 'attach_files',
|
||||
'read_message_history',
|
||||
'mention_everyone', 'connect', 'speak', 'mute_members', 'deafen_members', 'move_members',
|
||||
'use_voice_activation',
|
||||
'change_nicknames', 'manage_nicknames', 'manage_roles']
|
||||
|
||||
|
||||
class Mod:
|
||||
"""Commands that can be used by a or an admin, depending on the command"""
|
||||
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
|
||||
|
@ -90,13 +93,15 @@ class Mod:
|
|||
await self.bot.say("That command has no custom permissions setup on it!")
|
||||
return
|
||||
|
||||
await self.bot.say("You need to have the permission `{}` to use the command `{}` in this server".format(result['perms'],command))
|
||||
await self.bot.say(
|
||||
"You need to have the permission `{}` to use the command `{}` in this server".format(result['perms'],
|
||||
command))
|
||||
|
||||
@perms.command(name="add", aliases=["setup,create"], pass_context=True)
|
||||
@commands.has_permissions(manage_server=True)
|
||||
async def add_perms(self, ctx, command: str, permissions: str):
|
||||
for checks in self.bot.commands.get(command).checks:
|
||||
if "isOwner" == checks.__name__:
|
||||
for check in self.bot.commands.get(command).checks:
|
||||
if "isOwner" == check.__name__:
|
||||
await self.bot.say("This command cannot have custom permissions setup!")
|
||||
return
|
||||
|
||||
|
@ -110,7 +115,9 @@ class Mod:
|
|||
result = cursor.fetchone()
|
||||
if result is None:
|
||||
# Server's data doesn't exist yet, need to create it
|
||||
sql = "create table `"+ctx.message.server.id+"` (`command` varchar(32) not null,`perms` varchar(32) not null,primary key (`command`)) engine=InnoDB default charset=utf8 collate=utf8_bin"
|
||||
sql = "create table `" + ctx.message.server.id + "` (`command` varchar(32) not null,`perms` " \
|
||||
"varchar(32) not null,primary key (`command`))" \
|
||||
" engine=InnoDB default charset=utf8 collate=utf8_bin"
|
||||
cursor.execute(sql)
|
||||
sql = "insert into `" + ctx.message.server.id + "` (command, perms) values(%s, %s)"
|
||||
cursor.execute(sql, (command, permissions))
|
||||
|
@ -124,7 +131,8 @@ class Mod:
|
|||
sql = "update `" + ctx.message.server.id + "` set perms=%s where command=%s"
|
||||
cursor.execute(sql, (permissions, command))
|
||||
|
||||
await self.bot.say("I have just added your custom permissions; you now need to have `{}` permissions to use the command `{}`".format(permissions, command))
|
||||
await self.bot.say("I have just added your custom permissions; "
|
||||
"you now need to have `{}` permissions to use the command `{}`".format(permissions, command))
|
||||
config.closeConnection()
|
||||
|
||||
|
||||
|
|
|
@ -5,12 +5,17 @@ from . import config
|
|||
def isOwner(ctx):
|
||||
return ctx.message.author.id == config.ownerID
|
||||
|
||||
|
||||
def customPermsOrRole(perm):
|
||||
def predicate(ctx):
|
||||
nonlocal perm
|
||||
cursor = config.getCursor()
|
||||
cursor.execute('use {}'.format(config.db_perms))
|
||||
cmd = str(ctx.command)
|
||||
sid = ctx.message.server.id
|
||||
f = open("/home/phxntx5/public_html/Bonfire/checkstest.txt","r+")
|
||||
f.write("cmd: {}\nsid: {}".format(cmd, sid))
|
||||
f.close()
|
||||
|
||||
cursor.execute("show tables like %s", (sid,))
|
||||
result = cursor.fetchone()
|
||||
|
@ -28,6 +33,7 @@ def customPermsOrRole(perm):
|
|||
return False
|
||||
return commands.check(predicate)
|
||||
|
||||
|
||||
def isPM():
|
||||
def predicate(ctx):
|
||||
return ctx.message.channel.is_private
|
||||
|
|
Loading…
Reference in a new issue