-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: progress * chore: blaming regex. permalink: http://whatthecommit.com/7eaa73b94ca6e8f964d99b6f2db6e9e4 * chore: permalink: * chore: lol * chore: accidental commit permalink: http://whatthecommit.com/7c6c9323d8c243d10cd93c8bbbc55d09 * fix syntx * fix list not showing up * prety * chore: refresh lockfile * chore: progress * fix list not showing up * refactor: cleanup some mess * Update preprocessor.ts --------- Co-authored-by: Jacob Nguyen <[email protected]>
- Loading branch information
1 parent
42bd528
commit 5fd2a7b
Showing
5 changed files
with
124 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { blueBright, bold, cyanBright, greenBright, italic, magentaBright, underline } from 'colorette'; | ||
import { getSern } from '../utilities/getSern'; | ||
import { readFileSync } from 'node:fs'; | ||
import type { CommandData, GuildId } from '../utilities/types'; | ||
|
||
export function list() { | ||
const files = getSern(); | ||
if (!files.includes('command-data-remote.json')) { | ||
console.error(`No commands found\nPlease run ${cyanBright('sern commands publish')} to publish your commands`); | ||
process.exit(1); | ||
} | ||
|
||
const commands: Record<GuildId, CommandData[]> = JSON.parse(readFileSync('.sern/command-data-remote.json', 'utf-8')); | ||
const globalCommands = commands.global; | ||
|
||
delete commands.global; | ||
console.log(bold('Global Commands')); | ||
for (const command of globalCommands) log(command); | ||
|
||
console.log('\t'); | ||
|
||
for (const guildId in commands) { | ||
const guildCommands = commands[guildId]; | ||
console.log(`${bold('Guild Commands')} [${underline(cyanBright(guildId))}]`); | ||
for (const command of guildCommands) log(command); | ||
} | ||
} | ||
|
||
const AppCommandsType: Record<number, string> = { | ||
1: magentaBright('Slash'), | ||
2: magentaBright('User'), | ||
3: magentaBright('Message'), | ||
}; | ||
|
||
const AppCommandOptionType: Record<number, string> = { | ||
1: magentaBright('SubCommand'), | ||
2: magentaBright('SubCommand Group'), | ||
3: magentaBright('String'), | ||
4: magentaBright('Integer'), | ||
5: magentaBright('Boolean'), | ||
6: magentaBright('User'), | ||
7: magentaBright('Channel'), | ||
8: magentaBright('Role'), | ||
9: magentaBright('Mentionable'), | ||
10: magentaBright('Number'), | ||
11: magentaBright('Attachment'), | ||
}; | ||
|
||
function log(command: CommandData) { | ||
console.log(clean(`\t${cyanBright(command.name)} ${italic(command.description)} (${greenBright(command.id)})`)); | ||
console.log(`\t Type: ${AppCommandsType[command.type]}`); | ||
|
||
if (command.options) { | ||
console.log(`\t Options:`); | ||
for (const option of command.options) { | ||
console.log(`\t ${blueBright(option.name)}: ${AppCommandOptionType[option.type]}`); | ||
if (option.options) { | ||
console.log(`\t Options:`); | ||
for (const subOption of option.options) { | ||
console.log(`\t ${cyanBright(subOption.name)}: ${AppCommandOptionType[subOption.type]}`); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
const clean = (str: string) => str.split(' ').filter(Boolean).join(' '); |
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,17 @@ | ||
import { readdirSync } from 'node:fs'; | ||
import { fromCwd } from './fromCwd'; | ||
import { redBright, cyanBright } from 'colorette'; | ||
|
||
export function getSern() { | ||
let files: string[] = []; | ||
|
||
try { | ||
const sern = fromCwd('.sern'); | ||
files = readdirSync(sern); | ||
} catch (error) { | ||
console.error(`${redBright('Error:')} Could not locate ${cyanBright('.sern')} directory`); | ||
process.exit(1); | ||
} finally { | ||
return files; | ||
} | ||
} |
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 +1,35 @@ | ||
export type PackageManagerChoice = 'skip' | 'npm' | 'yarn'; | ||
|
||
export type GuildId = string; | ||
|
||
export interface CommandData { | ||
id: string; | ||
application_id: string; | ||
version: string; | ||
default_member_permissions?: string; | ||
type: number; | ||
name: string; | ||
name_localizations?: Record<string, string>; | ||
description: string; | ||
description_localizations?: Record<string, string>; | ||
dm_permission: boolean; | ||
guild_id: string; | ||
nsfw: boolean; | ||
options?: OptionData[]; | ||
} | ||
|
||
interface OptionData { | ||
type: number; | ||
name: string; | ||
name_localizations?: Record<string, string>; | ||
description: string; | ||
description_localizations?: Record<string, string>; | ||
required?: boolean; | ||
choices?: ChoiceData[]; | ||
options?: OptionData[]; | ||
} | ||
|
||
interface ChoiceData { | ||
name: string; | ||
value: string | number; | ||
} |