(client, guildId, destination, channelId)
| 393 | } |
| 394 | |
| 395 | export async function setLogChannel(client, guildId, destination, channelId) { |
| 396 | if (!LOG_DESTINATIONS.includes(destination)) { |
| 397 | throw new Error(`Invalid log destination: ${destination}`); |
| 398 | } |
| 399 | |
| 400 | try { |
| 401 | const config = await getGuildConfig(client, guildId); |
| 402 | const logging = { |
| 403 | ...config.logging, |
| 404 | channels: { ...(config.logging?.channels || {}), [destination]: channelId }, |
| 405 | }; |
| 406 | |
| 407 | if (channelId) { |
| 408 | logging.enabled = true; |
| 409 | } |
| 410 | |
| 411 | await updateGuildConfig(client, guildId, { logging }); |
| 412 | return true; |
| 413 | } catch (error) { |
| 414 | logger.error('Error setting log channel:', error); |
| 415 | return false; |
| 416 | } |
| 417 | } |
| 418 | |
| 419 | /** @deprecated Use setLogChannel(client, guildId, 'audit', channelId) */ |
| 420 | export async function setLoggingChannel(client, guildId, channelId) { |
no test coverage detected