Skip to content
This repository has been archived by the owner on Jan 21, 2024. It is now read-only.

Commit

Permalink
Merge pull request #54 from MitchTalmadge/develop
Browse files Browse the repository at this point in the history
Join Announcements
  • Loading branch information
MitchTalmadge authored Mar 30, 2021
2 parents 704943a + 28b32af commit 616108f
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/controllers/channel/course-selection.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import * as Discord from "discord.js";
import _ from "lodash";
import { Course } from "models/course";
import { CourseImplementChannelType } from "models/implement/course";
import { Major } from "models/major";
import { CourseService } from "services/course";
import { CourseImplementService } from "services/implement/course/implement";
import { MemberUpdateService } from "services/member-update";
import { CourseUtils } from "utils/course";
import { DiscordMessageUtils } from "utils/discord-message";
Expand All @@ -21,9 +23,22 @@ export class CourseSelectionChannelController extends ChannelController {
} else {
DiscordMessageUtils.sendMessage(message.channel, `Success! ${message.author}, I have added you to the following courses: ${validCourseNames.join(", ")}.`);
}

for(let course of result.validCourses) {
CourseImplementService.getCourseImplementIfExists(this.guildContext, course)
.then(implement => {
if (implement) {
const courseChannel = this.guildContext.guild.channels.resolve(implement.channelIds[CourseImplementChannelType.CHAT]) as Discord.TextChannel;
courseChannel?.send(`Welcome, ${message.author}!`);
}
})
.catch(err => {
console.error("Could not get course implement when announcing user course join:", err);
});
}
})
.catch(errorMessage => {
DiscordMessageUtils.sendMessage(message.channel, `${errorMessage} Example usage: join cs1410`);
DiscordMessageUtils.sendMessage(message.channel, `${errorMessage} Example usage: join 1410`);
// TODO: Better example.
});
} else if (message.content.toLowerCase().startsWith("leave")) {
Expand All @@ -37,7 +52,7 @@ export class CourseSelectionChannelController extends ChannelController {
}
})
.catch(errorMessage => {
DiscordMessageUtils.sendMessage(message.channel, `${errorMessage} Example usage: leave cs1410`);
DiscordMessageUtils.sendMessage(message.channel, `${errorMessage} Example usage: leave 1410`);
// TODO: Better example.
});
} else if (message.content.toLowerCase().startsWith("ta")) {
Expand All @@ -55,12 +70,12 @@ export class CourseSelectionChannelController extends ChannelController {
});
})
.catch(errorMessage => {
DiscordMessageUtils.sendMessage(message.channel, `${errorMessage} Example usage: ta cs1410`);
DiscordMessageUtils.sendMessage(message.channel, `${errorMessage} Example usage: ta 1410`);
// TODO: Better example.
});
} else {
//TODO: Better example
DiscordMessageUtils.sendMessage(message.channel, `${message.author}, I'm not sure what you want to do. Make sure your request starts with 'join', 'leave', or 'ta'. For example: 'join cs1410'`);
DiscordMessageUtils.sendMessage(message.channel, `${message.author}, I'm not sure what you want to do. Make sure your request starts with 'join', 'leave', or 'ta'. For example: 'join 1410'`);
}
}

Expand Down

0 comments on commit 616108f

Please sign in to comment.