MCPcopy Index your code
hub / github.com/codebymitch/TitanBot / safeReply

Method safeReply

src/utils/interactionHelper.js:198–243  ·  view source on GitHub ↗
(interaction, options)

Source from the content-addressed store, hash-verified

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 {

Callers 15

safeEditReplyMethod · 0.95
universalReplyMethod · 0.95
executeFunction · 0.80
executeFunction · 0.80
handleChannelDeletionFunction · 0.80
executeFunction · 0.80
executeFunction · 0.80
executeFunction · 0.80
executeFunction · 0.80
executeFunction · 0.80
executeFunction · 0.80
executeFunction · 0.80

Calls 9

getCoordinatorMethod · 0.95
isInteractionValidMethod · 0.95
sanitizeEditReplyOptionsFunction · 0.85
isUsageFinalizedMethod · 0.80
hasRespondedMethod · 0.80
editMethod · 0.80
respondMethod · 0.80
followUpMethod · 0.80

Tested by

no test coverage detected