Skip to content

Commit

Permalink
Update AI linking
Browse files Browse the repository at this point in the history
LunaUrsa committed Dec 20, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent ab4fe24 commit 71ee670
Showing 1 changed file with 25 additions and 20 deletions.
45 changes: 25 additions & 20 deletions src/discord/commands/global/d.ai.ts
Original file line number Diff line number Diff line change
@@ -1096,6 +1096,7 @@ async function link(
interaction: ChatInputCommandInteraction,
): Promise<void> {
const visible = interaction.options.getBoolean('ephemeral') !== false;
if (!interaction.guild) return;
await interaction.deferReply({ ephemeral: !visible });

const personaName = interaction.options.getString('name') ?? 'tripbot';
@@ -1139,38 +1140,42 @@ async function link(
},
});

if (aiLinkData) {
await db.ai_channels.update({
where: {
id: aiLinkData.id,
},
data: {
const verb = aiLinkData ? 'updated' : 'created';

await db.ai_channels.upsert({
where: {
channel_id_persona_id: {
channel_id: textChannel.id,
persona_id: personaData.id,
},
});
await interaction.editReply({
embeds: [embedTemplate()
.setTitle('Modal')
.setColor(Colors.Red)
.setDescription(`Success: The link between ${personaName} and <#${textChannel.id}> was updated!`)],

});
return;
}

await db.ai_channels.create({
data: {
},
create: {
channel_id: textChannel.id,
persona_id: personaData.id,
},
update: {
channel_id: textChannel.id,
persona_id: personaData.id,
},
});

await interaction.editReply({
embeds: [embedTemplate()
.setTitle('Modal')
.setColor(Colors.Red)
.setDescription(`Success: The link between ${personaName} and <#${textChannel.id}> was ${verb}!`)],
});

await interaction.editReply({
embeds: [embedTemplate()
.setTitle('Modal')
.setColor(Colors.Red)
.setDescription(`Success: The link between ${personaName} and <#${textChannel.id}> was created!`)],
.setDescription(`Success: The link between ${personaName} and <#${textChannel.id}> was ${verb}!`)],
});

const channelAiLog = await discordClient.channels.fetch(env.CHANNEL_AILOG) as TextChannel;
await channelAiLog.send({
content: `New AI link between ${personaName} and <#${textChannel.id}> on the ${interaction.guild.name} server ${interaction.member} (<@${env.DISCORD_OWNER_ID}>)`,

Check warning on line 1178 in src/discord/commands/global/d.ai.ts

GitHub Actions / Lint

This line has a length of 168. Maximum allowed is 120
});
return;
}

0 comments on commit 71ee670

Please sign in to comment.