Geeksbot/exts/git.py
2018-04-14 02:54:15 -08:00

58 lines
2.0 KiB
Python
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import discord
from discord.ext import commands
import os, logging
from .imports.utils import paginate, run_command
import asyncio
owner_id = 351794468870946827
embed_color = discord.Colour.from_rgb(49,107,111)
git_log = logging.getLogger('git')
class Git():
def __init__(self, bot):
self.bot = bot
@commands.group(case_insensitive=True)
async def git(self, ctx):
'''Run help set for more info'''
pass
@git.command()
@commands.is_owner()
async def pull(self, ctx):
em = discord.Embed( style='rich',
title=f'Git Pull',
color=embed_color)
em.set_thumbnail(url=f'{ctx.guild.me.avatar_url}')
result = await asyncio.wait_for(self.bot.loop.create_task(run_command('git','fetch','--all')),10)
results = paginate(result, maxlen=1014)
for page in results[:1]:
em.add_field(name='', value=f'```{page}```')
result = await asyncio.wait_for(self.bot.loop.create_task(run_command('git','reset','--hard','origin/master')),10)
results = paginate(result, maxlen=1014)
for page in results[:1]:
em.add_field(name='', value=f'```{page}```')
result = await asyncio.wait_for(self.bot.loop.create_task(run_command('git','show','--stat')),10)
results = paginate(result, maxlen=1014)
for page in results[:4]:
em.add_field(name='', value=f'```{page}```')
await ctx.send(embed=em)
@git.command()
@commands.is_owner()
async def status(self, ctx):
em = discord.Embed( style='rich',
title=f'Git Pull',
color=embed_color)
em.set_thumbnail(url=f'{ctx.guild.me.avatar_url}')
result = await asyncio.wait_for(self.bot.loop.create_task(run_command('git','status')),10)
results = paginate(result, maxlen=1014)
for page in results[:5]:
em.add_field(name='', value=f'```{page}```')
await ctx.send(embed=em)
def setup(bot):
bot.add_cog(Git(bot))