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

Function setReactionRoleChannel

src/services/reactionRoleService.js:377–415  ·  view source on GitHub ↗
(client, guildId, messageId, channelId)

Source from the content-addressed store, hash-verified

375}
376
377export async function setReactionRoleChannel(client, guildId, messageId, channelId) {
378 try {
379 validateGuildId(guildId);
380 validateMessageId(messageId);
381
382 if (!channelId || typeof channelId !== 'string' || !/^\d{17,19}$/.test(channelId)) {
383 throw createError(
384 `Invalid channel ID: ${channelId}`,
385 ErrorTypes.VALIDATION,
386 'Invalid channel ID provided.',
387 { channelId }
388 );
389 }
390
391 const key = `reaction_roles:${guildId}:${messageId}`;
392 const data = await getReactionRoleMessage(client, guildId, messageId) || {
393 messageId,
394 guildId,
395 channelId: '',
396 roles: {}
397 };
398
399 data.channelId = channelId;
400 await client.db.set(key, data);
401 logger.info(`Set channel ${channelId} for reaction role message ${messageId}`);
402 return true;
403 } catch (error) {
404 if (error.name === 'TitanBotError') {
405 throw error;
406 }
407 logger.error(`Error setting channel for reaction role message ${messageId}:`, error);
408 throw createError(
409 `Database error setting reaction role channel`,
410 ErrorTypes.DATABASE,
411 'Failed to update reaction role channel. Please try again.',
412 { guildId, messageId, channelId, originalError: error.message }
413 );
414 }
415}
416
417export async function reconcileReactionRoleMessages(client, guildId = null) {
418 const summary = {

Callers

nothing calls this directly

Calls 5

createErrorFunction · 0.90
validateGuildIdFunction · 0.85
validateMessageIdFunction · 0.85
getReactionRoleMessageFunction · 0.85
setMethod · 0.45

Tested by

no test coverage detected