-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9be62a6
commit e077785
Showing
4 changed files
with
353 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "snot", | ||
"version": "1.0.0", | ||
"description": "Discord bot used to log and copy all text messages sent within the bot(s) eyes.", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"keywords": [ | ||
"rat", | ||
"copy", | ||
"discord", | ||
"bot" | ||
], | ||
"author": "Whit3Xlightning", | ||
"license": "ISC", | ||
"dependencies": { | ||
"@types/node": "^12.6.8", | ||
"discord.js": "^11.5.1", | ||
"node.js": "0.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import * as d from "discord.js"; | ||
import * as fs from "fs"; | ||
import * as p from "path"; | ||
|
||
const b: d.Client = new d.Client(); | ||
|
||
b.on("ready", () => { | ||
console.log("Connected to discord with token: " + process.argv[2].toString() + "."); | ||
b.user.setStatus('invisible'); | ||
fs.access(p.join(__dirname, "Guilds"), fs.constants.F_OK, (err) => { | ||
if (err) { | ||
console.log('Failed to find \"Guilds\" folder. Attemping to create.'); | ||
fs.mkdir(p.join(__dirname, "Guilds"), (err) => { | ||
if (err) throw err; | ||
}) | ||
console.log('\"Guilds\" folder created.'); | ||
} | ||
}); | ||
}); | ||
|
||
b.login(process.argv[2].toString()) | ||
|
||
b.on("message", async message => { | ||
fs.mkdir(p.join(__dirname, "Guilds", message.guild.name), (err) => { | ||
if (err && err.code != 'EEXIST') throw err; | ||
}) | ||
fs.mkdir(p.join(__dirname, "Guilds", message.guild.name, message.channel.parent.name), (err) => { | ||
if (err && err.code != 'EEXIST') throw err; | ||
}); | ||
fs.open(p.join(__dirname, "Guilds", message.guild.name, message.channel.parent.name, message.channel.name + ".txt"), 'a', (err, fd) => { | ||
if (err && err.code != "ENOENT") throw err; | ||
var am = "[ " + message.createdAt + " ] " + message.author.username + ": " + message.content | ||
if (message.attachments) { | ||
message.attachments.forEach(attachment => { | ||
am = am + " " + attachment.filename + "(" + attachment.url + ")" | ||
}); | ||
} | ||
fs.appendFile(fd, am + "\r\n", 'utf8', (err) => { | ||
fs.close(fd, (err) => { | ||
if (err) throw err; | ||
}); | ||
if (err) throw err; | ||
}); | ||
console.log("logged 1 message in "+p.join(__dirname, "Guilds", message.guild.name, message.channel.parent.name, message.channel.name + ".txt")) | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es6", | ||
"module": "commonjs", | ||
"outDir": "dist", | ||
"removeComments": true, | ||
"strict": false, | ||
"skipLibCheck": true, | ||
"strictNullChecks": true, | ||
"noImplicitThis": true, | ||
}, | ||
"include": [ | ||
"src" | ||
], | ||
"exclude": [ | ||
|
||
] | ||
} |