1
0
Fork 0
mirror of https://github.com/myned/modufur.git synced 2024-11-01 13:02:38 +00:00

Add block command group

This commit is contained in:
Myned 2019-01-03 18:03:56 -05:00
parent 36f4b3ae1f
commit 2a3f4d99f7
3 changed files with 57 additions and 1 deletions

View file

@ -78,6 +78,55 @@ class Bot:
for page in paginator.pages:
await ctx.send(f'**Guilds:**\n{page}')
@cmds.group(name=',block', aliases=[',bl', ',b'])
@cmds.is_owner()
async def block(self, ctx):
pass
@block.group(name='list', aliases=['l'])
async def block_list(self, ctx):
pass
@block_list.command(name='guilds', aliases=['g'])
async def block_list_guilds(self, ctx):
await formatter.paginate(ctx, u.block['guild_ids'])
@block.command(name='user', aliases=['u'])
async def block_user(self, ctx, *users: d.User):
for user in users:
u.block['user_ids'].append(user.id)
u.dump(u.block, 'cogs/block.json', json=True)
@block.command(name='guild', aliases=['g'])
async def block_guild(self, ctx, *guilds):
for guild in guilds:
u.block['guild_ids'].append(guild)
u.dump(u.block, 'cogs/block.json', json=True)
@cmds.group(name=',unblock', aliases=[',unbl', ',unb'])
@cmds.is_owner()
async def unblock(self, ctx):
pass
@unblock.command(name='user', aliases=['u'])
async def unblock_user(self, ctx, *users: d.User):
for user in users:
u.block['user_ids'].remove(user.id)
u.dump(u.block, 'cogs/block.json', json=True)
await ctx.send('\N{WHITE HEAVY CHECK MARK} **Unblocked users**')
@unblock.command(name='guild', aliases=['g'])
async def unblock_guild(self, ctx, *guilds):
for guild in guilds:
u.block['guild_ids'].remove(guild)
u.dump(u.block, 'cogs/block.json', json=True)
await ctx.send('\N{WHITE HEAVY CHECK MARK} **Unblocked guilds**')
@cmds.command(name=',permissions', aliases=[',permission', ',perms', ',perm'])
@cmds.is_owner()
async def permissions(self, ctx, *args: d.Member):

View file

@ -127,7 +127,7 @@ async def on_ready():
@bot.event
async def on_message(message):
if not u.config['selfbot']:
if message.author is not bot.user and not message.author.bot:
if message.author is not bot.user and not message.author.bot and message.author.id not in u.block['user_ids']:
await bot.process_commands(message)
else:
if not message.author.bot:
@ -213,6 +213,12 @@ async def on_command_completion(ctx):
u.last_commands[ctx.author.id] = ctx
@bot.event
async def on_guild_join(guild):
if str(guild.id) in u.block['guild_ids']:
print(f'LEAVING : {guild.name}')
await guild.leave()
@bot.event
async def on_guild_remove(guild):
print(f'LEFT : {guild.name}')

View file

@ -85,6 +85,7 @@ def dump(obj, filename, *, json=False):
settings = setdefault('misc/settings.pkl', default={'del_ctx': [], 'del_resp': [], 'prefixes': {}})
tasks = setdefault('cogs/tasks.pkl', default={'auto_del': [], 'auto_hrt': [], 'auto_rev': []})
temp = setdefault('temp/temp.pkl', default={'startup': ()})
block = setdefault('cogs/block.json', default={'guild_ids': [], 'user_ids': []}, json=True)
cogs = {}
color = d.Color(0x1A1A1A)