├── examples ├── example.js └── discord.js ├── src ├── config.json ├── Events │ ├── WatchEvent.js │ ├── ForkEvent.js │ ├── PullRequestReviewEvent.js │ ├── IssueCommentEvent.js │ ├── PushEvent.js │ ├── IssuesEvent.js │ ├── DeleteEvent.js │ ├── CreateEvent.js │ └── PullRequestEvent.js ├── util.js └── index.js ├── package.json └── README.md /examples/example.js: -------------------------------------------------------------------------------- 1 | const Github = require("gitcord") 2 | const github = new Github("CTK-WARRIOR", { 3 | repositories: ["Discord-Bot-For-Starters", "canvas-senpai"] 4 | }) 5 | github.setup() 6 | 7 | github.on('newEvent', (json) => { 8 | console.log(json) 9 | }) -------------------------------------------------------------------------------- /src/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "TimeLimit": 60000, 3 | "Headers": { 4 | "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36", 5 | "content-type": "application/json; charset=utf-8", 6 | "accept-language": "en-US", 7 | "accept-encoding": "gzip" 8 | } 9 | } -------------------------------------------------------------------------------- /src/Events/WatchEvent.js: -------------------------------------------------------------------------------- 1 | module.exports = (json, {color="#161b22"}={}) => { 2 | return { 3 | color, 4 | author: { 5 | name: json.actor.login, 6 | icon_url: json.actor.avatar_url 7 | }, 8 | title: `[${json.repo.name}] New star added`, 9 | url: `https://github.com/${json.repo.name}`, 10 | footer: { text: "Github"}, 11 | timestamp: new Date() 12 | } 13 | } -------------------------------------------------------------------------------- /src/Events/ForkEvent.js: -------------------------------------------------------------------------------- 1 | module.exports = (json, { color = "BLUE" } = {}) => { 2 | return { 3 | color, 4 | author: { name: json.actor.login, icon_url: json.actor.avatar_url }, 5 | title: `[${json.repo.name}] Fork Created : ${json.payload.forkee.full_name}`, 6 | url: json.payload.forkee.html_url, 7 | footer: { text: "Github" }, 8 | timestamp: new Date() 9 | } 10 | } -------------------------------------------------------------------------------- /src/Events/PullRequestReviewEvent.js: -------------------------------------------------------------------------------- 1 | module.exports = (json, {color="#161b22"}={}) => { 2 | return { 3 | color, 4 | author: { 5 | name: json.actor.login, 6 | icon_url: json.actor.avatar_url 7 | }, 8 | title: `[${json.repo.name}] Pull request review submitted: #${json.payload.pull_request.number} ${json.payload.pull_request.title}`, 9 | url: json.payload.review.html_url, 10 | description: json.payload.review.body 11 | } 12 | } -------------------------------------------------------------------------------- /examples/discord.js: -------------------------------------------------------------------------------- 1 | const Github = require("gitcord") 2 | const Discord = require("discord.js") 3 | const client = new Discord.Client(); 4 | const github = new Github("CTK-WARRIOR", { repositories: ["GitCord"] }) 5 | github.setup() 6 | 7 | client.on("ready", () => { 8 | console.log("Connected to the discord, now ready for fight :D") 9 | }) 10 | 11 | github.on("newEvent", (embed) => { 12 | client.channels.cache.get("CHANNEL ID").send({embed}) 13 | }) 14 | 15 | client.login("TOKEN") -------------------------------------------------------------------------------- /src/Events/IssueCommentEvent.js: -------------------------------------------------------------------------------- 1 | module.exports = (json, {color="#e68d60"}={}) => { 2 | return { 3 | color: json.payload.issue.pull_request ? "#bfe5bf" : "#e68d60", 4 | author: { name: json.actor.login, icon_url: json.actor.avatar_url }, 5 | title: `[${json.repo.name}] New comment on ${json.payload.issue.pull_request ? 'pull request' : 'issue'} #${json.payload.issue.number}: ${json.payload.issue.title}`, 6 | url: json.payload.comment.html_url, 7 | description: json.payload.comment.body 8 | } 9 | } 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/Events/PushEvent.js: -------------------------------------------------------------------------------- 1 | module.exports = (json, { color="blue" } = {}) => { 2 | return { 3 | color, 4 | author: { 5 | name: json.actor.login, 6 | icon_url: json.actor.avatar_url 7 | }, 8 | title: `[${json.repo.name}] ${json.payload.commits.length} New commit`, 9 | url: `https://github.com/${json.repo.name}/commit/${json.payload.head}`, 10 | description: json.payload.commits.map(x => `[\`${x.sha.substring(0, 7)}\`](https://github.com/${json.repo.name}/commit/${x.sha}) ${x.message} - ${x.author.name}`).join("\n"), 11 | footer: { text: "Github" }, 12 | timestamp: new Date() 13 | }; 14 | }; -------------------------------------------------------------------------------- /src/Events/IssuesEvent.js: -------------------------------------------------------------------------------- 1 | const colorObject = { closed: "RED", opened: "GREEN", reopened: "#161b22" } 2 | 3 | module.exports = (json, { color } = {}) => { 4 | return { 5 | color: color ? color : (colorObject[json.payload.action] ? colorObject[json.payload.action] : "GREEN"), 6 | author: { name: json.actor.login, icon_url: json.actor.avatar_url }, 7 | title: `[${json.repo.name}] Issue ${json.payload.action}: #${json.payload.issue.number} ${json.payload.issue.title}`, 8 | url: json.payload.issue.html_url, 9 | description: json.payload.action === "opened" ? json.payload.issue.body : null 10 | } 11 | } -------------------------------------------------------------------------------- /src/Events/DeleteEvent.js: -------------------------------------------------------------------------------- 1 | module.exports = (json, { color = "RED" } = {}) => { 2 | const obj = { 3 | color, 4 | author: { name: json.actor.login, icon_url: json.actor.avatar_url }, 5 | title: ["branch", "tag"].includes(json.payload.ref_type) ? `[${json.repo.name}] ${json.payload.ref_type} deleted: ${json.payload.ref}` : json.payload.ref_type === "repository" ? `[${json.repo.name}] repository deleted` : `[${json.repo.name}] something deleted`, 6 | url: `https://github.com/${json.repo.name}`, 7 | description: json.payload.description, 8 | footer: { text: "Github" }, 9 | timestamp: new Date() 10 | }; 11 | 12 | 13 | return obj; 14 | }; -------------------------------------------------------------------------------- /src/Events/CreateEvent.js: -------------------------------------------------------------------------------- 1 | module.exports = (json, { color="GREEN" } = {}) => { 2 | const obj = { 3 | color, 4 | author: { name: json.actor.login, icon_url: json.actor.avatar_url }, 5 | title: ["branch", "tag"].includes(json.payload.ref_type) ? `[${json.repo.name}] new ${json.payload.ref_type} created: ${json.payload.ref}` : json.payload.ref_type === "repository" ? `[${json.repo.name}] new repository created` : `[${json.repo.name}] something created`, 6 | url: `https://github.com/${json.repo.name}`, 7 | description: json.payload.description, 8 | footer: { text: "Github" }, 9 | timestamp: new Date() 10 | }; 11 | 12 | return obj; 13 | }; -------------------------------------------------------------------------------- /src/Events/PullRequestEvent.js: -------------------------------------------------------------------------------- 1 | const colorObject = { closed: "RED", opened: "GREEN", reopened: "#161b22" } 2 | 3 | module.exports = (json, { color } = {}) => { 4 | return { 5 | color: color ? color : (colorObject[json.payload.action] ? colorObject[json.payload.action] : "GREEN"), 6 | author: { name: json.actor.login, icon_url: json.actor.avatar_url }, 7 | title: `[${json.repo.name}] Pull request ${json.payload.action} #${json.payload.pull_request.number}: ${json.payload.pull_request.title}`, 8 | url: json.payload.pull_request.html_url, 9 | description: json.payload.action.includes("opened") ? json.payload.pull_request.body : null 10 | } 11 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gitcord", 3 | "version": "1.0.3", 4 | "description": "GitCord allows you to send the github feeds at your discord server without having any issue.", 5 | "main": "src/index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git+https://github.com/CTK-WARRIOR/GitCord.git" 12 | }, 13 | "bugs": { 14 | "url": "https://github.com/CTK-WARRIOR/GitCord/issues" 15 | }, 16 | "keywords": [ 17 | "Github", 18 | "github-notifier", 19 | "githubfeed", 20 | "GitCord", 21 | "discord-github" 22 | ], 23 | "author": "ctk", 24 | "license": "ISC", 25 | "dependencies": { 26 | "axios": "^0.21.1" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GitCord 2 |
