Update git.py (#18)

This commit is contained in:
Espy | Neko | 404 2018-05-23 12:05:03 +01:00 committed by GitHub
parent 8e05970ac6
commit 124df7eab1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -30,13 +30,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import discord import discord
from discord.ext import commands from discord.ext import commands
import logging import logging
from ..shared_libs.utils import paginate, run_command from ..shared_libs.utils import paginate, run_command, loggable
import asyncio import asyncio
git_log = logging.getLogger('git')
class Git(loggable.Loggable):
class Git:
def __init__(self, bot): def __init__(self, bot):
self.bot = bot self.bot = bot
@ -44,9 +42,14 @@ class Git:
async def git(self, ctx): async def git(self, ctx):
"""Run help git for more info""" """Run help git for more info"""
await ctx.send('https://github.com/Annihilator708/Sebi-Machine/') await ctx.send('https://github.com/Annihilator708/Sebi-Machine/')
@commands.command(case_insensitive=True, brief='Gets the Trello link.')
async def trello(self, ctx):
await ctx.send('<https://trello.com/b/x02goBbW/sebis-bot-tutorial-roadmap>')
@git.command() @git.command()
async def pull(self, ctx): async def pull(self, ctx):
self.logger.warning('Invoking git-pull')
await ctx.trigger_typing() await ctx.trigger_typing()
if ctx.author.id not in self.bot.ownerlist: if ctx.author.id not in self.bot.ownerlist:
return await ctx.send('Only my contributors can use me like this :blush:', delete_after=10) return await ctx.send('Only my contributors can use me like this :blush:', delete_after=10)
@ -55,6 +58,8 @@ class Git:
color=self.bot.embed_color) color=self.bot.embed_color)
em.set_thumbnail(url=f'{ctx.guild.me.avatar_url}') em.set_thumbnail(url=f'{ctx.guild.me.avatar_url}')
# Pretty sure you can just do await run_command() if that is async,
# or run in a TPE otherwise.
result = await asyncio.wait_for(self.bot.loop.create_task( result = await asyncio.wait_for(self.bot.loop.create_task(
run_command('git fetch --all')), 120) + '\n' run_command('git fetch --all')), 120) + '\n'
result += await asyncio.wait_for(self.bot.loop.create_task( result += await asyncio.wait_for(self.bot.loop.create_task(