Example #1
0
def should_show_deleted_in_guild(g_id) -> bool:
    g = Guild.objects().filter(guild_id=g_id).first()
    if not g:
        raise exceptions.UpdateError("An error has occured")
    if not g.log_channel:
        raise exceptions.UpdateError(
            "There is no log channel set yet.\n Use `!.slc` to assign a channel to logging"
        )
    return g.should_show_deleted
Example #2
0
def get_log_channel_in_guild(guild: discord.Guild) -> discord.TextChannel:
    g = Guild.objects().filter(guild_id=guild.id).first()
    if not g:
        raise exceptions.UpdateError("An error has occured")
    if not g.log_channel:
        raise exceptions.UpdateError("There is no log channel set")

    c = guild.get_channel(g.log_channel)
    if not c:
        raise exceptions.UpdateError("Couldn't find the log channel")
    return c
Example #3
0
def update_should_show_deleted(g_id) -> bool:
    g = Guild.objects().filter(guild_id=g_id).first()
    if not g:
        raise exceptions.UpdateError("Couldn't update 'should_show_deleted'")
    if not g.log_channel:
        raise exceptions.UpdateError(
            "There is no log channel set yet.\n Use `!.slc` to assign a channel to logging"
        )
    g.should_show_deleted = not g.should_show_deleted
    g.save()

    return g.should_show_deleted
Example #4
0
def update_should_save_messages(g_id) -> bool:
    g = Guild.objects().filter(guild_id=g_id).first()
    if not g:
        raise exceptions.UpdateError("Couldn't update 'should_save_message'")
    g.should_save_messages = not g.should_save_messages
    g.save()
    return g.should_save_messages
Example #5
0
def update_should_show_edited(g_id) -> bool:
    g = Guild.objects(guild_id=g_id).first()
    if not g:
        raise exceptions.UpdateError("Cannot update should_show_edited")
    g.should_show_edited = not g.should_show_edited
    g.save()
    return g.should_show_edited
Example #6
0
def update_should_verify(g_id):
    g = Guild.objects(guild_id=g_id).first()
    if not g:
        raise exceptions.UpdateError("Cannot update should_verify")
    g.should_verify = not g.should_verify
    g.save()
    return g.should_verify
Example #7
0
def set_settings_to_default_in_guild(g_id):
    g = get_guild(g_id)
    if not g:
        raise exceptions.UpdateError(
            "Cannot set the settings to the default values")
    g.should_verify = False
    g.should_show_deleted = False
    g.should_save_messages = False
    g.should_welcome_members = True
    g.should_show_edited = False
    g.should_show_joining = False
    g.should_show_leaving = False
    g.save()
Example #8
0
def update_log_channel_in_guild(g_id, c_id):
    g = Guild.objects().filter(guild_id=g_id).first()
    if not g:
        raise exceptions.UpdateError("Couldn't set the log channel")
    g.log_channel = c_id
    g.save()