Updated help messages for admin commands

doc_update
Joey Hines 2018-08-11 13:46:03 -05:00
parent fe30c9405f
commit 51bf3846c5
5 changed files with 50 additions and 17 deletions

View File

@ -8,7 +8,6 @@ from Geoffrey import bot_commands
class Add_Commands: class Add_Commands:
''' '''
Commands for adding things to Geoffrey. Commands for adding things to Geoffrey.
*You must use ?register before using any of these commands!* *You must use ?register before using any of these commands!*
''' '''
def __init__(self, bot): def __init__(self, bot):
@ -113,7 +112,6 @@ class Add_Commands:
''' '''
Adds an item to a shop's inventory. Adds an item to a shop's inventory.
Quantity for Diamond Price. Quantity for Diamond Price.
?additem [Item Name] [Quantity] [Price] [Shop name] ?additem [Item Name] [Quantity] [Price] [Shop name]
''' '''
shop_name = get_name(args) shop_name = get_name(args)
@ -134,4 +132,4 @@ class Add_Commands:
def setup(bot): def setup(bot):
bot.add_cog(Add_Commands(bot)) bot.add_cog(Add_Commands(bot))

View File

@ -1,8 +1,8 @@
from discord.ext import commands from discord.ext import commands
from BotErrors import * from BotErrors import *
from BotConfig import bot_config from BotConfig import bot_config
from DiscordHelperFunctions import *
from Geoffrey import bot_commands from Geoffrey import bot_commands
from discord import Game
def check_mod(user): def check_mod(user):
@ -25,12 +25,12 @@ class Admin_Commands:
self.bot = bot self.bot = bot
async def error(self, error, ctx): async def error(self, error, ctx):
if isinstance(error.original, PlayerNotFound): if isinstance(error, PlayerNotFound):
error_str = 'that player is not in the database.' error_str = 'that player is not in the database.'
elif isinstance(error.original, DeleteEntryError): elif isinstance(error, DeleteEntryError):
error_str = 'that player does not have a location by that name.' error_str = 'that player does not have a location by that name.'
else: else:
return error_str = 'the bot encountered the following error: *{}*'.format(error.__str__())
await self.bot.send_message(ctx.message.channel, '{}, {}'.format(ctx.message.author.mention, error_str)) await self.bot.send_message(ctx.message.channel, '{}, {}'.format(ctx.message.author.mention, error_str))
@ -46,7 +46,9 @@ class Admin_Commands:
@commands.group(pass_context=True) @commands.group(pass_context=True)
async def mod(self, ctx): async def mod(self, ctx):
'''
Bot moderation tools.
'''
if check_mod(ctx.message.author): if check_mod(ctx.message.author):
if ctx.invoked_subcommand is None: if ctx.invoked_subcommand is None:
await self.bot.say('{}, invalid sub-command for command **mod**.'.format(ctx.message.author.mention)) await self.bot.say('{}, invalid sub-command for command **mod**.'.format(ctx.message.author.mention))
@ -55,6 +57,9 @@ class Admin_Commands:
@mod.command(pass_context=True) @mod.command(pass_context=True)
async def delete(self, ctx, discord_uuid: str, location_name: str): async def delete(self, ctx, discord_uuid: str, location_name: str):
'''
Deletes a location in the database/
'''
bot_commands.delete(location_name, discord_uuid=discord_uuid) bot_commands.delete(location_name, discord_uuid=discord_uuid)
await self.bot.say('{}, **{}** has been deleted.'.format(ctx.message.author.mention, location_name)) await self.bot.say('{}, **{}** has been deleted.'.format(ctx.message.author.mention, location_name))
@ -63,17 +68,23 @@ class Admin_Commands:
await self.error(error, ctx) await self.error(error, ctx)
@mod.command(pass_context=True) @mod.command(pass_context=True)
async def edit(self, ctx, discord_uuid: str, new_name: str, current_name: str): async def edit_name(self, ctx, discord_uuid: str, new_name: str, current_name: str):
'''
Edits the name of a location in the database.
'''
bot_commands.edit_name(new_name, current_name, discord_uuid=discord_uuid) bot_commands.edit_name(new_name, current_name, discord_uuid=discord_uuid)
await self.bot.say('{}, **{}** has been rename to **{}**.'.format(ctx.message.author.mention, current_name, await self.bot.say('{}, **{}** has been rename to **{}**.'.format(ctx.message.author.mention, current_name,
new_name)) new_name))
@edit.error @edit_name.error
async def edit_error(self, error, ctx): async def edit_error(self, error, ctx):
await self.error(error, ctx) await self.error(error, ctx)
@mod.command(pass_context=True) @mod.command(pass_context=True)
async def update_mc_uuid(self, ctx, discord_uuid: str, mc_uuid: str): async def update_mc_uuid(self, ctx, discord_uuid: str, mc_uuid: str):
'''
Updates a user's MC UUID
'''
bot_commands.update_mc_uuid(discord_uuid, mc_uuid) bot_commands.update_mc_uuid(discord_uuid, mc_uuid)
await self.bot.say('{}, **{}** has been updated.'.format(ctx.message.author.mention, discord_uuid)) await self.bot.say('{}, **{}** has been updated.'.format(ctx.message.author.mention, discord_uuid))
@ -83,6 +94,9 @@ class Admin_Commands:
@mod.command(pass_context=True) @mod.command(pass_context=True)
async def update_discord_uuid(self, ctx, current_discord_uuid: str, new_discord_uuid: str): async def update_discord_uuid(self, ctx, current_discord_uuid: str, new_discord_uuid: str):
'''
Updates a user's Discord UUID
'''
bot_commands.update_mc_uuid(current_discord_uuid, new_discord_uuid) bot_commands.update_mc_uuid(current_discord_uuid, new_discord_uuid)
await self.bot.say('{}, user **{}** has been updated.'.format(ctx.message.author.mention, current_discord_uuid)) await self.bot.say('{}, user **{}** has been updated.'.format(ctx.message.author.mention, current_discord_uuid))
@ -91,14 +105,24 @@ class Admin_Commands:
await self.error(error, ctx) await self.error(error, ctx)
@mod.command(pass_context=True) @mod.command(pass_context=True)
async def update_mc_name(self, ctx, discord_uuid: str, mc_name: str): async def update_mc_name(self, ctx, discord_uuid: str):
bot_commands.update_mc_name(discord_uuid, mc_name) '''
await self.bot.say('{}, user **{}** has been renamed.'.format(ctx.message.author.mention, mc_name)) Updates a user's MC name to the current name on the MC UUID
'''
bot_commands.update_mc_name(discord_uuid)
await self.bot.say('{}, user **{}**\'s MC name has update.'.format(ctx.message.author.mention, discord_uuid))
@update_mc_name.error @update_mc_name.error
async def update_mc_name_error(self, error, ctx): async def update_mc_name_error(self, error, ctx):
await self.error(error, ctx) await self.error(error, ctx)
@mod.command(pass_context=True)
async def status(self, ctx, status: str):
'''
Updates playing game status of the bot
'''
await self.bot.change_presence(game=Game(name=status))
await self.bot.say('{}, status has been changed'.format(ctx.message.author.mention))
def setup(bot): def setup(bot):

View File

@ -4,6 +4,17 @@ import configparser
class Config: class Config:
def __init__(self): def __init__(self):
self.config = ''
self.engine_args = ''
self.token = ''
self.world_name = ''
self.status = ''
self.prefix = ''
self.dynmap_url = ''
self.bot_mod = ''
self.load_config()
def load_config(self):
try: try:
self.config = self.read_config() self.config = self.read_config()
self.engine_args = self.read_engine_arg() self.engine_args = self.read_engine_arg()

View File

@ -358,13 +358,13 @@ class Commands:
finally: finally:
session.close() session.close()
def update_mc_name(self, discord_uuid, mc_name): def update_mc_name(self, discord_uuid):
session = self.interface.database.Session() session = self.interface.database.Session()
try: try:
player = self.interface.find_player_by_discord_uuid(session, discord_uuid) player = self.interface.find_player_by_discord_uuid(session, discord_uuid)
player.name = mc_name player.name = grab_playername(player.mc_uuid)
session.commit() session.commit()
except Exception as e: except Exception as e:

View File

@ -135,8 +135,8 @@ class Search_Commands:
try: try:
loc_str = bot_commands.me(discord_uuid=ctx.message.author.id) loc_str = bot_commands.me(discord_uuid=ctx.message.author.id)
await self.bot.say('{}, here are your locations in the database: {}'.format(ctx.message.author.mention, await self.bot.say('{}, here are your locations in the database: \n {}'.format(ctx.message.author.mention,
loc_str)) loc_str))
except PlayerNotFound: except PlayerNotFound:
await self.bot.say('{}, you don\'t have any locations in the database.'.format(ctx.message.author.mention)) await self.bot.say('{}, you don\'t have any locations in the database.'.format(ctx.message.author.mention))