Skip to content

Commit

Permalink
GH-204: Add custom message if trying to duel a bot
Browse files Browse the repository at this point in the history
  • Loading branch information
utarwyn committed Apr 1, 2022
1 parent fa1a9a9 commit cfe978a
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 8 deletions.
1 change: 1 addition & 0 deletions config/locales/de.json
Expand Up @@ -10,6 +10,7 @@
"expire": ":x: `{invited}` ist nicht zum Match angetreten.",
"reject": ":x: `{invited}` hat das Match abgelehnt.",
"unknown-user": "Du kannst diesen User nicht herausfordern.",
"no-bot": "you cannot challenge bots.",
"button": {
"accept": "Akzeptieren",
"decline": "Ablehnen"
Expand Down
1 change: 1 addition & 0 deletions config/locales/en.json
Expand Up @@ -10,6 +10,7 @@
"expire": ":x: `{invited}` did not rise up to the challenge.",
"reject": ":x: `{invited}` has rejected the duel.",
"unknown-user": "you cannot challenge that user.",
"no-bot": "you cannot challenge bots.",
"button": {
"accept": "Accept",
"decline": "Decline"
Expand Down
1 change: 1 addition & 0 deletions config/locales/es.json
Expand Up @@ -10,6 +10,7 @@
"expire": ":x: `{invited}` no se puso a la altura del desafío.",
"reject": ":x: `{invited}` ha rechazado el duelo.",
"unknown-user": "no pudiste desafiar a ese usuario.",
"no-bot": "you cannot challenge bots.",
"button": {
"accept": "Aceptar",
"decline": "Rechazar"
Expand Down
1 change: 1 addition & 0 deletions config/locales/fr.json
Expand Up @@ -10,6 +10,7 @@
"expire": ":x: `{invited}` n'a pas répondu à la demande dans les temps.",
"reject": ":x: `{invited}` a rejeté votre proposition de duel.",
"unknown-user": "vous ne pouvez pas défier ce membre.",
"no-bot": "vous ne pouvez pas défier un robot.",
"button": {
"accept": "Accepter",
"decline": "Décliner"
Expand Down
1 change: 1 addition & 0 deletions config/locales/it.json
Expand Up @@ -10,6 +10,7 @@
"expire": ":x: `{invited}` non ha risposto.",
"reject": ":x: `{invited}` non ha accettato.",
"unknown-user": "non puoi sfidare questo utente.",
"no-bot": "you cannot challenge bots.",
"button": {
"accept": "Accettare",
"decline": "Rifiutare"
Expand Down
1 change: 1 addition & 0 deletions config/locales/nl.json
Expand Up @@ -10,6 +10,7 @@
"expire": ":x: `{invited}` heeft te laat gereageerd!",
"reject": ":x: `{invited}` heeft het spel geweigerd!",
"unknown-user": "Je kan dit lid niet uitdagen!",
"no-bot": "you cannot challenge bots.",
"button": {
"accept": "Accepteren",
"decline": "Refuse"
Expand Down
1 change: 1 addition & 0 deletions config/locales/pl.json
Expand Up @@ -10,6 +10,7 @@
"expire": ":x: `{invited}` nie odpowiedział na zaproszenie do pojedynku.",
"reject": ":x: `{invited}` odrzucił zaproszenie do pojedynku.",
"unknown-user": "nie możesz wyzwać na pojedynek tego użytkownika.",
"no-bot": "you cannot challenge bots.",
"button": {
"accept": "Akceptuj",
"decline": "Odmawiający"
Expand Down
1 change: 1 addition & 0 deletions config/locales/pt-br.json
Expand Up @@ -10,6 +10,7 @@
"expire": ":x: `{invited}` não apareceu para o duelo.",
"reject": ":x: `{invited}` rejeitou o duelo.",
"unknown-user": "você não pode desafiar este usuário.",
"no-bot": "you cannot challenge bots.",
"button": {
"accept": "Accept",
"decline": "Decline"
Expand Down
1 change: 1 addition & 0 deletions config/locales/ru.json
Expand Up @@ -10,6 +10,7 @@
"expire": ":x: `{invited}` Не ответил на Ваше предложение.",
"reject": ":x: `{invited}` Отклонил вызов на игру.",
"unknown-user": "Вы не можете вызвать данного игрока **{username}**. Пожалуйста линканите другого пользователя.",
"no-bot": "you cannot challenge bots.",
"button": {
"accept": "Принять",
"decline": "отказывать"
Expand Down
1 change: 1 addition & 0 deletions config/locales/vi.json
Expand Up @@ -10,6 +10,7 @@
"expire": ":x: `{invited}` đã không phản hồi gì về lời mời của bạn",
"reject": ":x: `{invited}` đã từ chối lời mời của bạn.",
"unknown-user": "Bạn không thể thách đấu **{username}**. Hãy mention một người khác.",
"no-bot": "you cannot challenge bots.",
"button": {
"accept": "Accept",
"decline": "Decline"
Expand Down
18 changes: 10 additions & 8 deletions src/bot/command/GameCommand.ts
Expand Up @@ -86,7 +86,6 @@ export default class GameCommand {
* or requesting a duel between two members.
*
* @param tunnel game messaging tunnel
* @param channel
* @param inviter discord.js inviter member instance
* @param invited discord.js invited member instance, can be undefined to play against AI
*/
Expand All @@ -96,14 +95,17 @@ export default class GameCommand {
invited?: GuildMember
): Promise<void> {
if (invited) {
if (
!invited.user.bot &&
inviter.user.id !== invited.user.id &&
invited.permissionsIn(tunnel.channel).has('VIEW_CHANNEL')
) {
await this.manager.requestDuel(tunnel, invited);
if (!invited.user.bot) {
if (
inviter.user.id !== invited.user.id &&
invited.permissionsIn(tunnel.channel).has('VIEW_CHANNEL')
) {
await this.manager.requestDuel(tunnel, invited);
} else {
await tunnel.replyWith({ content: localize.__('duel.unknown-user') }, true);
}
} else {
await tunnel.replyWith({ content: localize.__('duel.unknown-user') }, true);
await tunnel.replyWith({ content: localize.__('duel.no-bot') }, true);
}
} else {
await this.manager.createGame(tunnel);
Expand Down

0 comments on commit cfe978a

Please sign in to comment.