Compare commits
No commits in common. "91bffb65c7285f2b8e5dc74a58eab5a0e03296b6" and "1f504ae0c449b848f51c37f4739df88767539585" have entirely different histories.
91bffb65c7
...
1f504ae0c4
|
@ -1,5 +1,5 @@
|
||||||
const { SlashCommandBuilder } = require('discord.js');
|
const { SlashCommandBuilder } = require('discord.js');
|
||||||
const { checkUserRegistration } = require('../../databaseHelperFunctions.js');
|
const { Users } = require ('../../dbObjects.js');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
|
@ -10,8 +10,16 @@ module.exports = {
|
||||||
// interaction.user is the object representing the user who ran the command
|
// interaction.user is the object representing the user who ran the command
|
||||||
// interaction.member is the GuildMember object, which represents the user in the specific guild
|
// interaction.member is the GuildMember object, which represents the user in the specific guild
|
||||||
|
|
||||||
if (checkUserRegistration(interaction.user)) return interaction.reply(`User "${interaction.user.username}" is registered`);
|
const user = await Users.findOne({ where: { discord_id: interaction.user.id } })
|
||||||
|
.catch((err) => {
|
||||||
|
console.log(err);
|
||||||
|
});
|
||||||
|
if (user) return interaction.reply(`User "${interaction.user.username}" is already registered`);
|
||||||
|
|
||||||
return interaction.reply(`Issue checking registration with "${interaction.user.username}".`);
|
await Users.create({ discord_id: interaction.user.id, username: interaction.user.username })
|
||||||
|
.then(await interaction.reply(`${interaction.user.username} was manually registered.`))
|
||||||
|
.catch((err) => {
|
||||||
|
console.log(err);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
};
|
};
|
|
@ -1,28 +0,0 @@
|
||||||
const { SlashCommandBuilder } = require('discord.js');
|
|
||||||
const { Users } = require ('./dbObjects.js');
|
|
||||||
|
|
||||||
async function checkUserRegistration(user) {
|
|
||||||
|
|
||||||
let u = await Users.findOne({ where: { discord_id: user.id } })
|
|
||||||
.catch((err) => {
|
|
||||||
console.log(err);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (u) return true;
|
|
||||||
|
|
||||||
await Users.create({ discord_id: user.id, username: user.username })
|
|
||||||
.then((data) => {
|
|
||||||
u = data;
|
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
console.log(err);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (u) return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
checkUserRegistration,
|
|
||||||
};
|
|
|
@ -14,6 +14,7 @@ require('./models/beatenGames.js')(sequelize, Sequelize.DataTypes);
|
||||||
const force = process.argv.includes('--force') || process.argv.includes('-f');
|
const force = process.argv.includes('--force') || process.argv.includes('-f');
|
||||||
|
|
||||||
sequelize.sync({ force }).then(async () => {
|
sequelize.sync({ force }).then(async () => {
|
||||||
|
// await Promise.all();
|
||||||
console.log('Database synced');
|
console.log('Database synced');
|
||||||
sequelize.close();
|
sequelize.close();
|
||||||
}).catch(console.error);
|
}).catch(console.error);
|
||||||
|
|
Loading…
Reference in New Issue