Skip to content
This repository has been archived by the owner on Jun 13, 2019. It is now read-only.

Commit

Permalink
Add basic files
Browse files Browse the repository at this point in the history
  • Loading branch information
lepon01 committed Jul 31, 2018
1 parent 1bd3197 commit 20f47b3
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,6 @@ typings/

# next.js build output
.next

# configuration
config.json
File renamed without changes.
45 changes: 45 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
const Eris = require('eris');
const fs = require('fs');
const path = require('path');
const child_process = require('child_process');

const config = require('./config.json');

const client = new Eris.Client(config.token);

// If forkdata doesn't exist, clone
if (!fs.existsSync(path.join(__dirname, 'forkdata'))) {

}

client.on('ready', () => {
console.log('Ready!');
});

client.on('messageCreate', (message) => {
if (message.channel.id !== '353911657665396736') return;
if (message.author.id === client.user.id) return;
try {
const inData = JSON.parse(message.content);

if (typeof inData === 'object') {
const outData = {};
const botCount = parseInt(inData.botCount) || 0;
if (botCount) outData.botCount = botCount;

const fileData = JSON.stringify(outData);

fs.writeFile(path.join(__dirname, 'forkdata', `${message.author.id}.json`), fileData, { encoding: 'utf8' }, (error) => {
if (error) {
message.channel.createMessage(`Error writing to file:\n${error.message}`);
} else {
message.channel.createMessage(`Successfully wrote to file:\n${fileData}`);
}
})
}
} catch (e) {
message.channel.createMessage(`Error encountered:\n${e.message}`);
}
});

client.connect();
43 changes: 43 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "discordforkappdata",
"version": "1.0.0",
"description": "Application data for Discord_Fork",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Terminal/DiscordForkAppdata.git"
},
"author": "",
"license": "MIT",
"bugs": {
"url": "https://github.com/Terminal/DiscordForkAppdata/issues"
},
"homepage": "https://github.com/Terminal/DiscordForkAppdata#readme",
"dependencies": {
"eris": "^0.8.6"
}
}

0 comments on commit 20f47b3

Please sign in to comment.