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

Function transferChannelOwnership

src/events/voiceStateUpdate.js:254–285  ·  view source on GitHub ↗
(client, channel, guildId, newOwnerId)

Source from the content-addressed store, hash-verified

252 }
253
254 async function transferChannelOwnership(client, channel, guildId, newOwnerId) {
255 try {
256 const config = await getJoinToCreateConfig(client, guildId);
257 const tempChannelInfo = config.temporaryChannels[channel.id];
258
259 if (!tempChannelInfo) return;
260
261 config.temporaryChannels[channel.id].ownerId = newOwnerId;
262 await client.db.set(`guild:${guildId}:jointocreate`, config);
263
264 const newOwner = await channel.guild.members.fetch(newOwnerId);
265 if (newOwner) {
266 const channelOptions = config.channelOptions?.[tempChannelInfo.triggerChannelId] || {};
267 const nameTemplate = channelOptions.nameTemplate || config.channelNameTemplate;
268
269 const newChannelName = sanitizeVoiceChannelName(formatChannelName(nameTemplate, {
270 username: newOwner.user.username,
271 userTag: newOwner.user.tag,
272 displayName: newOwner.displayName,
273 guildName: channel.guild.name,
274 channelName: channel.guild.channels.cache.get(tempChannelInfo.triggerChannelId)?.name || 'Voice Channel'
275 }));
276
277 await channel.setName(newChannelName);
278 }
279
280 logger.info(`Transferred ownership of temporary channel ${channel.id} to user ${newOwnerId}`);
281
282 } catch (error) {
283 logger.error(`Failed to transfer ownership of channel ${channel.id}:`, error);
284 }
285 }
286 }
287};
288

Callers 2

handleVoiceLeaveFunction · 0.85
handleVoiceMoveFunction · 0.85

Calls 5

getJoinToCreateConfigFunction · 0.90
formatChannelNameFunction · 0.90
sanitizeVoiceChannelNameFunction · 0.85
setMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected