From 19304b5d27035d452f3d125c3ece5870682762ec Mon Sep 17 00:00:00 2001 From: Rich Oberholtzer Date: Tue, 14 Apr 2020 20:23:42 -0400 Subject: [PATCH 1/3] adding version to info command --- r0b3bot.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/r0b3bot.py b/r0b3bot.py index f1829bb..6a18a62 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") + 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,20 @@ 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) +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) -- 2.39.5 From 86d7e414c2bcd625a9dd0b1601f560b020a51fc1 Mon Sep 17 00:00:00 2001 From: Rich Oberholtzer Date: Tue, 14 Apr 2020 20:27:40 -0400 Subject: [PATCH 2/3] forgot {} --- r0b3bot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/r0b3bot.py b/r0b3bot.py index 6a18a62..6afc04f 100644 --- a/r0b3bot.py +++ b/r0b3bot.py @@ -552,7 +552,7 @@ async def info(ctx): print("Getting git describe data to display as version") bot_version = await run('git describe') - embed.add_field(name="Version:", value=f"bot_version", inline=False) + 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) -- 2.39.5 From 6deb4455ed52bd24ee2943b6194ea5396040a04a Mon Sep 17 00:00:00 2001 From: Rich Oberholtzer Date: Tue, 14 Apr 2020 20:31:37 -0400 Subject: [PATCH 3/3] minor console output text change --- r0b3bot.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/r0b3bot.py b/r0b3bot.py index 6afc04f..5b53c74 100644 --- a/r0b3bot.py +++ b/r0b3bot.py @@ -550,7 +550,7 @@ 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") + 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) @@ -917,6 +917,7 @@ 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, -- 2.39.5