Skip to content

Commit e4d8ee8

Browse files
authored
Merge pull request #38 from neilenns/neilenns/issue37
Include channel name in error messages
2 parents 217bc55 + 3da9481 commit e4d8ee8

File tree

1 file changed

+30
-12
lines changed

1 file changed

+30
-12
lines changed

src/events/threadUpdate.js

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,14 @@ module.exports = {
4949
async execute(oldThread, newThread) {
5050
try {
5151
if (!newThread.manageable) {
52-
logger.error(`No permission to manage thread "${newThread.name}"`, {
53-
thread: newThread.name,
54-
});
52+
logger.error(
53+
`No permission to manage thread "${newThread.name}" in channel <#${newThread.parentId}>`,
54+
{
55+
thread: newThread.name,
56+
parent: newThread.parent.name,
57+
parentId: newThread.parentId,
58+
}
59+
);
5560
return;
5661
}
5762

@@ -65,11 +70,12 @@ module.exports = {
6570
// This is debug instead of warn because it's quite common to have no tags, it means the bot was triggered by a thread
6671
// change in a channel that doesn't have the tags enabled on it.
6772
logger.debug(
68-
`Unable to lock thread "${newThread.name}": couldn't find tag name ${process.env.SOLVED_TAG_NAME} in channel #${newThread.parent.name}.`,
73+
`Unable to lock thread "${newThread.name}": couldn't find tag name ${process.env.SOLVED_TAG_NAME} in channel <#${newThread.parentId}>.`,
6974
{
7075
thread: newThread.name,
7176
solvedTag: process.env.SOLVED_TAG_NAME,
72-
channe: newThread.parent.name,
77+
parent: newThread.parent.name,
78+
parentId: newThread.parentId,
7379
}
7480
);
7581
return;
@@ -85,24 +91,36 @@ module.exports = {
8591
newThread.createdTimestamp
8692
).toUTCString();
8793
logger.info(
88-
`Not sending closed message to "${newThread.name}" since it was created ${createdDate} which is more than ${process.env.OLD_THREAD_AGE_IN_DAYS} days ago.`,
94+
`Not sending closed message to "${newThread.name}" in channel <#${newThread.parentId}> since it was created ${createdDate} which is more than ${process.env.OLD_THREAD_AGE_IN_DAYS} days ago.`,
8995
{
9096
thread: newThread.name,
97+
parent: newThread.parent.name,
98+
parentId: newThread.parentId,
9199
createdDate,
92100
oldThreadAge: process.env.OLD_THREAD_AGE_IN_DAYS,
93101
}
94102
);
95103
}
96104

97105
await newThread.setLocked(true);
98-
logger.debug(`Locked thread "${newThread.name}"`, {
99-
thread: newThread.name,
100-
});
106+
logger.debug(
107+
`Locked thread "${newThread.name}" in channel <#${newThread.parentId}>`,
108+
{
109+
thread: newThread.name,
110+
parent: newThread.parent.name,
111+
parentId: newThread.parentId,
112+
}
113+
);
101114
} else if (wasUnSolved(oldThread, newThread, tagId)) {
102115
await newThread.setLocked(false);
103-
logger.debug(`Unlocked thread "${newThread.name}"`, {
104-
thread: newThread.name,
105-
});
116+
logger.debug(
117+
`Unlocked thread "${newThread.name}" in channel <#${newThread.parentId}>`,
118+
{
119+
thread: newThread.name,
120+
parent: newThread.parent.name,
121+
parentId: newThread.parentId,
122+
}
123+
);
106124

107125
// This will only have a value if the cache contains the last message.
108126
// for the channel.

0 commit comments

Comments
 (0)