diff --git a/r0b3bot.py b/r0b3bot.py index f1829bb..5b53c74 100644 --- a/r0b3bot.py +++ b/r0b3bot.py @@ -550,6 +550,9 @@ async def info(ctx): second = int(second) embed.add_field(name="Uptime [WW:DD:HH:MM:SS]:", value=f"{week:02d}:{day:02d}:{hour:02d}:{minute:02d}:{second:02d}", inline=False) + print("Getting git describe data to display as version in info embed") + bot_version = await run('git describe') + embed.add_field(name="Version:", value=f"{bot_version}", inline=False) # Gitlab link to source embed.add_field(name="Source Code:", value="[R0b3Bot on Gitlab](https://gitlab.rickelobe.com/Bots/r0b3BOT)", inline=False) @@ -914,4 +917,21 @@ async def help(ctx): embed = discord.Embed(title="A note about sound clips:", description="Sound clips are only played in voice channels. If a user is not specified when calling the command, the sound will played in the channel of that issuing user is currently joined to. When a username is specified, the bot will play the sound in the channel that user is currently in.") await ctx.send(embed=embed) +# Function to run shell command and return stdout or sterr +async def run(cmd): + proc = await asyncio.create_subprocess_shell( + cmd, + stdout=asyncio.subprocess.PIPE, + stderr=asyncio.subprocess.PIPE) + + stdout, stderr = await proc.communicate() + + print(f'[{cmd!r} exited with {proc.returncode}]') + if stdout: + #print(f'[stdout]\n{stdout.decode()}') + return stdout.decode() + if stderr: + #print(f'[stderr]\n{stderr.decode()}') + return stderr.decode() + bot.run(DISCORD_AUTH_TOKEN)