Skip to content

Commit 7f1faed

Browse files
authored
Always ping Mod in Convene Mods, fix Track for new message types (#80)
1 parent 1f44e06 commit 7f1faed

File tree

14 files changed

+10935
-9784
lines changed

14 files changed

+10935
-9784
lines changed

.github/workflows/node.js.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
- run: npm ci
6363

6464
- name: Run vitest
65-
run: npm run test -- --coverage
65+
run: npm run test
6666

6767
build:
6868
runs-on: ubuntu-latest

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ k8s-context
1212
*.sqlite3
1313
/cypress/screenshots
1414
/cypress/videos
15+
tsconfig.tsbuildinfo

app/commands/convene.tsx

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {
2-
ApplicationCommandType,
32
ChannelType,
43
ContextMenuCommandBuilder,
54
PermissionFlagsBits,
@@ -8,6 +7,7 @@ import type {
87
MessageContextMenuCommandInteraction,
98
TextChannel,
109
} from "discord.js";
10+
import { ApplicationCommandType } from "discord-api-types/v10";
1111

1212
import { reacord } from "~/discord/client.server";
1313
import { quoteAndEscape } from "~/helpers/discord";
@@ -16,7 +16,7 @@ import { resolutions } from "~/helpers/modResponse";
1616

1717
import { fetchSettings, SETTINGS } from "~/models/guilds.server";
1818
import { applyRestriction, ban, kick, timeout } from "~/models/discord.server";
19-
import { Confirmation, ModResponse } from "~/commands/reacord/ModResponse";
19+
import { ModResponse } from "~/commands/reacord/ModResponse";
2020

2121
export const command = new ContextMenuCommandBuilder()
2222
.setName("Convene mods")
@@ -157,15 +157,6 @@ This isn't a formal warning, but your message concerned the moderators enough th
157157
);
158158
return;
159159

160-
case resolutions.okay:
161-
reportUser({
162-
reason: ReportReasons.mod,
163-
message,
164-
staff,
165-
extra: "✅ Determined to be okay",
166-
});
167-
return;
168-
169160
case resolutions.track:
170161
reportUser({
171162
reason: ReportReasons.track,
@@ -190,15 +181,8 @@ This isn't a formal warning, but your message concerned the moderators enough th
190181
);
191182

192183
// reply
193-
const ackInstance = reacord.ephemeralReply(
194-
interaction,
195-
<Confirmation
196-
modRoleId={moderator}
197-
thread={thread}
198-
onNotify={() => {
199-
ackInstance.render("Mods notified");
200-
ackInstance.deactivate();
201-
}}
202-
/>,
203-
);
184+
await interaction.reply({
185+
content: `Discussion thread created <#${thread.id}>`,
186+
ephemeral: true,
187+
});
204188
};

app/commands/demo.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import type { CommandInteraction } from "discord.js";
2-
import {
3-
ApplicationCommandType,
4-
ContextMenuCommandBuilder,
5-
SlashCommandBuilder,
6-
} from "discord.js";
2+
import { ContextMenuCommandBuilder, SlashCommandBuilder } from "discord.js";
3+
import { ApplicationCommandType } from "discord-api-types/v10";
74

85
export const command = new SlashCommandBuilder()
96
.setName("demo")

app/commands/reacord/ModResponse.tsx

Lines changed: 7 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
import type { AnyThreadChannel } from "discord.js";
21
import type { UserInfo } from "reacord";
32
import { Button } from "reacord";
43

54
import type { Resolution } from "~/helpers/modResponse";
6-
import { humanReadableResolutions } from "~/helpers/modResponse";
7-
import { resolutions, useVotes } from "~/helpers/modResponse";
5+
import {
6+
humanReadableResolutions,
7+
resolutions,
8+
useVotes,
9+
} from "~/helpers/modResponse";
810

911
const VOTES_TO_APPROVE = 3;
1012

@@ -55,18 +57,13 @@ export const ModResponse = ({
5557

5658
return (
5759
<>
58-
{`After ${votesRequired} or more votes, the leading resolution will be automatically enforced.`}
60+
{`After ${votesRequired} or more votes, the leading resolution will be automatically enforced. <@&${modRoleId}> please respond.`}
5961
{/* TODO: show vote in progress, reveal votes and unvoted mods */}
60-
{renderButton(
61-
votes,
62-
resolutions.okay,
63-
humanReadableResolutions[resolutions.okay],
64-
"success",
65-
)}
6662
{renderButton(
6763
votes,
6864
resolutions.track,
6965
humanReadableResolutions[resolutions.track],
66+
"success",
7067
)}
7168
{renderButton(
7269
votes,
@@ -103,29 +100,3 @@ export const ModResponse = ({
103100
</>
104101
);
105102
};
106-
107-
export const Confirmation = ({
108-
thread,
109-
modRoleId,
110-
onNotify,
111-
}: {
112-
thread: AnyThreadChannel;
113-
modRoleId: string;
114-
onNotify: () => void;
115-
}) => {
116-
return (
117-
<>
118-
Discussion thread created
119-
<Button
120-
label="Notify mods"
121-
style="success"
122-
onClick={async (event) => {
123-
await thread.send(
124-
`<@${event.user.id}> indicated this is urgent. <@&${modRoleId}> please respond`,
125-
);
126-
await onNotify();
127-
}}
128-
/>
129-
</>
130-
);
131-
};

app/commands/report.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { MessageContextMenuCommandInteraction } from "discord.js";
2-
import { PermissionFlagsBits } from "discord.js";
3-
import { ApplicationCommandType, ContextMenuCommandBuilder } from "discord.js";
2+
import { PermissionFlagsBits, ContextMenuCommandBuilder } from "discord.js";
3+
import { ApplicationCommandType } from "discord-api-types/v10";
44
import { ReportReasons, reportUser } from "~/helpers/modLog";
55

66
export const command = new ContextMenuCommandBuilder()

app/commands/setup.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import type { ChatInputCommandInteraction } from "discord.js";
2-
import { PermissionFlagsBits } from "discord.js";
3-
import { SlashCommandBuilder } from "discord.js";
2+
import { PermissionFlagsBits, SlashCommandBuilder } from "discord.js";
43

54
import { SETTINGS, setSettings, registerGuild } from "~/models/guilds.server";
65

app/commands/track.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { MessageContextMenuCommandInteraction } from "discord.js";
2-
import { PermissionFlagsBits } from "discord.js";
3-
import { ApplicationCommandType, ContextMenuCommandBuilder } from "discord.js";
2+
import { PermissionFlagsBits, ContextMenuCommandBuilder } from "discord.js";
3+
import { ApplicationCommandType } from "discord-api-types/v10";
44
import { Button } from "reacord";
55
import { reacord } from "~/discord/client.server";
66

app/helpers/discord.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import type {
88
MessageContextMenuCommandInteraction,
99
UserContextMenuCommandInteraction,
1010
ChatInputCommandInteraction,
11+
Poll,
1112
} from "discord.js";
1213
import {
1314
ApplicationCommandType,
@@ -103,6 +104,12 @@ export const quoteAndEscape = (content: string) => {
103104
return escapeDisruptiveContent(quoteMessageContent(content));
104105
};
105106

107+
export const quoteAndEscapePoll = (poll: Poll) => {
108+
return `Poll:
109+
> ${poll.question.text}
110+
${poll.answers.map((a) => `> - ${a.text}`).join("\n")}`;
111+
};
112+
106113
//
107114
// Types and type helpers for command configs
108115
//

app/helpers/discordCommands.test.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import { calculateChangedCommands, compareCommands } from "./discordCommands";
22

3-
import {
4-
ApplicationCommandType,
5-
ContextMenuCommandBuilder,
6-
SlashCommandBuilder,
7-
} from "discord.js";
3+
import { ContextMenuCommandBuilder, SlashCommandBuilder } from "discord.js";
4+
import { ApplicationCommandType } from "discord-api-types/v10";
85

96
const l = {
107
slashCommand: new SlashCommandBuilder()

0 commit comments

Comments
 (0)