2022-11-09 14:44:05 +01:00
|
|
|
const fs = require('fs');
|
|
|
|
const Sequelize = require('sequelize');
|
|
|
|
const { Client, GatewayIntentBits } = require("discord.js");
|
2022-11-11 22:19:06 +01:00
|
|
|
const { token, sequelizeCredentials } = require('./config.json');
|
2022-11-09 14:44:05 +01:00
|
|
|
const { deploy_commands } = require('./functions.js');
|
|
|
|
|
|
|
|
const client = new Client({
|
|
|
|
intents: [
|
|
|
|
GatewayIntentBits.Guilds,
|
|
|
|
GatewayIntentBits.GuildMembers,
|
|
|
|
GatewayIntentBits.GuildBans,
|
|
|
|
GatewayIntentBits.GuildMessages
|
|
|
|
]
|
|
|
|
});
|
|
|
|
|
2022-11-11 22:19:06 +01:00
|
|
|
const sequelize = new Sequelize('database', sequelizeCredentials.username, sequelizeCredentials.password, {
|
2022-11-09 14:44:05 +01:00
|
|
|
host: 'localhost',
|
|
|
|
dialect: 'sqlite',
|
|
|
|
logging: false,
|
|
|
|
storage: 'database.sqlite',
|
|
|
|
});
|
|
|
|
const blacklistdb = sequelize.define('blacklist', {
|
|
|
|
name: {//id
|
|
|
|
type: Sequelize.STRING,
|
|
|
|
unique: true,
|
|
|
|
},
|
|
|
|
username: Sequelize.STRING,
|
|
|
|
reason: Sequelize.TEXT,
|
|
|
|
timestamp: Sequelize.STRING,
|
|
|
|
moderatorid: Sequelize.STRING
|
|
|
|
});
|
|
|
|
|
|
|
|
const modlog = sequelize.define('sanctions', {
|
|
|
|
name: Sequelize.STRING,//id
|
|
|
|
username: Sequelize.STRING,
|
|
|
|
type: Sequelize.STRING,
|
|
|
|
reason: Sequelize.TEXT,
|
|
|
|
timestamp: Sequelize.STRING,
|
|
|
|
moderatorid: Sequelize.STRING
|
|
|
|
});
|
2022-11-09 15:13:03 +01:00
|
|
|
|
2022-11-11 21:05:55 +01:00
|
|
|
const artists = sequelize.define('artists', {
|
|
|
|
name: Sequelize.STRING,//id
|
|
|
|
emoji: Sequelize.STRING,
|
|
|
|
});
|
|
|
|
|
2022-11-09 14:44:05 +01:00
|
|
|
client.database = {
|
|
|
|
sequelize: sequelize,
|
|
|
|
modlog: modlog,
|
|
|
|
blacklistdb: blacklistdb,
|
2022-11-11 21:05:55 +01:00
|
|
|
artists: artists,
|
2022-11-09 14:44:05 +01:00
|
|
|
};
|
|
|
|
blacklistdb.sync();
|
|
|
|
modlog.sync();
|
2022-11-11 21:05:55 +01:00
|
|
|
artists.sync();
|
2022-11-09 14:44:05 +01:00
|
|
|
|
|
|
|
const eventFiles = fs.readdirSync('./events').filter(file => file.endsWith('.js'));
|
|
|
|
for (const file of eventFiles) {
|
|
|
|
const event = require(`./events/${file}`);
|
|
|
|
if (event.once) {
|
|
|
|
client.once(event.name, (...args) => event.execute(...args, client));
|
|
|
|
} else {
|
|
|
|
client.on(event.name, (...args) => event.execute(...args, client));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-24 20:38:45 +02:00
|
|
|
deploy_commands(client, true);
|
|
|
|
/*
|
|
|
|
true will refresh slash commands (SET endpoint)
|
|
|
|
false will delete them (SET endpoint with an empty array)
|
|
|
|
*/
|
2022-11-09 14:44:05 +01:00
|
|
|
|
|
|
|
|
2023-04-24 20:38:45 +02:00
|
|
|
client.login(token);
|