Beispiel #1
0
async def set_self_mute(ctx: Context, bot: MrFreeze,
                        proposed_time: Optional[int]) -> None:
    """Take a proposed new self mute time for a server and try to set it."""
    mention = ctx.author.mention
    server = ctx.guild
    current = bot.get_self_mute_time(server)
    old_time = current or "the default value"
    new_time = f"{proposed_time} minutes" if proposed_time else "the default value"
    msg = None

    if proposed_time == current:
        msg = f"{mention} The self mute time for this server is already set to {new_time}."

    elif proposed_time is not None and proposed_time < 0:
        msg = f"{mention} {new_time}? Now you're just being silly."

    elif proposed_time is not None and proposed_time > 3600 * 24:
        msg = f"{mention} You're being completely unreasonable, "
        msg += f"{new_time} is more than a day!"

    else:
        setting_saved = bot.settings.set_self_mute_time(server, proposed_time)
        if setting_saved:
            msg = f"{mention} The self mute time has been changed from "
            msg += f"{old_time} to {new_time}."
        else:
            msg = f"{mention} I tried so hard, and got so far, but in the end "
            msg += f"I wasn't able to change the self mute time from {old_time} "
            msg += f"to {new_time}."

    if msg:
        await ctx.send(msg)
Beispiel #2
0
def setup(bot: MrFreeze) -> None:
    """Add the cog to the bot."""
    bot.add_cog(Moderation(bot))
Beispiel #3
0
state = MagicMock()
channel = MagicMock()
guild = MagicMock()

message_instance = discord.Message(state=state,
                                   channel=channel,
                                   data=message_data)

channel_instance = discord.TextChannel(state=state,
                                       guild=guild,
                                       data=channel_data)

# TODO: Add some option to MrFreeze for skipping
#       the directory configuration thing.
bot_instance = MrFreeze(command_prefix=MagicMock())
bot_instance.http_session = None
bot_instance.api_client = None


class CustomMockMixin(MagicMock):
    child_mock_type = MagicMock
    discord_id = itertools.count(0)

    def __init__(self, spec_set: Any = None, **kwargs):
        name = kwargs.pop("name", None)
        super().__init__(spec_set=spec_set, **kwargs)

        if name:
            self.name = name
        if spec_set:
def setup(bot: MrFreeze):
    """Add the cog to the bot."""
    bot.add_cog(ErrorHandler(bot))
Beispiel #5
0
def setup(bot: MrFreeze) -> None:
    """Add the cog to the bot."""
    bot.add_cog(LeaveMessages(bot))
Beispiel #6
0
def setup(bot: MrFreeze) -> None:
    """Load the cog into the bot."""
    bot.add_cog(BanishAndRegion(bot))
Beispiel #7
0
def create_table(bot: MrFreeze) -> None:
    """Create the mutes database if it doesn't exist."""
    bot.db_create(bot, dbname, dbtable)
Beispiel #8
0
def setup(bot: MrFreeze) -> None:
    """Add the cog to the bot."""
    bot.add_cog(UserCommands(bot))
Beispiel #9
0
def setup(bot: MrFreeze) -> None:
    """Add the cog to the bot."""
    bot.add_cog(About(bot))
Beispiel #10
0
def setup(bot: MrFreeze) -> None:
    """Add the cog to the bot."""
    bot.add_cog(TemperatureConverter(bot))
Beispiel #11
0
def setup(bot: MrFreeze) -> None:
    """Add the cog to the bot."""
    bot.add_cog(DevTools(bot))
Beispiel #12
0
def setup(bot: MrFreeze) -> None:
    """Add the cog to the bot."""
    bot.add_cog(LogLevel(bot))
Beispiel #13
0
def setup(bot: MrFreeze) -> None:
    """Add the cog to the bot."""
    bot.add_cog(CommandLogger(bot))
Beispiel #14
0
def setup(bot: MrFreeze) -> None:
    """Add the cog to the bot."""
    bot.add_cog(Inkcyclopedia(bot))