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:
'''
Commands for adding things to Geoffrey.
*You must use ?register before using any of these commands!*
'''
def __init__(self, bot):
@ -113,7 +112,6 @@ class Add_Commands:
'''
Adds an item to a shop's inventory.
Quantity for Diamond Price.
?additem [Item Name] [Quantity] [Price] [Shop name]
'''
shop_name = get_name(args)
@ -134,4 +132,4 @@ class Add_Commands:
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 BotErrors import *
from BotConfig import bot_config
from DiscordHelperFunctions import *
from Geoffrey import bot_commands
from discord import Game
def check_mod(user):
@ -25,12 +25,12 @@ class Admin_Commands:
self.bot = bot
async def error(self, error, ctx):
if isinstance(error.original, PlayerNotFound):
if isinstance(error, PlayerNotFound):
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.'
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))
@ -46,7 +46,9 @@ class Admin_Commands:
@commands.group(pass_context=True)
async def mod(self, ctx):
'''
Bot moderation tools.
'''
if check_mod(ctx.message.author):
if ctx.invoked_subcommand is None:
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)
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)
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)
@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)
await self.bot.say('{}, **{}** has been rename to **{}**.'.format(ctx.message.author.mention, current_name,
new_name))
@edit.error
@edit_name.error
async def edit_error(self, error, ctx):
await self.error(error, ctx)
@mod.command(pass_context=True)
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)
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)
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)
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)
@mod.command(pass_context=True)
async def update_mc_name(self, ctx, discord_uuid: str, mc_name: 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))
async def update_mc_name(self, ctx, discord_uuid: str):
'''
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
async def update_mc_name_error(self, 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):

View File

@ -4,6 +4,17 @@ import configparser
class Config:
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:
self.config = self.read_config()
self.engine_args = self.read_engine_arg()

View File

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

View File

@ -135,8 +135,8 @@ class Search_Commands:
try:
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,
loc_str))
await self.bot.say('{}, here are your locations in the database: \n {}'.format(ctx.message.author.mention,
loc_str))
except PlayerNotFound:
await self.bot.say('{}, you don\'t have any locations in the database.'.format(ctx.message.author.mention))