Skip to content

Commit

Permalink
Fix bugs with /ban and rare exceptions.
Browse files Browse the repository at this point in the history
  • Loading branch information
retrixe committed Nov 5, 2018
1 parent 5644b87 commit 61dba67
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions server/bot/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export default class CommandParser {
}

async onMessage (message: Message) {
if (!message.content.startsWith('/')) {
if (message.content && !message.content.startsWith('/')) {
botCallback(message, this.client, this.tempDB, this.db)
return // Don't process it if it's not a command.
}
Expand Down Expand Up @@ -198,7 +198,7 @@ export default class CommandParser {
// For evaluating messages which weren't evaluated.
async onMessageUpdate (message: Message, oldMessage?: Message) {
// We won't bother with a lot of messages..
if (!message.content.startsWith('/')) return
if (message.content && !message.content.startsWith('/')) return
else if (this.evaluatedMessages.includes(message.id)) return
else if (!oldMessage || Date.now() - message.timestamp > 30000) return
else if (message.editedTimestamp - message.timestamp > 30000) return
Expand Down
6 changes: 4 additions & 2 deletions server/bot/commands/admin/ban.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const handleBan: Command = {
try { user = await client.getRESTUser(userSpecified) } catch (e) {
return 'I cannot find that user.'
}
} else return 'I cannot find that user.'
}
if (!user) return `Specify a valid user, ${getInsult()}.`
// If the user cannot ban the person..
if (
Expand Down Expand Up @@ -75,7 +75,9 @@ export const handleUnban: Command = {
user = client.users.find(i => i.username === userSpecified)
} else if (client.users.find(i => i.id === userSpecified)) {
user = client.users.find(i => i.id === userSpecified)
} else user = await client.getRESTUser(userSpecified)
} else {
try { user = await client.getRESTUser(userSpecified) } catch (e) {}
}
if (!user) return 'I cannot find that user.'
// Now we unban the person.
try {
Expand Down

0 comments on commit 61dba67

Please sign in to comment.