Skip to content

Commit

Permalink
feat: initial sqlite3 implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperchupuDev committed Aug 27, 2021
1 parent f02fe56 commit 6b8a349
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/.github
/node_modules
database.sqlite3

# General
.DS_Store
Expand Down
8 changes: 5 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { Client } = require('discord.js');
const Database = require('better-sqlite3');
const client = new Client({
intents: ['GUILDS', 'GUILD_MESSAGES', 'GUILD_MESSAGE_REACTIONS', 'GUILD_MEMBERS'],
partials: ['MESSAGE', 'REACTION', 'USER', 'GUILD_MEMBER'],
Expand All @@ -9,12 +10,12 @@ const client = new Client({
}
});

const { readdirSync } = require('fs');
client.db = new Database('database.sqlite3', { fileMustExist: true, verbose: console.log });

client.config = require('./config.json');
client.prefix = client.config.prefix;


const { readdirSync } = require('fs');
const loaders = readdirSync('./loaders').filter(file => file.endsWith('.js'));

loaders.forEach(file => {
Expand All @@ -23,4 +24,5 @@ loaders.forEach(file => {


process.on('unhandledRejection', console.error);
client.login(process.env.DISCORD_TOKEN);
process.on('exit', client.db.close);
client.login(client.config.token);
14 changes: 8 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,26 @@
"description": "A bot to remove and protect you from the letter G.",
"main": "index.js",
"scripts": {
"lint": "eslint",
"start": "node index.js"
},
"repository": {
"url": "https://github.com/h-projects/gasbot"
},
"keywords": [],
"author": "Aytch Software",
"license": "MIT",
"dependencies": {
"better-sqlite3": "^7.4.3",
"bufferutil": "^4.0.3",
"discord.js": "^13.1.0",
"utf-8-validate": "^5.0.5",
"zlib-sync": "^0.1.7"
},
"engines": {
"node": "16.7.0"
},
"repository": {
"url": "https://github.com/h-projects/gasbot"
},
"devDependencies": {
"eslint": "^7.32.0"
},
"engines": {
"node": "16.7.0"
}
}

0 comments on commit 6b8a349

Please sign in to comment.