Repository navigation
Expand file tree
/
Copy pathpersonality.js
More file actions
62 lines (53 loc) · 2.03 KB
/
Copy pathpersonality.js
File metadata and controls
62 lines (53 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import { SlashCommandBuilder } from "discord.js";
import { readFileSync } from "fs";
import { interactionReply } from "ewilib";
import { slashCommandsInit } from "./slash.js";
import { PERSONALITY } from "../classes/personality.js";
const command = new SlashCommandBuilder()
.setName(PERSONALITY.getPersonality().personality.name)
.setDescription(PERSONALITY.getPersonality().personality.description)
.setDefaultMemberPermissions(0x0000010000000000)
.addStringOption((option) =>
option
.setName(PERSONALITY.getPersonality().personality.stringOption.name)
.setDescription(
PERSONALITY.getPersonality().personality.stringOption.description,
)
.setRequired(false)
.addChoices(
...PERSONALITY.getPersonalities().map((pName) => {
return { name: pName, value: "personality_" + pName };
}),
),
);
const action = (interaction) => {
const perso = PERSONALITY.getPersonality().personality;
const nameList = PERSONALITY.getPersonalities(); // List of all personalities names
const option = interaction.options.getString(perso.stringOption.name);
if (option) {
//want to change personality
const foundP = nameList.find((name) => option.includes(name));
if (foundP) {
//open file
const path = "static/personalities/";
const newP = JSON.parse(readFileSync(path + foundP + ".json"));
PERSONALITY.setPersonality(newP.name, newP[foundP]);
slashCommandsInit(interaction.guildId, interaction.client); //commands submit to API
interactionReply(interaction, perso.changed + newP.name);
} else interactionReply(interaction, perso.nameError);
} else {
//ant to get current personality name
const content = perso.currentName + PERSONALITY.getName() + ".";
interactionReply(interaction, content);
}
};
const personality = {
command,
action,
help: (interaction) => {
const perso = PERSONALITY.getPersonality().personality;
interactionReply(interaction, perso.help);
},
admin: true,
};
export default personality;