Contributors now can use git

This commit is contained in:
annihilator708 2018-05-21 03:38:59 +02:00
parent 038cfa9d8b
commit 5e0e4fd4ab
2 changed files with 25 additions and 22 deletions

View File

@ -46,31 +46,34 @@ class Git:
pass pass
@git.command() @git.command()
@commands.is_owner()
async def pull(self, ctx): async def pull(self, ctx):
async with ctx.typing(): await ctx.trigger_typing()
em = discord.Embed(style='rich', if ctx.author.id not in self.bot.ownerlist:
title=f'Git Pull', return await ctx.send('Only my creator can use me like this :blush:', delete_after=10)
color=self.bot.embed_color) em = discord.Embed(style='rich',
em.set_thumbnail(url=f'{ctx.guild.me.avatar_url}') title=f'Git Pull',
color=self.bot.embed_color)
em.set_thumbnail(url=f'{ctx.guild.me.avatar_url}')
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(
run_command('git reset --hard origin/$(git rev-parse ' run_command('git reset --hard origin/$(git rev-parse '
'--symbolic-full-name --abbrev-ref HEAD)')), '--symbolic-full-name --abbrev-ref HEAD)')),
120) + '\n\n' 120) + '\n\n'
result += await asyncio.wait_for(self.bot.loop.create_task( result += await asyncio.wait_for(self.bot.loop.create_task(
run_command('git show --stat | sed "s/.*@.*[.].*/ /g"')), 10) run_command('git show --stat | sed "s/.*@.*[.].*/ /g"')), 10)
results = paginate(result, maxlen=1014) results = paginate(result, maxlen=1014)
for page in results[:5]: for page in results[:5]:
em.add_field(name='\uFFF0', value=f'{page}') em.add_field(name='\uFFF0', value=f'{page}')
await ctx.send(embed=em) await ctx.send(embed=em)
@git.command() @git.command()
@commands.is_owner()
async def status(self, ctx): async def status(self, ctx):
await ctx.trigger_typing()
if ctx.author.id not in self.bot.ownerlist:
return await ctx.send('Only my creator can use me like this :blush:', delete_after=10)
em = discord.Embed(style='rich', em = discord.Embed(style='rich',
title=f'Git Pull', title=f'Git Pull',
color=self.bot.embed_color) color=self.bot.embed_color)

View File

@ -18,7 +18,7 @@ class Upload:
"""Reload an extension.""" """Reload an extension."""
if ctx.author.id not in self.bot.ownerlist: if ctx.author.id not in self.bot.ownerlist:
return await ctx.send('Only my creator can use me like this :blush:', delete_after=1) return await ctx.send('Only my creator can use me like this :blush:', delete_after=10)
extension = extension.lower() extension = extension.lower()
try: try:
@ -34,7 +34,7 @@ class Upload:
async def reloadall(self, ctx): async def reloadall(self, ctx):
"""Reload all extensions.""" """Reload all extensions."""
if ctx.author.id not in self.bot.ownerlist: if ctx.author.id not in self.bot.ownerlist:
return await ctx.send('Only my creator can use me like this :blush:', delete_after=1) return await ctx.send('Only my creator can use me like this :blush:', delete_after=10)
try: try:
for extension in self.bot.extensions: for extension in self.bot.extensions:
@ -48,7 +48,7 @@ class Upload:
async def unload(self, ctx, *, extension: str): async def unload(self, ctx, *, extension: str):
"""Unload an extension.""" """Unload an extension."""
if ctx.author.id not in self.bot.ownerlist: if ctx.author.id not in self.bot.ownerlist:
return await ctx.send('Only my creator can use me like this :blush:', delete_after=1) return await ctx.send('Only my creator can use me like this :blush:', delete_after=10)
extension = extension.lower() extension = extension.lower()
try: try:
@ -66,7 +66,7 @@ class Upload:
async def load(self, ctx, *, extension: str): async def load(self, ctx, *, extension: str):
"""Load an extension.""" """Load an extension."""
if ctx.author.id not in self.bot.ownerlist: if ctx.author.id not in self.bot.ownerlist:
return await ctx.send('Only my creator can use me like this :blush:', delete_after=1) return await ctx.send('Only my creator can use me like this :blush:', delete_after=10)
extension = extension.lower() extension = extension.lower()
try: try: