(client, guildId, messageId, channelId)
| 375 | } |
| 376 | |
| 377 | export 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 | |
| 417 | export async function reconcileReactionRoleMessages(client, guildId = null) { |
| 418 | const summary = { |
nothing calls this directly
no test coverage detected