Skip to content

Commit

Permalink
GH-178: Do not send message with "." when accepting a duel
Browse files Browse the repository at this point in the history
  • Loading branch information
utarwyn committed Aug 30, 2022
1 parent 767554f commit a93d2c8
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
1 change: 0 additions & 1 deletion src/bot/entity/DuelRequest.ts
Expand Up @@ -181,7 +181,6 @@ export default class DuelRequest {
*/
private async challengeAnswered(accepted: boolean): Promise<void> {
if (accepted) {
await this.tunnel.end();
await this.manager.createGame(this.tunnel, this.invited);
} else {
return this.tunnel.end({
Expand Down
10 changes: 6 additions & 4 deletions src/bot/messaging/CommandInteractionMessagingTunnel.ts
Expand Up @@ -68,9 +68,11 @@ export default class CommandInteractionMessagingTunnel extends MessagingTunnel {
}

this._reply = (await this.interaction.reply({
components: [],
embeds: [],
...answer,
fetchReply: true,
ephemeral: direct
ephemeral: direct,
fetchReply: true
})) as Message;

return this._reply;
Expand All @@ -88,10 +90,10 @@ export default class CommandInteractionMessagingTunnel extends MessagingTunnel {
/**
* @inheritdoc
*/
public async end(reason?: MessagingAnswer): Promise<void> {
public async end(reason: MessagingAnswer): Promise<void> {
if (this.reply) {
try {
await this.editReply(reason ?? { content: '.', components: [], embeds: [] });
await this.editReply(reason);
await this.reply.reactions.removeAll();
} catch {
// ignore api error
Expand Down
6 changes: 4 additions & 2 deletions src/bot/messaging/ComponentInteractionMessagingTunnel.ts
Expand Up @@ -67,6 +67,8 @@ export default class ComponentInteractionMessagingTunnel extends MessagingTunnel
await this.interaction.editReply(answer);
} else {
this._reply = (await this.interaction.update({
components: [],
embeds: [],
...answer,
fetchReply: true
})) as Message;
Expand All @@ -85,9 +87,9 @@ export default class ComponentInteractionMessagingTunnel extends MessagingTunnel
/**
* @inheritdoc
*/
public async end(reason?: MessagingAnswer): Promise<void> {
public async end(reason: MessagingAnswer): Promise<void> {
try {
await this.editReply(reason ?? { content: '.', components: [], embeds: [] });
await this.editReply(reason);
await (this.interaction.message as Message).reactions.removeAll();
} catch (e) {
// ignore api error
Expand Down
2 changes: 1 addition & 1 deletion src/bot/messaging/MessagingTunnel.ts
Expand Up @@ -53,5 +53,5 @@ export default abstract class MessagingTunnel {
*
* @param reason reason of the tunnel ending
*/
public abstract end(reason?: MessagingAnswer): Promise<void>;
public abstract end(reason: MessagingAnswer): Promise<void>;
}
6 changes: 2 additions & 4 deletions src/bot/messaging/TextMessagingTunnel.ts
Expand Up @@ -75,7 +75,7 @@ export default class TextMessagingTunnel extends MessagingTunnel {
/**
* @inheritdoc
*/
public async end(reason?: MessagingAnswer): Promise<void> {
public async end(reason: MessagingAnswer): Promise<void> {
if (this.reply) {
if (this.reply.deletable) {
try {
Expand All @@ -84,9 +84,7 @@ export default class TextMessagingTunnel extends MessagingTunnel {
// ignore api error
}
}
if (reason) {
await this.channel.send(reason);
}
await this.channel.send(reason);
this._reply = undefined;
}
}
Expand Down

0 comments on commit a93d2c8

Please sign in to comment.