Skip to content

Commit

Permalink
fix: "Show message in chat" button not working for some commands.
Browse files Browse the repository at this point in the history
  • Loading branch information
vxern committed Jan 14, 2024
1 parent e8c56e2 commit bdf986b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "logos",
"description": "A multi-purpose community bot built to cater to language-learning communities on Discord.",
"license": "ISC",
"version": "3.42.0",
"version": "3.42.1",
"type": "module",
"keywords": [
"discord",
Expand Down
2 changes: 1 addition & 1 deletion src/lib/commands/moderation/commands/rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ async function handleCiteRule([client, bot]: [Client, Discord.Bot], interaction:
return;
}

const show = interaction.show ?? showParameter;
const show = interaction.show ?? showParameter ?? false;
const locale = show ? interaction.guildLocale : interaction.locale;

const ruleId = rules.at(ruleIndex);
Expand Down
7 changes: 6 additions & 1 deletion src/lib/commands/music/commands/now.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ async function handleDisplayCurrentlyPlaying(
[client, bot]: [Client, Discord.Bot],
interaction: Logos.Interaction,
): Promise<void> {
const [{ collection, show }] = parseArguments(interaction.data?.options, { collection: "boolean", show: "boolean" });
const [{ collection, show: showParameter }] = parseArguments(interaction.data?.options, {
collection: "boolean",
show: "boolean",
});

const show = interaction.show ?? showParameter ?? false;
const locale = show ? interaction.guildLocale : interaction.locale;

const guildId = interaction.guildId;
Expand Down
13 changes: 11 additions & 2 deletions src/lib/commands/social/commands/profile/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Client, autocompleteMembers, localise, resolveInteractionToMember } fro
import { Praise } from "../../../../database/praise";
import { User } from "../../../../database/user";
import { Warning } from "../../../../database/warning";
import { parseArguments, reply } from "../../../../interactions";
import { getShowButton, parseArguments, reply } from "../../../../interactions";
import { OptionTemplate } from "../../../command";
import { show, user } from "../../../parameters";

Expand Down Expand Up @@ -35,7 +35,9 @@ async function handleDisplayProfile(
[client, bot]: [Client, Discord.Bot],
interaction: Logos.Interaction,
): Promise<void> {
const [{ user, show }] = parseArguments(interaction.data?.options, { show: "boolean" });
const [{ user, show: showParameter }] = parseArguments(interaction.data?.options, { show: "boolean" });

const show = interaction.show ?? showParameter ?? false;
const locale = show ? interaction.guildLocale : interaction.locale;

const member = resolveInteractionToMember(
Expand Down Expand Up @@ -149,6 +151,12 @@ async function handleDisplayProfile(
sent: localise(client, "profile.options.view.strings.information.description.sent", locale)(),
};

const showButton = getShowButton(client, interaction, { locale });

const components: Discord.ActionRow[] | undefined = show
? undefined
: [{ type: Discord.MessageComponentTypes.ActionRow, components: [showButton] }];

reply(
[client, bot],
interaction,
Expand Down Expand Up @@ -184,6 +192,7 @@ async function handleDisplayProfile(
],
},
],
components,
},
{ visible: show },
);
Expand Down

0 comments on commit bdf986b

Please sign in to comment.