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 (settings.systemNotice === true) {
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'] })
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: [
'{{timestamp}} | {{title}} | {{file}} | {{message}}',
{

View file

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