Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow the bot to work with Jira Cloud #301

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ node_modules
.vscode/*
.history
**/.DS_Store
.idea/

**/*.log
settings.json
Expand Down
3 changes: 2 additions & 1 deletion config/local.template.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 1. Copy this file
# 2. Rename the copy to `local.yml`
# 3. Change the bot token, and your Jira personal access token if desired, and save the file
# 3. Change the bot token, and your Jira email+personal access token if desired, and save the file
#
# You can add more configs if you want to.
#
Expand All @@ -11,4 +11,5 @@
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

token: <your bot token>
jireUser: <your jira email>
jiraPat: <your personal access token>
3 changes: 2 additions & 1 deletion config/template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ logDirectory: <string | false>
# Your bot token used to log in to Discord with the bot.
token: <string>

# Your Jira personal access token.
# Your Jira E-Mail and personal access token.
# Optional; if not assigned a value, the bot will not attempt to log into Jira.
jiraUser: <string>
jiraPat: <string>

# A list of user IDs for owner only commands.
Expand Down
12 changes: 8 additions & 4 deletions src/BotConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ export default class BotConfig {

private static token: string;
private static jiraPat?: string;
private static jiraUser?: string;

public static owners: Snowflake[];

Expand Down Expand Up @@ -149,6 +150,7 @@ export default class BotConfig {
this.logDirectory = getOrDefault( 'logDirectory', false );

this.token = config.get( 'token' );
this.jiraUser = getOrDefault( 'jiraUser', undefined );
this.jiraPat = getOrDefault( 'jiraPat', undefined );

this.owners = getOrDefault( 'owners', [] );
Expand Down Expand Up @@ -194,10 +196,12 @@ export default class BotConfig {
public static jiraLogin(): void {
// TODO: integrate newErrorHandling from Jira.js
MojiraBot.jira = new JiraClient( {
host: 'https://bugs.mojang.com',
telemetry: false,
authentication: this.jiraPat === undefined ? undefined : {
personalAccessToken: this.jiraPat,
host: 'https://mojira.atlassian.net',
authentication: this.jiraPat === undefined || this.jiraUser === undefined ? undefined : {
basic: {
email: this.jiraUser,
apiToken: this.jiraPat,
},
},
} );
}
Expand Down
2 changes: 1 addition & 1 deletion src/commands/SearchCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default class SearchCommand extends SlashCommand {

try {
const embed = new EmbedBuilder();
const searchFilter = `text ~ "${ plainArgs }" AND project in (${ BotConfig.projects.join( ', ' ) })`;
const searchFilter = `(description ~ "${ plainArgs }" OR summary ~ "${ plainArgs }") AND project in (${ BotConfig.projects.join( ', ' ) })`;
const searchResults = await MojiraBot.jira.issueSearch.searchForIssuesUsingJql( {
jql: searchFilter,
maxResults: BotConfig.maxSearchResults,
Expand Down
2 changes: 1 addition & 1 deletion src/tasks/VersionFeedTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface JiraVersion {
archived: boolean;
released: boolean;
releaseDate?: string;
projectId: number;
projectId: number | string;
}

function versionConv( version: Version ): JiraVersion | undefined {
Expand Down