mirror of
https://github.com/myned/modufur.git
synced 2024-11-01 21:02:38 +00:00
Hopefully fixed the various conceptual errors qwq
This commit is contained in:
parent
6f38e0bc8e
commit
09b456faf3
3 changed files with 74 additions and 65 deletions
|
@ -24,7 +24,7 @@ class MsG:
|
||||||
self.color = d.Color(0x1A1A1A)
|
self.color = d.Color(0x1A1A1A)
|
||||||
self.LIMIT = 100
|
self.LIMIT = 100
|
||||||
self.RATE_LIMIT = u.RATE_LIMIT
|
self.RATE_LIMIT = u.RATE_LIMIT
|
||||||
self.HISTORY_LIMIT = 99
|
self.HISTORY_LIMIT = 100
|
||||||
self.queue = asyncio.Queue()
|
self.queue = asyncio.Queue()
|
||||||
self.qualitifying = False
|
self.qualitifying = False
|
||||||
|
|
||||||
|
@ -45,7 +45,8 @@ class MsG:
|
||||||
@commands.command(aliases=['rel'], brief='e621 Related tag search', description='e621 | NSFW\nReturn a link search for given tags')
|
@commands.command(aliases=['rel'], brief='e621 Related tag search', description='e621 | NSFW\nReturn a link search for given tags')
|
||||||
@checks.del_ctx()
|
@checks.del_ctx()
|
||||||
async def related(self, ctx, *args):
|
async def related(self, ctx, *args):
|
||||||
dest, tags = u.get_args(ctx, args, rem=True)
|
kwargs = u.get_kwargs(ctx, args)
|
||||||
|
dest, tags = kwargs['destination'], kwargs['remaining']
|
||||||
related = []
|
related = []
|
||||||
|
|
||||||
await dest.trigger_typing()
|
await dest.trigger_typing()
|
||||||
|
@ -65,7 +66,8 @@ class MsG:
|
||||||
@commands.command(name='aliases', aliases=['alias'], brief='e621 Tag aliases', description='e621 | NSFW\nSearch aliases for given tag')
|
@commands.command(name='aliases', aliases=['alias'], brief='e621 Tag aliases', description='e621 | NSFW\nSearch aliases for given tag')
|
||||||
@checks.del_ctx()
|
@checks.del_ctx()
|
||||||
async def tag_aliases(self, ctx, *args):
|
async def tag_aliases(self, ctx, *args):
|
||||||
dest, tags = u.get_args(ctx, args, rem=True)
|
kwargs = u.get_kwargs(ctx, args)
|
||||||
|
dest, tags = kwargs['destination'], kwargs['remaining']
|
||||||
aliases = []
|
aliases = []
|
||||||
|
|
||||||
await dest.trigger_typing()
|
await dest.trigger_typing()
|
||||||
|
@ -85,7 +87,8 @@ class MsG:
|
||||||
@checks.del_ctx()
|
@checks.del_ctx()
|
||||||
async def get_image(self, ctx, *args):
|
async def get_image(self, ctx, *args):
|
||||||
try:
|
try:
|
||||||
dest, urls = u.get_args(ctx, args, rem=True)
|
kwargs = u.get_kwargs(ctx, args)
|
||||||
|
dest, urls = kwargs['destination'], kwargs['remaining']
|
||||||
|
|
||||||
if not urls:
|
if not urls:
|
||||||
raise exc.MissingArgument
|
raise exc.MissingArgument
|
||||||
|
@ -110,7 +113,8 @@ class MsG:
|
||||||
@checks.del_ctx()
|
@checks.del_ctx()
|
||||||
async def reverse_image_search(self, ctx, *args):
|
async def reverse_image_search(self, ctx, *args):
|
||||||
try:
|
try:
|
||||||
dest, urls = u.get_args(ctx, args, rem=True)
|
kwargs = u.get_kwargs(ctx, args)
|
||||||
|
dest, urls = kwargs['destination'], kwargs['remaining']
|
||||||
c = 0
|
c = 0
|
||||||
|
|
||||||
if not urls and not ctx.message.attachments:
|
if not urls and not ctx.message.attachments:
|
||||||
|
@ -153,7 +157,8 @@ class MsG:
|
||||||
@checks.del_ctx()
|
@checks.del_ctx()
|
||||||
async def quality_reverse_image_search(self, ctx, *args):
|
async def quality_reverse_image_search(self, ctx, *args):
|
||||||
try:
|
try:
|
||||||
dest, urls = u.get_args(ctx, args, rem=True)
|
kwargs = u.get_kwargs(ctx, args)
|
||||||
|
dest, urls = kwargs['destination'], kwargs['remaining']
|
||||||
c = 0
|
c = 0
|
||||||
|
|
||||||
if not urls and not ctx.message.attachments:
|
if not urls and not ctx.message.attachments:
|
||||||
|
@ -200,14 +205,17 @@ class MsG:
|
||||||
@checks.del_ctx()
|
@checks.del_ctx()
|
||||||
async def reversify(self, ctx, *args):
|
async def reversify(self, ctx, *args):
|
||||||
try:
|
try:
|
||||||
dest, remove, limit = u.get_args(ctx, args, rm=True, lim=self.HISTORY_LIMIT)
|
kwargs = u.get_kwargs(ctx, args, limit=self.HISTORY_LIMIT / 5)
|
||||||
|
dest, remove, limit = kwargs['destination'], kwargs['remove'], kwargs['limit']
|
||||||
urls = []
|
urls = []
|
||||||
attachments = []
|
attachments = []
|
||||||
|
|
||||||
if not ctx.author.permissions_in(ctx.channel).manage_messages:
|
if not ctx.author.permissions_in(ctx.channel).manage_messages:
|
||||||
dest = ctx.author
|
dest = ctx.author
|
||||||
|
|
||||||
async for message in ctx.channel.history(limit=limit + 1):
|
async for message in ctx.channel.history(limit=self.HISTORY_LIMIT * limit):
|
||||||
|
if len(urls) + len(attachments) >= limit:
|
||||||
|
break
|
||||||
if message.author.id != self.bot.user.id and re.search('(http[a-z]?:\/\/[^ ]*\.(?:gif|png|jpg|jpeg))', message.content) is not None:
|
if message.author.id != self.bot.user.id and re.search('(http[a-z]?:\/\/[^ ]*\.(?:gif|png|jpg|jpeg))', message.content) is not None:
|
||||||
urls.append(message)
|
urls.append(message)
|
||||||
await message.add_reaction('⏳')
|
await message.add_reaction('⏳')
|
||||||
|
@ -267,14 +275,17 @@ class MsG:
|
||||||
@checks.del_ctx()
|
@checks.del_ctx()
|
||||||
async def qualitify(self, ctx, *args):
|
async def qualitify(self, ctx, *args):
|
||||||
try:
|
try:
|
||||||
dest, remove, limit = u.get_args(ctx, args, rm=True, lim=self.HISTORY_LIMIT)
|
kwargs = u.get_kwargs(ctx, args, limit=self.HISTORY_LIMIT / 5)
|
||||||
|
dest, remove, limit = kwargs['destination'], kwargs['remove'], kwargs['limit']
|
||||||
urls = []
|
urls = []
|
||||||
attachments = []
|
attachments = []
|
||||||
|
|
||||||
if not ctx.author.permissions_in(ctx.channel).manage_messages:
|
if not ctx.author.permissions_in(ctx.channel).manage_messages:
|
||||||
dest = ctx.author
|
dest = ctx.author
|
||||||
|
|
||||||
async for message in ctx.channel.history(limit=limit + 1):
|
async for message in ctx.channel.history(limit=self.HISTORY_LIMIT * limit):
|
||||||
|
if len(urls) + len(attachments) >= limit:
|
||||||
|
break
|
||||||
if message.author.id != self.bot.user.id and re.search('(http[a-z]?:\/\/[^ ]*\.(?:gif|png|jpg|jpeg))', message.content) is not None:
|
if message.author.id != self.bot.user.id and re.search('(http[a-z]?:\/\/[^ ]*\.(?:gif|png|jpg|jpeg))', message.content) is not None:
|
||||||
urls.append(message)
|
urls.append(message)
|
||||||
await message.add_reaction('⏳')
|
await message.add_reaction('⏳')
|
||||||
|
@ -330,9 +341,9 @@ class MsG:
|
||||||
except exc.NotFound:
|
except exc.NotFound:
|
||||||
await ctx.send('**No matches found.**', delete_after=10)
|
await ctx.send('**No matches found.**', delete_after=10)
|
||||||
await ctx.message.add_reaction('❌')
|
await ctx.message.add_reaction('❌')
|
||||||
except ValueError:
|
# except ValueError:
|
||||||
await ctx.send('**Invalid limit.**', delete_after=10)
|
# await ctx.send('**Invalid limit.**', delete_after=10)
|
||||||
await ctx.message.add_reaction('❌')
|
# await ctx.message.add_reaction('❌')
|
||||||
|
|
||||||
async def _qualitify(self):
|
async def _qualitify(self):
|
||||||
while self.qualitifying:
|
while self.qualitifying:
|
||||||
|
@ -496,7 +507,8 @@ class MsG:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
dest, query = u.get_args(ctx, args, rem=True)
|
kwargs = u.get_kwargs(ctx, args)
|
||||||
|
dest, query = kwargs['destination'], kwargs['remaining']
|
||||||
starred = []
|
starred = []
|
||||||
c = 1
|
c = 1
|
||||||
|
|
||||||
|
@ -676,7 +688,8 @@ class MsG:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
dest, tags = u.get_args(ctx, args, rem=True)
|
kwargs = u.get_kwargs(ctx, args)
|
||||||
|
dest, tags = kwargs['destination'], kwargs['remaining']
|
||||||
limit = self.LIMIT / 5
|
limit = self.LIMIT / 5
|
||||||
starred = []
|
starred = []
|
||||||
c = 1
|
c = 1
|
||||||
|
@ -814,7 +827,8 @@ class MsG:
|
||||||
@checks.is_nsfw()
|
@checks.is_nsfw()
|
||||||
async def e621(self, ctx, *args):
|
async def e621(self, ctx, *args):
|
||||||
try:
|
try:
|
||||||
dest, args, limit = u.get_args(ctx, args, rem=True, lim=3)
|
kwargs = u.get_kwargs(ctx, args, limit=3)
|
||||||
|
dest, args, limit = kwargs['destination'], kwargs['remaining'], kwargs['limit']
|
||||||
|
|
||||||
tags = self.get_favorites(ctx, args)
|
tags = self.get_favorites(ctx, args)
|
||||||
|
|
||||||
|
@ -867,7 +881,8 @@ class MsG:
|
||||||
@checks.del_ctx()
|
@checks.del_ctx()
|
||||||
async def e926(self, ctx, *args):
|
async def e926(self, ctx, *args):
|
||||||
try:
|
try:
|
||||||
dest, args, limit = u.get_args(ctx, args, rem=True, lim=3)
|
kwargs = u.get_kwargs(ctx, args, limit=3)
|
||||||
|
dest, args, limit = kwargs['destination'], kwargs['remaining'], kwargs['limit']
|
||||||
|
|
||||||
tags = self.get_favorites(ctx, args)
|
tags = self.get_favorites(ctx, args)
|
||||||
|
|
||||||
|
@ -923,7 +938,7 @@ class MsG:
|
||||||
|
|
||||||
@_get_favorite.command(name='tags', aliases=['t'])
|
@_get_favorite.command(name='tags', aliases=['t'])
|
||||||
async def __get_favorite_tags(self, ctx, *args):
|
async def __get_favorite_tags(self, ctx, *args):
|
||||||
dest = u.get_args(ctx, *args)
|
dest = u.get_kwargs(ctx, args)['destination']
|
||||||
|
|
||||||
await dest.send('⭐ {}**\'s favorite tags:**\n```\n{}```'.format(ctx.author.mention, formatter.tostring(self.favorites.get(ctx.author.id, {}).get('tags', set()))), delete_after=10)
|
await dest.send('⭐ {}**\'s favorite tags:**\n```\n{}```'.format(ctx.author.mention, formatter.tostring(self.favorites.get(ctx.author.id, {}).get('tags', set()))), delete_after=10)
|
||||||
await ctx.message.add_reaction('✅')
|
await ctx.message.add_reaction('✅')
|
||||||
|
@ -939,7 +954,8 @@ class MsG:
|
||||||
@_add_favorite.command(name='tags', aliases=['t'])
|
@_add_favorite.command(name='tags', aliases=['t'])
|
||||||
async def __add_favorite_tags(self, ctx, *args):
|
async def __add_favorite_tags(self, ctx, *args):
|
||||||
try:
|
try:
|
||||||
dest, tags = u.get_args(ctx, args, rem=True)
|
kwargs = u.get_kwargs(ctx, args)
|
||||||
|
dest, tags = kwargs['destination'], kwargs['remaining']
|
||||||
|
|
||||||
for tag in tags:
|
for tag in tags:
|
||||||
if tag in self.blacklists['user_blacklist'].get(ctx.author.id, set()):
|
if tag in self.blacklists['user_blacklist'].get(ctx.author.id, set()):
|
||||||
|
@ -971,7 +987,8 @@ class MsG:
|
||||||
@_remove_favorite.command(name='tags', aliases=['t'])
|
@_remove_favorite.command(name='tags', aliases=['t'])
|
||||||
async def __remove_favorite_tags(self, ctx, *args):
|
async def __remove_favorite_tags(self, ctx, *args):
|
||||||
try:
|
try:
|
||||||
dest, tags = u.get_args(ctx, args, rem=True)
|
kwargs = u.get_kwargs(ctx, args)
|
||||||
|
dest, tags = kwargs['destination'], kwargs['remaining']
|
||||||
|
|
||||||
for tag in tags:
|
for tag in tags:
|
||||||
try:
|
try:
|
||||||
|
@ -999,7 +1016,7 @@ class MsG:
|
||||||
|
|
||||||
@_clear_favorite.command(name='tags', aliases=['t'])
|
@_clear_favorite.command(name='tags', aliases=['t'])
|
||||||
async def __clear_favorite_tags(self, ctx, *args):
|
async def __clear_favorite_tags(self, ctx, *args):
|
||||||
dest = u.get_args(ctx, args)
|
dest = u.get_kwargs(ctx, args)['destination']
|
||||||
|
|
||||||
with suppress(KeyError):
|
with suppress(KeyError):
|
||||||
del self.favorites[ctx.author.id]
|
del self.favorites[ctx.author.id]
|
||||||
|
@ -1033,14 +1050,14 @@ class MsG:
|
||||||
|
|
||||||
@_get_blacklist.command(name='global', aliases=['gl', 'g'])
|
@_get_blacklist.command(name='global', aliases=['gl', 'g'])
|
||||||
async def __get_global_blacklist(self, ctx, *args):
|
async def __get_global_blacklist(self, ctx, *args):
|
||||||
dest = u.get_args(ctx, args)
|
dest = u.get_kwargs(ctx, args)['destination']
|
||||||
|
|
||||||
await dest.send('🚫 **Global blacklist:**\n```\n{}```'.format(formatter.tostring(self.blacklists['global_blacklist'])))
|
await dest.send('🚫 **Global blacklist:**\n```\n{}```'.format(formatter.tostring(self.blacklists['global_blacklist'])))
|
||||||
await ctx.message.add_reaction('✅')
|
await ctx.message.add_reaction('✅')
|
||||||
|
|
||||||
@_get_blacklist.command(name='channel', aliases=['ch', 'c'])
|
@_get_blacklist.command(name='channel', aliases=['ch', 'c'])
|
||||||
async def __get_channel_blacklist(self, ctx, *args):
|
async def __get_channel_blacklist(self, ctx, *args):
|
||||||
dest = u.get_args(ctx, args)
|
dest = u.get_kwargs(ctx, args)['destination']
|
||||||
|
|
||||||
guild = ctx.guild if isinstance(
|
guild = ctx.guild if isinstance(
|
||||||
ctx.guild, d.Guild) else ctx.channel
|
ctx.guild, d.Guild) else ctx.channel
|
||||||
|
@ -1050,14 +1067,14 @@ class MsG:
|
||||||
|
|
||||||
@_get_blacklist.command(name='me', aliases=['m'])
|
@_get_blacklist.command(name='me', aliases=['m'])
|
||||||
async def __get_user_blacklist(self, ctx, *args):
|
async def __get_user_blacklist(self, ctx, *args):
|
||||||
dest = u.get_args(ctx, args)
|
dest = u.get_kwargs(ctx, args)['destination']
|
||||||
|
|
||||||
await dest.send('🚫 {}**\'s blacklist:**\n```\n{}```'.format(ctx.author.mention, formatter.tostring(self.blacklists['user_blacklist'].get(ctx.author.id, set()))), delete_after=10)
|
await dest.send('🚫 {}**\'s blacklist:**\n```\n{}```'.format(ctx.author.mention, formatter.tostring(self.blacklists['user_blacklist'].get(ctx.author.id, set()))), delete_after=10)
|
||||||
await ctx.message.add_reaction('✅')
|
await ctx.message.add_reaction('✅')
|
||||||
|
|
||||||
@_get_blacklist.command(name='here', aliases=['h'])
|
@_get_blacklist.command(name='here', aliases=['h'])
|
||||||
async def __get_here_blacklists(self, ctx, *args):
|
async def __get_here_blacklists(self, ctx, *args):
|
||||||
dest = u.get_args(ctx, args)
|
dest = u.get_kwargs(ctx, args)['destination']
|
||||||
|
|
||||||
guild = ctx.guild if isinstance(
|
guild = ctx.guild if isinstance(
|
||||||
ctx.guild, d.Guild) else ctx.channel
|
ctx.guild, d.Guild) else ctx.channel
|
||||||
|
@ -1074,7 +1091,7 @@ class MsG:
|
||||||
@__get_all_blacklists.command(name='guild', aliases=['g'])
|
@__get_all_blacklists.command(name='guild', aliases=['g'])
|
||||||
@commands.has_permissions(manage_channels=True)
|
@commands.has_permissions(manage_channels=True)
|
||||||
async def ___get_all_guild_blacklists(self, ctx, *args):
|
async def ___get_all_guild_blacklists(self, ctx, *args):
|
||||||
dest = u.get_args(ctx, args)
|
dest = u.get_kwargs(ctx, args)['destination']
|
||||||
|
|
||||||
guild = ctx.guild if isinstance(
|
guild = ctx.guild if isinstance(
|
||||||
ctx.guild, d.Guild) else ctx.channel
|
ctx.guild, d.Guild) else ctx.channel
|
||||||
|
@ -1085,7 +1102,7 @@ class MsG:
|
||||||
@__get_all_blacklists.command(name='user', aliases=['u', 'member', 'm'])
|
@__get_all_blacklists.command(name='user', aliases=['u', 'member', 'm'])
|
||||||
@commands.is_owner()
|
@commands.is_owner()
|
||||||
async def ___get_all_user_blacklists(self, ctx, *args):
|
async def ___get_all_user_blacklists(self, ctx, *args):
|
||||||
dest = u.get_args(ctx, args)
|
dest = u.get_kwargs(ctx, args)['destination']
|
||||||
|
|
||||||
await dest.send('🚫 **__User blacklists:__**\n\n{}'.format(formatter.dict_tostring(self.blacklists['user_blacklist'])))
|
await dest.send('🚫 **__User blacklists:__**\n\n{}'.format(formatter.dict_tostring(self.blacklists['user_blacklist'])))
|
||||||
await ctx.message.add_reaction('✅')
|
await ctx.message.add_reaction('✅')
|
||||||
|
@ -1099,7 +1116,8 @@ class MsG:
|
||||||
@_add_tags.command(name='global', aliases=['gl', 'g'])
|
@_add_tags.command(name='global', aliases=['gl', 'g'])
|
||||||
@commands.is_owner()
|
@commands.is_owner()
|
||||||
async def __add_global_tags(self, ctx, *args):
|
async def __add_global_tags(self, ctx, *args):
|
||||||
dest, tags = u.get_args(ctx, args, rem=True)
|
kwargs = u.get_kwargs(ctx, args)
|
||||||
|
dest, tags = kwargs['destination'], kwargs['remaining']
|
||||||
|
|
||||||
await dest.trigger_typing()
|
await dest.trigger_typing()
|
||||||
|
|
||||||
|
@ -1120,7 +1138,8 @@ class MsG:
|
||||||
@_add_tags.command(name='channel', aliases=['ch', 'c'])
|
@_add_tags.command(name='channel', aliases=['ch', 'c'])
|
||||||
@commands.has_permissions(manage_channels=True)
|
@commands.has_permissions(manage_channels=True)
|
||||||
async def __add_channel_tags(self, ctx, *args):
|
async def __add_channel_tags(self, ctx, *args):
|
||||||
dest, tags = u.get_args(ctx, args, rem=True)
|
kwargs = u.get_kwargs(ctx, args)
|
||||||
|
dest, tags = kwargs['destination'], kwargs['remaining']
|
||||||
|
|
||||||
guild = ctx.guild if isinstance(
|
guild = ctx.guild if isinstance(
|
||||||
ctx.guild, d.Guild) else ctx.channel
|
ctx.guild, d.Guild) else ctx.channel
|
||||||
|
@ -1144,7 +1163,8 @@ class MsG:
|
||||||
|
|
||||||
@_add_tags.command(name='me', aliases=['m'])
|
@_add_tags.command(name='me', aliases=['m'])
|
||||||
async def __add_user_tags(self, ctx, *args):
|
async def __add_user_tags(self, ctx, *args):
|
||||||
dest, tags = u.get_args(ctx, args, rem=True)
|
kwargs = u.get_kwargs(ctx, args)
|
||||||
|
dest, tags = kwargs['destination'], kwargs['remaining']
|
||||||
|
|
||||||
await dest.trigger_typing()
|
await dest.trigger_typing()
|
||||||
|
|
||||||
|
@ -1172,7 +1192,8 @@ class MsG:
|
||||||
@commands.is_owner()
|
@commands.is_owner()
|
||||||
async def __remove_global_tags(self, ctx, *args):
|
async def __remove_global_tags(self, ctx, *args):
|
||||||
try:
|
try:
|
||||||
dest, tags = u.get_args(ctx, args, rem=True)
|
kwargs = u.get_kwargs(ctx, args)
|
||||||
|
dest, tags = kwargs['destination'], kwargs['remaining']
|
||||||
|
|
||||||
for tag in tags:
|
for tag in tags:
|
||||||
try:
|
try:
|
||||||
|
@ -1194,7 +1215,8 @@ class MsG:
|
||||||
@commands.has_permissions(manage_channels=True)
|
@commands.has_permissions(manage_channels=True)
|
||||||
async def __remove_channel_tags(self, ctx, *args):
|
async def __remove_channel_tags(self, ctx, *args):
|
||||||
try:
|
try:
|
||||||
dest, tags = u.get_args(ctx, args, rem=True)
|
kwargs = u.get_kwargs(ctx, args)
|
||||||
|
dest, tags = kwargs['destination'], kwargs['remaining']
|
||||||
|
|
||||||
guild = ctx.guild if isinstance(
|
guild = ctx.guild if isinstance(
|
||||||
ctx.guild, d.Guild) else ctx.channel
|
ctx.guild, d.Guild) else ctx.channel
|
||||||
|
@ -1218,7 +1240,8 @@ class MsG:
|
||||||
@_remove_tags.command(name='me', aliases=['m'])
|
@_remove_tags.command(name='me', aliases=['m'])
|
||||||
async def __remove_user_tags(self, ctx, *args):
|
async def __remove_user_tags(self, ctx, *args):
|
||||||
try:
|
try:
|
||||||
dest, tags = u.get_args(ctx, args, rem=True)
|
kwargs = u.get_kwargs(ctx, args)
|
||||||
|
dest, tags = kwargs['destination'], kwargs['remaining']
|
||||||
|
|
||||||
for tag in tags:
|
for tag in tags:
|
||||||
try:
|
try:
|
||||||
|
@ -1245,7 +1268,7 @@ class MsG:
|
||||||
@_clear_blacklist.command(name='global', aliases=['gl', 'g'])
|
@_clear_blacklist.command(name='global', aliases=['gl', 'g'])
|
||||||
@commands.is_owner()
|
@commands.is_owner()
|
||||||
async def __clear_global_blacklist(self, ctx, *args):
|
async def __clear_global_blacklist(self, ctx, *args):
|
||||||
dest = u.get_args(ctx, args)
|
dest = u.get_kwargs(ctx, args)['destination']
|
||||||
|
|
||||||
self.blacklists['global_blacklist'].clear()
|
self.blacklists['global_blacklist'].clear()
|
||||||
u.dump(self.blacklists, 'cogs/blacklists.pkl')
|
u.dump(self.blacklists, 'cogs/blacklists.pkl')
|
||||||
|
@ -1256,7 +1279,7 @@ class MsG:
|
||||||
@_clear_blacklist.command(name='channel', aliases=['ch', 'c'])
|
@_clear_blacklist.command(name='channel', aliases=['ch', 'c'])
|
||||||
@commands.has_permissions(manage_channels=True)
|
@commands.has_permissions(manage_channels=True)
|
||||||
async def __clear_channel_blacklist(self, ctx, *args):
|
async def __clear_channel_blacklist(self, ctx, *args):
|
||||||
dest = u.get_args(ctx, args)
|
dest = u.get_kwargs(ctx, args)['destination']
|
||||||
|
|
||||||
guild = ctx.guild if isinstance(
|
guild = ctx.guild if isinstance(
|
||||||
ctx.guild, d.Guild) else ctx.channel
|
ctx.guild, d.Guild) else ctx.channel
|
||||||
|
@ -1270,7 +1293,7 @@ class MsG:
|
||||||
|
|
||||||
@_clear_blacklist.command(name='me', aliases=['m'])
|
@_clear_blacklist.command(name='me', aliases=['m'])
|
||||||
async def __clear_user_blacklist(self, ctx, *args):
|
async def __clear_user_blacklist(self, ctx, *args):
|
||||||
dest = u.get_args(ctx, args)
|
dest = u.get_kwargs(ctx, args)['destination']
|
||||||
|
|
||||||
with suppress(KeyError):
|
with suppress(KeyError):
|
||||||
del self.blacklists['user_blacklist'][ctx.author.id]
|
del self.blacklists['user_blacklist'][ctx.author.id]
|
||||||
|
|
|
@ -24,7 +24,7 @@ class Info:
|
||||||
|
|
||||||
@commands.command(hidden=True)
|
@commands.command(hidden=True)
|
||||||
async def hi(self, ctx, *args):
|
async def hi(self, ctx, *args):
|
||||||
dest = u.get_args(ctx, args)
|
dest = u.get_kwargs(ctx, args)
|
||||||
|
|
||||||
hello = 'Hewwo, {}.'.format(ctx.author.mention)
|
hello = 'Hewwo, {}.'.format(ctx.author.mention)
|
||||||
if ctx.author.id == checks.owner_id:
|
if ctx.author.id == checks.owner_id:
|
||||||
|
|
|
@ -113,11 +113,11 @@ async def fetch(url, *, params={}, json=False):
|
||||||
# def geneate_embed(**kwargs):
|
# def geneate_embed(**kwargs):
|
||||||
# embed = d.Embed(title=kwargs['title'], )
|
# embed = d.Embed(title=kwargs['title'], )
|
||||||
|
|
||||||
def get_args(ctx, args, *, rem=False, rm=False, lim=False):
|
def get_kwargs(ctx, args, *, limit=False):
|
||||||
destination = ctx
|
destination = ctx
|
||||||
remaining = list(args[:])
|
remaining = list(args[:])
|
||||||
remove = False
|
rm = False
|
||||||
limit = lim
|
lim = 1
|
||||||
|
|
||||||
if '-d' in remaining or '-dm' in remaining:
|
if '-d' in remaining or '-dm' in remaining:
|
||||||
destination = ctx.author
|
destination = ctx.author
|
||||||
|
@ -127,40 +127,26 @@ def get_args(ctx, args, *, rem=False, rm=False, lim=False):
|
||||||
except ValueError:
|
except ValueError:
|
||||||
remaining.remove('-dm')
|
remaining.remove('-dm')
|
||||||
|
|
||||||
if rm:
|
if ('-r' in remaining or '-rm' in remaining or '-remove' in remaining) and ctx.author.permissions_in(ctx.channel).manage_messages:
|
||||||
if ('-r' in remaining or '-rm' in remaining or '-remove' in remaining) and ctx.author.permissions_in(ctx.channel).manage_messages:
|
rm = True
|
||||||
remove = True
|
|
||||||
print('remove')
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
remaining.remove('-r')
|
||||||
|
except ValueError:
|
||||||
try:
|
try:
|
||||||
remaining.remove('-r')
|
remaining.remove('-rm')
|
||||||
except ValueError:
|
except ValueError:
|
||||||
try:
|
remaining.remove('-remove')
|
||||||
remaining.remove('-rm')
|
|
||||||
except ValueError:
|
|
||||||
remaining.remove('-remove')
|
|
||||||
|
|
||||||
if lim:
|
if limit:
|
||||||
for arg in remaining:
|
for arg in remaining:
|
||||||
if 1 <= len(arg) <= 2:
|
if 1 <= len(arg) <= 2:
|
||||||
with suppress(ValueError):
|
with suppress(ValueError):
|
||||||
if 1 <= int(arg) <= lim:
|
if 1 <= int(arg) <= limit:
|
||||||
limit = int(arg)
|
lim = int(arg)
|
||||||
remaining.remove(arg)
|
remaining.remove(arg)
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
raise exc.BoundsError(arg)
|
raise exc.BoundsError(arg)
|
||||||
|
|
||||||
if rem:
|
return {'destination': destination, 'remaining': remaining, 'remove': rm, 'limit': lim}
|
||||||
if rm and lim:
|
|
||||||
return destination, remaining, remove, limit
|
|
||||||
if rm:
|
|
||||||
return destination, remaining, remove
|
|
||||||
if lim:
|
|
||||||
return destination, remaining, limit
|
|
||||||
return destination, remaining
|
|
||||||
if rm:
|
|
||||||
return destination, remove
|
|
||||||
if lim:
|
|
||||||
return destination, limit
|
|
||||||
return destination
|
|
||||||
|
|
Loading…
Reference in a new issue