(interaction, client, messageId, voteType)
| 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 | }; |
nothing calls this directly
no test coverage detected