Skip to content

Commit

Permalink
new commands
Browse files Browse the repository at this point in the history
  • Loading branch information
hmbanan666 committed Apr 7, 2024
1 parent 3d5ec79 commit 459337c
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ jobs:

- name: Lint
run: |
npm ci
npm i
npm run lint
4 changes: 4 additions & 0 deletions apps/api/src/bot/bot.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ export class BotController {
this.service.commandGift(),
this.service.commandSell(),
this.service.commandBuy(),
this.service.commandHelp(),
this.service.commandHelpEn(),
this.service.commandDonate(),
this.service.commandDonateEn(),
];
}

Expand Down
47 changes: 47 additions & 0 deletions apps/api/src/bot/bot.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createBotCommand } from "@twurple/easy-bot";
import { DISCORD_SERVER_INVITE_URL, DONATE_URL } from "../config";
import {
addStoneToVillage,
addWoodToVillage,
Expand Down Expand Up @@ -229,4 +230,50 @@ export class BotService {
},
);
}

public commandHelp() {
return createBotCommand(
"помощь",
async (_, { userId, userName, reply }) => {
await this.game.findOrCreatePlayer(userId, userName);

void reply(
`${userName}, это интерактивная игра-чат, в которой может участвовать любой зритель! Пиши команды (примеры на экране) для управления своим героем. Вступай в наше комьюнити: ${DISCORD_SERVER_INVITE_URL}`,
);
return;
},
);
}

public commandHelpEn() {
return createBotCommand("help", async (_, { userId, userName, reply }) => {
await this.game.findOrCreatePlayer(userId, userName);

void reply(
`${userName}, this is an interactive chat game that any viewer can participate in! Write commands (examples on the screen) to control your hero. Join our community: ${DISCORD_SERVER_INVITE_URL}`,
);
return;
});
}

public commandDonate() {
return createBotCommand("донат", async (_, { userId, userName, reply }) => {
await this.game.findOrCreatePlayer(userId, userName);

void reply(`${userName}, поддержи игру: ${DONATE_URL}`);
return;
});
}

public commandDonateEn() {
return createBotCommand(
"donate",
async (_, { userId, userName, reply }) => {
await this.game.findOrCreatePlayer(userId, userName);

void reply(`${userName}, support the game: ${DONATE_URL}`);
return;
},
);
}
}
3 changes: 3 additions & 0 deletions apps/api/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ export const MAX_X = 1300;

export const MIN_Y = 20;
export const MAX_Y = 1200;

export const DONATE_URL = "https://www.donationalerts.com/r/hmbanan666";
export const DISCORD_SERVER_INVITE_URL = "https://discord.gg/B6etUajrGZ";

0 comments on commit 459337c

Please sign in to comment.