Geoffrey-Django/cogs/Edit_Commands.py

72 lines
2.9 KiB
Python
Raw Normal View History

from discord.ext import commands
2018-08-12 19:00:04 +00:00
from BotErrors import *
from DiscordHelperFunctions import *
2018-08-11 21:07:33 +00:00
from bot import bot_commands
class Edit_Commands:
2018-08-18 17:01:59 +00:00
"""
Commands for editing your stuff in Geoffrey.
"""
def __init__(self, bot):
self.bot = bot
@commands.command(pass_context=True)
@commands.cooldown(5, 60, commands.BucketType.user)
async def edit_pos(self, ctx, x_pos: int, y_pos: int, *args):
"""
2018-08-18 17:01:59 +00:00
Edits the position of a location
?edit_pos [X Coordinate] [Z Coordinate] [Location Name]
"""
loc = get_name(args)
try:
loc_str = bot_commands.edit_pos(x_pos, y_pos, loc, discord_uuid=ctx.message.author.id)
await self.bot.say(
'{}, the following location has been updated: \n\n{}'.format(ctx.message.author.mention, loc_str))
except LocationLookUpError:
await self.bot.say('{}, you do not have a location called **{}**.'.format(
ctx.message.author.mention, loc))
@commands.command(pass_context=True)
@commands.cooldown(5, 60, commands.BucketType.user)
async def edit_tunnel(self, ctx, tunnel_color: str, tunnel_number: int, *args):
"""
2018-08-18 17:01:59 +00:00
Edits the tunnel of a location
?edit_tunnel [Tunnel Color] [Tunnel Number] [Location Name]
"""
loc = get_name(args)
try:
loc_str = bot_commands.edit_tunnel(tunnel_color, tunnel_number, loc, discord_uuid=ctx.message.author.id)
await self.bot.say(
'{}, the following location has been updated: \n\n{}'.format(ctx.message.author.mention, loc_str))
except LocationLookUpError:
await self.bot.say('{}, you do not have a location called **{}**.'.format(
ctx.message.author.mention, loc))
except InvalidTunnelError:
await self.bot.say(
'{}, **{}** is an invalid tunnel color.'.format(ctx.message.author.mention, tunnel_color))
@commands.command(pass_context=True)
@commands.cooldown(5, 60, commands.BucketType.user)
async def edit_name(self, ctx, new_name: str, current_name: str):
"""
2018-08-18 17:01:59 +00:00
Edits the name of a location
IF A NAME HAS SPACES IN IT YOU NEED TO WRAP IT IN QUOTATION MARKS. eg. "Cool Shop 123"
?edit_name [New Name] [Current Name]
"""
try:
loc_str = bot_commands.edit_name(new_name, current_name, discord_uuid=ctx.message.author.id)
await self.bot.say(
'{}, the following location has been updated: \n\n{}'.format(ctx.message.author.mention, loc_str))
except LocationLookUpError:
await self.bot.say('{}, you do not have a location called **{}**.'.format(
ctx.message.author.mention, current_name))
def setup(bot):
bot.add_cog(Edit_Commands(bot))