This commit is contained in:
Emily 2020-04-05 02:13:18 +10:00
parent 4b66acc01d
commit a94671dc06
4 changed files with 23 additions and 18 deletions

View file

@ -56,7 +56,6 @@ module.exports = async (client, message) => {
} }
} }
console.log(settings.systemNotice)
if (level < client.levelCache[cmd.conf.permLevel]) { if (level < client.levelCache[cmd.conf.permLevel]) {
if (settings.systemNotice === true) { if (settings.systemNotice === true) {
return message.channel.send('You don\'t have permission to run this command!') return message.channel.send('You don\'t have permission to run this command!')

4
file.log Normal file
View file

@ -0,0 +1,4 @@
2020-04-05T02:10:36 | info | index.js | Loading 3 commands.
2020-04-05T02:10:36 | info | index.js | Loading 7 events.
2020-04-05T02:10:36 | info | mongoose.js | Connected to the database.
2020-04-05T02:10:41 | ready | ready.js | Connected to Discord as WoomyDev#4547

View file

@ -15,6 +15,13 @@ const Discord = require('discord.js')
const client = new Discord.Client({ disabledEvents: ['TYPING_START'] }) const client = new Discord.Client({ disabledEvents: ['TYPING_START'] })
client.logger = require('tracer').colorConsole({ client.logger = require('tracer').colorConsole({
transport: function (data) {
console.log(data.output)
fs.appendFile('./file.log', data.rawoutput + '\n', err => {
if (err) throw err
})
},
format: [ format: [
'{{timestamp}} | {{title}} | {{file}} | {{message}}', '{{timestamp}} | {{title}} | {{file}} | {{message}}',
{ {

View file

@ -7,7 +7,6 @@ module.exports = client => {
let permlvl = 0 let permlvl = 0
const permOrder = client.config.permLevels.slice(0).sort((p, c) => p.level < c.level ? 1 : -1) const permOrder = client.config.permLevels.slice(0).sort((p, c) => p.level < c.level ? 1 : -1)
console.log(permOrder)
while (permOrder.length) { while (permOrder.length) {
const currentLevel = permOrder.shift() const currentLevel = permOrder.shift()
@ -32,27 +31,23 @@ module.exports = client => {
// Update settings // Update settings
client.updateGuild = async (guild, settings) => { client.updateGuild = async (guild, settings) => {
const data = await client.getGuild(guild) let data = await client.getGuild(guild)
if (typeof data !== 'object') data = {}
for (const key in settings) { for (const key in settings) {
// eslint-disable-next-line no-prototype-builtins if (data[key] !== settings[key]) {
if (settings.hasOwnProperty(key)) { data[key] = settings[key]
if (data[key] !== settings[key]) { } else return
data[key] = settings[key]
} else {
return
}
}
client.logger.debug(`Updated settings for ${data.guildName}: ${Object.keys(settings)}`)
} }
return data.updateOne(settings)
} }
// Create new entry for new guild // Create new entry for new guild
client.createGuild = async (settings) => { client.createGuild = async (settings) => {
const merged = Object.assign({ _id: mongoose.Types.ObjectId() }, settings) const merged = Object.assign({ _id: mongoose.Types.ObjectId() }, settings)
const newGuild = await new Guild(merged) const newGuild = await new Guild(merged)
return newGuild.save().then(g => { return newGuild.save()
client.logger.debug(`Created settings for guild ${g.guildName}`)
})
} }
// Delete guild data // Delete guild data
@ -138,6 +133,7 @@ module.exports = client => {
} }
} }
// Embed colour function
client.embedColour = function (guild) { client.embedColour = function (guild) {
if (!guild || guild.member(client.user).displayHexColor === '#000000') { if (!guild || guild.member(client.user).displayHexColor === '#000000') {
return ['#ff9d68', '#ff97cb', '#d789ff', '#74FFFF'].random() return ['#ff9d68', '#ff97cb', '#d789ff', '#74FFFF'].random()
@ -146,7 +142,7 @@ module.exports = client => {
} }
} }
// Returns a random number between min and max // Returns a random int between min and max
client.intBetween = function (min, max) { client.intBetween = function (min, max) {
return Math.floor((Math.random() * (max - min)) + min) return Math.floor((Math.random() * (max - min)) + min)
} }
@ -208,8 +204,7 @@ module.exports = client => {
} }
client.findRole = function (guild, search) { client.findRole = function (guild, search) {
var role var role = guild.roles.cache.find(r => r.name.toLowerCase() === search.toLowerCase())
role = guild.roles.cache.find(r => r.name.toLowerCase() === search.toLowerCase())
if (!role) { if (!role) {
role = guild.roles.cache.get(search.toLowerCase()) role = guild.roles.cache.get(search.toLowerCase())
} }