Ejemplo n.º 1
0
async def on_guild_join(bot, guild: Guild):
    blocked = Configuration.get_persistent_var("server_blocklist", [])
    if guild.id in blocked:
        GearbotLogging.info(
            f"Someone tried to add me to blocked guild {guild.name} ({guild.id})"
        )
        try:
            await guild.owner.send(
                "Someone tried adding me to {guild.name} (``{guild.id}``) but the server has been blocked"
            )
        except Exception:
            pass
        await guild.leave()
    elif guild.owner_id in Configuration.get_persistent_var(
            "user_blocklist", []):
        GearbotLogging.info(
            f"Someone tried to add me to {Utils.clean(guild.name)} ({guild.id}) but the owner ({guild.owner} ({guild.owner_id})) is blocked"
        )
        try:
            await (await bot.fetch_user(guild.owner_id)).send(
                f"Someone tried adding me to {guild.name} (``{guild.id}``) but you have been blocked due to bot abuse, so i left"
            )
        except Exception:
            pass
        await guild.leave()
    else:
        bot.missing_guilds.add(guild.id)
        await guild.chunk(cache=True)
        bot.missing_guilds.remove(guild.id)
        GearbotLogging.info(f"A new guild came up: {guild.name} ({guild.id}).")
        Configuration.load_config(guild.id)
        name = await Utils.clean(guild.name)
        await GearbotLogging.bot_log(
            f"{Emoji.get_chat_emoji('JOIN')} A new guild came up: {name} ({guild.id}).",
            embed=server_info.server_info_embed(guild))
Ejemplo n.º 2
0
async def on_guild_remove(guild):
    blocked = Configuration.get_persistent_var("server_blocklist", [])
    blocked_users = Configuration.get_persistent_var("user_blocklist", [])
    if guild.id not in blocked and guild.owner_id not in blocked_users:
        GearbotLogging.info(
            f"I was removed from a guild: {guild.name} ({guild.id}).")
        await GearbotLogging.bot_log(
            f"{Emoji.get_chat_emoji('LEAVE')} I was removed from a guild: {guild.name} ({guild.id}).",
            embed=server_info.server_info_embed(guild))