@@ -19,15 +19,12 @@ internal class ComponentEventWaiter : IDisposable
1919 private readonly ConcurrentHashSet < ComponentMatchRequest > matchRequests = [ ] ;
2020 private readonly ConcurrentHashSet < ComponentCollectRequest > collectRequests = [ ] ;
2121
22- private readonly DiscordFollowupMessageBuilder message ;
2322 private readonly InteractivityConfiguration config ;
2423
2524 public ComponentEventWaiter ( DiscordClient client , InteractivityConfiguration config )
2625 {
2726 this . client = client ;
2827 this . config = config ;
29-
30- this . message = new ( ) { Content = config . ResponseMessage ?? "This message was not meant for you." , IsEphemeral = true } ;
3128 }
3229
3330 /// <summary>
@@ -90,17 +87,27 @@ internal async Task HandleAsync(DiscordClient _, ComponentInteractionCreatedEven
9087 {
9188 try
9289 {
93- string responseMessage = this . config . ResponseMessage ??
94- this . config . ResponseMessageFactory ( args , client . ServiceProvider ) ;
95-
96- await args . Interaction . CreateFollowupMessageAsync
97- (
98- new DiscordFollowupMessageBuilder { Content = responseMessage , IsEphemeral = true }
99- ) ;
90+ string responseMessage = this . config . ResponseMessage ?? this . config . ResponseMessageFactory ( args , this . client . ServiceProvider ) ;
91+
92+ if ( args . Interaction . ResponseState is DiscordInteractionResponseState . Unacknowledged )
93+ {
94+ await args . Interaction . CreateResponseAsync
95+ (
96+ DiscordInteractionResponseType . ChannelMessageWithSource ,
97+ new ( ) { Content = responseMessage , IsEphemeral = true }
98+ ) ;
99+ }
100+ else
101+ {
102+ await args . Interaction . CreateFollowupMessageAsync
103+ (
104+ new ( ) { Content = responseMessage , IsEphemeral = true }
105+ ) ;
106+ }
100107 }
101108 catch ( Exception e )
102109 {
103- client . Logger . LogWarning ( e , "An exception was thrown during an interactivity response." ) ;
110+ this . client . Logger . LogWarning ( e , "An exception was thrown during an interactivity response." ) ;
104111 }
105112 }
106113 }
@@ -119,17 +126,27 @@ await args.Interaction.CreateFollowupMessageAsync
119126 {
120127 try
121128 {
122- string responseMessage = this . config . ResponseMessage ??
123- this . config . ResponseMessageFactory ( args , client . ServiceProvider ) ;
124-
125- await args . Interaction . CreateFollowupMessageAsync
126- (
127- new DiscordFollowupMessageBuilder { Content = responseMessage , IsEphemeral = true }
128- ) ;
129+ string responseMessage = this . config . ResponseMessage ?? this . config . ResponseMessageFactory ( args , this . client . ServiceProvider ) ;
130+
131+ if ( args . Interaction . ResponseState is DiscordInteractionResponseState . Unacknowledged )
132+ {
133+ await args . Interaction . CreateResponseAsync
134+ (
135+ DiscordInteractionResponseType . ChannelMessageWithSource ,
136+ new ( ) { Content = responseMessage , IsEphemeral = true }
137+ ) ;
138+ }
139+ else
140+ {
141+ await args . Interaction . CreateFollowupMessageAsync
142+ (
143+ new ( ) { Content = responseMessage , IsEphemeral = true }
144+ ) ;
145+ }
129146 }
130147 catch ( Exception e )
131148 {
132- client . Logger . LogWarning ( e , "An exception was thrown during an interactivity response." ) ;
149+ this . client . Logger . LogWarning ( e , "An exception was thrown during an interactivity response." ) ;
133150 }
134151 }
135152 }
0 commit comments