Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix AI ToS spam #842

Merged
merged 1 commit into from
Aug 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading