Updated all database queries to not use string formatting.
This commit is contained in:
parent
69fab0e7a3
commit
33df91ab8f
@ -75,17 +75,17 @@ class admin():
|
||||
emoji_code = f'<a:{emoji.name}:{emoji.id}>'
|
||||
else:
|
||||
emoji_code = f'<:{emoji.name}:{emoji.id}>'
|
||||
if self.bot.con.all(f'select id from geeksbot_emojis where id = %(id)s', {'id':emoji.id}):
|
||||
self.bot.con.run(f"update geeksbot_emojis set id = %(id)s, name = %(name)s, code = %(emoji_code)s where name = %(name)s", {'name':emoji.name,'id':emoji.id,'emoji_code':emoji_code})
|
||||
if self.bot.con.all('select id from geeksbot_emojis where id = %(id)s', {'id':emoji.id}):
|
||||
self.bot.con.run("update geeksbot_emojis set id = %(id)s, name = %(name)s, code = %(emoji_code)s where name = %(name)s", {'name':emoji.name,'id':emoji.id,'emoji_code':emoji_code})
|
||||
else:
|
||||
self.bot.con.run(f"insert into geeksbot_emojis(id,name,code) values (%(id)s,%(name)s,%(emoji_code)s)", {'name':emoji.name,'id':emoji.id,'emoji_code':emoji_code})
|
||||
self.bot.con.run("insert into geeksbot_emojis(id,name,code) values (%(id)s,%(name)s,%(emoji_code)s)", {'name':emoji.name,'id':emoji.id,'emoji_code':emoji_code})
|
||||
await ctx.message.add_reaction('✅')
|
||||
await ctx.send(f'Emojis have been updated in the database.')
|
||||
|
||||
@commands.command(hidden=True)
|
||||
@commands.check(checks.is_guild_owner)
|
||||
async def get_guild_config(self, ctx):
|
||||
config = self.bot.con.one(f'select * from guild_config where guild_id = {ctx.guild.id}')
|
||||
config = self.bot.con.one('select * from guild_config where guild_id = %(id)s', {'id':ctx.guild.id}))
|
||||
configs = [str(config)[i:i+1990] for i in range(0, len(config), 1990)]
|
||||
await ctx.message.author.send(f'The current config for the {ctx.guild.name} guild is:\n')
|
||||
admin_log.info(configs)
|
||||
@ -113,7 +113,7 @@ class admin():
|
||||
if ctx.guild:
|
||||
if checks.is_admin(self.bot, ctx):
|
||||
if channel != None:
|
||||
self.bot.con.run(f'update guild_config set admin_chat = %(chan)s where guild_id = {ctx.guild.id}', {'chan': channel.id})
|
||||
self.bot.con.run('update guild_config set admin_chat = %(chan)s where guild_id = %(id)s', {'id':ctx.guild.id, 'chan': channel.id})
|
||||
await ctx.send(f'{channel.name} is now set as the Admin Chat channel for this guild.')
|
||||
|
||||
@set.command(name='channel_lockdown', aliases=['lockdown', 'restrict_access', 'cl'])
|
||||
@ -121,14 +121,14 @@ class admin():
|
||||
if ctx.guild:
|
||||
if checks.is_admin(self.bot, ctx):
|
||||
if str(config).lower() == 'true':
|
||||
if self.bot.con.one(f'select allowed_channels from guild_config where guild_id = {ctx.guild.id}') == []:
|
||||
if self.bot.con.one('select allowed_channels from guild_config where guild_id = %(id)s', {'id':ctx.guild.id}) == []:
|
||||
await ctx.send('Please set at least one allowed channel before running this command.')
|
||||
else:
|
||||
self.bot.con.run(f'update guild_config set channel_lockdown = True where guild_id = {ctx.guild.id}')
|
||||
self.bot.con.run('update guild_config set channel_lockdown = True where guild_id = %(id)s', {'id':ctx.guild.id})
|
||||
await ctx.send('Channel Lockdown is now active.')
|
||||
elif str(config).lower() == 'false':
|
||||
if self.bot.con.one(f'select channel_lockdown from guild_config where guild_id = {ctx.guild.id}'):
|
||||
self.bot.con.run(f'update guild_config set channel_lockdown = False where guild_id = {ctx.guild.id}')
|
||||
if self.bot.con.one('select channel_lockdown from guild_config where guild_id = %(id)s', {'id':ctx.guild.id}):
|
||||
self.bot.con.run('update guild_config set channel_lockdown = False where guild_id = %(id)s', {'id':ctx.guild.id})
|
||||
await ctx.send('Channel Lockdown has been deactivated.')
|
||||
else:
|
||||
await ctx.send('Channel Lockdown is already deactivated.')
|
||||
@ -150,19 +150,19 @@ class admin():
|
||||
await ctx.send(f'{channel} is not a valid text channel in this guild.')
|
||||
else:
|
||||
admin_log.info('Chan found')
|
||||
if self.bot.con.one(f'select allowed_channels from guild_config where guild_id = {ctx.guild.id}'):
|
||||
if chnl.id in json.loads(self.bot.con.one(f'select allowed_channels from guild_config where guild_id = {ctx.guild.id}')):
|
||||
if self.bot.con.one('select allowed_channels from guild_config where guild_id = %(id)s', {'id':ctx.guild.id}):
|
||||
if chnl.id in json.loads(self.bot.con.one('select allowed_channels from guild_config where guild_id = %(id)s', {'id':ctx.guild.id})):
|
||||
admin_log.info('Chan found in config')
|
||||
await ctx.send(f'{channel} is already in the list of allowed channels. Skipping...')
|
||||
else:
|
||||
admin_log.info('Chan not found in config')
|
||||
allowed_channels = json.loads(self.bot.con.one(f'select allowed_channels from guild_config where guild_id = {ctx.guild.id}')).append(chnl.id)
|
||||
self.bot.con.run(f"update guild_config set allowed_channels = %(channels)s where guild_id = {ctx.guild.id}", {'channels':allowed_channels})
|
||||
allowed_channels = json.loads(self.bot.con.one('select allowed_channels from guild_config where guild_id = %(id)s', {'id':ctx.guild.id})).append(chnl.id)
|
||||
self.bot.con.run('update guild_config set allowed_channels = %(channels)s where guild_id = %(id)s', {'id':ctx.guild.id, 'channels':allowed_channels})
|
||||
added = f'{added}\n{channel}'
|
||||
else:
|
||||
admin_log.info('Chan not found in config')
|
||||
allowed_channels = [chnl.id]
|
||||
self.bot.con.run(f"update guild_config set allowed_channels = %(channels)s where guild_id = {ctx.guild.id}", {'channels':allowed_channels})
|
||||
self.bot.con.run('update guild_config set allowed_channels = %(channels)s where guild_id = %(id)s', {'id':ctx.guild.id, 'channels':allowed_channels})
|
||||
added = f'{added}\n{channel}'
|
||||
if added != '':
|
||||
await ctx.send(f'The following channels have been added to the allowed channel list: {added}')
|
||||
@ -182,7 +182,7 @@ class admin():
|
||||
async def add_prefix(self, ctx, *, prefix=None):
|
||||
if ctx.guild:
|
||||
if checks.is_admin(self.bot, ctx):
|
||||
prefixes = self.bot.con.one(f'select prefix from guild_config where guild_id = {ctx.guild.id}')
|
||||
prefixes = self.bot.con.one('select prefix from guild_config where guild_id = %(id)s', {'id':ctx.guild.id})
|
||||
if prefix == None:
|
||||
await ctx.send(prefixes)
|
||||
return
|
||||
@ -194,7 +194,7 @@ class admin():
|
||||
if len(prefixes) > 10:
|
||||
await ctx.send(f'Only 10 prefixes are allowed per guild.\nPlease remove some before adding more.')
|
||||
prefixes = prefixes[:10]
|
||||
self.bot.con.run(f"update guild_config set prefix = %(prefixes)s where guild_id = {ctx.guild.id}", {'prefixes':prefixes})
|
||||
self.bot.con.run('update guild_config set prefix = %(prefixes)s where guild_id = %(id)s', {'id':ctx.guild.id, 'prefixes':prefixes})
|
||||
await ctx.guild.me.edit(nick=f'[{prefixes[0]}] Geeksbot')
|
||||
await ctx.send(f"Updated. You currently have {len(prefixes)} {'prefix' if len(prefixes) == 1 else 'prefixes'} in your config.\n{', '.join(prefixes)}")
|
||||
else:
|
||||
@ -208,7 +208,7 @@ class admin():
|
||||
if ctx.guild:
|
||||
if checks.is_admin(self.bot, ctx):
|
||||
prefixes = []
|
||||
prefixes = self.bot.con.one(f'select prefix from guild_config where guild_id = {ctx.guild.id}')
|
||||
prefixes = self.bot.con.one('select prefix from guild_config where guild_id = %(id)s', {'id':ctx.guild.id})
|
||||
found = 0
|
||||
if prefix == None:
|
||||
await ctx.send(prefixes)
|
||||
@ -225,7 +225,7 @@ class admin():
|
||||
else:
|
||||
await ctx.send(f'The prefix {p} is not in the config for this guild.')
|
||||
if found:
|
||||
self.bot.con.run(f"update guild_config set prefix = %(prefixes)s where guild_id = {ctx.guild.id}", {'prefixes':prefixes})
|
||||
self.bot.con.run('update guild_config set prefix = %(prefixes)s where guild_id = %(id)s', {'id':ctx.guild.id, 'prefixes':prefixes})
|
||||
await ctx.guild.me.edit(nick=f'[{prefixes[0] if len(prefixes) != 0 else self.bot.default_prefix}] Geeksbot')
|
||||
await ctx.send(f"Updated. You currently have {len(prefixes)} {'prefix' if len(prefixes) == 1 else 'prefixes'} in your config.\n{', '.join(prefixes)}")
|
||||
else:
|
||||
@ -239,12 +239,12 @@ class admin():
|
||||
async def _add_admin_role(self, ctx, role=None):
|
||||
role = discord.utils.get(ctx.guild.roles, name=role)
|
||||
if role != None:
|
||||
roles = json.loads(self.bot.con.one(f'select admin_roles from guild_config where guild_id = {ctx.guild.id}'))
|
||||
roles = json.loads(self.bot.con.one('select admin_roles from guild_config where guild_id = %(id)s', {'id':ctx.guild.id}))
|
||||
if role.name in roles:
|
||||
await ctx.send(f'{role.name} is already registered as an admin role in this guild.')
|
||||
else:
|
||||
roles[role.name] = role.id
|
||||
self.bot.con.run(f"update guild_config set admin_roles = %(roles)s where guild_id = {ctx.guild.id}", {'roles':json.dumps(roles)})
|
||||
self.bot.con.run('update guild_config set admin_roles = %(roles)s where guild_id = %(id)s', {'id':ctx.guild.id, 'roles':json.dumps(roles)})
|
||||
await ctx.send(f'{role.name} has been added to the list of admin roles for this guild.')
|
||||
else:
|
||||
await ctx.send('You must include a role with this command.')
|
||||
@ -255,10 +255,10 @@ class admin():
|
||||
async def _remove_admin_role(self, ctx, role=None):
|
||||
role = discord.utils.get(ctx.guild.roles, name=role)
|
||||
if role != None:
|
||||
roles = json.loads(self.bot.con.one(f'select admin_roles from guild_config where guild_id = {ctx.guild.id}'))
|
||||
roles = json.loads(self.bot.con.one('select admin_roles from guild_config where guild_id = %(id)s', {'id':ctx.guild.id}))
|
||||
if role.name in roles:
|
||||
del roles[role.name]
|
||||
self.bot.con.run(f"update guild_config set admin_roles = %(roles)s where guild_id = {ctx.guild.id}", {'roles':roles})
|
||||
self.bot.con.run('update guild_config set admin_roles = %(roles)s where guild_id = %(id)s', {'id':ctx.guild.id, 'roles':roles})
|
||||
await ctx.send(f'{role.name} has been removed from the list of admin roles for this guild.')
|
||||
else:
|
||||
await ctx.send(f'{role.name} is not registered as an admin role in this guild.')
|
||||
|
||||
@ -94,7 +94,7 @@ class bot_events():
|
||||
if ctx.author != ctx.guild.me:
|
||||
if self.bot.con.one(f"select pg_filter from guild_config where guild_id = {ctx.guild.id}"):
|
||||
profane = 0
|
||||
for word in self.bot.con.one(f'select profane_words from guild_config where guild_id = {ctx.guild.id}'):
|
||||
for word in self.bot.con.one('select profane_words from guild_config where guild_id = {ctx.guild.id}'):
|
||||
word = word.strip()
|
||||
if word in ctx.content.lower():
|
||||
events_log.info(f'Found non PG word {word}')
|
||||
@ -121,15 +121,15 @@ class bot_events():
|
||||
await react.message.channel.send(f"You can't Poop on me {user.mention} :P")
|
||||
reactions = react.message.reactions
|
||||
reacts = [json.dumps({'emoji': r.emoji, 'count': r.count}) for r in reactions]
|
||||
self.bot.con.run(f'update messages set reactions = %(reacts)s where id = {react.message.id}', {'reacts': reacts})
|
||||
self.bot.con.run('update messages set reactions = %(reacts)s where id = {react.message.id}', {'reacts': reacts})
|
||||
|
||||
async def on_message_edit(self, before, ctx):
|
||||
previous_content = self.bot.con.one(f'select previous_content from messages where id = {ctx.id}')
|
||||
previous_content = self.bot.con.one('select previous_content from messages where id = {ctx.id}')
|
||||
if previous_content:
|
||||
previous_content.append(before.content)
|
||||
else:
|
||||
previous_content = [before.content]
|
||||
previous_embeds = self.bot.con.one(f'select previous_embeds from messages where id = {ctx.id}')
|
||||
previous_embeds = self.bot.con.one('select previous_embeds from messages where id = {ctx.id}')
|
||||
if previous_embeds:
|
||||
previous_embeds.append([json.dumps(e.to_dict()) for e in before.embeds])
|
||||
else:
|
||||
@ -184,12 +184,12 @@ class bot_events():
|
||||
# await guild.owner.send(f'Geeksbot has joined your guild {guild.name}!\nYour current configuration is:\n```{config_str}```\nEnjoy!')
|
||||
|
||||
async def on_guild_remove(self, guild):
|
||||
self.bot.con.run(f'delete from guild_config where guild_id = {guild.id}')
|
||||
self.bot.con.run(f'delete from guild_config where guild_id = %(id)s', {'id':ctx.guild.id})
|
||||
events_log.info(f'Left the {guild.name} guild.')
|
||||
|
||||
async def on_member_join(self, member):
|
||||
events_log.info(f'Member joined: {member.name} {member.id} Guild: {member.guild.name} {member.guild.id}')
|
||||
join_chan = self.bot.con.one(f'select join_leave_chat from guild_config where guild_id = {member.guild.id}')
|
||||
join_chan = self.bot.con.one('select join_leave_chat from guild_config where guild_id = %(id)s', {'id':member.guild.id})
|
||||
if join_chan:
|
||||
em = discord.Embed( style='rich',
|
||||
color=embed_color
|
||||
@ -205,22 +205,22 @@ class bot_events():
|
||||
'discriminator': member.discriminator,
|
||||
'bot': member.bot
|
||||
}
|
||||
mem = self.bot.con.one(f'select guilds,nicks from user_data where id = {member.id}')
|
||||
mem = self.bot.con.one('select guilds,nicks from user_data where id = {member.id}')
|
||||
if mem:
|
||||
mem[1].append(json.dumps({member.guild.id: member.display_name}))
|
||||
mem[0].append(member.guild.id)
|
||||
mem_data['nicks'] = mem[1]
|
||||
mem_data['guilds'] = mem[0]
|
||||
self.bot.con.run(f'update user_data set (name, discriminator, bot, nicks, guilds) = (%(name)s, %(discriminator)s, %(bot)s, %(nicks)s, %(guilds)s) where id = %(id)s',mem_data)
|
||||
self.bot.con.run('update user_data set (name, discriminator, bot, nicks, guilds) = (%(name)s, %(discriminator)s, %(bot)s, %(nicks)s, %(guilds)s) where id = %(id)s',mem_data)
|
||||
else:
|
||||
mem_data['nicks'] = [json.dumps({member.guild.id: member.display_name})]
|
||||
mem_data['guilds'] = [member.guild.id]
|
||||
self.bot.con.run(f'insert into user_data (id, name, discriminator, bot, nicks, guilds) values (%(id)s, %(name)s, %(discriminator)s, %(bot)s, %(nicks)s, %(guilds)s)',mem_data)
|
||||
self.bot.con.run('insert into user_data (id, name, discriminator, bot, nicks, guilds) values (%(id)s, %(name)s, %(discriminator)s, %(bot)s, %(nicks)s, %(guilds)s)',mem_data)
|
||||
|
||||
async def on_member_remove(self, member):
|
||||
leave_time = datetime.utcnow()
|
||||
events_log.info(f'Member left: {member.name} {member.id} Guild: {member.guild.name} {member.guild.id}')
|
||||
join_chan = self.bot.con.one(f'select join_leave_chat from guild_config where guild_id = {member.guild.id}')
|
||||
join_chan = self.bot.con.one('select join_leave_chat from guild_config where guild_id = %(id)s', {'id':member.guild.id})
|
||||
if join_chan:
|
||||
em = discord.Embed( style='rich',
|
||||
color=red_color
|
||||
|
||||
@ -16,8 +16,8 @@ class patreon():
|
||||
@commands.cooldown(1, 5, type=commands.BucketType.user)
|
||||
async def get_patreon_links(self, ctx, target: discord.Member=None):
|
||||
'Prints Patreon information for creators on the server.'
|
||||
if self.bot.con.one(f'select patreon_enabled from guild_config where guild_id = {ctx.guild.id}'):
|
||||
patreon_info = self.bot.con.one(f'select patreon_message,patreon_links from guild_config where guild_id = {ctx.guild.id}')
|
||||
if self.bot.con.one('select patreon_enabled from guild_config where guild_id = %(id)s', {'id':ctx.guild.id}):
|
||||
patreon_info = self.bot.con.one('select patreon_message,patreon_links from guild_config where guild_id = %(id)s', {'id':ctx.guild.id})
|
||||
message = patreon_info[0].replace('\\n','\n')
|
||||
patreon_links = json.loads(patreon_info[1])
|
||||
for key in patreon_links:
|
||||
@ -32,11 +32,11 @@ class patreon():
|
||||
@commands.command(aliases=['patreon_message'])
|
||||
async def set_patreon_message(self, ctx, message):
|
||||
if checks.is_admin(self.bot, ctx):
|
||||
patreon_message = self.bot.con.one(f'select patreon_message from guild_config where guild_id = {ctx.guild.id}')
|
||||
patreon_message = self.bot.con.one('select patreon_message from guild_config where guild_id = %(id)s', {'id':ctx.guild.id})
|
||||
if message == patreon_message:
|
||||
await ctx.send('That is already the current message for this guild.')
|
||||
else:
|
||||
self.bot.con.run(f'update guild_config set patreon_message = %(message)s where guild_id = {ctx.guild.id}', {'message': message})
|
||||
self.bot.con.run('update guild_config set patreon_message = %(message)s where guild_id = %(id)s', {'id':ctx.guild.id, 'message': message})
|
||||
await ctx.send(f'The patreon message for this guild has been set to:\n{message}')
|
||||
else:
|
||||
await ctx.send(f'You are not authorized to run this command.')
|
||||
@ -44,7 +44,7 @@ class patreon():
|
||||
@commands.command(aliases=['add_patreon', 'set_patreon'])
|
||||
async def add_patreon_info(self, ctx, name, url):
|
||||
if checks.is_admin(self.bot, ctx):
|
||||
patreon_info = self.bot.con.one(f'select patreon_links from guild_config where guild_id = {ctx.guild.id}')
|
||||
patreon_info = self.bot.con.one('select patreon_links from guild_config where guild_id = %(id)s', {'id':ctx.guild.id})
|
||||
patreon_links = {}
|
||||
update = 0
|
||||
if patreon_info:
|
||||
@ -52,7 +52,7 @@ class patreon():
|
||||
if name in patreon_links:
|
||||
update = 1
|
||||
patreon_links[name] = url
|
||||
self.bot.con.run(f'update guild_config set patreon_links = %(links)s where guild_id = {ctx.guild.id}', {'links': json.dumps(patreon_links)})
|
||||
self.bot.con.run('update guild_config set patreon_links = %(links)s where guild_id = %(id)s', {'id':ctx.guild.id, 'links': json.dumps(patreon_links)})
|
||||
await ctx.send(f"The Patreon link for {name} has been {'updated to the new url.' if update else'added to the config for this guild.'}")
|
||||
else:
|
||||
await ctx.send(f'You are not authorized to run this command.')
|
||||
@ -60,13 +60,13 @@ class patreon():
|
||||
@commands.command(aliases=['remove_patreon'])
|
||||
async def remove_patreon_info(self, ctx, name):
|
||||
if checks.is_admin(self.bot, ctx):
|
||||
patreon_info = self.bot.con.one(f'select patreon_links from guild_config where guild_id = {ctx.guild.id}')
|
||||
patreon_info = self.bot.con.one('select patreon_links from guild_config where guild_id = %(id)s', {'id':ctx.guild.id})
|
||||
patreon_links = {}
|
||||
if patreon_info:
|
||||
patreon_links = json.loads(patreon_info)
|
||||
if name in patreon_links:
|
||||
del patreon_links[name]
|
||||
self.bot.con.run(f'update guild_config set patreon_links = %(links)s where guild_id = {ctx.guild.id}', {'links': json.dumps(patreon_links)})
|
||||
self.bot.con.run('update guild_config set patreon_links = %(links)s where guild_id = %(id)s', {'id':ctx.guild.id, 'links': json.dumps(patreon_links)})
|
||||
await ctx.send(f'The Patreon link for {name} has been removed from the config for this guild.')
|
||||
return
|
||||
else:
|
||||
@ -79,14 +79,14 @@ class patreon():
|
||||
@commands.command()
|
||||
async def enable_patreon(self, ctx, state:bool=True):
|
||||
if checks.is_admin(self.bot, ctx):
|
||||
patreon_status = self.bot.con.one(f'select patreon_enabled from guild_config where guild_id = {ctx.guild.id}')
|
||||
patreon_status = self.bot.con.one('select patreon_enabled from guild_config where guild_id = %(id)s', {'id':ctx.guild.id})
|
||||
if patreon_status and state:
|
||||
await ctx.send('Patreon is already enabled for this guild.')
|
||||
elif patreon_status and not state:
|
||||
self.bot.con.run(f'update guild_config set patreon_enabled = %(state)s where guild_id = {ctx.guild.id}', {'state': state})
|
||||
self.bot.con.run('update guild_config set patreon_enabled = %(state)s where guild_id = %(id)s', {'id':ctx.guild.id, 'state': state})
|
||||
await ctx.send('Patreon has been disabled for this guild.')
|
||||
elif not patreon_status and state:
|
||||
self.bot.con.run(f'update guild_config set patreon_enabled = %(state)s where guild_id = {ctx.guild.id}', {'state': state})
|
||||
self.bot.con.run('update guild_config set patreon_enabled = %(state)s where guild_id = %(id)s', {'id':ctx.guild.id, 'state': state})
|
||||
await ctx.send('Patreon has been enabled for this guild.')
|
||||
elif not patreon_status and not state:
|
||||
await ctx.send('Patreon is already disabled for this guild.')
|
||||
@ -95,8 +95,8 @@ class patreon():
|
||||
@commands.cooldown(1, 5, type=commands.BucketType.user)
|
||||
async def referral_links(self, ctx, target: discord.Member=None):
|
||||
'Prints G-Portal Referral Links.'
|
||||
if self.bot.con.one(f'select referral_enabled from guild_config where guild_id = {ctx.guild.id}'):
|
||||
referral_info = self.bot.con.one(f'select referral_message,referral_links from guild_config where guild_id = {ctx.guild.id}')
|
||||
if self.bot.con.one('select referral_enabled from guild_config where guild_id = %(id)s', {'id':ctx.guild.id}):
|
||||
referral_info = self.bot.con.one('select referral_message,referral_links from guild_config where guild_id = %(id)s', {'id':ctx.guild.id})
|
||||
message = referral_info[0]
|
||||
referral_links = json.loads(referral_info[1])
|
||||
for key in referral_links:
|
||||
|
||||
34
exts/rcon.py
34
exts/rcon.py
@ -131,11 +131,11 @@ class rcon():
|
||||
To view all the valid ARK servers for this guild see list_ark_servers.'''
|
||||
if checks.is_rcon_admin(self.bot, ctx):
|
||||
if server != None:
|
||||
rcon_connections = json.loads(self.bot.con.one(f"select rcon_connections from guild_config where guild_id = {ctx.guild.id}"))
|
||||
rcon_connections = json.loads(self.bot.con.one('select rcon_connections from guild_config where guild_id = %(id)s', {'id':ctx.guild.id}))
|
||||
server = server.replace('_',' ').title()
|
||||
if server in rcon_connections:
|
||||
rcon_connections[server]["monitoring_chat"] = 1
|
||||
self.bot.con.run(f"update guild_config set rcon_connections = '{json.dumps(rcon_connections)}' where guild_id = {ctx.guild.id}")
|
||||
self.bot.con.run('update guild_config set rcon_connections = %(json)s where guild_id = %(id)s', {'id':ctx.guild.id, 'json': json.dumps(rcon_connections)})
|
||||
channel = self.bot.get_channel(rcon_connections[server]['game_chat_chan_id'])
|
||||
await channel.send('Started monitoring on the {0} server.'.format(server))
|
||||
await ctx.message.add_reaction('✅')
|
||||
@ -169,7 +169,7 @@ class rcon():
|
||||
message = func(ctx, message, rcon_connections['server'])
|
||||
await channel.send('{0}'.format(message))
|
||||
await asyncio.sleep(1)
|
||||
rcon_connections = json.loads(self.bot.con.one(f"select rcon_connections from guild_config where guild_id = {ctx.guild.id}"))
|
||||
rcon_connections = json.loads(self.bot.con.one('select rcon_connections from guild_config where guild_id = %(id)s', {'id':ctx.guild.id}))
|
||||
await channel.send('Monitoring Stopped')
|
||||
else:
|
||||
await ctx.send(f'Server not found: {server}')
|
||||
@ -185,11 +185,11 @@ class rcon():
|
||||
Context is the same as monitor_chat'''
|
||||
if checks.is_rcon_admin(self.bot, ctx):
|
||||
if server != None:
|
||||
rcon_connections = json.loads(self.bot.con.one(f"select rcon_connections from guild_config where guild_id = {ctx.guild.id}"))
|
||||
rcon_connections = json.loads(self.bot.con.one('select rcon_connections from guild_config where guild_id = %(id)s', {'id':ctx.guild.id}))
|
||||
server = server.replace('_',' ').title()
|
||||
if server in rcon_connections:
|
||||
rcon_connections[server]["monitoring_chat"] = 0
|
||||
self.bot.con.run(f"update guild_config set rcon_connections = '{json.dumps(rcon_connections)}' where guild_id = {ctx.guild.id}")
|
||||
self.bot.con.run('update guild_config set rcon_connections = %(json)s where guild_id = %(id)s', {'id':ctx.guild.id, 'json': json.dumps(rcon_connections)})
|
||||
else:
|
||||
await ctx.send(f'Server not found: {server}')
|
||||
else:
|
||||
@ -209,7 +209,7 @@ class rcon():
|
||||
"first last"
|
||||
To view all the valid ARK servers for this guild see list_ark_servers.'''
|
||||
if checks.is_rcon_admin(self.bot, ctx):
|
||||
rcon_connections = json.loads(self.bot.con.one(f"select rcon_connections from guild_config where guild_id = {ctx.guild.id}"))
|
||||
rcon_connections = json.loads(self.bot.con.one('select rcon_connections from guild_config where guild_id = %(id)s', {'id':ctx.guild.id}))
|
||||
if server != None:
|
||||
server = server.replace('_',' ').title()
|
||||
if server in rcon_connections:
|
||||
@ -245,7 +245,7 @@ class rcon():
|
||||
All strings (<server>, <ip>, <password>) must be contained inside double quotes.'''
|
||||
if checks.is_rcon_admin(self.bot, ctx):
|
||||
server = server.title()
|
||||
rcon_connections = json.loads(self.bot.con.one(f"select rcon_connections from guild_config where guild_id = {ctx.guild.id}"))
|
||||
rcon_connections = json.loads(self.bot.con.one('select rcon_connections from guild_config where guild_id = %(id)s', {'id':ctx.guild.id}))
|
||||
if server not in rcon_connections:
|
||||
rcon_connections[server] = {
|
||||
'ip': ip,
|
||||
@ -256,7 +256,7 @@ class rcon():
|
||||
'msg_chan_id': 0,
|
||||
'monitoring_chat': 0
|
||||
}
|
||||
self.bot.con.run(f"update guild_config set rcon_connections = %(connections)s where guild_id = {ctx.guild.id}", {'connections':json.dumps(rcon_connections)})
|
||||
self.bot.con.run('update guild_config set rcon_connections = %(connections)s where guild_id = %(id)s', {'id':ctx.guild.id, 'connections':json.dumps(rcon_connections)})
|
||||
await ctx.send('{0} server has been added to my configuration.'.format(server))
|
||||
else:
|
||||
await ctx.send('This server name is already in my configuration. Please choose another.')
|
||||
@ -272,10 +272,10 @@ class rcon():
|
||||
All strings <server> must be contained inside double quotes.'''
|
||||
if checks.is_rcon_admin(self.bot, ctx):
|
||||
server = server.title()
|
||||
rcon_connections = json.loads(self.bot.con.one(f"select rcon_connections from guild_config where guild_id = {ctx.guild.id}"))
|
||||
rcon_connections = json.loads(self.bot.con.one('select rcon_connections from guild_config where guild_id = %(id)s', {'id':ctx.guild.id}))
|
||||
if server in rcon_connections:
|
||||
del rcon_connections[server]
|
||||
self.bot.con.run(f"update guild_config set rcon_connections = %(connections)s where guild_id = {ctx.guild.id}", {'connections':json.dumps(rcon_connections)})
|
||||
self.bot.con.run('update guild_config set rcon_connections = %(connections)s where guild_id = %(id)s', {'id':ctx.guild.id, 'connections':json.dumps(rcon_connections)})
|
||||
await ctx.send('{0} has been removed from my configuration.'.format(server))
|
||||
else:
|
||||
await ctx.send('{0} is not in my configuration.'.format(server))
|
||||
@ -290,7 +290,7 @@ class rcon():
|
||||
Example: 76561198024193239,76561198024193239,76561198024193239'''
|
||||
if checks.is_rcon_admin(self.bot, ctx):
|
||||
if steam_ids != None:
|
||||
rcon_connections = json.loads(self.bot.con.one(f"select rcon_connections from guild_config where guild_id = {ctx.guild.id}"))
|
||||
rcon_connections = json.loads(self.bot.con.one('select rcon_connections from guild_config where guild_id = %(id)s', {'id':ctx.guild.id}))
|
||||
error = 0
|
||||
error_msg = ''
|
||||
success_msg = 'Adding to the running whitelist on all servers.'
|
||||
@ -332,7 +332,7 @@ class rcon():
|
||||
If a server is not specified it will default to running saveworld on all servers in the guild\'s config.
|
||||
Will print out "World Saved" for each server when the command completes sucessfully.'''
|
||||
if checks.is_rcon_admin(self.bot, ctx):
|
||||
rcon_connections = json.loads(self.bot.con.one(f"select rcon_connections from guild_config where guild_id = {ctx.guild.id}"))
|
||||
rcon_connections = json.loads(self.bot.con.one('select rcon_connections from guild_config where guild_id = %(id)s', {'id':ctx.guild.id}))
|
||||
success_msg = 'Running saveworld'
|
||||
if server == None:
|
||||
success_msg += ' on all the servers:'
|
||||
@ -376,7 +376,7 @@ class rcon():
|
||||
The message will be prefixed with the Discord name of the person running the command.
|
||||
Will print "Success" for each server once the broadcast is sent.'''
|
||||
if checks.is_rcon_admin(self.bot, ctx):
|
||||
rcon_connections = json.loads(self.bot.con.one(f"select rcon_connections from guild_config where guild_id = {ctx.guild.id}"))
|
||||
rcon_connections = json.loads(self.bot.con.one('select rcon_connections from guild_config where guild_id = %(id)s', {'id':ctx.guild.id}))
|
||||
if message != None:
|
||||
message = f'{ctx.author.display_name}: {message}'
|
||||
success_msg = f'Broadcasting "{message}" to all servers.'
|
||||
@ -408,7 +408,7 @@ class rcon():
|
||||
The message will be prefixed with the Discord name of the person running the command.
|
||||
If <server> has more than one word in it's name it will either need to be sorrounded by double quotes or the words seperated by _'''
|
||||
if checks.is_rcon_admin(self.bot, ctx):
|
||||
rcon_connections = json.loads(self.bot.con.one(f"select rcon_connections from guild_config where guild_id = {ctx.guild.id}"))
|
||||
rcon_connections = json.loads(self.bot.con.one('select rcon_connections from guild_config where guild_id = %(id)s', {'id':ctx.guild.id}))
|
||||
if server != None:
|
||||
server = server.replace('_',' ').title()
|
||||
if message != None:
|
||||
@ -440,7 +440,7 @@ class rcon():
|
||||
Inside this category a channel will be created for each server in the current guild's rcon config and these channel's permissions will be synced to the category.
|
||||
These channels will be added to the guild's rcon config and are where the server chat messages will be sent when monitor_chat is run.'''
|
||||
if checks.is_rcon_admin(self.bot, ctx):
|
||||
rcon_connections = json.loads(self.bot.con.one(f"select rcon_connections from guild_config where guild_id = {ctx.guild.id}"))
|
||||
rcon_connections = json.loads(self.bot.con.one('select rcon_connections from guild_config where guild_id = %(id)s', {'id':ctx.guild.id}))
|
||||
edited = 0
|
||||
category = discord.utils.get(ctx.guild.categories, name='Server Chats')
|
||||
if category == None:
|
||||
@ -463,7 +463,7 @@ class rcon():
|
||||
rcon_connections[server]['game_chat_chan_id'] = chan.id
|
||||
edited = 1
|
||||
if edited == 1:
|
||||
self.bot.con.run(f"update guild_config set rcon_connections = '{json.dumps(rcon_connections)}' where guild_id = {ctx.guild.id}")
|
||||
self.bot.con.run('update guild_config set rcon_connections = %(json)s where guild_id = %(id)s', {'id':ctx.guild.id, 'json': json.dumps(rcon_connections)})
|
||||
await ctx.message.add_reaction('✅')
|
||||
else:
|
||||
await ctx.send(f'You are not authorized to run this command.')
|
||||
@ -473,7 +473,7 @@ class rcon():
|
||||
@commands.check(checks.is_restricted_chan)
|
||||
async def list_ark_servers(self, ctx):
|
||||
'''Returns a list of all the ARK servers in the current guild\'s config.'''
|
||||
servers = json.loads(self.bot.con.one(f"select rcon_connections from guild_config where guild_id = {ctx.guild.id}"))
|
||||
servers = json.loads(self.bot.con.one('select rcon_connections from guild_config where guild_id = %(id)s', {'id':ctx.guild.id}))
|
||||
em = discord.Embed( style='rich',
|
||||
title=f'__**There are currently {len(servers)} ARK servers in my config:**__',
|
||||
color=discord.Colour.green()
|
||||
|
||||
@ -369,7 +369,7 @@ class utils():
|
||||
def is_me(message):
|
||||
if message.author == self.bot.user:
|
||||
return True
|
||||
prefixes = self.bot.con.one(f'select prefix from guild_config where guild_id = {ctx.guild.id}')
|
||||
prefixes = self.bot.con.one('select prefix from guild_config where guild_id = %(id)s', {'id':ctx.guild.id})
|
||||
if prefixes:
|
||||
for prefix in prefixes:
|
||||
if message.content.startswith(prefix):
|
||||
|
||||
@ -65,7 +65,7 @@ class Geeksbot(commands.Bot):
|
||||
self.gcs_service = build('customsearch', 'v1', developerKey=self.bot_secrets['google_search_key'])
|
||||
|
||||
async def get_custom_prefix(self, bot, message):
|
||||
return self.con.one(f'select prefix from guild_config where guild_id = %(id)s', {'id': message.guild.id}) or self.default_prefix
|
||||
return self.con.one('select prefix from guild_config where guild_id = %(id)s', {'id': message.guild.id}) or self.default_prefix
|
||||
|
||||
async def load_ext(self, ctx, mod):
|
||||
bot.load_extension('{0}.{1}'.format(extension_dir,mod))
|
||||
@ -113,11 +113,11 @@ async def unload(ctx, mod):
|
||||
async def on_message(ctx):
|
||||
if not ctx.author.bot:
|
||||
if ctx.guild:
|
||||
if int(bot.con.one(f"select channel_lockdown from guild_config where guild_id = {ctx.guild.id}")):
|
||||
if ctx.channel.id in json.loads(bot.con.one(f"select allowed_channels from guild_config where guild_id = {ctx.guild.id}")):
|
||||
if int(bot.con.one(f"select channel_lockdown from guild_config where guild_id = %(id)s", {'id':ctx.guild.id})):
|
||||
if ctx.channel.id in json.loads(bot.con.one(f"select allowed_channels from guild_config where guild_id = %(id)s", {'id':ctx.guild.id}))):
|
||||
await bot.process_commands(ctx)
|
||||
elif ctx.channel.id == 418452585683484680:
|
||||
prefix = bot.con.one(f'select prefix from guild_config where guild_id = {ctx.guild.id}')
|
||||
prefix = bot.con.one('select prefix from guild_config where guild_id = %(id)s", {'id':ctx.guild.id}))
|
||||
prefix = prefix[0] if prefix else bot.default_prefix
|
||||
ctx.content = f'{prefix}{ctx.content}'
|
||||
await bot.process_commands(ctx)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user