Esempio n. 1
0
 async def allcatmdls(self, ctx: aoi.AoiContext,
                      category: discord.CategoryChannel,
                      enabled: disenable()):
     await self.db.add_permission(ctx.guild.id,
                                  f"axm {category.id} {enabled}")
     await ctx.send_ok(f"**axm <#{category.id}> {enabled}** added",
                       trash=False)
Esempio n. 2
0
 async def svrcmd(self, ctx: aoi.AoiContext, enabled: disenable(),
                  command: str):
     cmd = self.bot.get_command(command.lower())
     if not cmd:
         raise commands.BadArgument(f"Command {command} not found")
     await self.db.add_permission(ctx.guild.id, f"sc {enabled} {command}")
     await ctx.send_ok(f"**sc {enabled} {command}** added.", trash=False)
Esempio n. 3
0
 async def usrmdl(self, ctx: aoi.AoiContext, member: discord.Member,
                  enabled: disenable(), module: str):
     module = self.bot.find_cog(module)[0]
     await self.db.add_permission(ctx.guild.id,
                                  f"um {member.id} {enabled} {module}")
     await ctx.send_ok(f"**um <@{member.id}> {enabled} {module}** added.",
                       trash=False)
Esempio n. 4
0
 async def rolemdl(self, ctx: aoi.AoiContext, role: discord.Role,
                   enabled: disenable(), module: str):
     module = self.bot.find_cog(module)[0]
     await self.db.add_permission(ctx.guild.id,
                                  f"rm {role.id} {enabled} {module}")
     await ctx.send_ok(f"**rm <&{role.id}> {enabled} {module}** added.",
                       trash=False)
Esempio n. 5
0
 async def chnlmdl(self, ctx: aoi.AoiContext, channel: discord.TextChannel,
                   enabled: disenable(), module: str):
     module = self.bot.find_cog(module)[0]
     await self.db.add_permission(ctx.guild.id,
                                  f"cm {channel.id} {enabled} {module}")
     await ctx.send_ok(f"**cm <#{channel.id}> {enabled} {module}** added.",
                       trash=False)
Esempio n. 6
0
 async def catmdl(self, ctx: aoi.AoiContext,
                  category: discord.CategoryChannel, enabled: disenable(),
                  module: str):
     module = self.bot.find_cog(module)[0]
     await self.db.add_permission(ctx.guild.id,
                                  f"xm {category.id} {enabled} {module}")
     await ctx.send_ok(f"**xm <#{category.id}> {enabled} {module}** added.",
                       trash=False)
Esempio n. 7
0
 async def chancmd(self, ctx: aoi.AoiContext, channel: discord.TextChannel,
                   enabled: disenable(), command: str):
     cmd = self.bot.get_command(command.lower())
     if not cmd:
         raise commands.BadArgument(f"Command {command} not found")
     await self.db.add_permission(ctx.guild.id,
                                  f"cc {channel.id} {enabled} {command}")
     await ctx.send_ok(f"**cc <#{channel.id}> {enabled} {command}** added.",
                       trash=False)
Esempio n. 8
0
 async def gencur(self, ctx: aoi.AoiContext,
                  channel: Optional[discord.TextChannel],
                  state: disenable()):
     channel = channel or ctx.channel
     if state.lower() == "enable":
         if channel.id not in (await self.bot.db.guild_setting(
                 ctx.guild.id)).currency_gen_channels:
             await self.bot.db.add_currency_channel(channel)
             return await ctx.send_ok(
                 f"Currency will now generate in {channel.mention}")
         return await ctx.send_ok(
             f"Currency can already generate in {channel.mention}")
     if channel.id in (await
                       self.bot.db.guild_setting(ctx.guild.id
                                                 )).currency_gen_channels:
         await self.bot.db.remove_currency_channel(channel)
         return await ctx.send_ok(
             f"Currency will not generate in {channel.mention}")
     return await ctx.send_ok(
         f"Currency already couldn't generate in {channel.mention}")
Esempio n. 9
0
 async def config(self,
                  ctx: aoi.AoiContext,
                  setting: str = None,
                  *,
                  value: str = None):  # noqa c901
     #  note to self cuz am idot
     #  make sure to add setting in /complexity/context/guildconfig.json
     if not setting:
         # view possible configs
         config_list = re.sub(
             r"<.*?>", "",
             LINQ(self.guild_configs).select(
                 lambda config:
                 f"⋄ `{config['name']}` - {config['description']}").join(
                     "\n"))
         if await ctx.using_embeds():
             return await ctx.embed(title="Config list",
                                    description=config_list)
         else:
             return await ctx.send(f"**Config list**\n" f"{config_list}")
     if not value:
         return await ctx.send_error("You must pass a value")
     setting = setting.lower()
     color_funcs = {
         "okcolor": self.okcolor,
         "errorcolor": self.errorcolor,
         "infocolor": self.infocolor
     }
     if setting in color_funcs:
         try:
             color: AoiColor = await AoiColor.convert(ctx, value)
         except commands.CommandError:
             return await ctx.send_error("Invalid color")
         # noinspection PyArgumentList
         return await color_funcs[setting](ctx, color)
     if setting == "prefix":
         await self.bot.db.set_prefix(ctx.guild.id, value)
         return await ctx.send_ok(f"Prefix set to `{escape(value, ctx)}`")
     if setting == "currencygain":
         try:
             v = int(value)
             if v < 0 or v > 50:
                 return await ctx.send_error(
                     "Gain value must be between 0 and 50")
             await self.bot.db.set_currency_gain(ctx.guild, v)
             return await ctx.send_ok(f"Currency gain " + (
                 "turned off" if not v else f"set to {v}/3min"))
         except ValueError:
             return await ctx.send_error(
                 "Gain value must be a number between 0 and 50")
     if setting == "embeds":
         value = disenable()(value)
         await self.bot.db.set_reply_embeds(ctx.guild.id, value == "enable")
         return await ctx.send_ok(f"Normal responses will now " +
                                  ("" if value == "enable" else "not ") +
                                  "be in an embed")
     if setting == "currencymin":
         try:
             v = int(value)
             if v < 0:
                 return await ctx.send_error("Value must be above 0")
             if v > (await self.bot.db.guild_setting(ctx.guild.id
                                                     )).currency_max:
                 return await ctx.send_error(
                     "Minimum currency generation value cannot be above maximum"
                 )
         except ValueError:
             return await ctx.send_error("Value must be a number above 0")
         await self.bot.db.set_currency_gen(ctx.guild.id, min_amt=v)
         return await ctx.send_ok(
             f"Min currency generation amount set to ${v}")
     if setting == "currencymax":
         try:
             v = int(value)
             if v < 0:
                 return await ctx.send_error("Value must be above 0")
             if v < (await self.bot.db.guild_setting(ctx.guild.id
                                                     )).currency_min:
                 return await ctx.send_error(
                     "Minimum currency generation value cannot be below minimum"
                 )
         except ValueError:
             return await ctx.send_error("Value must be a number above 0")
         await self.bot.db.set_currency_gen(ctx.guild.id, max_amt=v)
         return await ctx.send_ok(
             f"Max currency generation amount set to ${v}")
     if setting == "currencychance":
         try:
             v = int(value)
             if v < 0 or v > 100:
                 return await ctx.send_error(
                     "Currency generation chance must be between 0 and 100")
         except ValueError:
             return await ctx.send_error(
                 "Currency generation chance must be a number between 0 and 100"
             )
         await self.bot.db.set_currency_gen(ctx.guild.id, chance=v)
         return await ctx.send_ok(f"Currency generation chance set to {v}%")
Esempio n. 10
0
 async def allusrmdls(self, ctx: aoi.AoiContext, member: discord.Member,
                      enabled: disenable()):
     await self.db.add_permission(ctx.guild.id,
                                  f"aum {member.id} {enabled}")
     await ctx.send_ok(f"**aum <@{member.id}> {enabled}** added.",
                       trash=False)
Esempio n. 11
0
 async def allrolemdls(self, ctx: aoi.AoiContext, role: discord.Role,
                       enabled: disenable()):
     await self.db.add_permission(ctx.guild.id, f"arm {role.id} {enabled}")
     await ctx.send_ok(f"**arm <@&{role.id}> {enabled}** added.",
                       trash=False)
Esempio n. 12
0
 async def allchnlmdls(self, ctx: aoi.AoiContext,
                       channel: discord.TextChannel, enabled: disenable()):
     await self.db.add_permission(ctx.guild.id,
                                  f"acm {channel.id} {enabled}")
     await ctx.send_ok(f"**acm <#{channel.id}> {enabled}** added",
                       trash=False)
Esempio n. 13
0
 async def allsvrmdls(self, ctx: aoi.AoiContext, enabled: disenable()):
     await self.db.add_permission(ctx.guild.id, f"asm {enabled}")
     await ctx.send_ok(f"`asm {enabled}` added", trash=False)
Esempio n. 14
0
 async def svrmdl(self, ctx: aoi.AoiContext, enabled: disenable(),
                  module: str):
     module = self.bot.find_cog(module)[0]
     await self.db.add_permission(ctx.guild.id, f"sm {enabled} {module}")
     await ctx.send_ok(f"**sm {enabled} {module}** added.", trash=False)