Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

サーバーごとの権限管理システム (#92) #99

Merged
merged 14 commits into from
May 9, 2024

Conversation

takejohn
Copy link
Member

@takejohn takejohn commented May 9, 2024

内容

/permコマンドにより、サーバー管理者が権限にロールやユーザーを割り当てることができるようになります。
今のところ、/reply コマンドによる自動応答の編集権限を設定できるようにしています。

開発者向け使用例

const { SlashCommandBuilder } = require('discord.js');
const { feature: perms } = require('perms');

perms.registerPermission('useHello', 'helloコマンドの使用');

module.exports = {
    data: new SlashCommandBuilder()
        .setName('hello')
        .setDescription('Hello, Sekai!'),
    async execute(/** @type {import('discord.js').ChatInputCommandInteraction} */ interaction) {
        if (interaction.inCachedGuild() && await perms.hasPermission(interaction.member, 'useHello')) {
            await interaction.reply('Hello, Sekai!');
        } else {
            await interaction.reply('このコマンドは使用できません!')
        }
    }
}

変更点

  • perms Feature、/perm コマンドの作成
  • /perm コマンドによって設定された replyCustomize 権限を持っているメンバーは /replyコマンドによる自動応答の設定を行えるように
  • Command インターフェイスに任意で autocomplete メソッドを持たせられるように
  • SimpleChoiceOptionDataautocomplete フィールドをオプショナルな関数に変更
  • SimpleCommandBuilderMentionable 型オプションを追加できるように

チェックリスト:

  • このリポジトリのコードスタイルに沿っているか
  • 自分自身で動作確認を行ったか、また、それは正常に動作したか

@takejohn takejohn marked this pull request as ready for review May 9, 2024 03:09
@takejohn takejohn requested a review from ringo360 May 9, 2024 03:09
@ringo360
Copy link
Member

ringo360 commented May 9, 2024

Good PR! I'll check later ✅

Copy link
Member

@ringo360 ringo360 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good!

@ringo360 ringo360 merged commit 4f16226 into v14-dev May 9, 2024
3 checks passed
@ringo360
Copy link
Member

ringo360 commented May 9, 2024

🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

権限システムの改善と強化
2 participants