Skip to content

Commit

Permalink
Fixed broken build. Removed help text
Browse files Browse the repository at this point in the history
Fixed the previous broken build due to trailing lines when
the logicical statements were broken into two lines
Removed the help text from the configuration file, the help
text can be displayed using the built in discord.py
help command and the brief added to the commands
  • Loading branch information
eesandoval committed Apr 23, 2019
1 parent f9ecbf6 commit b0e89d9
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 40 deletions.
16 changes: 1 addition & 15 deletions config_example.ini
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,4 @@ Support = <:unit_support:564117603895869440>
# These values are for server calls
# Unless necessary, these should be left alone
[Other]
PictureServer = http://sandoval.duckdns.org/
HelpText = {0}adv - Search for an adventurer by providing the name
Example usage: {0}adv Euden
{0}wyr - Search for a wyrmprint by providing the name
Example usage: {0}wyr Glorious Tempest
{0}dra - Search for a dragon by providing the name
Example usage: {0}dra Midgardsormr
{0}query - Search for an adventurer, dragon, or wyrmprint given select criteria
Usage: {0}query type=(adv|dra|wyr) element=(Flame|Wind|Water|Light|Shadow) weapon=(Sword|Blade|Dagger|Axe|Lance|Bow|Staff|Wand) skill=(skillname) ability=(abilityname)
Note that weapon is only applicable to adventurers, and element is only applicable to adventurers and dragons!
Wrap these around quotations if they are longer then one word
Example usage: {0}query type=adv element=Flame ability=Stun
{0}update - Updates the bot, fetching the latest data from the configuration file.
Note that the database does not get updated with this, it only updates information set in the config file.
{0}exit - Shut down the bot
PictureServer = http://sandoval.duckdns.org/
8 changes: 4 additions & 4 deletions controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ def query_adventurers(criteria):
ability = criteria["ability"]
if "rarity" in criteria:
rarity = criteria["rarity"]
if element is None and skill is None and weapon is None
and ability is None and rarity is None:
if (element is None and skill is None and weapon is None and
ability is None and rarity is None):
return []
return Adventurer.find_adventurers(element, weapon, skill, ability, rarity)

Expand Down Expand Up @@ -115,8 +115,8 @@ def query_dragons(criteria):
rarity = criteria["rarity"]
if "level" in criteria:
level = criteria["level"]
if element is None and skill is None and ability is None
and rarity is None:
if (element is None and skill is None and ability is None and
rarity is None):
return []
return Dragon.find_dragons(element, skill, ability, rarity, level)

Expand Down
1 change: 0 additions & 1 deletion utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ def update(self):
self.rarity_emoji = {int(k): v
for k, v in config.items("RarityEmojis")}
self.picture_server = config["Other"]["PictureServer"]
self.help_text = config["Other"]["HelpText"].format(self.command_start)
self.adventurer_reactions = ["\U0001F5BC", "\U0001F508",
"\U0001F509", "\U0001F50A"]
self.wyrmprint_reactions = ["\U0001F5BC", "\U0001F508", "\U0001F509"]
Expand Down
37 changes: 17 additions & 20 deletions view.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,12 @@ def start_discord_bot():

@client.command(name="exit",
description="Shuts down the bot",
brief="Shuts down the bot (authorized users only)",
aliases=["shutdown", "quit", "close"],
pass_context=True)
async def exit(context):
if config.authorized_ids == []
or context.message.author.id in config.authorized_ids:
if (config.authorized_ids == [] or
context.message.author.id in config.authorized_ids):
await client.say("Shutting down")
await client.close()
else:
Expand All @@ -57,6 +58,7 @@ async def exit(context):

@client.command(name="get_adventurer",
description="Gets an adventurer with the given name",
brief="Gets an adventurer using a case insensitive search",
aliases=["adv", "adventurer", "a"],
pass_context=True)
async def get_adventurer(context):
Expand All @@ -67,6 +69,7 @@ async def get_adventurer(context):

@client.command(name="get_wyrmprint",
description="Gets a wyrmprint with the given name",
brief="Gets a wyrmprint using a case insensitive search",
aliases=["wyr", "wyrmprint", "w"],
pass_context=True)
async def get_wyrmprint(context):
Expand All @@ -77,6 +80,7 @@ async def get_wyrmprint(context):

@client.command(name="get_dragon",
description="Gets a dragon with the given name",
brief="Gets a dragon using a case insensitive search",
aliases=["dra", "dragon", "d"],
pass_context=True)
async def get_dragon(context):
Expand All @@ -87,6 +91,7 @@ async def get_dragon(context):

@client.command(name="query",
description="Queries for anything",
brief="Queries for any adventurer, print, or dragon",
aliases=["que", "q"],
pass_context=True)
async def query(context):
Expand All @@ -95,17 +100,9 @@ async def query(context):
await controller.query(convert_args_to_dict(message))


@client.command(name="help",
description="Shows all commands",
aliases=["h"],
pass_context=True)
async def help(context):
message = handle_context(context)
await client.send_message(channel, config.help_text)


@client.command(name="update",
description="Updates the bot's config",
brief="Updates the bot's configurations",
aliases=["u"],
pass_context=True)
async def update(context):
Expand Down Expand Up @@ -289,27 +286,27 @@ def get_emoji_rarity(rarity):

@client.event
async def on_reaction_add(reaction, user):
if reaction.message.id in active_adventurer_messages
and reaction.emoji in config.adventurer_reactions
and user != client.user:
if (reaction.message.id in active_adventurer_messages and
reaction.emoji in config.adventurer_reactions and
user != client.user):
await client.remove_reaction(reaction.message, reaction.emoji, user)
await controller.process_adventurers_reaction(
reaction.emoji,
active_adventurer_messages[reaction.message.id],
reaction.message)

elif reaction.message.id in active_wyrmprint_messages
and reaction.emoji in config.wyrmprint_reactions
and user != client.user:
elif (reaction.message.id in active_wyrmprint_messages and
reaction.emoji in config.wyrmprint_reactions and
user != client.user):
await client.remove_reaction(reaction.message, reaction.emoji, user)
await controller.process_wyrmprint_reaction(
reaction.emoji,
active_wyrmprint_messages[reaction.message.id],
reaction.message)

elif reaction.message.id in active_dragon_messages
and reaction.emoji in config.dragon_reactions
and user != client.user:
elif (reaction.message.id in active_dragon_messages and
reaction.emoji in config.dragon_reactions and
user != client.user):
await client.remove_reaction(reaction.message, reaction.emoji, user)
await controller.process_dragon_reaction(
reaction.emoji,
Expand Down

0 comments on commit b0e89d9

Please sign in to comment.