Added permunload (#35)

* Update contributors.py
* Update contributors.py
* Added myself as a contributor
* Rename cogs.txt to extensions.txt
* Update contributors.py
This commit is contained in:
davfsa 2018-05-30 19:15:14 +02:00 committed by Espy | Neko | 404
parent ae6cd84004
commit 5dfe9cbd8e
3 changed files with 36 additions and 2 deletions

View File

@ -6,7 +6,7 @@ Sebi-Machine.
__author__ = 'Annihilator708'
# TODO: add yourselves here. I can't remember everyones handles.
__contributors__ = (__author__, 'Neko404NotFound', 'Dusty.P')
__contributors__ = (__author__, 'Neko404NotFound', 'Dusty.P', 'davfsa')
__license__ = 'MIT'
__title__ = 'Sebi-Machine'
__version__ = 'tbd'

View File

@ -4,6 +4,7 @@
from discord.ext import commands
import discord
import traceback
import aiofiles
class Upload:
"""
@ -80,6 +81,39 @@ class Upload:
await ctx.send(f'Could not unload `{extension}` -> `{e}`')
else:
await ctx.send(f'Loaded `{extension}`.')
@commands.command()
async def permunload(self, ctx, extension=None):
"""Disables permanently a cog."""
await ctx.trigger_typing()
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)
if cog is None:
return await ctx.send("Please provide a extension. Do `help permunload` for more info")
extension = extension.lower()
async with aiofiles.open("extension.txt") as fp:
lines=fp.readlines()
removed = False
async with aiofiles.open("extension.txt", "w") as fp:
for i in lines:
if i.replace("\n", "") != extension:
fp.write(i)
else:
removed = True
break
if removed is True:
try:
self.bot.unload_extension(extension)
except:
pass
return await ctx.send("Extension removed successfully")
await ctx.send("Extension not found")
def setup(bot):
bot.add_cog(Upload(bot))
bot.add_cog(Upload(bot))