Пример #1
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
Пример #2
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
Пример #3
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
Пример #4
0
def get_verified_role_in_guild(guild: discord.Guild) -> discord.Role:
    g = Guild.objects(guild_id=guild.id).first()
    r = Role.objects(id__in=g.roles) \
        .filter(category="verify") \
        .first()
    if not r:
        return None
    return guild.get_role(r.role_id)
Пример #5
0
def get_role_from_payload(payload: discord.RawReactionActionEvent,
                          guild: discord.Guild) -> discord.Role:
    g = Guild.objects(guild_id=payload.guild_id).first()
    r = Role.objects(id__in=g.roles) \
        .filter(message_id=payload.message_id) \
        .filter(reaction=payload.emoji.name).first()
    if not r:
        return None
    return guild.get_role(r.role_id)
Пример #6
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
Пример #7
0
def update_guild_welcome_message(guild: discord.Guild, message) -> str:
    g = Guild.objects().filter(guild_id=guild.id).first()
    if not g:
        create_default_guild(guild)
        r = update_guild_welcome_message(guild, messages)
        return r
    g.welcome_message = message
    g.save()

    return g.welcome_message
Пример #8
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
Пример #9
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
Пример #10
0
def increment_retarded_user(g_id):
    Guild.objects(guild_id=g_id).update_one(inc__retarded_user=1)
Пример #11
0
def should_save_messages_in_guild(g_id) -> bool:
    g = Guild.objects().filter(guild_id=g_id).first()
    if not g:
        return False
    return g.should_save_messages
Пример #12
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()
Пример #13
0
def should_welcome_in_guild(g_id) -> bool:
    g = Guild.objects().filter(guild_id=g_id).first()
    if not g:
        return False
    return g.should_welcome_members
Пример #14
0
def channel_is_verification(ctx: discord.ext.commands.Context) -> bool:
    return Guild.objects(
        guild_id=ctx.guild.id).first().verification_channel == ctx.channel.id
Пример #15
0
def get_guild(g_id):
    return Guild.objects().filter(guild_id=g_id).first()
Пример #16
0
def increment_underaged_user(g_id):
    Guild.objects(guild_id=g_id).update_one(inc__underaged_user=1)
Пример #17
0
def increment_verified_user(g_id):
    Guild.objects(guild_id=g_id).update_one(inc__verified_user=1)
Пример #18
0
def increment_message_edited(g_id: discord.Guild.id):
    Guild.objects(guild_id=g_id).update_one(inc__message_edited=1)
Пример #19
0
def get_password_in_guild(g_id) -> str:
    return Guild.objects(guild_id=g_id).first().password