MCPcopy
hub / github.com/LAION-AI/Open-Assistant / execute

Function execute

discord-bots/oa-bot-js/src/interactions/vote.ts:15โ€“68  ยท  view source on GitHub โ†—
(interaction, client, messageId, voteType)

Source from the content-addressed store, hash-verified

13 description: "Vote buttons for the assistant messages.",
14 },
15 async execute(interaction, client, messageId, voteType) {
16 let chatId = await redis.get(`chat_${interaction.user.id}`);
17 if (!chatId)
18 return interaction.reply({
19 content: "You don't have an active chat.",
20 ephemeral: true,
21 });
22 await interaction.deferUpdate();
23 var row;
24 const OA = await createInferenceClient(
25 interaction.user.username,
26 interaction.user.id
27 );
28 let score = 0;
29 if (voteType == "up") {
30 score = 1;
31 row = new ActionRowBuilder().addComponents(
32 new ButtonBuilder()
33 .setStyle(ButtonStyle.Primary)
34 .setLabel(`๐Ÿ‘`)
35 .setDisabled(true)
36 .setCustomId(`vote__up`),
37 new ButtonBuilder()
38 .setStyle(ButtonStyle.Secondary)
39 .setLabel(`๐Ÿ‘Ž`)
40 .setDisabled(true)
41 .setCustomId(`vote__down`)
42 );
43 }
44 if (voteType == "down") {
45 row = new ActionRowBuilder().addComponents(
46 new ButtonBuilder()
47 .setStyle(ButtonStyle.Secondary)
48 .setLabel(`๐Ÿ‘`)
49 .setDisabled(true)
50 .setCustomId(`vote__up`),
51 new ButtonBuilder()
52 .setStyle(ButtonStyle.Primary)
53 .setLabel(`๐Ÿ‘Ž`)
54 .setDisabled(true)
55 .setCustomId(`vote__down`)
56 );
57 }
58 let vote = await OA.vote({
59 chat_id: chatId,
60 message_id: messageId,
61 score: score,
62 });
63 console.log(vote);
64
65 await interaction.editReply({
66 components: [row],
67 });
68 },
69};

Callers

nothing calls this directly

Calls 4

createInferenceClientFunction ยท 0.90
logMethod ยท 0.80
getMethod ยท 0.45
voteMethod ยท 0.45

Tested by

no test coverage detected