From 3fc283e8f21cb1bb79303ea96edfa6637ec72850 Mon Sep 17 00:00:00 2001 From: Bryan <8569851+itsthedevman@users.noreply.github.com> Date: Sun, 16 Jul 2023 17:15:00 -0400 Subject: [PATCH] Allow some mixing of groups and subcommands Discord allows defining slash commands so long as a group and a subcommand do not share the same name --- lib/discordrb/events/interactions.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/discordrb/events/interactions.rb b/lib/discordrb/events/interactions.rb index c10a11e9e..0b9df9f8a 100644 --- a/lib/discordrb/events/interactions.rb +++ b/lib/discordrb/events/interactions.rb @@ -246,7 +246,7 @@ def initialize(attributes, block) # @yieldparam [SubcommandBuilder] # @return [ApplicationCommandEventHandler] def group(name) - raise ArgumentError, 'Unable to mix subcommands and groups' if @subcommands.any? { |_, v| v.is_a? Proc } + raise ArgumentError, 'Unable to mix subcommands and groups' if @subcommands.any? { |n, v| n == name && v.is_a?(Proc) } builder = SubcommandBuilder.new(name) yield builder @@ -259,7 +259,7 @@ def group(name) # @yieldparam [SubcommandBuilder] # @return [ApplicationCommandEventHandler] def subcommand(name, &block) - raise ArgumentError, 'Unable to mix subcommands and groups' if @subcommands.any? { |_, v| v.is_a? Hash } + raise ArgumentError, 'Unable to mix subcommands and groups' if @subcommands.any? { |n, v| n == name && v.is_a?(Hash) } @subcommands[name.to_sym] = block