mirror of
https://github.com/NekoMonci12/RakunNakun-AI.git
synced 2025-12-19 14:59:15 +00:00
implement "/setpersona"
This commit is contained in:
40
index.js
40
index.js
@@ -65,6 +65,15 @@ const pastebin = new PastebinClient(process.env.PASTEBIN_DEV_KEY);
|
||||
new SlashCommandBuilder()
|
||||
.setName('invite')
|
||||
.setDescription('Invite RakunNakun Into Your Server!'),
|
||||
|
||||
new SlashCommandBuilder()
|
||||
.setName('setpersona')
|
||||
.setDescription('Change the persona for your server.')
|
||||
.addStringOption(option =>
|
||||
option.setName('persona')
|
||||
.setDescription('The new persona text')
|
||||
.setRequired(true)
|
||||
),
|
||||
].map(c => c.toJSON());
|
||||
|
||||
await new CommandDeployer(commands, process.env.CLIENT_ID, process.env.DISCORD_TOKEN).deploy();
|
||||
@@ -122,7 +131,7 @@ const pastebin = new PastebinClient(process.env.PASTEBIN_DEV_KEY);
|
||||
const { commandName, guildId, user, options } = interaction;
|
||||
|
||||
// Only run permission check for certain commands
|
||||
const commandsRequiringOwnership = ['generate-api', 'list-api', 'delete-api'];
|
||||
const commandsRequiringOwnership = ['generate-api', 'list-api', 'delete-api', 'setpersona'];
|
||||
if (commandsRequiringOwnership.includes(commandName)) {
|
||||
const [guildRows] = await db.pool.query(
|
||||
'SELECT GUILD_OWNER_ID FROM Guilds WHERE GUILD_ID = ?',
|
||||
@@ -226,6 +235,35 @@ const pastebin = new PastebinClient(process.env.PASTEBIN_DEV_KEY);
|
||||
ephemeral: true
|
||||
});
|
||||
}
|
||||
|
||||
// Handle /setpersona
|
||||
else if (commandName === 'setpersona') {
|
||||
const persona = options.getString('persona');
|
||||
|
||||
try {
|
||||
// Defer reply (to avoid timeout)
|
||||
if (!interaction.deferred && !interaction.replied) {
|
||||
await interaction.deferReply({ ephemeral: true });
|
||||
}
|
||||
|
||||
// Update the persona in database
|
||||
await db.pool.query(
|
||||
'UPDATE Guilds SET CHAT_PERSONA = ? WHERE GUILD_ID = ?',
|
||||
[persona, guildId]
|
||||
);
|
||||
|
||||
logInfo(`Updated persona for guild ${guildId} to: ${persona}`);
|
||||
|
||||
await interaction.editReply({
|
||||
content: `✅ Persona updated successfully to:\n\`\`\`\n${persona}\n\`\`\``,
|
||||
});
|
||||
} catch (err) {
|
||||
logError('Error while setting persona:', err);
|
||||
await interaction.editReply({
|
||||
content: `❌ Failed to update persona. Please try again later.`,
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
client.login(process.env.DISCORD_TOKEN);
|
||||
|
||||
Reference in New Issue
Block a user