Skip to content

Commit

Permalink
fixes for reset and setchannel
Browse files Browse the repository at this point in the history
  • Loading branch information
curtisf committed Apr 3, 2019
1 parent 72ac0c6 commit 0eec26d
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -1,2 +1,4 @@
node_modules/
.env
src/miscellaneous/migratenicknames.js
test.js
8 changes: 8 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "loggerv3",
"version": "0.5.0",
"version": "3.0.5",
"description": "Logger version 3, hopefully it was worth the wait!",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -30,6 +30,7 @@
"pg": "^7.8.0",
"raven": "^2.6.4",
"redis": "^2.8.0",
"rethinkdbdash": "^2.3.31",
"standard": "^12.0.1",
"superagent": "^4.0.0",
"util": "^0.11.1"
Expand Down
2 changes: 1 addition & 1 deletion src/bot/commands/info.js
Expand Up @@ -21,7 +21,7 @@ module.exports = {
'fields': [
{
'name': 'Technical Details',
'value': `${global.bot.user.username} is written in JavaScript utilizing the Node.js runtime. It uses the [eris](https://github.com/abalabahaha/eris) library to interact with the Discord API. RethinkDB and Redis are used.`
'value': `${global.bot.user.username} is written in JavaScript utilizing the Node.js runtime. It uses the [eris](https://github.com/abalabahaha/eris) library to interact with the Discord API. PostgreSQL and Redis are used.`
},
{
'name': 'The Author',
Expand Down
2 changes: 2 additions & 0 deletions src/db/interfaces/postgres/create.js
@@ -1,5 +1,6 @@
const pool = require('../../clients/postgres')
const aes = require('../../aes')
const cacheGuild = require('../../../bot/utils/cacheGuild')
let arr = []
arr[0] = 'placeholder'
arr = JSON.stringify(arr)
Expand Down Expand Up @@ -35,6 +36,7 @@ async function createGuild (guild) {
console.log(`Creating a guild document for guild ${guild.name} with ${guild.memberCount} members.`)
try {
await pool.query('INSERT INTO guilds (id, owner_id, ignored_channels, disabled_events, event_logs, log_bots) VALUES ($1, $2, $3, $4, $5, $6)', [guild.id, guild.ownerID, [], [], eventLogs, false]) // Regenerate the document if a user kicks and reinvites the bot.
await cacheGuild(guild.id)
} catch (e) {}
}

Expand Down
6 changes: 6 additions & 0 deletions src/db/interfaces/postgres/update.js
Expand Up @@ -2,6 +2,7 @@ const pool = require('../../clients/postgres')
const getDoc = require('./read').getGuild
const getMessageById = require('./read').getMessageById
const getUser = require('./read').getUser
const cacheGuild = require('../../../bot/utils/cacheGuild')
const aes = require('../../aes')

const eventList = [
Expand Down Expand Up @@ -57,6 +58,7 @@ const eventLogs = {
}

async function clearEventLog (guildID) {
await cacheGuild(guildID)
return await pool.query('UPDATE guilds SET event_logs=$1 WHERE id=$2', [eventLogs, guildID])
}

Expand All @@ -68,6 +70,7 @@ async function clearEventByID (guildID, channelID) {
eventLogs[event] = ''
}
})
await cacheGuild(guildID)
return await pool.query('UPDATE guilds SET event_logs=$1 WHERE id=$2', [eventLogs, guildID])
}

Expand All @@ -76,6 +79,7 @@ async function setAllEventsOneId (guildID, channelID) {
eventList.forEach(event => {
doc.event_logs[event] = channelID
})
await cacheGuild(guildID)
return await pool.query('UPDATE guilds SET event_logs=$1 WHERE id=$2', [doc.event_logs, guildID])
}

Expand All @@ -84,6 +88,7 @@ async function setEventsLogId (guildID, channelID, events) {
events.forEach(event => {
doc.event_logs[event] = channelID
})
await cacheGuild(guildID)
return await pool.query('UPDATE guilds SET event_logs=$1 WHERE id=$2', [doc.event_logs, guildID])
}

Expand All @@ -97,6 +102,7 @@ async function disableEvent (guildID, event) {
doc.disabled_events.push(event)
}
await pool.query('UPDATE guilds SET disabled_events=$1 WHERE id=$2', [doc.disabled_events, guildID])
await cacheGuild(guildID)
return disabled
}

Expand Down
10 changes: 0 additions & 10 deletions test.js
@@ -1,10 +0,0 @@
const pool = require('./src/db/clients/postgres')
const getAllMessages = require('./src/db/interfaces/postgres/read').getAllMessages

async function test () {
const messages = await getAllMessages()
const m = await messages[0]
console.log(new Date().getTime() - new Date(m.ts).getTime())
}

test()

0 comments on commit 0eec26d

Please sign in to comment.