Skip to content

Commit

Permalink
Improvements to project file organization, imports
Browse files Browse the repository at this point in the history
This commit improves the organization of source code files and imports. It does not make any changes to the front-end user experience.
  • Loading branch information
ZelnickB committed Jan 19, 2025
1 parent 2232f92 commit 615357b
Show file tree
Hide file tree
Showing 25 changed files with 517 additions and 538 deletions.
6 changes: 3 additions & 3 deletions discordBot/commands/ChatInput/logic/buildinginfo.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { buildingInfo } from '../../common/buildings/embedBuilders.js'
import { buildingQuery } from '../../common/buildings/retrievers.js'
import { BadGatewayError } from '../../../lib/errors.js'
import { buildingQuery } from '../../../../lib/publicAPIs/whereis.js'
import { BadGatewayError } from '../../../../lib/genericErrors.js'
import { buildingInfo } from '../../../embedBuilders.js'

export default async function (interaction) {
const query = interaction.options.get('query').value
Expand Down
14 changes: 7 additions & 7 deletions discordBot/commands/ChatInput/logic/courseinfo.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
import { courseInformation as courseInformationEmbed, departmentInformation as departmentInformationEmbed } from '../../common/courses/embedBuilders.js'
import { courseInformation as getCourseInformation, departmentInformation, CourseNotFoundError } from '../../common/courses/retrievers.js'
import * as courses from '../../../../lib/publicAPIs/courses.js'
import { courseInfo, departmentInfo } from '../../../embedBuilders.js'

export default async function (interaction) {
const idQuery = interaction.options.get('id').value
if (idQuery.includes('.')) {
try {
const courseInformation = await getCourseInformation(idQuery)
const courseInformation = await courses.courseInformation(idQuery)
interaction.reply({
embeds: [courseInformationEmbed(courseInformation)]
embeds: [courseInfo(courseInformation)]
})
} catch (e) {
if (e instanceof CourseNotFoundError) {
if (e instanceof courses.CourseNotFoundError) {
interaction.reply({
content: `**Error:** The specified course ID, \`${idQuery}\`, was not found in the course catalog.`,
ephemeral: true
})
}
}
} else {
if (idQuery in departmentInformation) {
if (idQuery in courses.departmentInformation) {
interaction.reply({
embeds: [departmentInformationEmbed(idQuery, departmentInformation[idQuery])]
embeds: [departmentInfo(idQuery, courses.departmentInformation[idQuery])]
})
} else {
interaction.reply({
Expand Down
6 changes: 3 additions & 3 deletions discordBot/commands/ChatInput/logic/dining.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default async function (interaction) {
})
}
}
} else {
return 0
}
} /* else {
// Area for subcommand groups (unimplemented)
} */
}
7 changes: 3 additions & 4 deletions discordBot/commands/ChatInput/logic/emergency.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import _ from 'lodash'
import { EmbedBuilder } from 'discord.js'
import * as emergency from '../../../../lib/publicAPIs/emergency.js'

Expand Down Expand Up @@ -52,7 +51,7 @@ export default async function (interaction) {
})
}
}
} else {
return 0
}
} /* else {
// Area for subcommand groups (unimplemented)
} */
}
2 changes: 1 addition & 1 deletion discordBot/commands/ChatInput/logic/idcard.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getUserInfo, UnlinkedUserError } from '../../common/whois/retrievers.js'
import { AttachmentBuilder, EmbedBuilder } from 'discord.js'
import { getUserInfo, UnlinkedUserError } from '../../../../lib/userLinks.js'

export default async function (interaction) {
const showIdPhoto = interaction.options.getBoolean('withpicture') !== false
Expand Down
4 changes: 2 additions & 2 deletions discordBot/commands/ChatInput/logic/resetnick.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { getNewNickname } from '../../common/resetnick.js'
import { authorizeServerAndReply } from '../../authorization.js'
import { getAutoNickname } from '../../../../lib/userLinks.js'

export default async function (interaction) {
if (!await authorizeServerAndReply(interaction)) return
const targetUser = interaction.options.get('user').user
const newNickname = await getNewNickname(targetUser)
const newNickname = await getAutoNickname(targetUser)
if (newNickname === false) {
interaction.reply({
content: `**Error:** User <@${targetUser.id}> has not linked a Kerberos account. Their nickname cannot be reset.`,
Expand Down
14 changes: 5 additions & 9 deletions discordBot/commands/ChatInput/logic/searchdir.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
import {
detailSearch,
MultipleDirectoryResultsError,
NoDirectoryResultsError
} from '../../common/directory/retrievers.js'
import { directoryResult, directoryResultList } from '../../common/directory/embedBuilders.js'
import * as webDirectory from '../../../../lib/publicAPIs/webDirectory.js'
import { directoryResult, directoryResultList } from '../../../embedBuilders.js'

export default async function (interaction) {
try {
const result = (await detailSearch(interaction.options.get('query').value))[0]
const result = (await webDirectory.detailSearch(interaction.options.get('query').value))[0]
interaction.reply({
embeds: [await directoryResult(result)]
})
} catch (e) {
if (e instanceof NoDirectoryResultsError) {
if (e instanceof webDirectory.NoDirectoryResultsError) {
interaction.reply({
content: `**Error:** The specified query, \`${interaction.options.get('query').value}\`, returned no directory results.`,
ephemeral: true
})
}
if (e instanceof MultipleDirectoryResultsError) {
if (e instanceof webDirectory.MultipleDirectoryResultsError) {
interaction.reply({
embeds: [await directoryResultList(e.results, interaction.options.get('query').value)],
ephemeral: true
Expand Down
2 changes: 1 addition & 1 deletion discordBot/commands/ChatInput/logic/seeidphoto.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AttachmentBuilder, EmbedBuilder } from 'discord.js'
import * as authorization from '../../authorization.js'
import { readUserConfig } from '../../../../lib/configurationReaders.js'
import { getKerberos, UnlinkedUserError } from '../../common/whois/retrievers.js'
import { getKerberos, UnlinkedUserError } from '../../../../lib/userLinks.js'
import { get as getPhoto } from '../../../../lib/mitDeveloperConnection/peoplePictures.js'

export default async function (interaction) {
Expand Down
2 changes: 1 addition & 1 deletion discordBot/commands/ChatInput/logic/sipbdoor.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EmbedBuilder } from 'discord.js'
import { DateTime } from 'luxon'
import { EmbedBuilder } from 'discord.js'

export default async function (interaction) {
const sipbDoorResponseText = await fetch('https://sipb-door.mit.edu/text').then(res => res.text())
Expand Down
6 changes: 3 additions & 3 deletions discordBot/commands/ChatInput/logic/usersettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export default async function (interaction) {
})
}
}
} else {
return 0
}
} /* else {
// Area for subcommand groups (unimplemented)
} */
}
2 changes: 1 addition & 1 deletion discordBot/commands/ChatInput/logic/whois.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { authorizeServerAndReply, checkUserVerificationAndReply } from '../../authorization.js'
import respond from '../../common/whois/respond.js'
import { respond } from '../../common/whois.js'

export default async function (interaction) {
if (!(await authorizeServerAndReply(interaction) && await checkUserVerificationAndReply(interaction))) return
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { authorizeServerAndReply, checkUserVerificationAndReply } from '../../authorization.js'
import respond from '../../common/whois/respond.js'
import { respond } from '../../common/whois.js'

export default async function (interaction) {
if (!(await authorizeServerAndReply(interaction) && await checkUserVerificationAndReply(interaction))) return
Expand Down
79 changes: 0 additions & 79 deletions discordBot/commands/common/buildings/embedBuilders.js

This file was deleted.

116 changes: 0 additions & 116 deletions discordBot/commands/common/courses/embedBuilders.js

This file was deleted.

Loading

0 comments on commit 615357b

Please sign in to comment.