April/index.js

76 lines
1.9 KiB
JavaScript
Raw Normal View History

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');
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, {
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
const artists = sequelize.define('artists', {
name: Sequelize.STRING,//id
emoji: Sequelize.STRING,
});
client.database = {
sequelize: sequelize,
modlog: modlog,
blacklistdb: blacklistdb,
artists: artists,
};
blacklistdb.sync();
modlog.sync();
artists.sync();
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));
}
}
deploy_commands(client, true);
/*
2023-04-24 20:45:36 +02:00
true will refresh slash commands (SET endpoint)
false will delete them (SET endpoint with an empty array)
null will not change slash commands
*/
client.login(token);