renaming directories and moving some code
This commit is contained in:
36
commands/system/new-chat.js
Normal file
36
commands/system/new-chat.js
Normal file
@ -0,0 +1,36 @@
|
||||
const { EmbedBuilder } = require('discord.js');
|
||||
var unirest = require('unirest');
|
||||
const jsonfile = require('jsonfile')
|
||||
|
||||
module.exports = {
|
||||
name: "create-session",
|
||||
description: "create a new session chat",
|
||||
private: true,
|
||||
run: async (client, interaction) => {
|
||||
const file = './cache/' + interaction.user.id
|
||||
|
||||
unirest
|
||||
.post(`https://${process.env.PUBLIC_URL}/api/chat`)
|
||||
.headers({ 'Accept': 'application/json', 'Content-Type': 'application/json' })
|
||||
.auth({
|
||||
user: process.env.USERNAME,
|
||||
pass: process.env.PASS,
|
||||
sendImmediately: true
|
||||
})
|
||||
.then((response) => {
|
||||
const obj = { id: response.body }
|
||||
|
||||
jsonfile.writeFile(file, obj, function (err) {
|
||||
if (err) console.error(err)
|
||||
})
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setColor("#FF0000")
|
||||
.setTitle("New Chat Session Started!")
|
||||
.setDescription(`New Chat Session ID: \n` + response.body)
|
||||
.setTimestamp()
|
||||
.setFooter({ text: `Requested by ${interaction.user.tag}`, iconURL: `${interaction.user.displayAvatarURL()}` });
|
||||
interaction.followUp({ embeds: [embed] });
|
||||
})
|
||||
},
|
||||
};
|
Reference in New Issue
Block a user