-
Notifications
You must be signed in to change notification settings - Fork 0
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
535ce9d
commit 2dec220
Showing
16 changed files
with
391 additions
and
429 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
11 changes: 0 additions & 11 deletions
11
packages/bot/src/framework/discord/commands/create-character.ts
This file was deleted.
Oops, something went wrong.
36 changes: 24 additions & 12 deletions
36
packages/bot/src/framework/discord/commands/create-chronicle.ts
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,28 +1,40 @@ | ||
import { type ChronicleGateway } from '../../../gateway/chronicle/types' | ||
import { type ICommand } from '../types' | ||
import { SlashCommandBuilder } from 'discord.js' | ||
import { chronicleMessage } from '../messages/chronicle.js' | ||
import { createChronicle } from '../../../use-case/create-chronicle.js' | ||
|
||
/** | ||
* Handles creating a chronicle (game). This game is tied to the discord server id. | ||
*/ | ||
export default { | ||
name: 'create-chronicle', | ||
description: 'Creates a game.', | ||
title: 'Create Chronicle', | ||
execute( | ||
message, | ||
args: [string, 'vtm', 'v5'], | ||
chronicleGateway: ChronicleGateway | ||
) { | ||
command: new SlashCommandBuilder() | ||
.setName('game') | ||
.setDescription('Creates a new game tied to this Discord server.') | ||
.addStringOption((option) => | ||
option.setName('name').setDescription('Name of game').setRequired(true) | ||
) | ||
.addStringOption((option) => | ||
option | ||
.setName('type') | ||
.setDescription('Type of game') | ||
.setRequired(true) | ||
.addChoices({ name: 'VtM - v5', value: 'vtm' }) | ||
), | ||
execute(interaction, chronicleGateway: ChronicleGateway) { | ||
// Using a TypeGuard here but not sure it should ever get that far?> | ||
// Might be better to make ICommand a generic | ||
if (!interaction.isChatInputCommand()) { | ||
return | ||
} | ||
// For each command, we will pass on the fluture but pipe here error results or success results | ||
// then the caller can just return the result | ||
return createChronicle(chronicleGateway)({ | ||
name: args[0], | ||
referenceId: message.guild.id, | ||
name: interaction.options.getString('name', true), | ||
referenceId: interaction.guild.id, | ||
referenceType: 'discord', | ||
game: args[1], | ||
version: args[2], | ||
game: 'vtm', | ||
version: 'v5', | ||
}).map(chronicleMessage) | ||
}, | ||
} as ICommand |
15 changes: 0 additions & 15 deletions
15
packages/bot/src/framework/discord/commands/create-player-character.ts
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,16 +1,6 @@ | ||
// Import all commands here, quick than trying to dynamically load commands with top level await and forcing | ||
// the application to wait to load realtime. | ||
import type { ICommand } from '../types.js' | ||
import createCharacter from './create-character.js' | ||
import createChronicle from './create-chronicle.js' | ||
import createPlayerCharacter from './create-player-character.js' | ||
import help from './help.js' | ||
import roll from './roll.js' | ||
|
||
export const all: ICommand[] = [ | ||
createCharacter, | ||
createChronicle, | ||
createPlayerCharacter, | ||
help, | ||
roll, | ||
] | ||
export const all: ICommand[] = [createChronicle] |
This file was deleted.
Oops, something went wrong.
17 changes: 0 additions & 17 deletions
17
packages/bot/src/framework/discord/commands/update-character.ts
This file was deleted.
Oops, something went wrong.
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,27 @@ | ||
import { REST, Routes } from 'discord.js' | ||
import { commands } from './configurations.js' | ||
|
||
const { DISCORD_TOKEN, DISCORD_CLIENT_ID, DISCORD_GUILD_ID } = process.env | ||
|
||
const rest = new REST().setToken(DISCORD_TOKEN) | ||
|
||
const slashCommands = commands.map((command) => command.command.toJSON()) | ||
|
||
;(async () => { | ||
try { | ||
console.log(`Started refreshing ${commands.size} application (/) commands.`) | ||
|
||
// The put method is used to fully refresh all commands in the guild with the current set | ||
const data = (await rest.put( | ||
Routes.applicationGuildCommands(DISCORD_CLIENT_ID, DISCORD_GUILD_ID), | ||
{ body: slashCommands } | ||
)) as Array<unknown> | ||
|
||
console.log( | ||
`Successfully reloaded ${data.length} application (/) commands.` | ||
) | ||
} catch (error) { | ||
// And of course, make sure you catch and log any errors! | ||
console.error(error) | ||
} | ||
})() |
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.