Skip to content

Commit a143f63

Browse files
committed
bots/asakatsu-bot: fix executor
1 parent 6adf50a commit a143f63

1 file changed

Lines changed: 18 additions & 18 deletions

File tree

bots/asakatsu-bot/lib/executor.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,26 @@ export async function execWithContext(fn: (c: Context) => Promise<void>) {
1313
partials: [Partials.Message, Partials.Channel, Partials.Reaction],
1414
});
1515

16-
const channel = await client.channels.fetch(env.CHANNEL_ID);
17-
if (!channel?.isTextBased()) {
18-
console.error(
19-
"指定チャンネルが見つからないか、テキストチャンネルではありません",
20-
);
21-
return;
22-
}
23-
if (!channel.isSendable()) {
24-
console.error("チャンネルはメッセージ送信不可能です");
25-
return;
26-
}
27-
28-
const ctx: Context = {
29-
env,
30-
channel,
31-
client,
32-
};
33-
3416
client.once("ready", async () => {
3517
try {
18+
const channel = await client.channels.fetch(env.CHANNEL_ID);
19+
if (!channel?.isTextBased()) {
20+
console.error(
21+
"指定チャンネルが見つからないか、テキストチャンネルではありません",
22+
);
23+
return;
24+
}
25+
if (!channel.isSendable()) {
26+
console.error("チャンネルはメッセージ送信不可能です");
27+
return;
28+
}
29+
30+
const ctx: Context = {
31+
env,
32+
channel,
33+
client,
34+
};
35+
3636
await fn(ctx);
3737
} finally {
3838
client.destroy();

0 commit comments

Comments
 (0)