forked from embee/woomy
Perm levels fixed, guild create/delete
This commit is contained in:
parent
a82c054ce3
commit
4b66acc01d
11 changed files with 49 additions and 12 deletions
|
@ -15,7 +15,7 @@ exports.help = {
|
|||
usage: 'eval [code]'
|
||||
}
|
||||
|
||||
exports.run = async (client, message, args) => {
|
||||
exports.run = async (client, message, args, level, settings) => {
|
||||
const hastebin = require('hastebin-gen')
|
||||
const code = args.join(' ')
|
||||
try {
|
||||
|
|
|
@ -2,7 +2,7 @@ exports.conf = {
|
|||
enabled: true,
|
||||
guildOnly: false,
|
||||
aliases: ['plevel', 'permlevel'],
|
||||
permLevel: 'Administrator',
|
||||
permLevel: 'User',
|
||||
requiredPerms: [],
|
||||
cooldown: 2000
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ exports.help = {
|
|||
usage: 'level'
|
||||
}
|
||||
|
||||
exports.run = async (client, message, args, level) => {
|
||||
exports.run = async (client, message, args, level, settings) => {
|
||||
try {
|
||||
const friendly = client.config.permLevels.find(l => l.level === level).name
|
||||
message.reply(`your permission level is ${level} (${friendly}).`)
|
||||
|
|
|
@ -14,7 +14,7 @@ exports.help = {
|
|||
usage: 'ping'
|
||||
}
|
||||
|
||||
exports.run = async (client, message) => {
|
||||
exports.run = async (client, message, args, level, settings) => {
|
||||
const msg = await message.channel.send('Pinging...')
|
||||
msg.edit(
|
||||
`Pong! \`${msg.createdTimestamp - message.createdTimestamp}ms\` (💗 \`${Math.round(client.ws.ping)}ms\`)`
|
||||
|
|
|
@ -5,8 +5,7 @@ module.exports = async (client, guild) => {
|
|||
// Create DB entry for newly joined guild
|
||||
try {
|
||||
const newGuild = {
|
||||
guildID: guild.id,
|
||||
guildName: guild.name
|
||||
guildID: guild.id
|
||||
}
|
||||
await client.createGuild(newGuild)
|
||||
} catch (err) {
|
||||
|
|
21
events/guildDelete.js
Normal file
21
events/guildDelete.js
Normal file
|
@ -0,0 +1,21 @@
|
|||
const Discord = require('discord.js')
|
||||
module.exports = async (client, guild) => {
|
||||
if (!guild.available) return
|
||||
|
||||
client.logger.info('Guild left.')
|
||||
|
||||
// Delete this guild's data from our database
|
||||
try {
|
||||
await client.deleteGuild(guild)
|
||||
} catch (err) {
|
||||
client.logger.error('Failed to delete DB entry for guild: ' + err)
|
||||
}
|
||||
|
||||
if (client.devmode === false) {
|
||||
const channel = client.channels.cache.get(client.config.support.serverLogs)
|
||||
const embed = new Discord.MessageEmbed()
|
||||
embed.setColor('#9494FF')
|
||||
embed.setDescription(`Left a server. I'm now in \`${client.guilds.cache.size}\` servers.`)
|
||||
channel.send(embed)
|
||||
}
|
||||
}
|
|
@ -6,8 +6,7 @@ module.exports = async (client, message) => {
|
|||
} catch (err) {
|
||||
try {
|
||||
const newGuild = {
|
||||
guildID: message.guild.id,
|
||||
guildName: message.guild.name
|
||||
guildID: message.guild.id
|
||||
}
|
||||
await client.createGuild(newGuild)
|
||||
} catch (err) {
|
||||
|
@ -37,7 +36,7 @@ module.exports = async (client, message) => {
|
|||
|
||||
if (message.guild && !message.member) await message.guild.fetchMember(message.author)
|
||||
|
||||
const level = client.permlevel(message)
|
||||
const level = client.permlevel(message, settings)
|
||||
|
||||
const cmd = client.commands.get(command) || client.commands.get(client.aliases.get(command))
|
||||
if (!cmd) return
|
||||
|
|
|
@ -1,3 +1,15 @@
|
|||
module.exports = (client) => {
|
||||
const activities = client.commands.keyArray()
|
||||
let activity = activities.random()
|
||||
|
||||
client.user.setActivity(`${client.config.defaultGuildSettings.prefix + activity} | v${client.version.number}`, { type: 'PLAYING' })
|
||||
|
||||
setInterval(() => {
|
||||
activity = activities.random()
|
||||
if (client.lockActivity === false) {
|
||||
client.user.setActivity(`${client.config.defaultGuildSettings.prefix + activity} | v${client.version.number}`, { type: 'PLAYING' })
|
||||
};
|
||||
}, 30000)
|
||||
|
||||
client.logger.ready('Connected to Discord as ' + client.user.tag)
|
||||
}
|
||||
|
|
1
index.js
1
index.js
|
@ -44,6 +44,7 @@ client.cooldown = new Discord.Collection()
|
|||
client.aliases = new Discord.Collection()
|
||||
|
||||
client.config = require('./config')
|
||||
client.version = require('./version.json')
|
||||
client.db = require('./util/mongoose')
|
||||
require('./util/functions')(client)
|
||||
require('./util/music')(client)
|
||||
|
|
|
@ -24,6 +24,6 @@ module.exports = mongoose.model('Guild', new Schema({
|
|||
|
||||
adminRole: {
|
||||
type: String,
|
||||
default: defaults.modRole
|
||||
default: defaults.adminRole
|
||||
}
|
||||
}))
|
||||
|
|
|
@ -3,15 +3,16 @@ const Guild = require('../models/guild')
|
|||
|
||||
module.exports = client => {
|
||||
// Permission level function
|
||||
client.permlevel = message => {
|
||||
client.permlevel = (message, settings) => {
|
||||
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()
|
||||
if (message.guild && currentLevel.guildOnly) continue
|
||||
if (currentLevel.check(message)) {
|
||||
if (currentLevel.check(message, settings)) {
|
||||
permlvl = currentLevel.level
|
||||
break
|
||||
}
|
||||
|
|
4
version.json
Normal file
4
version.json
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"number": "2.0",
|
||||
"changelog": "uwu"
|
||||
}
|
Loading…
Reference in a new issue