This repository has been archived by the owner on Mar 27, 2021. It is now read-only.
forked from zekro-archive/tutorialJSBot
-
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
ゼクロ
committed
Dec 21, 2017
0 parents
commit ed28e8d
Showing
10 changed files
with
282 additions
and
0 deletions.
There are no files selected for viewing
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,2 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto |
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,59 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# Typescript v1 declaration files | ||
typings/ | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variables file | ||
.env | ||
|
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,14 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "node", | ||
"request": "launch", | ||
"name": "Launch Program", | ||
"program": "${workspaceFolder}\\main.js" | ||
} | ||
] | ||
} |
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 @@ | ||
# tutorialJSBot |
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,5 @@ | ||
{ | ||
"token": "DISCORD BOT TOKEN", | ||
"owner": "221905671296253953", | ||
"prefix": "::" | ||
} |
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,5 @@ | ||
{ | ||
"token": "MzI4NTc5NjU2MzIyMjUyODAx.DQ7s9A.XxStY0q1_HWbhPfyqwI-tCqreZE", | ||
"owner": "221905671296253953", | ||
"prefix": "::" | ||
} |
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,50 @@ | ||
const { RichEmbed } = require('discord.js') | ||
|
||
const COLORS = { | ||
red: 0xe74c3c, | ||
green: 0x2ecc71 | ||
} | ||
|
||
exports.test = "test" | ||
|
||
module.exports = { | ||
|
||
/** | ||
* Send an error embed message into a channel | ||
* @param {Discord.Channel} chan Channel where mesage is send to | ||
* @param {string} cont | ||
* @param {string} title | ||
*/ | ||
error(chan, cont, title) { | ||
var message | ||
var emb = new RichEmbed() | ||
.setColor(COLORS.red) | ||
.setDescription(cont) | ||
if (title) { | ||
emb.setTitle(title) | ||
} | ||
chan.send('', emb).then((m) => { | ||
message = m | ||
}) | ||
return message | ||
}, | ||
|
||
info(chan, cont, title) { | ||
var emb = { | ||
embed: { | ||
color: COLORS.green, | ||
description: cont, | ||
title: title, | ||
fields: [ | ||
{ | ||
name: "test", | ||
value: "test", | ||
inline: false | ||
} | ||
] | ||
} | ||
} | ||
chan.send('', emb) | ||
} | ||
|
||
} |
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,66 @@ | ||
const Discord = require('discord.js') | ||
const fs = require('fs') | ||
const Embeds = require('./embed') | ||
|
||
const config = JSON.parse(fs.readFileSync('config.json', 'utf8')) | ||
|
||
var client = new Discord.Client() | ||
|
||
|
||
const AUTOROLEID = "289905364055621634" | ||
|
||
|
||
client.on('ready', () => { | ||
console.log(`Logged in as ${client.user.username}...`) | ||
}) | ||
|
||
|
||
var cmdmap = { | ||
say: cmd_say, | ||
test: cmd_test | ||
} | ||
|
||
function cmd_say(msg, args) { | ||
msg.channel.send(args.join(' ')) | ||
} | ||
|
||
function cmd_test(msg, args) { | ||
//Embeds.error(msg.channel, 'This is actuially not an error', 'Not an error') | ||
Embeds.info(msg.channel, "this is a content lel") | ||
} | ||
|
||
|
||
client.on('message', (msg) => { | ||
|
||
var cont = msg.content, | ||
author = msg.member, | ||
chan = msg.channel, | ||
guild = msg.guild | ||
|
||
if (author.id != client.user.id && cont.startsWith(config.prefix)) { | ||
|
||
// ::say hello world! | ||
var invoke = cont.split(' ')[0].substr(config.prefix.length), | ||
args = cont.split(' ').slice(1) | ||
|
||
if (invoke in cmdmap) { | ||
cmdmap[invoke](msg, args) | ||
} | ||
} | ||
|
||
}) | ||
|
||
|
||
client.on('guildMemberAdd', (memb) => { | ||
var guild = memb.guild | ||
|
||
var role = guild.roles.find(r => r.id == AUTOROLEID) | ||
if (role) { | ||
memb.addRole(role) | ||
memb.send("", Discord.RichEmbed().setDescription(`Hey! YOu got automatically assigned the role <@&${AUTOROLEID}>!`)) | ||
} | ||
|
||
}) | ||
|
||
|
||
client.login(config.token) |
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,15 @@ | ||
{ | ||
"name": "tutorialjsbot", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "main.js", | ||
"scripts": { | ||
"test": "node main.js debug", | ||
"start": "node main.js" | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"discord.js": "" | ||
} | ||
} |