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
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
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
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)
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)
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
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
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
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
def increment_retarded_user(g_id): Guild.objects(guild_id=g_id).update_one(inc__retarded_user=1)
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
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()
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
def channel_is_verification(ctx: discord.ext.commands.Context) -> bool: return Guild.objects( guild_id=ctx.guild.id).first().verification_channel == ctx.channel.id
def get_guild(g_id): return Guild.objects().filter(guild_id=g_id).first()
def increment_underaged_user(g_id): Guild.objects(guild_id=g_id).update_one(inc__underaged_user=1)
def increment_verified_user(g_id): Guild.objects(guild_id=g_id).update_one(inc__verified_user=1)
def increment_message_edited(g_id: discord.Guild.id): Guild.objects(guild_id=g_id).update_one(inc__message_edited=1)
def get_password_in_guild(g_id) -> str: return Guild.objects(guild_id=g_id).first().password