Skip to content

Commit

Permalink
fix(ai): tos spam
Browse files Browse the repository at this point in the history
  • Loading branch information
theimperious1 committed Aug 25, 2024
1 parent 96b167a commit 770c95b
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/discord/commands/global/d.ai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1712,14 +1712,14 @@ async function agreeToTerms(
embeds: [embedTemplate()
.setTitle('🤖 Welcome to TripBot\'s AI Module! 🤖')
.setDescription(`
Please agree to the following. Use \`/ai help\` for more more information.
Please agree to the following. Use \`/ai help\` for more information.
${termsOfService}
`)
.setFooter(null)],
components: [
new ActionRowBuilder<ButtonBuilder>().addComponents(
buttonAiAgree.setCustomId(`AI~messageAgree~${messageData.id}`),
buttonAiAgree.setCustomId(`AI~messageAgree~${messageData.author.id}`),
),
],
};
Expand Down Expand Up @@ -2397,11 +2397,12 @@ export async function aiButton(
):Promise<void> {
const buttonID = interaction.customId;
log.debug(F, `buttonID: ${buttonID}`);
const [, buttonAction] = buttonID.split('~') as [
const [, buttonAction, messageAuthorId] = buttonID.split('~') as [
null,
'help' | 'personas' | 'setup' | 'agree' | 'privacy' |
'link' | 'unlink' | 'messageAgree' | 'modify' | 'new' |
'create' | 'delete' | 'deleteConfirm' | 'deleteHistory' | 'deleteHistoryConfirm'];
'create' | 'delete' | 'deleteConfirm' | 'deleteHistory' | 'deleteHistoryConfirm',
string];

// eslint-disable-next-line sonarjs/no-small-switch
switch (buttonAction) {
Expand All @@ -2427,6 +2428,12 @@ export async function aiButton(
},
});

// const messageData = await interaction.message.fetchReference();

if (messageAuthorId !== interaction.user.id) {
log.debug(F, `${interaction.user.displayName} tried to accept the AI ToS using someone else's instance of the ToS.`);
return;
}
await aiMessage(interaction.message);
break;
}
Expand Down

0 comments on commit 770c95b

Please sign in to comment.