(client, guildId, channelId, options = {})
| 1429 | } |
| 1430 | |
| 1431 | export async function addJoinToCreateTrigger(client, guildId, channelId, options = {}) { |
| 1432 | try { |
| 1433 | const config = await getJoinToCreateConfig(client, guildId); |
| 1434 | |
| 1435 | if (config.triggerChannels.includes(channelId)) { |
| 1436 | return false; |
| 1437 | } |
| 1438 | |
| 1439 | config.triggerChannels.push(channelId); |
| 1440 | config.enabled = config.triggerChannels.length > 0; |
| 1441 | |
| 1442 | if (Object.keys(options).length > 0) { |
| 1443 | if (!config.channelOptions) { |
| 1444 | config.channelOptions = {}; |
| 1445 | } |
| 1446 | config.channelOptions[channelId] = { |
| 1447 | nameTemplate: options.nameTemplate || config.channelNameTemplate, |
| 1448 | userLimit: options.userLimit || config.userLimit, |
| 1449 | bitrate: options.bitrate || config.bitrate |
| 1450 | }; |
| 1451 | } |
| 1452 | |
| 1453 | return await saveJoinToCreateConfig(client, guildId, config); |
| 1454 | } catch (error) { |
| 1455 | logger.error(`Error adding Join to Create trigger for guild ${guildId}:`, error); |
| 1456 | return false; |
| 1457 | } |
| 1458 | } |
| 1459 | |
| 1460 | export async function removeJoinToCreateTrigger(client, guildId, channelId) { |
| 1461 | try { |
no test coverage detected