2022-07-05 22:19:59 +00:00
|
|
|
import hikari
|
|
|
|
import lightbulb
|
|
|
|
from miru.ext import nav
|
|
|
|
|
|
|
|
import config as c
|
|
|
|
from tools import components
|
|
|
|
|
|
|
|
|
|
|
|
plugin = lightbulb.Plugin("info", default_enabled_guilds=c.config["guild"])
|
|
|
|
|
|
|
|
|
2022-08-16 18:57:50 +00:00
|
|
|
# Get list of members not in activity database
|
2022-07-05 22:19:59 +00:00
|
|
|
@plugin.command
|
|
|
|
@lightbulb.add_checks(lightbulb.has_guild_permissions(hikari.Permissions.MANAGE_GUILD))
|
2022-07-05 22:43:56 +00:00
|
|
|
@lightbulb.command("limbo", "List members not in activity database", ephemeral=True)
|
2022-07-05 22:19:59 +00:00
|
|
|
@lightbulb.implements(lightbulb.SlashCommand)
|
2022-07-05 22:43:56 +00:00
|
|
|
async def limbo(context):
|
2022-08-16 18:57:50 +00:00
|
|
|
# Embed builder
|
2022-07-05 22:19:59 +00:00
|
|
|
def build(index, content):
|
|
|
|
return hikari.Embed(
|
2022-07-05 22:43:56 +00:00
|
|
|
title="Limbo", description=content, color=context.get_guild().get_my_member().get_top_role().color
|
|
|
|
).set_footer(f"{len(limbo)} members")
|
2022-07-05 22:19:59 +00:00
|
|
|
|
2022-08-16 18:57:50 +00:00
|
|
|
# Get, sort, and filter list of members if not a bot, without excluded role, and not in db
|
2022-07-05 22:43:56 +00:00
|
|
|
limbo = {
|
2022-07-05 22:19:59 +00:00
|
|
|
snowflake: member
|
|
|
|
for snowflake, member in sorted(
|
|
|
|
context.get_guild().get_members().items(), key=lambda item: item[1].display_name
|
|
|
|
)
|
2022-07-05 22:43:56 +00:00
|
|
|
if not member.is_bot
|
|
|
|
and c.config["exclude"] not in [role.id for role in member.get_roles()]
|
|
|
|
and snowflake not in c.db
|
2022-07-05 22:19:59 +00:00
|
|
|
}
|
|
|
|
|
2022-08-16 18:57:50 +00:00
|
|
|
# Build paginator
|
2022-07-05 22:19:59 +00:00
|
|
|
paginator = lightbulb.utils.EmbedPaginator()
|
|
|
|
paginator.set_embed_factory(build)
|
2022-07-05 22:43:56 +00:00
|
|
|
for snowflake, member in limbo.items():
|
2022-07-05 22:19:59 +00:00
|
|
|
paginator.add_line(f"{member.mention} {snowflake}")
|
|
|
|
pages = [page for page in paginator.build_pages()]
|
|
|
|
|
2022-08-16 18:57:50 +00:00
|
|
|
# Send paginator
|
2022-07-05 22:19:59 +00:00
|
|
|
if len(pages) > 1:
|
|
|
|
navigator = nav.NavigatorView(
|
|
|
|
pages=pages,
|
|
|
|
buttons=[components.Back(), components.Forward()],
|
|
|
|
timeout=600,
|
|
|
|
)
|
|
|
|
await navigator.send(context.interaction, ephemeral=True)
|
|
|
|
else:
|
|
|
|
await context.respond(pages[0])
|
|
|
|
|
|
|
|
|
|
|
|
def load(bot):
|
|
|
|
bot.add_plugin(plugin)
|
|
|
|
|
|
|
|
|
|
|
|
def unload(bot):
|
|
|
|
bot.remove_plugin(plugin)
|