ソースを参照

initial commit

master
Haku 3年前
コミット
473995f8bf
4個のファイルの変更70行の追加0行の削除
  1. +1
    -0
      .gitignore
  2. +7
    -0
      libcordroster/__init__.py
  3. +18
    -0
      libcordroster/info.json
  4. +44
    -0
      libcordroster/libcordroster.py

+ 1
- 0
.gitignore ファイルの表示

@@ -0,0 +1 @@
.idea/

+ 7
- 0
libcordroster/__init__.py ファイルの表示

@@ -0,0 +1,7 @@
from redbot.core.bot import Red
from .libcordroster import LibcordRoster


def setup(bot: Red):
cog = LibcordRoster(bot)
bot.add_cog(cog)

+ 18
- 0
libcordroster/info.json ファイルの表示

@@ -0,0 +1,18 @@
{
"author": [
"Haku"
],
"name": "Libcord Roster",
"bot_version": [
3,
0,
0
],
"description": "Libcord roster.",
"hidden": false,
"install_msg": "Libcord roster successfully installed.",
"short": "Libcord roster Stuff",
"tags": [
"fun"
]
}

+ 44
- 0
libcordroster/libcordroster.py ファイルの表示

@@ -0,0 +1,44 @@
from redbot.core import commands
from redbot.core.bot import Red
from redbot.core.utils.chat_formatting import pagify
import discord


async def has_update_command_role(ctx):
"""
Checks if the user has the update command role.
"""
if ctx.guild is None:
return False
uc_role = discord.utils.get(ctx.guild.roles, name="Update Command")
reporter_role = discord.utils.get(ctx.guild.roles, name="Reporter")
if uc_role is None:
return False
return (uc_role in ctx.author.roles) or (reporter_role in ctx.author.roles)


class LibcordRoster(commands.Cog):

def __init__(self, bot: Red, *args, **kwargs):
super().__init__(*args, **kwargs)
self.bot = bot

def cog_unload(self):
pass

@commands.command()
@commands.check(has_update_command_role)
async def roster(self, ctx: commands.Context):
"""Get the names of all users with the Updating role"""
guild = ctx.guild
role = discord.utils.get(guild.roles, name="Updating")
members = [member for member in guild.members if role in member.roles]
out = ""
for member in members:
if member.nick:
out += f"{member.nick}\n"
elif member.name:
out += f"{member.name}\n"
out = '\n'.join(sorted(out.splitlines(), key=str.lower))
for page in pagify(out):
await ctx.send("```\n" + page + "```")

読み込み中…
キャンセル
保存