-
Notifications
You must be signed in to change notification settings - Fork 6
refactor: index.tsのclient.onを分割し、マジックナンバーを削減 #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 6 commits
4a1abbf
1f767bc
c59b0e5
a13a42f
6bb0ffc
9b3403d
8c2e4ab
a04631c
d732ca2
5904f22
9303e4e
eee0d04
4683c14
af5e7bd
9873435
f5a897f
1862bd3
8376d55
1a8cb58
965c1a9
f555f67
f3895f7
30e7015
6b416a2
451bae5
98a5d73
0bb1166
c7c47eb
8e9e446
49ba0de
4a02dcf
6fddf90
a31abb9
7822495
19b88a5
2bfc777
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import dotenv from "dotenv" | ||
|
|
||
| dotenv.config() | ||
|
|
||
| export const env = { | ||
| tokens: { | ||
| discordToken: process.env.DISCORD_TOKEN | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import type { MessageReaction, PartialMessageReaction, User, PartialUser } from "discord.js"; | ||
|
|
||
| import addReactionRole from "../../services/reactionRole/addReactionRole"; | ||
|
|
||
| export default async function onMessageReactionAdd(reaction: MessageReaction | PartialMessageReaction, user: User | PartialUser) { | ||
| const message = reaction.message; | ||
| const member = message?.guild?.members.resolve(user.id); | ||
|
|
||
| console.log("[INFO] messageReactionAdded"); | ||
| console.log(` -> message: ${message.content?.toString()}`); | ||
| console.log(` -> member : ${member?.displayName}`); | ||
|
|
||
| if (!member || !reaction.emoji.name) return; | ||
|
|
||
| console.log(` -> react : ${reaction.emoji.name}`); | ||
|
|
||
| // ReactionRole: ロール付与 | ||
| if (message.id === reactionRoleMessage) { | ||
| try { | ||
| await addReactionRole(member, reaction.emoji.name); | ||
| } catch (e) { | ||
| console.error(e); | ||
| } | ||
| } | ||
| }); | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,25 @@ | ||||||
| import type { MessageReaction, PartialMessageReaction, PartialUser, User } from "discord.js"; | ||||||
| import removeReactionRole from "../../services/reactionRole/removeReactionRole"; | ||||||
|
|
||||||
| export default async function onMessageReactionRemove(reaction: MessageReaction | PartialMessageReaction, user: User | PartialUser) { | ||||||
| const message = reaction.message; | ||||||
| const member = message?.guild?.members.resolve(user.id); | ||||||
|
|
||||||
| console.log("[INFO] messageReactionAdded"); | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Incorrect log message — copy-paste from the "add" handler. The log says ✏️ Proposed fix- console.log("[INFO] messageReactionAdded");
+ console.log("[INFO] messageReactionRemoved");📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| console.log(` -> message: ${message.content?.toString()}`); | ||||||
| console.log(` -> member : ${member?.displayName}`); | ||||||
|
|
||||||
| if (!member || !reaction.emoji.name) return; | ||||||
|
tanahiro2010 marked this conversation as resolved.
|
||||||
|
|
||||||
| console.log(` -> react : ${reaction.emoji.name}`); | ||||||
|
|
||||||
| // ReactionRole: ロール剥奪 | ||||||
| if (message.id === reactionRoleMessage) { | ||||||
| try { | ||||||
| await removeReactionRole(member, reaction.emoji.name); | ||||||
| } catch (e) { | ||||||
| console.error(e); | ||||||
| // この先通知処理も追加 | ||||||
| } | ||||||
| } | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shared root cause: The handler in 🤖 Prompt for AI Agents |
||||||
| } | ||||||
Uh oh!
There was an error while loading. Please reload this page.