diff --git a/bot.js b/bot.js index f07f079..16fff46 100644 --- a/bot.js +++ b/bot.js @@ -14,12 +14,143 @@ const { botToken } = require("./config.json") bot.login(botToken) module.exports = bot +const oauth = require("./util/oauth.js") const pool = require("./util/setupDB.js") +const registerSlashcommands = () => { + bot.application.commands.set([{ + name: "hook", + type: Discord.ApplicationCommandType.ChatInput, + description: "Create and edit GitHub event webhooks", + defaultMemberPermissions: ["ManageGuild"], + dmPermission: false, + options: [{ + name: "create", + type: Discord.ApplicationCommandOptionType.Subcommand, + description: "Create a new webhook", + options: [{ + name: "name", + type: Discord.ApplicationCommandOptionType.String, + description: "The name of the webhook", + maxLength: 32, + required: true + },{ + name: "events", + type: Discord.ApplicationCommandOptionType.String, + description: "Events to trigger the webhook, separated by commas", + maxLength: 220 + },{ + name: "actions", + type: Discord.ApplicationCommandOptionType.String, + description: "Actions (of events) to trigger the webhook, separated by commas", + maxLength: 220 + }] + },{ + name: "edit-message", + type: Discord.ApplicationCommandOptionType.Subcommand, + description: "Edit the message sent on an event", + options: [{ + name: "hook", + type: Discord.ApplicationCommandOptionType.String, + description: "The webhook to edit", + autocomplete: true, + required: true + }] + },{ + name: "delete", + type: Discord.ApplicationCommandOptionType.Subcommand, + description: "Delete a webhook", + options: [{ + name: "hook", + type: Discord.ApplicationCommandOptionType.String, + description: "The webhook to delete", + autocomplete: true, + required: true + }] + }] + }]) +} + bot.on("ready", () => { - bot.user.setPresence({activities: [{name: "Custom Status", state: "Customizable GitHub hooks!", type: Discord.ActivityType.Custom}], status: "dnd"}) + bot.user.setPresence({activities: [{name: "Custom Status", state: "Customizable GitHub hooks!", type: Discord.ActivityType.Custom}], status: "online"}) + //registerSlashcommands() +}) + +bot.on("guildCreate", guild => { + const embed = new Discord.MessageEmbed() + .setColor(Discord.Colors.Green) + .setTitle(guild.name) + .setThumbnail(guild.iconURL()) + .addField("Member count", "" + guild.memberCount, true) + .addField("Owner", "<@" + guild.ownerId + ">", true) + bot.channels.cache.get("1169875077110693951").send({embeds: [embed]}) }) bot.on("guildDelete", guild => { pool.query("DELETE FROM `hook` WHERE `guild` = ?", [guild.id]) + + const embed = new Discord.MessageEmbed() + .setColor(Discord.Colors.Red) + .setTitle(guild.name) + .setThumbnail(guild.iconURL()) + .addField("Member count", "" + guild.memberCount, true) + .addField("Owner", "<@" + guild.ownerId + ">", true) + bot.channels.cache.get("1169875077110693951").send({embeds: [embed]}) +}) + +const channelOrWebhookRow = new Discord.ActionRowBuilder() + .addComponents( + new Discord.ChannelSelectMenuBuilder() + .setCustomId("setup_channel") + .setChannelTypes([Discord.ChannelType.GuildText, Discord.ChannelType.GuildAnnouncement, Discord.ChannelType.GuildVoice, Discord.ChannelType.GuildStageVoice, Discord.ChannelType.GuildForum]) + ) + +bot.on("interactionCreate", async interaction => { + if (interaction.type == Discord.InteractionType.ApplicationCommand) { + if (interaction.commandName == "hook") { + const subcommand = interaction.options.getSubcommand() + + if (subcommand == "create") { + const msg = await interaction.reply({ + content: "You're creating the webhook **" + Discord.escapeMarkdown(interaction.options.getString("name")) + "**.\n\nNow, choose the channel to send the messages to.\n**Tip**: Start typing and the channels matching your input will appear.", + components: [channelOrWebhookRow], + fetchReply: true, + ephemeral: true + }) + + msg.createMessageComponentCollector({componentType: Discord.ComponentType.ChannelSelect}).on("collect", async i => { + let id = oauth.generateToken(8) + while (true) { + const [rows] = await pool.query("SELECT * FROM `hook` WHERE `id` = ?", [id]) + if (rows.length == 0) break + id = oauth.generateToken(8) + } + + const secret = oauth.generateToken() + await pool.query( + "INSERT INTO `hook` (`id`, `name`, `server`, `webhook`, `channel`, `message`, `secret`, `filterEvent`, `filterAction`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", + [id, interaction.options.getString("name"), interaction.guild.id, null, i.values[0], null, secret, + interaction.options.getString("events") ? JSON.stringify(interaction.options.getString("events").split(",")) : null, + interaction.options.getString("actions") ? JSON.stringify(interaction.options.getString("actions").split(",")) : null] + ) + + i.reply({ + content: "Successfully created the hook!\n\nYou can now use it on GitHub to receive events in <#" + i.values[0] + ">.\n\n" + + "Full POST URL: `https://disgithook-api.tomatenkuchen.com/hook/" + id + "/" + secret + + "`\nMore secure POST URL with secret in header: `https://disgithook-api.tomatenkuchen.com/hook/" + id + "`\nSecret: `" + secret + "`", + ephemeral: true + }) + }) + } else if (subcommand == "delete") { + const [rows] = await pool.query("SELECT * FROM `hook` WHERE `id` = ? AND `server` = ?", [interaction.options.getString("hook"), interaction.guild.id]) + if (rows.length == 0) return interaction.reply({content: "The hook `" + interaction.options.getString("hook") + "` doesn't exist or doesn't belong to this server.", ephemeral: true}) + + await pool.query("DELETE FROM `hook` WHERE `id` = ?", [interaction.options.getString("hook")]) + interaction.reply({content: "Successfully deleted the hook **" + rows[0].name + "**.", ephemeral: true}) + } + } + } else if (interaction.type == Discord.InteractionType.ApplicationCommandAutocomplete) { + const [rows] = await pool.query("SELECT * FROM `hook` WHERE `server` = ?", [interaction.guild.id]) + interaction.respond(rows.slice(0, 25).map(hook => ({name: hook.name, value: hook.id}))) + } }) diff --git a/generate.js b/generate.js index 6b7335d..b63ce01 100644 --- a/generate.js +++ b/generate.js @@ -77,7 +77,8 @@ const path = require("node:path") Object.keys(events).forEach(event => { fs.writeFile(path.join(__dirname, "templates", event + ".js"), - events[event].length == 0 ? + "const color = require(\"../util/color.js\")\n\n" + + (events[event].length == 0 ? "module.exports = [\n" + "\t{\n" + "\t\tembeds: [{\n" + @@ -86,14 +87,14 @@ Object.keys(events).forEach(event => { "\t\t\t\ticon_url: \"{{ sender.avatar_url }}\"\n" + "\t\t\t},\n" + "\t\t\ttitle: \"`" + event + "`\",\n" + - "\t\t\tcolor: 0\n" + + "\t\t\tcolor: color(\"black\")\n" + "\t\t}]\n" + "\t}\n" + "]\n" : - "module.exports = [\n" + + "module.exports = [\n\t" + events[event].map(action => { - return "\t{\n" + + return "{\n" + "\t\taction: \"" + action + "\",\n" + "\t\tembeds: [{\n" + "\t\t\tauthor: {\n" + @@ -101,11 +102,11 @@ Object.keys(events).forEach(event => { "\t\t\t\ticon_url: \"{{ sender.avatar_url }}\"\n" + "\t\t\t},\n" + "\t\t\ttitle: \"`" + event + "` (`" + action + "`)\",\n" + - "\t\t\tcolor: 0\n" + + "\t\t\tcolor: color(\"" + (action == "created" || action == "resolved" || action == "approved" ? "green" : (action == "deleted" || action == "rejected" ? "red" : "black")) + "\")\n" + "\t\t}]\n" + "\t}" - }).join(",\n") + - "]\n", + }).join(",") + + "\n]\n"), e => { if (e) throw e } diff --git a/index.js b/index.js index e80f620..8849114 100644 --- a/index.js +++ b/index.js @@ -3,6 +3,7 @@ const bot = require("./bot.js") const { botId, botSecret, userAgent, domain, port, cookieSecret } = require("./config.json") +const path = require("node:path") const encode = s => s.replace(/&/g, "&").replace(//g, ">").replace(/"/g, """).replace(/'/g, "'") const oauth = require("./util/oauth.js") @@ -25,12 +26,12 @@ app.use((req, res, next) => { if (!req.headers["cf-connecting-ip"]) return res.status(400).send("Direct access is not allowed") const ip = "%" + req.headers["cf-connecting-ip"] - if (req.path.startsWith("/hook/")) return next() - if (ratelimit30s[ip] && ratelimit30s[ip] >= 30) return res.status(429).send("Too many requests in the last 30 seconds") if (ratelimit5m[ip] && ratelimit5m[ip] >= 130) return res.status(429).send("Too many requests in the last 5 minutes") if (ratelimitGlobal5m >= 800) return res.status(429).send("Too many requests in the last 5 minutes") + if (req.path.startsWith("/hook/")) return next() + if (ratelimit30s[ip]) ratelimit30s[ip]++ else ratelimit30s[ip] = 1 if (ratelimit5m[ip]) ratelimit5m[ip]++ @@ -107,8 +108,8 @@ app.post("/servers/:id/hooks", async (req, res) => { const secret = oauth.generateToken() await pool.query( - "INSERT INTO `hook` (`id`, `server`, `webhook`, `name`, `avatar`, `username`, `channel`, `message`, `secret`, `filterEvent`, `filterAction`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", - [id, req.params.id, req.body.webhook, req.body.name, req.body.avatar, req.body.username, req.body.channel, req.body.message, secret, req.body.filterEvent, req.body.filterAction] + "INSERT INTO `hook` (`id`, `name`, `server`, `webhook`, `channel`, `message`, `secret`, `filterEvent`, `filterAction`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", + [id, req.body.name, req.params.id, req.body.webhook, req.body.channel, req.body.message, secret, JSON.stringify(req.body.filterEvent), JSON.stringify(req.body.filterAction)] ) res.send({success: true, id, secret}) }) @@ -127,8 +128,8 @@ app.post("/servers/:id/hooks/:hook", async (req, res) => { if (hook.server != req.params.id) return res.status(401).send({success: false, error: "Invalid server ID"}) await pool.query( - "UPDATE `hook` SET `webhook` = ?, `name` = ?, `avatar` = ?, `username` = ?, `channel` = ?, `message` = ?, `filterEvent` = ?, `filterAction` = ? WHERE `id` = ?", - [req.body.webhook, req.body.name, req.body.avatar, req.body.username, req.body.channel, req.body.message, req.body.filterEvent, req.body.filterAction, req.params.hook] + "UPDATE `hook` SET `webhook` = ?, `name` = ?, `channel` = ?, `message` = ?, `filterEvent` = ?, `filterAction` = ? WHERE `id` = ?", + [req.body.webhook, req.body.name, req.body.channel, req.body.message, JSON.stringify(req.body.filterEvent), JSON.stringify(req.body.filterAction), req.params.hook] ) res.send({success: true}) }) @@ -238,17 +239,18 @@ const hookFunc = async (req, res) => { const githubEvent = req.headers["x-github-event"] if (githubEvent == "ping") return res.sendStatus(204) - if (hook.filterEvent && !hook.filterEvent.includes(githubEvent)) return res.status(202).send({success: true, info: "Event " + encode(githubEvent) + " is disabled in settings for this hook"}) + if (hook.filterEvent && !JSON.parse(hook.filterEvent).includes(githubEvent)) return res.status(202).send({success: true, info: "Event " + encode(githubEvent) + " is disabled in settings for this hook"}) const data = req.body const action = data.action - if (hook.filterAction && !hook.filterAction.includes(action)) return res.status(202).send({success: true, info: "Action " + encode(action) + " is disabled in settings for this hook"}) + if (hook.filterAction && !JSON.parse(hook.filterAction).includes(action)) return res.status(202).send({success: true, info: "Action " + encode(action) + " is disabled in settings for this hook"}) - let message = hook.message + let message = hook.message || require(path.join(__dirname, "templates", githubEvent + ".js")).find(msg => msg.action == action) || require(path.join(__dirname, "templates", githubEvent + ".js"))[0] + console.log(message) const recursiveFunc = (obj, path = "") => { for (const property in obj) { if (typeof obj[property] == "object") recursiveFunc(obj[property], path + property + ".") - // Possible syntax: {sender.login} or {{ sender.login }} + // Possible syntax: {sender.login} or {{ sender.login }} or something in between else message = message.replace(new RegExp("{{? ?" + path + property + " ?}}?", "gi"), obj[property]) } } @@ -261,7 +263,12 @@ const hookFunc = async (req, res) => { return res.status(500).send("Invalid JSON in message: " + encode(e.message)) } - if (Array.isArray(parsed)) parsed = parsed.find(msg => msg.event == githubEvent && msg.action == action) || parsed.find(msg => msg.event == githubEvent) || parsed[0] + if (Array.isArray(parsed)) parsed = parsed.find(msg => { + if (!Array.isArray(msg.event)) msg.event = [msg.event] + if (!Array.isArray(msg.action)) msg.action = [msg.action] + + return msg.event.includes(githubEvent) && msg.action.includes(action) + }) || parsed.find(msg => msg.event == githubEvent) || parsed[0] if (!parsed || Object.keys(parsed).length == 0) return res.status(500).send({success: false, error: "Empty JSON in message"}) if (hook.webhook) { @@ -273,13 +280,12 @@ const hookFunc = async (req, res) => { if (channel) { await channel.send(parsed) res.sendStatus(204) - } else res.status(500).send({success: false, error: "Unable to send message of hook " + hook.id + " because the channel " + hook.channel + " does not exist"}) + } else res.status(500).send({success: false, error: "Unable to send message because the channel " + hook.channel + " doesn't exist"}) } } app.post("/hook/:id/:secret", hookFunc) app.post("/hook/:id", async (req, res) => { - console.log(req.headers) if (!req.get("X-Hub-Signature-256")) return res.status(401).send("Missing X-Hub-Signature-256 header") req.params.secret = req.get("X-Hub-Signature-256") diff --git a/templates/branch_protection_configuration.js b/templates/branch_protection_configuration.js index 28a3cc4..e0a30b2 100644 --- a/templates/branch_protection_configuration.js +++ b/templates/branch_protection_configuration.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { action: "disabled", @@ -7,10 +9,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`branch_protection_configuration` (`disabled`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "enabled", embeds: [{ author: { @@ -18,6 +19,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`branch_protection_configuration` (`enabled`)", - color: 0 + color: color("black") }] - }] + } +] diff --git a/templates/branch_protection_rule.js b/templates/branch_protection_rule.js index 782338c..6533317 100644 --- a/templates/branch_protection_rule.js +++ b/templates/branch_protection_rule.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { action: "created", @@ -7,10 +9,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`branch_protection_rule` (`created`)", - color: 0 + color: color("green") }] - }, - { + },{ action: "edited", embeds: [{ author: { @@ -18,10 +19,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`branch_protection_rule` (`edited`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "deleted", embeds: [{ author: { @@ -29,6 +29,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`branch_protection_rule` (`deleted`)", - color: 0 + color: color("red") }] - }] + } +] diff --git a/templates/check_run.js b/templates/check_run.js index 646614f..74c5922 100644 --- a/templates/check_run.js +++ b/templates/check_run.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { action: "completed", @@ -7,10 +9,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`check_run` (`completed`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "created", embeds: [{ author: { @@ -18,10 +19,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`check_run` (`created`)", - color: 0 + color: color("green") }] - }, - { + },{ action: "requested_action", embeds: [{ author: { @@ -29,10 +29,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`check_run` (`requested_action`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "rerequested", embeds: [{ author: { @@ -40,6 +39,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`check_run` (`rerequested`)", - color: 0 + color: color("black") }] - }] + } +] diff --git a/templates/check_suite.js b/templates/check_suite.js index f9475c0..750993e 100644 --- a/templates/check_suite.js +++ b/templates/check_suite.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { action: "completed", @@ -7,10 +9,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`check_suite` (`completed`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "requested", embeds: [{ author: { @@ -18,10 +19,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`check_suite` (`requested`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "rerequested", embeds: [{ author: { @@ -29,6 +29,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`check_suite` (`rerequested`)", - color: 0 + color: color("black") }] - }] + } +] diff --git a/templates/code_scanning_alert.js b/templates/code_scanning_alert.js index 6ff95e7..4472ace 100644 --- a/templates/code_scanning_alert.js +++ b/templates/code_scanning_alert.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { action: "appeared_in_branch", @@ -7,10 +9,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`code_scanning_alert` (`appeared_in_branch`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "closed_by_user", embeds: [{ author: { @@ -18,10 +19,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`code_scanning_alert` (`closed_by_user`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "created", embeds: [{ author: { @@ -29,10 +29,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`code_scanning_alert` (`created`)", - color: 0 + color: color("green") }] - }, - { + },{ action: "fixed", embeds: [{ author: { @@ -40,10 +39,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`code_scanning_alert` (`fixed`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "reopened", embeds: [{ author: { @@ -51,10 +49,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`code_scanning_alert` (`reopened`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "reopened_by_user", embeds: [{ author: { @@ -62,6 +59,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`code_scanning_alert` (`reopened_by_user`)", - color: 0 + color: color("black") }] - }] + } +] diff --git a/templates/commit_comment.js b/templates/commit_comment.js index 9a760aa..8076a97 100644 --- a/templates/commit_comment.js +++ b/templates/commit_comment.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { embeds: [{ @@ -6,7 +8,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`commit_comment`", - color: 0 + color: color("black") }] } ] diff --git a/templates/create.js b/templates/create.js index abaa2e0..aedddd7 100644 --- a/templates/create.js +++ b/templates/create.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { embeds: [{ @@ -6,7 +8,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`create`", - color: 0 + color: color("black") }] } ] diff --git a/templates/custom_property.js b/templates/custom_property.js index 4d4d7af..6d5f113 100644 --- a/templates/custom_property.js +++ b/templates/custom_property.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { action: "created", @@ -7,10 +9,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`custom_property` (`created`)", - color: 0 + color: color("green") }] - }, - { + },{ action: "deleted", embeds: [{ author: { @@ -18,10 +19,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`custom_property` (`deleted`)", - color: 0 + color: color("red") }] - }, - { + },{ action: "updated", embeds: [{ author: { @@ -29,6 +29,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`custom_property` (`updated`)", - color: 0 + color: color("black") }] - }] + } +] diff --git a/templates/custom_property_values.js b/templates/custom_property_values.js index 0f33221..07c726e 100644 --- a/templates/custom_property_values.js +++ b/templates/custom_property_values.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { embeds: [{ @@ -6,7 +8,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`custom_property_values`", - color: 0 + color: color("black") }] } ] diff --git a/templates/delete.js b/templates/delete.js index caf8166..b62929e 100644 --- a/templates/delete.js +++ b/templates/delete.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { embeds: [{ @@ -6,7 +8,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`delete`", - color: 0 + color: color("black") }] } ] diff --git a/templates/dependabot_alert.js b/templates/dependabot_alert.js index 8c4d070..0143204 100644 --- a/templates/dependabot_alert.js +++ b/templates/dependabot_alert.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { action: "auto_dismissed", @@ -7,10 +9,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`dependabot_alert` (`auto_dismissed`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "auto_reopened", embeds: [{ author: { @@ -18,10 +19,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`dependabot_alert` (`auto_reopened`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "created", embeds: [{ author: { @@ -29,10 +29,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`dependabot_alert` (`created`)", - color: 0 + color: color("green") }] - }, - { + },{ action: "dismissed", embeds: [{ author: { @@ -40,10 +39,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`dependabot_alert` (`dismissed`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "fixed", embeds: [{ author: { @@ -51,10 +49,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`dependabot_alert` (`fixed`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "reintroduced", embeds: [{ author: { @@ -62,10 +59,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`dependabot_alert` (`reintroduced`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "reopened", embeds: [{ author: { @@ -73,6 +69,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`dependabot_alert` (`reopened`)", - color: 0 + color: color("black") }] - }] + } +] diff --git a/templates/deploy_key.js b/templates/deploy_key.js index 8fab1a2..b8a3ba9 100644 --- a/templates/deploy_key.js +++ b/templates/deploy_key.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { action: "created", @@ -7,10 +9,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`deploy_key` (`created`)", - color: 0 + color: color("green") }] - }, - { + },{ action: "deleted", embeds: [{ author: { @@ -18,6 +19,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`deploy_key` (`deleted`)", - color: 0 + color: color("red") }] - }] + } +] diff --git a/templates/deployment.js b/templates/deployment.js index ee51aa3..7d36c45 100644 --- a/templates/deployment.js +++ b/templates/deployment.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { embeds: [{ @@ -6,7 +8,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`deployment`", - color: 0 + color: color("black") }] } ] diff --git a/templates/deployment_protection_rule.js b/templates/deployment_protection_rule.js index 27a09be..8cc7293 100644 --- a/templates/deployment_protection_rule.js +++ b/templates/deployment_protection_rule.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { embeds: [{ @@ -6,7 +8,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`deployment_protection_rule`", - color: 0 + color: color("black") }] } ] diff --git a/templates/deployment_review.js b/templates/deployment_review.js index f62f948..b58cdc3 100644 --- a/templates/deployment_review.js +++ b/templates/deployment_review.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { action: "approved", @@ -7,10 +9,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`deployment_review` (`approved`)", - color: 0 + color: color("green") }] - }, - { + },{ action: "rejected", embeds: [{ author: { @@ -18,10 +19,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`deployment_review` (`rejected`)", - color: 0 + color: color("red") }] - }, - { + },{ action: "requested", embeds: [{ author: { @@ -29,6 +29,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`deployment_review` (`requested`)", - color: 0 + color: color("black") }] - }] + } +] diff --git a/templates/deployment_status.js b/templates/deployment_status.js index 64ddb40..6992955 100644 --- a/templates/deployment_status.js +++ b/templates/deployment_status.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { embeds: [{ @@ -6,7 +8,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`deployment_status`", - color: 0 + color: color("black") }] } ] diff --git a/templates/discussion.js b/templates/discussion.js index 5e5e4b5..29ec699 100644 --- a/templates/discussion.js +++ b/templates/discussion.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { action: "answered", @@ -7,10 +9,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`discussion` (`answered`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "category_changed", embeds: [{ author: { @@ -18,10 +19,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`discussion` (`category_changed`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "closed", embeds: [{ author: { @@ -29,10 +29,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`discussion` (`closed`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "created", embeds: [{ author: { @@ -40,10 +39,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`discussion` (`created`)", - color: 0 + color: color("green") }] - }, - { + },{ action: "deleted", embeds: [{ author: { @@ -51,10 +49,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`discussion` (`deleted`)", - color: 0 + color: color("red") }] - }, - { + },{ action: "edited", embeds: [{ author: { @@ -62,10 +59,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`discussion` (`edited`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "labeled", embeds: [{ author: { @@ -73,10 +69,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`discussion` (`labeled`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "locked", embeds: [{ author: { @@ -84,10 +79,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`discussion` (`locked`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "pinned", embeds: [{ author: { @@ -95,10 +89,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`discussion` (`pinned`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "reopened", embeds: [{ author: { @@ -106,10 +99,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`discussion` (`reopened`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "transferred", embeds: [{ author: { @@ -117,10 +109,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`discussion` (`transferred`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "unanswered", embeds: [{ author: { @@ -128,10 +119,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`discussion` (`unanswered`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "unlabeled", embeds: [{ author: { @@ -139,10 +129,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`discussion` (`unlabeled`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "unlocked", embeds: [{ author: { @@ -150,10 +139,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`discussion` (`unlocked`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "unpinned", embeds: [{ author: { @@ -161,6 +149,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`discussion` (`unpinned`)", - color: 0 + color: color("black") }] - }] + } +] diff --git a/templates/discussion_comment.js b/templates/discussion_comment.js index a60f9c8..21455a7 100644 --- a/templates/discussion_comment.js +++ b/templates/discussion_comment.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { action: "created", @@ -7,10 +9,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`discussion_comment` (`created`)", - color: 0 + color: color("green") }] - }, - { + },{ action: "deleted", embeds: [{ author: { @@ -18,10 +19,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`discussion_comment` (`deleted`)", - color: 0 + color: color("red") }] - }, - { + },{ action: "edited", embeds: [{ author: { @@ -29,6 +29,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`discussion_comment` (`edited`)", - color: 0 + color: color("black") }] - }] + } +] diff --git a/templates/fork.js b/templates/fork.js index 4f2c781..90f7e4e 100644 --- a/templates/fork.js +++ b/templates/fork.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { embeds: [{ @@ -6,7 +8,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`fork`", - color: 0 + color: color("black") }] } ] diff --git a/templates/github_app_authorization.js b/templates/github_app_authorization.js index f204058..d4774a1 100644 --- a/templates/github_app_authorization.js +++ b/templates/github_app_authorization.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { embeds: [{ @@ -6,7 +8,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`github_app_authorization`", - color: 0 + color: color("black") }] } ] diff --git a/templates/gollum.js b/templates/gollum.js index 7880a20..f546f6e 100644 --- a/templates/gollum.js +++ b/templates/gollum.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { embeds: [{ @@ -6,7 +8,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`gollum`", - color: 0 + color: color("black") }] } ] diff --git a/templates/installation.js b/templates/installation.js index 5f8016e..63ce037 100644 --- a/templates/installation.js +++ b/templates/installation.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { action: "created", @@ -7,10 +9,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`installation` (`created`)", - color: 0 + color: color("green") }] - }, - { + },{ action: "deleted", embeds: [{ author: { @@ -18,10 +19,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`installation` (`deleted`)", - color: 0 + color: color("red") }] - }, - { + },{ action: "new_permissions_accepted", embeds: [{ author: { @@ -29,10 +29,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`installation` (`new_permissions_accepted`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "suspend", embeds: [{ author: { @@ -40,10 +39,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`installation` (`suspend`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "unsuspend", embeds: [{ author: { @@ -51,6 +49,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`installation` (`unsuspend`)", - color: 0 + color: color("black") }] - }] + } +] diff --git a/templates/installation_repositories.js b/templates/installation_repositories.js index 2b27714..c1a61cb 100644 --- a/templates/installation_repositories.js +++ b/templates/installation_repositories.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { action: "added", @@ -7,10 +9,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`installation_repositories` (`added`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "removed", embeds: [{ author: { @@ -18,6 +19,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`installation_repositories` (`removed`)", - color: 0 + color: color("black") }] - }] + } +] diff --git a/templates/installation_target.js b/templates/installation_target.js index 353c9d1..f76ae65 100644 --- a/templates/installation_target.js +++ b/templates/installation_target.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { embeds: [{ @@ -6,7 +8,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`installation_target`", - color: 0 + color: color("black") }] } ] diff --git a/templates/issue_comment.js b/templates/issue_comment.js index 4873665..6a535da 100644 --- a/templates/issue_comment.js +++ b/templates/issue_comment.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { action: "created", @@ -7,10 +9,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`issue_comment` (`created`)", - color: 0 + color: color("green") }] - }, - { + },{ action: "deleted", embeds: [{ author: { @@ -18,10 +19,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`issue_comment` (`deleted`)", - color: 0 + color: color("red") }] - }, - { + },{ action: "edited", embeds: [{ author: { @@ -29,6 +29,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`issue_comment` (`edited`)", - color: 0 + color: color("black") }] - }] + } +] diff --git a/templates/issues.js b/templates/issues.js index 7e23f33..449883c 100644 --- a/templates/issues.js +++ b/templates/issues.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { action: "assigned", @@ -7,10 +9,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`issues` (`assigned`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "closed", embeds: [{ author: { @@ -18,10 +19,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`issues` (`closed`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "deleted", embeds: [{ author: { @@ -29,10 +29,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`issues` (`deleted`)", - color: 0 + color: color("red") }] - }, - { + },{ action: "demilestoned", embeds: [{ author: { @@ -40,10 +39,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`issues` (`demilestoned`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "edited", embeds: [{ author: { @@ -51,10 +49,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`issues` (`edited`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "labeled", embeds: [{ author: { @@ -62,10 +59,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`issues` (`labeled`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "locked", embeds: [{ author: { @@ -73,10 +69,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`issues` (`locked`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "milestoned", embeds: [{ author: { @@ -84,10 +79,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`issues` (`milestoned`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "opened", embeds: [{ author: { @@ -95,10 +89,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`issues` (`opened`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "pinned", embeds: [{ author: { @@ -106,10 +99,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`issues` (`pinned`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "reopened", embeds: [{ author: { @@ -117,10 +109,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`issues` (`reopened`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "transferred", embeds: [{ author: { @@ -128,10 +119,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`issues` (`transferred`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "unassigned", embeds: [{ author: { @@ -139,10 +129,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`issues` (`unassigned`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "unlabeled", embeds: [{ author: { @@ -150,10 +139,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`issues` (`unlabeled`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "unlocked", embeds: [{ author: { @@ -161,10 +149,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`issues` (`unlocked`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "unpinned", embeds: [{ author: { @@ -172,6 +159,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`issues` (`unpinned`)", - color: 0 + color: color("black") }] - }] + } +] diff --git a/templates/label.js b/templates/label.js index 0da32ab..26b4759 100644 --- a/templates/label.js +++ b/templates/label.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { action: "created", @@ -7,10 +9,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`label` (`created`)", - color: 0 + color: color("green") }] - }, - { + },{ action: "deleted", embeds: [{ author: { @@ -18,10 +19,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`label` (`deleted`)", - color: 0 + color: color("red") }] - }, - { + },{ action: "edited", embeds: [{ author: { @@ -29,6 +29,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`label` (`edited`)", - color: 0 + color: color("black") }] - }] + } +] diff --git a/templates/marketplace_purchase.js b/templates/marketplace_purchase.js index 92bd372..ae400c6 100644 --- a/templates/marketplace_purchase.js +++ b/templates/marketplace_purchase.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { action: "cancelled", @@ -7,10 +9,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`marketplace_purchase` (`cancelled`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "changed", embeds: [{ author: { @@ -18,10 +19,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`marketplace_purchase` (`changed`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "pending_change", embeds: [{ author: { @@ -29,10 +29,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`marketplace_purchase` (`pending_change`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "pending_change_cancelled", embeds: [{ author: { @@ -40,10 +39,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`marketplace_purchase` (`pending_change_cancelled`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "purchased", embeds: [{ author: { @@ -51,6 +49,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`marketplace_purchase` (`purchased`)", - color: 0 + color: color("black") }] - }] + } +] diff --git a/templates/member.js b/templates/member.js index bab203a..aeb06a9 100644 --- a/templates/member.js +++ b/templates/member.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { action: "added", @@ -7,10 +9,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`member` (`added`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "edited", embeds: [{ author: { @@ -18,10 +19,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`member` (`edited`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "removed", embeds: [{ author: { @@ -29,6 +29,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`member` (`removed`)", - color: 0 + color: color("black") }] - }] + } +] diff --git a/templates/membership.js b/templates/membership.js index 0835fc9..17c047d 100644 --- a/templates/membership.js +++ b/templates/membership.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { action: "added", @@ -7,10 +9,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`membership` (`added`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "removed", embeds: [{ author: { @@ -18,6 +19,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`membership` (`removed`)", - color: 0 + color: color("black") }] - }] + } +] diff --git a/templates/merge_group.js b/templates/merge_group.js index 8993efc..575e4cc 100644 --- a/templates/merge_group.js +++ b/templates/merge_group.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { action: "checks_requested", @@ -7,10 +9,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`merge_group` (`checks_requested`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "destroyed", embeds: [{ author: { @@ -18,6 +19,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`merge_group` (`destroyed`)", - color: 0 + color: color("black") }] - }] + } +] diff --git a/templates/meta.js b/templates/meta.js index 67de008..cf242e1 100644 --- a/templates/meta.js +++ b/templates/meta.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { action: "deleted", @@ -7,6 +9,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`meta` (`deleted`)", - color: 0 + color: color("red") }] - }] + } +] diff --git a/templates/milestone.js b/templates/milestone.js index 585bc7b..55ce312 100644 --- a/templates/milestone.js +++ b/templates/milestone.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { action: "closed", @@ -7,10 +9,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`milestone` (`closed`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "created", embeds: [{ author: { @@ -18,10 +19,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`milestone` (`created`)", - color: 0 + color: color("green") }] - }, - { + },{ action: "deleted", embeds: [{ author: { @@ -29,10 +29,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`milestone` (`deleted`)", - color: 0 + color: color("red") }] - }, - { + },{ action: "edited", embeds: [{ author: { @@ -40,10 +39,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`milestone` (`edited`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "opened", embeds: [{ author: { @@ -51,6 +49,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`milestone` (`opened`)", - color: 0 + color: color("black") }] - }] + } +] diff --git a/templates/org_block.js b/templates/org_block.js index 226a014..cd76b55 100644 --- a/templates/org_block.js +++ b/templates/org_block.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { action: "blocked", @@ -7,10 +9,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`org_block` (`blocked`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "unblocked", embeds: [{ author: { @@ -18,6 +19,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`org_block` (`unblocked`)", - color: 0 + color: color("black") }] - }] + } +] diff --git a/templates/organization.js b/templates/organization.js index d1f4495..7c0a0f3 100644 --- a/templates/organization.js +++ b/templates/organization.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { action: "deleted", @@ -7,10 +9,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`organization` (`deleted`)", - color: 0 + color: color("red") }] - }, - { + },{ action: "member_added", embeds: [{ author: { @@ -18,10 +19,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`organization` (`member_added`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "member_invited", embeds: [{ author: { @@ -29,10 +29,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`organization` (`member_invited`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "member_removed", embeds: [{ author: { @@ -40,10 +39,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`organization` (`member_removed`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "renamed", embeds: [{ author: { @@ -51,6 +49,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`organization` (`renamed`)", - color: 0 + color: color("black") }] - }] + } +] diff --git a/templates/package.js b/templates/package.js index 23898fb..42d5028 100644 --- a/templates/package.js +++ b/templates/package.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { action: "published", @@ -7,10 +9,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`package` (`published`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "updated", embeds: [{ author: { @@ -18,6 +19,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`package` (`updated`)", - color: 0 + color: color("black") }] - }] + } +] diff --git a/templates/page_build.js b/templates/page_build.js index 1bf7abe..469e01f 100644 --- a/templates/page_build.js +++ b/templates/page_build.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { embeds: [{ @@ -6,7 +8,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`page_build`", - color: 0 + color: color("black") }] } ] diff --git a/templates/personal_access_token_request.js b/templates/personal_access_token_request.js index 03e0f89..6217356 100644 --- a/templates/personal_access_token_request.js +++ b/templates/personal_access_token_request.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { action: "approved", @@ -7,10 +9,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`personal_access_token_request` (`approved`)", - color: 0 + color: color("green") }] - }, - { + },{ action: "cancelled", embeds: [{ author: { @@ -18,10 +19,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`personal_access_token_request` (`cancelled`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "created", embeds: [{ author: { @@ -29,10 +29,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`personal_access_token_request` (`created`)", - color: 0 + color: color("green") }] - }, - { + },{ action: "denied", embeds: [{ author: { @@ -40,6 +39,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`personal_access_token_request` (`denied`)", - color: 0 + color: color("black") }] - }] + } +] diff --git a/templates/ping.js b/templates/ping.js deleted file mode 100644 index 3868f64..0000000 --- a/templates/ping.js +++ /dev/null @@ -1,10 +0,0 @@ -module.exports = [{ - embeds: [{ - author: { - name: "{{ sender.login }}", - icon_url: "{{ sender.avatar_url }}" - }, - title: "`ping`", - color: 0 - }] -}] diff --git a/templates/project.js b/templates/project.js index 120db89..ba26325 100644 --- a/templates/project.js +++ b/templates/project.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { action: "closed", @@ -7,10 +9,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`project` (`closed`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "created", embeds: [{ author: { @@ -18,10 +19,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`project` (`created`)", - color: 0 + color: color("green") }] - }, - { + },{ action: "deleted", embeds: [{ author: { @@ -29,10 +29,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`project` (`deleted`)", - color: 0 + color: color("red") }] - }, - { + },{ action: "edited", embeds: [{ author: { @@ -40,10 +39,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`project` (`edited`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "reopened", embeds: [{ author: { @@ -51,6 +49,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`project` (`reopened`)", - color: 0 + color: color("black") }] - }] + } +] diff --git a/templates/project_card.js b/templates/project_card.js index 1b53a46..af87d17 100644 --- a/templates/project_card.js +++ b/templates/project_card.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { action: "converted", @@ -7,10 +9,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`project_card` (`converted`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "created", embeds: [{ author: { @@ -18,10 +19,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`project_card` (`created`)", - color: 0 + color: color("green") }] - }, - { + },{ action: "deleted", embeds: [{ author: { @@ -29,10 +29,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`project_card` (`deleted`)", - color: 0 + color: color("red") }] - }, - { + },{ action: "edited", embeds: [{ author: { @@ -40,10 +39,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`project_card` (`edited`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "moved", embeds: [{ author: { @@ -51,6 +49,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`project_card` (`moved`)", - color: 0 + color: color("black") }] - }] + } +] diff --git a/templates/project_column.js b/templates/project_column.js index 4ecafcc..452e5e3 100644 --- a/templates/project_column.js +++ b/templates/project_column.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { action: "created", @@ -7,10 +9,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`project_column` (`created`)", - color: 0 + color: color("green") }] - }, - { + },{ action: "deleted", embeds: [{ author: { @@ -18,10 +19,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`project_column` (`deleted`)", - color: 0 + color: color("red") }] - }, - { + },{ action: "edited", embeds: [{ author: { @@ -29,10 +29,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`project_column` (`edited`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "moved", embeds: [{ author: { @@ -40,6 +39,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`project_column` (`moved`)", - color: 0 + color: color("black") }] - }] + } +] diff --git a/templates/projects_v2.js b/templates/projects_v2.js index e2d9a26..654e1b6 100644 --- a/templates/projects_v2.js +++ b/templates/projects_v2.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { action: "closed", @@ -7,10 +9,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`projects_v2` (`closed`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "created", embeds: [{ author: { @@ -18,10 +19,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`projects_v2` (`created`)", - color: 0 + color: color("green") }] - }, - { + },{ action: "deleted", embeds: [{ author: { @@ -29,10 +29,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`projects_v2` (`deleted`)", - color: 0 + color: color("red") }] - }, - { + },{ action: "edited", embeds: [{ author: { @@ -40,10 +39,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`projects_v2` (`edited`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "reopened", embeds: [{ author: { @@ -51,6 +49,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`projects_v2` (`reopened`)", - color: 0 + color: color("black") }] - }] + } +] diff --git a/templates/projects_v2_item.js b/templates/projects_v2_item.js index f7a1302..2a9bd5a 100644 --- a/templates/projects_v2_item.js +++ b/templates/projects_v2_item.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { action: "archived", @@ -7,10 +9,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`projects_v2_item` (`archived`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "converted", embeds: [{ author: { @@ -18,10 +19,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`projects_v2_item` (`converted`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "created", embeds: [{ author: { @@ -29,10 +29,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`projects_v2_item` (`created`)", - color: 0 + color: color("green") }] - }, - { + },{ action: "deleted", embeds: [{ author: { @@ -40,10 +39,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`projects_v2_item` (`deleted`)", - color: 0 + color: color("red") }] - }, - { + },{ action: "edited", embeds: [{ author: { @@ -51,10 +49,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`projects_v2_item` (`edited`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "reordered", embeds: [{ author: { @@ -62,10 +59,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`projects_v2_item` (`reordered`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "restored", embeds: [{ author: { @@ -73,6 +69,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`projects_v2_item` (`restored`)", - color: 0 + color: color("black") }] - }] + } +] diff --git a/templates/public.js b/templates/public.js index c5baec4..7b2c688 100644 --- a/templates/public.js +++ b/templates/public.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { embeds: [{ @@ -6,7 +8,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`public`", - color: 0 + color: color("black") }] } ] diff --git a/templates/pull_request.js b/templates/pull_request.js index 6fb2647..13a477e 100644 --- a/templates/pull_request.js +++ b/templates/pull_request.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { action: "assigned", @@ -7,10 +9,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`pull_request` (`assigned`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "auto_merge_disabled", embeds: [{ author: { @@ -18,10 +19,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`pull_request` (`auto_merge_disabled`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "auto_merge_enabled", embeds: [{ author: { @@ -29,10 +29,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`pull_request` (`auto_merge_enabled`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "closed", embeds: [{ author: { @@ -40,10 +39,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`pull_request` (`closed`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "converted_to_draft", embeds: [{ author: { @@ -51,10 +49,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`pull_request` (`converted_to_draft`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "demilestoned", embeds: [{ author: { @@ -62,10 +59,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`pull_request` (`demilestoned`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "dequeued", embeds: [{ author: { @@ -73,10 +69,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`pull_request` (`dequeued`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "edited", embeds: [{ author: { @@ -84,10 +79,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`pull_request` (`edited`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "enqueued", embeds: [{ author: { @@ -95,10 +89,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`pull_request` (`enqueued`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "labeled", embeds: [{ author: { @@ -106,10 +99,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`pull_request` (`labeled`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "locked", embeds: [{ author: { @@ -117,10 +109,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`pull_request` (`locked`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "milestoned", embeds: [{ author: { @@ -128,10 +119,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`pull_request` (`milestoned`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "opened", embeds: [{ author: { @@ -139,10 +129,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`pull_request` (`opened`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "ready_for_review", embeds: [{ author: { @@ -150,10 +139,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`pull_request` (`ready_for_review`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "reopened", embeds: [{ author: { @@ -161,10 +149,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`pull_request` (`reopened`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "review_request_removed", embeds: [{ author: { @@ -172,10 +159,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`pull_request` (`review_request_removed`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "review_requested", embeds: [{ author: { @@ -183,10 +169,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`pull_request` (`review_requested`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "synchronize", embeds: [{ author: { @@ -194,10 +179,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`pull_request` (`synchronize`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "unassigned", embeds: [{ author: { @@ -205,10 +189,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`pull_request` (`unassigned`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "unlabeled", embeds: [{ author: { @@ -216,10 +199,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`pull_request` (`unlabeled`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "unlocked", embeds: [{ author: { @@ -227,6 +209,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`pull_request` (`unlocked`)", - color: 0 + color: color("black") }] - }] + } +] diff --git a/templates/pull_request_review.js b/templates/pull_request_review.js index d6fe414..36ab95a 100644 --- a/templates/pull_request_review.js +++ b/templates/pull_request_review.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { action: "dismissed", @@ -7,10 +9,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`pull_request_review` (`dismissed`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "edited", embeds: [{ author: { @@ -18,10 +19,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`pull_request_review` (`edited`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "submitted", embeds: [{ author: { @@ -29,6 +29,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`pull_request_review` (`submitted`)", - color: 0 + color: color("black") }] - }] + } +] diff --git a/templates/pull_request_review_comment.js b/templates/pull_request_review_comment.js index 236d572..714c27b 100644 --- a/templates/pull_request_review_comment.js +++ b/templates/pull_request_review_comment.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { action: "created", @@ -7,10 +9,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`pull_request_review_comment` (`created`)", - color: 0 + color: color("green") }] - }, - { + },{ action: "deleted", embeds: [{ author: { @@ -18,10 +19,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`pull_request_review_comment` (`deleted`)", - color: 0 + color: color("red") }] - }, - { + },{ action: "edited", embeds: [{ author: { @@ -29,6 +29,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`pull_request_review_comment` (`edited`)", - color: 0 + color: color("black") }] - }] + } +] diff --git a/templates/pull_request_review_thread.js b/templates/pull_request_review_thread.js index ea67ce4..c401756 100644 --- a/templates/pull_request_review_thread.js +++ b/templates/pull_request_review_thread.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { action: "resolved", @@ -7,10 +9,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`pull_request_review_thread` (`resolved`)", - color: 0 + color: color("green") }] - }, - { + },{ action: "unresolved", embeds: [{ author: { @@ -18,6 +19,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`pull_request_review_thread` (`unresolved`)", - color: 0 + color: color("black") }] - }] + } +] diff --git a/templates/push.js b/templates/push.js index 27578d0..e3222fa 100644 --- a/templates/push.js +++ b/templates/push.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { embeds: [{ @@ -6,7 +8,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`push`", - color: 0 + color: color("black") }] } ] diff --git a/templates/registry_package.js b/templates/registry_package.js index 349aa26..007c2bd 100644 --- a/templates/registry_package.js +++ b/templates/registry_package.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { action: "published", @@ -7,10 +9,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`registry_package` (`published`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "updated", embeds: [{ author: { @@ -18,6 +19,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`registry_package` (`updated`)", - color: 0 + color: color("black") }] - }] + } +] diff --git a/templates/release.js b/templates/release.js index 4846245..492999e 100644 --- a/templates/release.js +++ b/templates/release.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { action: "created", @@ -7,10 +9,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`release` (`created`)", - color: 0 + color: color("green") }] - }, - { + },{ action: "deleted", embeds: [{ author: { @@ -18,10 +19,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`release` (`deleted`)", - color: 0 + color: color("red") }] - }, - { + },{ action: "edited", embeds: [{ author: { @@ -29,10 +29,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`release` (`edited`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "prereleased", embeds: [{ author: { @@ -40,10 +39,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`release` (`prereleased`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "published", embeds: [{ author: { @@ -51,10 +49,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`release` (`published`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "released", embeds: [{ author: { @@ -62,10 +59,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`release` (`released`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "unpublished", embeds: [{ author: { @@ -73,6 +69,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`release` (`unpublished`)", - color: 0 + color: color("black") }] - }] + } +] diff --git a/templates/repository.js b/templates/repository.js index eaf823a..5557a88 100644 --- a/templates/repository.js +++ b/templates/repository.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { action: "archived", @@ -7,10 +9,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`repository` (`archived`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "created", embeds: [{ author: { @@ -18,10 +19,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`repository` (`created`)", - color: 0 + color: color("green") }] - }, - { + },{ action: "deleted", embeds: [{ author: { @@ -29,10 +29,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`repository` (`deleted`)", - color: 0 + color: color("red") }] - }, - { + },{ action: "edited", embeds: [{ author: { @@ -40,10 +39,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`repository` (`edited`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "privatized", embeds: [{ author: { @@ -51,10 +49,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`repository` (`privatized`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "publicized", embeds: [{ author: { @@ -62,10 +59,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`repository` (`publicized`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "renamed", embeds: [{ author: { @@ -73,10 +69,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`repository` (`renamed`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "transferred", embeds: [{ author: { @@ -84,10 +79,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`repository` (`transferred`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "unarchived", embeds: [{ author: { @@ -95,6 +89,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`repository` (`unarchived`)", - color: 0 + color: color("black") }] - }] + } +] diff --git a/templates/repository_advisory.js b/templates/repository_advisory.js index b732cea..078fc92 100644 --- a/templates/repository_advisory.js +++ b/templates/repository_advisory.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { action: "published", @@ -7,10 +9,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`repository_advisory` (`published`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "reported", embeds: [{ author: { @@ -18,6 +19,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`repository_advisory` (`reported`)", - color: 0 + color: color("black") }] - }] + } +] diff --git a/templates/repository_dispatch.js b/templates/repository_dispatch.js index 0843945..f1a0951 100644 --- a/templates/repository_dispatch.js +++ b/templates/repository_dispatch.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { embeds: [{ @@ -6,7 +8,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`repository_dispatch`", - color: 0 + color: color("black") }] } ] diff --git a/templates/repository_import.js b/templates/repository_import.js index b17007e..db1a738 100644 --- a/templates/repository_import.js +++ b/templates/repository_import.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { embeds: [{ @@ -6,7 +8,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`repository_import`", - color: 0 + color: color("black") }] } ] diff --git a/templates/repository_ruleset.js b/templates/repository_ruleset.js index 8262e41..ff1a4e2 100644 --- a/templates/repository_ruleset.js +++ b/templates/repository_ruleset.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { action: "created", @@ -7,10 +9,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`repository_ruleset` (`created`)", - color: 0 + color: color("green") }] - }, - { + },{ action: "deleted", embeds: [{ author: { @@ -18,10 +19,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`repository_ruleset` (`deleted`)", - color: 0 + color: color("red") }] - }, - { + },{ action: "edited", embeds: [{ author: { @@ -29,6 +29,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`repository_ruleset` (`edited`)", - color: 0 + color: color("black") }] - }] + } +] diff --git a/templates/repository_vulnerability_alert.js b/templates/repository_vulnerability_alert.js index 8102f41..2b77702 100644 --- a/templates/repository_vulnerability_alert.js +++ b/templates/repository_vulnerability_alert.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { action: "create", @@ -7,10 +9,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`repository_vulnerability_alert` (`create`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "dismiss", embeds: [{ author: { @@ -18,10 +19,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`repository_vulnerability_alert` (`dismiss`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "reopen", embeds: [{ author: { @@ -29,10 +29,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`repository_vulnerability_alert` (`reopen`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "resolve", embeds: [{ author: { @@ -40,6 +39,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`repository_vulnerability_alert` (`resolve`)", - color: 0 + color: color("black") }] - }] + } +] diff --git a/templates/secret_scanning_alert.js b/templates/secret_scanning_alert.js index 8699e1e..d42f062 100644 --- a/templates/secret_scanning_alert.js +++ b/templates/secret_scanning_alert.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { action: "created", @@ -7,10 +9,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`secret_scanning_alert` (`created`)", - color: 0 + color: color("green") }] - }, - { + },{ action: "reopened", embeds: [{ author: { @@ -18,10 +19,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`secret_scanning_alert` (`reopened`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "resolved", embeds: [{ author: { @@ -29,10 +29,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`secret_scanning_alert` (`resolved`)", - color: 0 + color: color("green") }] - }, - { + },{ action: "revoked", embeds: [{ author: { @@ -40,6 +39,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`secret_scanning_alert` (`revoked`)", - color: 0 + color: color("black") }] - }] + } +] diff --git a/templates/secret_scanning_alert_location.js b/templates/secret_scanning_alert_location.js index b5feabd..f055bac 100644 --- a/templates/secret_scanning_alert_location.js +++ b/templates/secret_scanning_alert_location.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { action: "created", @@ -7,6 +9,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`secret_scanning_alert_location` (`created`)", - color: 0 + color: color("green") }] - }] + } +] diff --git a/templates/security_advisory.js b/templates/security_advisory.js index 78820d5..52d66fc 100644 --- a/templates/security_advisory.js +++ b/templates/security_advisory.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { action: "published", @@ -7,10 +9,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`security_advisory` (`published`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "updated", embeds: [{ author: { @@ -18,10 +19,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`security_advisory` (`updated`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "withdrawn", embeds: [{ author: { @@ -29,6 +29,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`security_advisory` (`withdrawn`)", - color: 0 + color: color("black") }] - }] + } +] diff --git a/templates/security_and_analysis.js b/templates/security_and_analysis.js index f413246..967982f 100644 --- a/templates/security_and_analysis.js +++ b/templates/security_and_analysis.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { embeds: [{ @@ -6,7 +8,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`security_and_analysis`", - color: 0 + color: color("black") }] } ] diff --git a/templates/sponsorship.js b/templates/sponsorship.js index 77acc2a..1476e6a 100644 --- a/templates/sponsorship.js +++ b/templates/sponsorship.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { action: "cancelled", @@ -7,10 +9,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`sponsorship` (`cancelled`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "created", embeds: [{ author: { @@ -18,10 +19,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`sponsorship` (`created`)", - color: 0 + color: color("green") }] - }, - { + },{ action: "edited", embeds: [{ author: { @@ -29,10 +29,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`sponsorship` (`edited`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "pending_cancellation", embeds: [{ author: { @@ -40,10 +39,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`sponsorship` (`pending_cancellation`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "pending_tier_change", embeds: [{ author: { @@ -51,10 +49,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`sponsorship` (`pending_tier_change`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "tier_changed", embeds: [{ author: { @@ -62,6 +59,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`sponsorship` (`tier_changed`)", - color: 0 + color: color("black") }] - }] + } +] diff --git a/templates/star.js b/templates/star.js index f7804a0..b1de6f1 100644 --- a/templates/star.js +++ b/templates/star.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { action: "created", @@ -7,10 +9,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`star` (`created`)", - color: 0 + color: color("green") }] - }, - { + },{ action: "deleted", embeds: [{ author: { @@ -18,6 +19,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`star` (`deleted`)", - color: 0 + color: color("red") }] - }] + } +] diff --git a/templates/status.js b/templates/status.js index 151dc74..05694c0 100644 --- a/templates/status.js +++ b/templates/status.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { embeds: [{ @@ -6,7 +8,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`status`", - color: 0 + color: color("black") }] } ] diff --git a/templates/team.js b/templates/team.js index 92a03bd..69d0413 100644 --- a/templates/team.js +++ b/templates/team.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { action: "added_to_repository", @@ -7,10 +9,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`team` (`added_to_repository`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "created", embeds: [{ author: { @@ -18,10 +19,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`team` (`created`)", - color: 0 + color: color("green") }] - }, - { + },{ action: "deleted", embeds: [{ author: { @@ -29,10 +29,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`team` (`deleted`)", - color: 0 + color: color("red") }] - }, - { + },{ action: "edited", embeds: [{ author: { @@ -40,10 +39,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`team` (`edited`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "removed_from_repository", embeds: [{ author: { @@ -51,6 +49,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`team` (`removed_from_repository`)", - color: 0 + color: color("black") }] - }] + } +] diff --git a/templates/team_add.js b/templates/team_add.js index d213009..c16fde4 100644 --- a/templates/team_add.js +++ b/templates/team_add.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { embeds: [{ @@ -6,7 +8,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`team_add`", - color: 0 + color: color("black") }] } ] diff --git a/templates/watch.js b/templates/watch.js index 1730f38..238d253 100644 --- a/templates/watch.js +++ b/templates/watch.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { action: "started", @@ -7,6 +9,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`watch` (`started`)", - color: 0 + color: color("black") }] - }] + } +] diff --git a/templates/workflow_dispatch.js b/templates/workflow_dispatch.js index b77f1fc..2f4cfcc 100644 --- a/templates/workflow_dispatch.js +++ b/templates/workflow_dispatch.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { embeds: [{ @@ -6,7 +8,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`workflow_dispatch`", - color: 0 + color: color("black") }] } ] diff --git a/templates/workflow_job.js b/templates/workflow_job.js index d4b4b18..b452e01 100644 --- a/templates/workflow_job.js +++ b/templates/workflow_job.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { action: "completed", @@ -7,10 +9,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`workflow_job` (`completed`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "in_progress", embeds: [{ author: { @@ -18,10 +19,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`workflow_job` (`in_progress`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "queued", embeds: [{ author: { @@ -29,10 +29,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`workflow_job` (`queued`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "waiting", embeds: [{ author: { @@ -40,6 +39,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`workflow_job` (`waiting`)", - color: 0 + color: color("black") }] - }] + } +] diff --git a/templates/workflow_run.js b/templates/workflow_run.js index cacb7dc..2b178ab 100644 --- a/templates/workflow_run.js +++ b/templates/workflow_run.js @@ -1,3 +1,5 @@ +const color = require("../util/color.js") + module.exports = [ { action: "completed", @@ -7,10 +9,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`workflow_run` (`completed`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "in_progress", embeds: [{ author: { @@ -18,10 +19,9 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`workflow_run` (`in_progress`)", - color: 0 + color: color("black") }] - }, - { + },{ action: "requested", embeds: [{ author: { @@ -29,6 +29,7 @@ module.exports = [ icon_url: "{{ sender.avatar_url }}" }, title: "`workflow_run` (`requested`)", - color: 0 + color: color("black") }] - }] + } +] diff --git a/util/color.js b/util/color.js new file mode 100644 index 0000000..58074a4 --- /dev/null +++ b/util/color.js @@ -0,0 +1,23 @@ +const colorMap = { + black: 0, + gray: 0x808080, + white: 0xffffff, + red: 0xff0000, + orange: 0xffa500, + yellow: 0xffff00, + green: 0x00ff00, + blue: 0x0000ff, + purple: 0x800080, + cyan: 0x00ffff, + magenta: 0xff00ff, + brown: 0x964b00, + olive: 0x808000, + teal: 0x008080, + navy: 0x000080 +} + +module.exports = (color = "") => { + if (colorMap[color]) return colorMap[color] + + return parseInt(color.replace("#", ""), 16) +} diff --git a/util/oauth.js b/util/oauth.js index 98993af..003afa4 100644 --- a/util/oauth.js +++ b/util/oauth.js @@ -84,7 +84,7 @@ module.exports.getAccessToken = async (token, pool) => { module.exports.generateToken = (length = 20) => { let result = "" - const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.,-!=?@#$%&*()" + const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-" for (let i = 0; i < length; i++) result += characters.charAt(Math.floor(Math.random() * characters.length)) return result diff --git a/util/setupDB.js b/util/setupDB.js index 699f26d..482525e 100644 --- a/util/setupDB.js +++ b/util/setupDB.js @@ -9,13 +9,12 @@ module.exports = pool pool.query( "CREATE TABLE IF NOT EXISTS `hook` (" + "`id` VARCHAR(8) NOT NULL PRIMARY KEY," + + "`name` VARCHAR(32) NOT NULL," + "`secret` VARCHAR(64) NOT NULL," + "`server` VARCHAR(21) NOT NULL," + "`channel` VARCHAR(21) NULL DEFAULT NULL," + "`webhook` VARCHAR(128) NULL DEFAULT NULL," + - "`name` VARCHAR(32) NULL DEFAULT NULL," + - "`avatar` VARCHAR(512) NULL DEFAULT NULL," + - "`message` VARCHAR(10240) NOT NULL," + // Either JSON message data or a string referring to a template + "`message` VARCHAR(10240) NULL DEFAULT NULL," + // Either JSON message data or a string referring to a template. If null, use default template. "`filterEvent` VARCHAR(256) NULL DEFAULT NULL," + "`filterAction` VARCHAR(256) NULL DEFAULT NULL" + ")"