Skip to content

Commit 4ed3284

Browse files
committed
can log in now but commands do not work
the async function were not doing anything, it also made the code hard to read and overall unpleasant. So I removed it :)
1 parent 7a92e82 commit 4ed3284

4 files changed

Lines changed: 10 additions & 31 deletions

File tree

index.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ console.log(`server invite link: https://discord.com/oauth2/authorize?client_id=
2525

2626
// Create a new client instance
2727
const client = new Client({
28-
intents: [
29-
GatewayIntentBits.Guilds,
30-
GatewayIntentBits.GuildMessages,
31-
GatewayIntentBits.GuildMembers,
32-
GatewayIntentBits.GuildMessageReactions,
33-
GatewayIntentBits.MessageContent
34-
]
28+
intents: [
29+
GatewayIntentBits.Guilds,
30+
GatewayIntentBits.GuildMessages,
31+
GatewayIntentBits.GuildMembers,
32+
GatewayIntentBits.GuildMessageReactions,
33+
GatewayIntentBits.MessageContent
34+
]
3535
});
3636

3737
client.commands = new Collection();

source/database/database.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,8 @@ const process = require('node:process');
44

55
const sequelize = setupDatabase();
66

7-
sequelize.sync().then(() => {
8-
logger.info('sequelize synced');
9-
}).catch(() => {
10-
logger.fatal('sequelize instance could not be synced');
11-
process.exit();
12-
});
13-
147
const User = sequelize.models.User;
158
const Guild = sequelize.models.Guild;
169
const Score = sequelize.models.Score;
1710

18-
(async () => {
19-
const scores = await Score.findAll({});
20-
if (!scores.length) logger.warn('database is empty');
21-
})();
22-
2311
module.exports = { User, Guild, Score }

source/database/setupDatabase.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const env = process.env.NODE_ENV || 'development';
66
const { logger } = require('../logger.js');
77
const config = require('./config.js')[env];
88

9-
async function setupDatabase() {
9+
function setupDatabase() {
1010
logger.info(`Setting up ${env} Database`);
1111
// defaults to the devleopment database
1212
const sequelize = new Sequelize(
@@ -26,15 +26,7 @@ async function setupDatabase() {
2626
Score.belongsTo(User);
2727
Guild.hasMany(Score);
2828
Score.belongsTo(Guild);
29-
30-
// testing environment needs to be renewed each time the database is initalized as opposed to a
31-
// production environment.
32-
if (env == "test") {
33-
await sequelize.sync({force: true});
34-
} else {
35-
await sequelize.sync();
36-
}
37-
29+
3830
return sequelize;
3931
};
4032

source/events/ready.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
const { Events, ActivityType } = require('discord.js');
22
const { logger } = require('../logger')
33

4-
// runs when the bot is logged into discord.
54
module.exports = {
65
name:Events.ClientReady,
76
once: true,
87
execute(client) {
98
logger.info(`Logged in as ${client.user.tag}`);
109
client.user.setActivity('https://youtu.be/q2FYfDpEpGc', { type: ActivityType.Watching });
1110
}
12-
};
11+
};

0 commit comments

Comments
 (0)