swapped to a new db locally hosted
This commit is contained in:
@@ -28,22 +28,21 @@ module.exports = {
|
||||
|
||||
const invite = await targetChannel.createInvite({ maxAge, maxUses, temporary, unique: true });
|
||||
|
||||
const db = readDb();
|
||||
if (!db[interaction.guildId]) db[interaction.guildId] = {};
|
||||
if (!db[interaction.guildId].invites) db[interaction.guildId].invites = [];
|
||||
|
||||
const api = require('../api');
|
||||
const item = {
|
||||
code: invite.code,
|
||||
url: invite.url,
|
||||
channelId: targetChannel.id,
|
||||
createdAt: new Date().toISOString(),
|
||||
maxUses: invite.maxUses || maxUses || 0,
|
||||
maxAge: invite.maxAge || maxAge || 0,
|
||||
channel_id: targetChannel.id,
|
||||
created_at: new Date().toISOString(),
|
||||
max_uses: invite.maxUses || maxUses || 0,
|
||||
max_age: invite.maxAge || maxAge || 0,
|
||||
temporary: !!invite.temporary,
|
||||
};
|
||||
|
||||
db[interaction.guildId].invites.push(item);
|
||||
writeDb(db);
|
||||
try {
|
||||
await api.addInvite(interaction.guildId, { channelId: targetChannel.id, maxAge, maxUses, temporary });
|
||||
} catch (e) {
|
||||
console.error('Error saving invite to backend:', e);
|
||||
}
|
||||
|
||||
await interaction.reply({ content: `Invite created: ${invite.url}`, ephemeral: true });
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user