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:
parent
ae6cd84004
commit
5dfe9cbd8e
@ -6,7 +6,7 @@ Sebi-Machine.
|
|||||||
|
|
||||||
__author__ = 'Annihilator708'
|
__author__ = 'Annihilator708'
|
||||||
# TODO: add yourselves here. I can't remember everyones handles.
|
# TODO: add yourselves here. I can't remember everyones handles.
|
||||||
__contributors__ = (__author__, 'Neko404NotFound', 'Dusty.P')
|
__contributors__ = (__author__, 'Neko404NotFound', 'Dusty.P', 'davfsa')
|
||||||
__license__ = 'MIT'
|
__license__ = 'MIT'
|
||||||
__title__ = 'Sebi-Machine'
|
__title__ = 'Sebi-Machine'
|
||||||
__version__ = 'tbd'
|
__version__ = 'tbd'
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
import discord
|
import discord
|
||||||
import traceback
|
import traceback
|
||||||
|
import aiofiles
|
||||||
|
|
||||||
class Upload:
|
class Upload:
|
||||||
"""
|
"""
|
||||||
@ -80,6 +81,39 @@ class Upload:
|
|||||||
await ctx.send(f'Could not unload `{extension}` -> `{e}`')
|
await ctx.send(f'Could not unload `{extension}` -> `{e}`')
|
||||||
else:
|
else:
|
||||||
await ctx.send(f'Loaded `{extension}`.')
|
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):
|
def setup(bot):
|
||||||
bot.add_cog(Upload(bot))
|
bot.add_cog(Upload(bot))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user