async def ignore(self, ctx, channels: commands.Greedy[discord.TextChannel] = None): logger.info("command: invite") added = "" removed = "" if channels is not None: logger.info(f"ignored channels: {[c.name for c in channels]}") for channel in channels: if database.zscore("ignore:global", str(channel.id)) is None: added += f"`#{channel.name}` (`{channel.category.name if channel.category else 'No Category'}`)\n" database.zadd("ignore:global", {str(channel.id): ctx.guild.id}) else: removed += f"`#{channel.name}` (`{channel.category.name if channel.category else 'No Category'}`)\n" database.zrem("ignore:global", str(channel.id)) else: await ctx.send("**No valid channels were passed.**") ignored = "".join([ f"`#{channel.name}` (`{channel.category.name if channel.category else 'No Category'}`)\n" for channel in map( lambda c: ctx.guild.get_channel(int(c)), database.zrangebyscore("ignore:global", ctx.guild.id - 0.1, ctx.guild.id + 0.1), ) ]) await ctx.send( (f"**Ignoring:**\n{added}" if added else "") + (f"**Stopped ignoring:**\n{removed}" if removed else "") + (f"**Ignored Channels:**\n{ignored}" if ignored else "**No channels in this server are currently ignored.**"))
async def unban(self, ctx, *, user: typing.Optional[discord.Member] = None): logger.info("command: unban") if user is None: logger.info("no args") await ctx.send("Invalid User!") return logger.info(f"user-id: {user.id}") database.zrem("banned:global", str(user.id)) await ctx.send(f"Ok, {user.name} can use the bot!")
def test_suite_cleanup_thing(self): yield database.delete(f"channel:{self.ctx.channel.id}") database.zrem("score:global", str(self.ctx.channel.id)) database.zrem("users:global", str(self.ctx.author.id)) database.zrem("streak:global", str(self.ctx.author.id)) database.zrem("streak.max:global", str(self.ctx.author.id)) database.delete(f"incorrect.user:{self.ctx.author.id}") if self.ctx.guild is not None: database.delete(f"users.server:{self.ctx.guild.id}") database.delete(f"incorrect.server:{self.ctx.guild.id}")
def setup(self, guild=False): self.bot = mock.Bot() self.cog = get_birds.Birds(self.bot) self.ctx = mock.Context() if guild: self.ctx.set_guild() database.delete(f"channel:{self.ctx.channel.id}") database.zrem("score:global", str(self.ctx.channel.id)) database.zrem("users:global", str(self.ctx.author.id)) database.zrem("streak:global", str(self.ctx.author.id)) database.zrem("streak.max:global", str(self.ctx.author.id)) if self.ctx.guild is not None: database.delete(f"users.server:{self.ctx.guild.id}")
def setup(self, guild=False): # pylint: disable=attribute-defined-outside-init self.bot = mock.Bot() self.cog = score.Score(self.bot) self.ctx = mock.Context(self.bot) if guild: self.ctx.set_guild() database.delete(f"channel:{self.ctx.channel.id}") database.zrem("score:global", str(self.ctx.channel.id)) database.zrem("users:global", str(self.ctx.author.id)) database.zrem("streak:global", str(self.ctx.author.id)) database.zrem("streak.max:global", str(self.ctx.author.id)) if self.ctx.guild is not None: database.delete(f"users.server:{self.ctx.guild.id}") asyncio.run(channel_setup(self.ctx)) asyncio.run(user_setup(self.ctx))