-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9abe91f
commit ca1c399
Showing
8 changed files
with
288 additions
and
203 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import Logger, { CommandDefinition, makeEmbed, makeLines, InputCommandOptions } from '../../lib'; | ||
import { CommandCategory, ResponseType } from '../../constants'; | ||
import { throws } from 'assert'; | ||
|
||
const repos = new Map ([ | ||
['org', 'https://github.com/owddm/org'], | ||
['site','https://github.com/owddm/owddm.com'], | ||
['data', 'https://github.com/owddm/public'], | ||
['bot', 'https://github.com/owddm/discord-bot'], | ||
['accounting', 'https://github.com/owddm/accounting'], | ||
['survey', 'https://github.com/owddm/survey'], | ||
['presentations', 'https://github.com/owddm/presentations'], | ||
['legacy_site', 'https://github.com/owddm/owddm.github.io'] | ||
]); | ||
|
||
const repoOptions: InputCommandOptions[] = [{ | ||
name: 'repo', | ||
description: 'enter a valid repo name to get it\'s url' | ||
}]; | ||
|
||
function getRepoUrl(option: string): string { | ||
const repo = repos.get(option); | ||
if (repo === undefined) { | ||
throw Object.assign(new Error(`Error: ${option} not found`), {code: 404}); | ||
} | ||
|
||
return repo; | ||
} | ||
|
||
const errorEmbed = makeEmbed({ | ||
title: '🚫 Error: Repository not found', | ||
description: makeLines([ | ||
'The indicated repository wasn\'t found, please enter one of the following repositories: ', | ||
'', | ||
'• org', | ||
'', | ||
'• site', | ||
'', | ||
'• data', | ||
'', | ||
'• bot', | ||
'', | ||
'• accounting', | ||
'', | ||
'• survey', | ||
'', | ||
'• presentations', | ||
'', | ||
'• legacy_site' | ||
]) | ||
}); | ||
|
||
|
||
export const repo: CommandDefinition = { | ||
name: 'repo', | ||
options: repoOptions, | ||
description: 'Fetch one of the OWDDM repos.', | ||
category: CommandCategory.GENERAL, | ||
response: ResponseType.EDIT, | ||
interaction: async (interaction) => { | ||
const input = interaction.options.getString(repoOptions[0].name)?.trim() ?? 'no text provided'; | ||
|
||
try { | ||
const response = getRepoUrl(input); | ||
|
||
interaction.reply({ | ||
content: response | ||
}); | ||
} catch (error) { | ||
interaction.reply({ | ||
embeds: [errorEmbed] | ||
}); | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,23 @@ | ||
import Logger, { CommandDefinition } from "../lib"; | ||
import Logger, { CommandDefinition } from '../lib'; | ||
import { cowsay } from './memes/cowsay'; | ||
import { chatgpt } from "./general/chatgpt"; | ||
import { chatgpt } from './general/chatgpt'; | ||
import { roleSelect } from './moderation/role_assignment'; | ||
import { repo } from './general/repo'; | ||
|
||
export const commands: CommandDefinition[] = [ | ||
cowsay, | ||
chatgpt, | ||
roleSelect, | ||
] | ||
cowsay, | ||
chatgpt, | ||
roleSelect, | ||
repo, | ||
]; | ||
|
||
const commandsObject: { [k: string]: CommandDefinition } = {}; | ||
|
||
for (const def of commands) { | ||
for (const name of def.name) { | ||
if (commandsObject[def.name]) { | ||
Logger.warn(`Duplicate command/alias inserted: ${name}`); | ||
} | ||
} | ||
commandsObject[def.name] = def; | ||
for (const name of def.name) { | ||
if (commandsObject[def.name]) { | ||
Logger.warn(`Duplicate command/alias inserted: ${name}`); | ||
} | ||
} | ||
commandsObject[def.name] = def; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.