Skip to content

Commit 5221ed6

Browse files
committed
refactor: remove typescript error suppression
1 parent e43c58f commit 5221ed6

File tree

5 files changed

+4
-11
lines changed

5 files changed

+4
-11
lines changed

src/listeners/discord/interaction_create/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export default async (interaction: Interaction) => {
2222
if (actionName in allCommands) {
2323
allCommands[actionName].action(interaction);
2424
} else {
25-
// @ts-expect-error - Discord API type incompatibility
2625
await interaction.reply("無法存取該指令");
2726
}
2827
};

src/listeners/discord/message_create/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,9 @@ const processChat = async (message: Message, content: string) => {
7272
return hey(message).say("所收到的訊息意圖不明。");
7373
}
7474

75-
// @ts-expect-error - Discord.js type compatibility
76-
await message.channel.sendTyping();
75+
if ("sendTyping" in message.channel) {
76+
await message.channel.sendTyping();
77+
}
7778

7879
try {
7980
const response = await chatWithAI(message.channel.id, content);
@@ -115,8 +116,7 @@ const processTranslation = async (message: Message, content: string) => {
115116
content, langs || undefined,
116117
);
117118

118-
if (translated && translated !== content) {
119-
// @ts-expect-error - Discord.js type compatibility
119+
if (translated && translated !== content && "send" in message.channel) {
120120
message.channel.send(`🌐> ${translated}`);
121121
}
122122
} catch (err) {

src/listeners/line/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export const prepare = async () => {
2020
const client = useClient();
2121

2222
const showStartupMessage = async () => {
23-
// @ts-expect-error - LINE SDK type compatibility
2423
const {displayName, basicId} = await client.getBotInfo();
2524
console.info(`LINE 身份:${displayName} (${basicId})`);
2625
};

src/listeners/line/message/index.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export default async (event: MessageEvent) => {
2020
const {
2121
type: sourceType,
2222
} = source;
23-
// @ts-expect-error - LINE SDK type compatibility
2423
const {
2524
quoteToken,
2625
text: messageText,
@@ -40,7 +39,6 @@ export default async (event: MessageEvent) => {
4039
}
4140

4241
if (!requestContent) {
43-
// @ts-expect-error - LINE API type compatibility
4442
await client.replyMessage({
4543
replyToken,
4644
messages: [{
@@ -58,7 +56,6 @@ export default async (event: MessageEvent) => {
5856
responseContent = await chatWithAI(sourceId, requestContent);
5957
} catch (error) {
6058
console.error(error);
61-
// @ts-expect-error - LINE API type compatibility
6259
await client.replyMessage({
6360
replyToken,
6461
messages: [{
@@ -72,7 +69,6 @@ export default async (event: MessageEvent) => {
7269

7370
responseContent = responseContent.trim();
7471
if (!responseContent) {
75-
// @ts-expect-error - LINE API type compatibility
7672
await client.replyMessage({
7773
replyToken,
7874
messages: [{

src/routes/line.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ const dispatcher = useDispatcher();
2020
const middlewareHandler = (req: Request, res: Response, next: NextFunction) => middleware(req, res, next);
2121

2222
router.post("/webhook", middlewareHandler, (req: Request, res: Response) => {
23-
// @ts-expect-error - Express req.body type
2423
Promise.all(req.body.events.map(dispatcher))
2524
.then((result) => res.json(result))
2625
.catch((err) => {

0 commit comments

Comments
 (0)