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

Merge branch 'dev'

This commit is contained in:
Myned 2019-01-03 18:07:24 -05:00
commit e1de87717c
4 changed files with 85 additions and 13 deletions

View file

@ -22,15 +22,20 @@ class Info:
#
# await ctx.send(embed=embed)
@cmds.group(name='info', aliases=['i'])
@cmds.group(name='info', aliases=['i'], hidden=True)
async def info(self, ctx):
if ctx.invoked_subcommand is None:
await ctx.send('<embed>BOT INFO</embed>')
@info.command(aliases=['g', 'server', 's'], brief='Provides info about a guild', hidden=True)
async def guild(self, ctx):
pass
@info.command(aliases=['g'], brief='Provides info about a guild')
async def guild(self, ctx, guild_id: int):
guild = d.utils.get(self.bot.guilds, id=guild_id)
@info.command(aliases=['u', 'member', 'm'], brief='Provides info about a user', hidden=True)
async def user(self, ctx):
if guild:
await ctx.send(guild.name)
else:
await ctx.send(f'**Not in any guilds by the id of: ** `{guild_id}`')
@info.command(aliases=['u'], brief='Provides info about a user')
async def user(self, ctx, user: d.User):
pass

View file

@ -67,17 +67,76 @@ class Bot:
await ctx.send('https://discordapp.com/oauth2/authorize?&client_id={}&scope=bot&permissions={}'.format(u.config['client_id'], u.config['permissions']))
@cmds.command(name=',guilds', aliases=[',glds', ',servers', ',svrs'])
@cmds.command(name=',guilds', aliases=[',gs'])
@cmds.is_owner()
async def guilds(self, ctx):
paginator = cmds.Paginator()
for guild in self.bot.guilds:
paginator.add_line(f'{guild.name} - @{guild.owner}')
paginator.add_line(f'{guild.name}: {guild.id}\n'
f' @{guild.owner}: {guild.owner.id}')
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=',leave', aliases=[',l'])
@cmds.is_owner()
async def leave(self, ctx, *guilds):
for guild in guilds:
temp = d.utils.get(self.bot.guilds, id=int(guild))
await temp.leave()
@cmds.command(name=',permissions', aliases=[',permission', ',perms', ',perm'])
@cmds.is_owner()
async def permissions(self, ctx, *args: d.Member):

View file

@ -85,9 +85,10 @@ async def on_ready():
await bot.change_presence(activity=d.Game(u.config['playing']))
print('\n> > > > > > > > >\nC O N N E C T E D : {}\n> > > > > > > > >\n'.format(bot.user.name))
await bot.get_channel(u.config['info_channel']).send(f'**Started** \N{BLACK SUN WITH RAYS} `{"` or `".join(u.config["prefix"])}`')
# u.notify('C O N N E C T E D')
try:
await bot.get_channel(u.config['info_channel']).send(f'**Started** \N{BLACK SUN WITH RAYS} `{"` or `".join(u.config["prefix"])}`')
if u.temp['startup']:
with suppress(err.NotFound):
if u.temp['startup'][0] == 'guild':
@ -104,6 +105,8 @@ async def on_ready():
checks.ready = True
except KeyError:
u.dump({'startup': ()}, 'temp/temp.pkl')
except AttributeError:
pass
else:
print('\n- - - -\nI N F O : reconnected, reinitializing tasks\n- - - -\n')
reconnect = await bot.get_user(u.config['owner_id']).send('**RECONNECTING**')
@ -127,7 +130,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:
@ -164,8 +167,6 @@ async def on_command_error(ctx, error):
print('NOT FOUND')
elif isinstance(error, err.Forbidden):
pass
elif isinstance(error, errext.CommandInvokeError):
print('INVOCATION ERROR')
elif isinstance(error, errext.CommandOnCooldown):
await u.add_reaction(ctx.message, '\N{HOURGLASS}')
await asyncio.sleep(error.retry_after)
@ -213,6 +214,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)