Skip to content

Commit

Permalink
Add version command (#177)
Browse files Browse the repository at this point in the history
* Add version command

* Fix various problems, ignore version file

* Get version string from file in AdminCog constructor
  • Loading branch information
Laura Demkowicz-Duffy authored Aug 24, 2021
1 parent 8b4b5b8 commit 610ed2b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
**/__pycache__
test-file.py
/src/cogs/TestCog.py
/src/esportsbot/version.txt
.vscode
.idea
secrets.env
13 changes: 13 additions & 0 deletions src/esportsbot/cogs/AdminCog.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ def __init__(self, bot):
self.bot = bot
self.STRINGS = bot.STRINGS["admin"]

# Get bot version from text file
try:
version_file_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "version.txt")
with open(version_file_path, "rt") as version_file:
self.bot_version = "`" + version_file.readline().strip() + "`"
except FileNotFoundError:
self.bot_version = self.STRINGS['no_version']

def is_dev(ctx):
if not devs:
return ctx.author.guild_permissions.administrator
Expand Down Expand Up @@ -38,6 +46,11 @@ async def clear_messages(self, ctx, amount=5):
}
)

@commands.check(is_dev)
@commands.command(name="version", help="Print the bot's version string")
async def print_version(self, ctx):
await ctx.channel.send(self.bot_version)

@commands.command(
name="members",
aliases=['Members'],
Expand Down
1 change: 1 addition & 0 deletions src/esportsbot/user_strings.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ channel_removed = "Log channel has been removed"
[admin]
channel_cleared = "{author_mention} has cleared {message_amount} messages from {author_mention}"
members = "This server has {member_count} members including me"
no_version = "No version recorded"

[default_role]
default_role_missing = "Default role has not been set"
Expand Down

0 comments on commit 610ed2b

Please sign in to comment.