mirror of https://github.com/thaldrin/thaldrin.git
add trello // webhook features
This commit is contained in:
parent
c1c79c4a21
commit
780086b8a2
|
@ -0,0 +1,30 @@
|
|||
import { Trello as TClient } from "trello-helper";
|
||||
import config from '../../config'
|
||||
|
||||
process.env.trelloHelper = JSON.stringify({
|
||||
appKey: config.trello.key,
|
||||
token: config.trello.token
|
||||
})
|
||||
|
||||
const Trello = new TClient({
|
||||
useExistingEnvVar: true
|
||||
})
|
||||
|
||||
|
||||
export async function suggest({ title, desc, author, guild }: { title: string, desc?: string, author: string, guild: string }) {
|
||||
let Card = await Trello.addCard({
|
||||
idList: config.trello.options.list.suggestions,
|
||||
name: `Suggestion - ${title}`,
|
||||
desc: `
|
||||
${desc || title}
|
||||
|
||||
Author: ${author}
|
||||
Server: ${guild}
|
||||
`
|
||||
})
|
||||
|
||||
return Card
|
||||
}
|
||||
|
||||
|
||||
export default Trello
|
|
@ -0,0 +1,28 @@
|
|||
import { Guild, MessageEmbed, User, WebhookClient } from "discord.js";
|
||||
import { Webhook } from "../utils/types"
|
||||
import embed from "../utils/embed";
|
||||
import config from "../../config";
|
||||
export default async function SendWS(
|
||||
webhook: Webhook,
|
||||
content: {
|
||||
title: string,
|
||||
desc: string,
|
||||
ctx: {
|
||||
author: User,
|
||||
guild: Guild | null
|
||||
}
|
||||
}) {
|
||||
|
||||
let Hook = new WebhookClient(webhook.id, webhook.token)
|
||||
let author = `${content.ctx.author.username} (${content.ctx.author.id})`
|
||||
let guild = `${content.ctx.guild?.name} (${content.ctx.guild?.id})`
|
||||
// @ts-ignore
|
||||
embed.setAuthor(`${author}\n${guild}`, content.ctx.author.avatarURL())
|
||||
embed.setDescription(`${content.title}${content.desc ? `\n\n${content.desc}` : ""}`)
|
||||
|
||||
Hook.send(`New ${webhook.type}`, {
|
||||
username: webhook.username,
|
||||
avatarURL: config.variables.avatar,
|
||||
embeds: [embed]
|
||||
})
|
||||
}
|
Loading…
Reference in New Issue