Skip to content

Commit

Permalink
chore: remove threadId functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
ChatDisabled committed Dec 6, 2023
1 parent 839dc14 commit a31e8fd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 31 deletions.
38 changes: 10 additions & 28 deletions src/discord.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { MessageEmbed, WebhookClient } = require('discord.js')
const MAX_MESSAGE_LENGTH = 72

module.exports.send = (id, token, repo, branch, url, commits, size, threadId) =>
module.exports.send = (id, token, repo, branch, url, commits, size) =>
new Promise((resolve, reject) => {
let client
const username = repo.replace('discord', '******')
Expand All @@ -13,33 +13,15 @@ module.exports.send = (id, token, repo, branch, url, commits, size, threadId) =>
id: id,
token: token,
})

if (threadId) {
if (isNaN(threadId)) {
throw new Error('threadId is not a number')
}
console.log('Found thread ID')
client
.send({
username: username,
embeds: [createEmbed(repo, branch, url, commits, size)],
threadId: threadId,
})
.then(() => {
console.log('Successfully sent the message!')
resolve()
}, reject)
} else {
client
.send({
username: username,
embeds: [createEmbed(repo, branch, url, commits, size)],
})
.then(() => {
console.log('Successfully sent the message!')
resolve()
}, reject)
}
client
.send({
username: username,
embeds: [createEmbed(repo, branch, url, commits, size)],
})
.then(() => {
console.log('Successfully sent the message!')
resolve()
}, reject)
} catch (error) {
console.log('Error creating Webhook')
reject(error.message)
Expand Down
3 changes: 0 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const core = require('@actions/core')
const github = require('@actions/github')

const webhook = require('../src/discord.js')

async function run() {
Expand All @@ -21,7 +20,6 @@ async function run() {

const id = core.getInput('id')
const token = core.getInput('token')
const threadId = core.getInput('threadId')

webhook
.send(
Expand All @@ -32,7 +30,6 @@ async function run() {
payload.compare,
commits,
size,
threadId
)
.catch((err) => core.setFailed(err.message))
}
Expand Down

0 comments on commit a31e8fd

Please sign in to comment.