From 9bc73d263035097169615c9448323dd9cff353cc Mon Sep 17 00:00:00 2001 From: baz Date: Sat, 30 Dec 2023 00:50:23 +0000 Subject: [PATCH] Update .env variable names --- .env.template | 6 +++--- dbObjects.js | 25 +++++++++++++++++++++++++ deploy-commands.js | 4 ++-- index.js | 2 +- 4 files changed, 31 insertions(+), 6 deletions(-) diff --git a/.env.template b/.env.template index ca0df38..787c457 100644 --- a/.env.template +++ b/.env.template @@ -1,6 +1,6 @@ -clientId= -guildId= -token= +discordClientId= +discordGuildId= +discordToken= igdbClientId= igdbClientSecret= igdbAccessToken= \ No newline at end of file diff --git a/dbObjects.js b/dbObjects.js index 7ddb568..58f148c 100644 --- a/dbObjects.js +++ b/dbObjects.js @@ -19,4 +19,29 @@ BeatenGames.belongsTo(Users); Games.hasMany(BeatenGames); BeatenGames.belongsTo(Games); +Reflect.defineProperty(Users.prototype, 'addUser', { + value: async function addUser(userData) { + const user = await Users.findOne({ + where: { user_id: userData.id }, + }); + + if (!user) { + return Users.create({ user_id: userData.discord_id, username: userData.username }); + } + }, +}); + +Reflect.defineProperty(Users.prototype, 'getUser', { + value: function getUser(userData) { + return Users.findAll({ + where: { user_id: userData.discord_id }, + }); + }, +}); + +sequelize.sync({ alter: true }) +.catch((err) => { + console.log(err); +}); + module.exports = { Users, Games, BeatenGames }; \ No newline at end of file diff --git a/deploy-commands.js b/deploy-commands.js index 524de57..e47d067 100644 --- a/deploy-commands.js +++ b/deploy-commands.js @@ -27,7 +27,7 @@ for (const folder of commandFolders) { } // Construct and prepare an instance of the REST module -const rest = new REST().setToken(process.env.token); +const rest = new REST().setToken(process.env.discordToken); // and deploy your commands! (async () => { @@ -36,7 +36,7 @@ const rest = new REST().setToken(process.env.token); // The put method is used to fully refresh all commands in the guild with the current set const data = await rest.put( - Routes.applicationGuildCommands(process.env.clientId, process.env.guildId), + Routes.applicationGuildCommands(process.env.discordClientId, process.env.discordGuildId), { body: commands }, ); diff --git a/index.js b/index.js index ae8ed4d..868d0fa 100644 --- a/index.js +++ b/index.js @@ -48,7 +48,7 @@ for (const file of eventFiles) { } } -client.login(process.env.token); +client.login(process.env.discordToken); client.once(Events.ClientReady, () => { console.log(`Logged in as ${client.user.tag}!`);