From 4040cbda5e2916fdc3a1b9939582b0023c433c3b Mon Sep 17 00:00:00 2001 From: takejohn <105504345+takejohn@users.noreply.github.com> Date: Fri, 28 Jun 2024 12:50:14 +0900 Subject: [PATCH] =?UTF-8?q?=E9=9F=B3=E6=A5=BD=E3=81=AE=E3=82=B9=E3=82=AD?= =?UTF-8?q?=E3=83=83=E3=83=97=E3=81=AB=E6=A8=A9=E9=99=90=E3=82=92=E8=A6=81?= =?UTF-8?q?=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/player/PlayerCommand.ts | 10 +++++++++- packages/player/commands/skip.ts | 11 +++++++++++ packages/player/index.ts | 3 ++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/packages/player/PlayerCommand.ts b/packages/player/PlayerCommand.ts index 2e88eb4..e2f550d 100644 --- a/packages/player/PlayerCommand.ts +++ b/packages/player/PlayerCommand.ts @@ -20,7 +20,7 @@ export class PlayerCommand implements Command { constructor( data: SlashCommandBuilder, action: ( - interaction: ChatInputCommandInteraction, + interaction: ChatInputCommandInteraction<'cached'>, queue: GuildQueue, voiceChannelId: string, ) => Promise, @@ -33,6 +33,14 @@ export class PlayerCommand implements Command { * @param interaction */ async execute(interaction: ChatInputCommandInteraction) { + if (!interaction.inCachedGuild()) { + await interaction.reply({ + content: LANG.common.message.useCommandInGuild, + ephemeral: true, + }); + return; + } + const voiceChannelId = getPlayableVoiceChannelId(interaction); if (voiceChannelId == null) { await interaction.reply({ diff --git a/packages/player/commands/skip.ts b/packages/player/commands/skip.ts index b9b6c1a..715043d 100755 --- a/packages/player/commands/skip.ts +++ b/packages/player/commands/skip.ts @@ -2,6 +2,9 @@ import assert from 'assert'; import { SlashCommandBuilder } from 'discord.js'; import { LANG, strFormat } from 'core'; import { PlayerCommand } from '../PlayerCommand'; +import { feature as perms } from 'perms'; + +perms.registerPermission('dj', '/skip コマンドの使用'); module.exports = new PlayerCommand( new SlashCommandBuilder() @@ -18,6 +21,14 @@ module.exports = new PlayerCommand( return; } + if (!perms.hasPermission(interaction.member, 'dj')) { + await interaction.reply({ + content: LANG.common.message.noPermission, + ephemeral: true, + }); + return; + } + try { queue.node.skip(); const currentTrack = queue.currentTrack; diff --git a/packages/player/index.ts b/packages/player/index.ts index 052b938..85aeed0 100644 --- a/packages/player/index.ts +++ b/packages/player/index.ts @@ -9,6 +9,7 @@ import { } from './players'; import { Client } from 'discord.js'; import * as db from 'db'; +import { feature as perms } from 'perms'; class PlayerFeature extends Feature { #player: Player | null = null; @@ -17,7 +18,7 @@ class PlayerFeature extends Feature { enabled = Config.features?.player ?? true; - dependencies = [db.feature]; + dependencies = [db.feature, perms]; private deletePromise?: Promise;