(interaction, options)
| 196 | } |
| 197 | |
| 198 | static async safeReply(interaction, options) { |
| 199 | try { |
| 200 | const coordinator = this.getCoordinator(interaction); |
| 201 | if (coordinator?.isUsageFinalized()) { |
| 202 | return false; |
| 203 | } |
| 204 | |
| 205 | if (!this.isInteractionValid(interaction)) { |
| 206 | logger.warn(`Interaction ${interaction.id} has expired before reply, ignoring`); |
| 207 | return false; |
| 208 | } |
| 209 | |
| 210 | if (coordinator && (interaction._isPrefixCommand || coordinator.hasResponded())) { |
| 211 | if (coordinator.hasResponded()) { |
| 212 | await coordinator.edit(sanitizeEditReplyOptions(options)); |
| 213 | } else { |
| 214 | await coordinator.respond(options); |
| 215 | } |
| 216 | return true; |
| 217 | } |
| 218 | |
| 219 | if (interaction.deferred && !interaction.replied) { |
| 220 | await interaction.editReply(sanitizeEditReplyOptions(options)); |
| 221 | return true; |
| 222 | } |
| 223 | |
| 224 | if (interaction.replied) { |
| 225 | await interaction.followUp(options); |
| 226 | return true; |
| 227 | } |
| 228 | |
| 229 | await interaction.reply(options); |
| 230 | return true; |
| 231 | } catch (error) { |
| 232 | if (isInteractionUnavailableError(error)) { |
| 233 | logger.warn(`Interaction ${interaction.id} unavailable during reply:`, error.message); |
| 234 | return false; |
| 235 | } |
| 236 | if (error.code === 40060) { |
| 237 | logger.warn(`Interaction ${interaction.id} already acknowledged during reply:`, error.message); |
| 238 | return false; |
| 239 | } |
| 240 | logger.error('Failed to reply:', error); |
| 241 | return false; |
| 242 | } |
| 243 | } |
| 244 | |
| 245 | static async safeShowModal(interaction, modal) { |
| 246 | try { |
no test coverage detected