fix: ensure message handling checks for guild presence before accessing member roles
This commit is contained in:
parent
7ed373337f
commit
cdeb2e54a3
1 changed files with 2 additions and 2 deletions
|
|
@ -15,7 +15,7 @@ interface MatchResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleMessage(message: Message): Promise<void> {
|
async function handleMessage(message: Message): Promise<void> {
|
||||||
if (!message.guild || !message.member)
|
if (!message.guild)
|
||||||
return
|
return
|
||||||
|
|
||||||
const serverConfig = config.servers.find((s: { guildId: string }) => s.guildId === message.guild!.id)
|
const serverConfig = config.servers.find((s: { guildId: string }) => s.guildId === message.guild!.id)
|
||||||
|
|
@ -32,7 +32,7 @@ async function handleMessage(message: Message): Promise<void> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!match && serverConfig.roles) {
|
if (!match && serverConfig.roles && message.member) {
|
||||||
const roleMatch = findHighestPriorityRole(message.member.roles.cache, serverConfig.roles)
|
const roleMatch = findHighestPriorityRole(message.member.roles.cache, serverConfig.roles)
|
||||||
if (roleMatch) {
|
if (roleMatch) {
|
||||||
match = { topicId: roleMatch.topicId, label: roleMatch.name, type: 'role' }
|
match = { topicId: roleMatch.topicId, label: roleMatch.name, type: 'role' }
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue