this is a rewrite of the bot in typescript. detritus is used as a discord library instead of discord.js
This commit is contained in:
spiral 2022-10-21 17:22:01 +00:00
parent 6688d4dcd8
commit 56091a6df7
No known key found for this signature in database
GPG key ID: 244A11E4B0BCF40E
33 changed files with 731 additions and 1116 deletions

30
model/jira.ts Normal file
View file

@ -0,0 +1,30 @@
import * as axios from 'axios';
import config from '../config';
export default async function search(version?: string): Promise<any[]> {
const params = {
'jql': 'project%20%3D%20SP%20AND%20status%20in%20(%22Claimed%20Fixed%22%2C%20%22In%20Pre-Testing%22)%20AND%20updated%20%3E%3D%20-24h%20ORDER%20BY%20created%20DESC',
'maxResults': 100,
'startAt': 0
};
if (version) {
params.jql = `project%20%3D%20SP%20AND%20status%20in%20(%22Claimed%20Fixed%22%2C%20%22In%20Pre-Testing%22)%20AND%20%22Fixed%20In%20Version%5BNumber%5D%22%20%3D%20%22${version}%22%20ORDER%20BY%20created%20DESC`;
}
const issues: any[] = [];
let response: any | null = null;
do {
// @ts-expect-error
const httpParams = Object.keys(params).map(key => `${key}=${params[key]}`).join('&');
const url = `${config.jira.baseUrl}/search?${httpParams}`;
// what even is this
response = JSON.parse((await new axios.Axios({}).get(url)).data);
issues.push(...response!.issues);
params.startAt += 100;
} while (response!.issues.length > 99 && response!.total > 100);
return issues;
}