Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
- const { Configuration, OpenAIApi } = require('openai');
- const configuration = new Configuration({
- apiKey: "Here your open ai key"})
- const openai = new OpenAIApi(configuration);
- module.exports = {
- data: new SlashCommandBuilder()
- .setName("windows95-key")
- .setDescription("Ask chatgpt a question")
- .setDMPermission(false),
- async execute(interaction) {
- await interaction.deferReply();
- const question = "Generate me 20 sets of strings in the form of xxxyy-OEM-NNNNNNN-zzzzz where xxx is day of year between 001 and 366 (for example, 192 = 10th of July) and yy is the year (for example, 94 = 1994). Your range is from the first date of 1995 to the last day of 2003. OEM must remain intact. The NNNNNNN segment consists of digits and must start with 2 zeroes. The rest of the numbers can be anything as long as their sum is divisible with no remainder. The last segment zzzzz should consist of random numbers, z representing a number.";
- try {
- const res = await openai.createCompletion({
- model: 'text-davinci-003',
- max_tokens: 2048,
- temperature: 0.5,
- prompt: question
- })
- const embed = new EmbedBuilder()
- .setColor("Blue")
- .setTitle(`Windows95 keys`)
- .setDescription(`\`\`\`${res.data.choices[0].text}\`\`\``)
- await interaction.editReply({ embeds: [embed] });
- } catch(e) {
- return await interaction.editReply({ content: `Request failed with status code **${e.response.status}**`, ephemeral: true })
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment