forked from embee/woomy
Reformatted stuff, added data to imports
This commit is contained in:
parent
95d84cfaef
commit
b2531d49b0
10 changed files with 184 additions and 60 deletions
|
@ -15,7 +15,7 @@ exports.help = {
|
||||||
usage: 'eval [code]'
|
usage: 'eval [code]'
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.run = async (client, message, args, level, settings) => {
|
exports.run = async (client, message, args, level, data) => {
|
||||||
const hastebin = require('hastebin-gen')
|
const hastebin = require('hastebin-gen')
|
||||||
const code = args.join(' ')
|
const code = args.join(' ')
|
||||||
try {
|
try {
|
||||||
|
|
21
commands/help.js
Normal file
21
commands/help.js
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
exports.conf = {
|
||||||
|
enabled: true,
|
||||||
|
guildOnly: false,
|
||||||
|
aliases: ['commands', 'cmds', 'h'],
|
||||||
|
permLevel: 'User',
|
||||||
|
requiredPerms: ['EMBED_LINKS'],
|
||||||
|
cooldown: 2000
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.help = {
|
||||||
|
name: 'help',
|
||||||
|
category: 'General',
|
||||||
|
description: 'Returns your permission level.',
|
||||||
|
usage: 'help <command>'
|
||||||
|
}
|
||||||
|
|
||||||
|
const Discord = require('discord.js')
|
||||||
|
exports.run = (client, message, args, level, data) => {
|
||||||
|
const embed = new Discord.MessageEmbed()
|
||||||
|
embed.setColor(client.embedColour(message.guild))
|
||||||
|
}
|
|
@ -14,7 +14,7 @@ exports.help = {
|
||||||
usage: 'level'
|
usage: 'level'
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.run = async (client, message, args, level, settings) => {
|
exports.run = async (client, message, args, level, data) => {
|
||||||
try {
|
try {
|
||||||
const friendly = client.config.permLevels.find(l => l.level === level).name
|
const friendly = client.config.permLevels.find(l => l.level === level).name
|
||||||
message.reply(`your permission level is ${level} (${friendly}).`)
|
message.reply(`your permission level is ${level} (${friendly}).`)
|
||||||
|
|
|
@ -14,7 +14,7 @@ exports.help = {
|
||||||
usage: 'ping'
|
usage: 'ping'
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.run = async (client, message, args, level, settings) => {
|
exports.run = async (client, message, args, level, data) => {
|
||||||
const msg = await message.channel.send('Pinging...')
|
const msg = await message.channel.send('Pinging...')
|
||||||
msg.edit(
|
msg.edit(
|
||||||
`Pong! \`${msg.createdTimestamp - message.createdTimestamp}ms\` (💗 \`${Math.round(client.ws.ping)}ms\`)`
|
`Pong! \`${msg.createdTimestamp - message.createdTimestamp}ms\` (💗 \`${Math.round(client.ws.ping)}ms\`)`
|
||||||
|
|
|
@ -1,33 +1,31 @@
|
||||||
module.exports = async (client, message) => {
|
module.exports = async (client, message) => {
|
||||||
if (message.author.bot) return
|
if (message.author.bot) return
|
||||||
|
|
||||||
|
const data = {}
|
||||||
|
|
||||||
|
data.userData = await client.findOrCreateUser(message.author)
|
||||||
|
|
||||||
|
if (message.guild) {
|
||||||
|
if (!message.channel.permissionsFor(client.user).has('SEND_MESSAGES')) {
|
||||||
try {
|
try {
|
||||||
await client.getGuild(message.guild)
|
return message.author.send(`I don't have permission to speak in **#${message.channel.name}**, Please ask a moderator to give me the send messages permission!`)
|
||||||
} catch (err) {
|
} catch (err) {}
|
||||||
try {
|
|
||||||
const newGuild = {
|
|
||||||
guildID: message.guild.id
|
|
||||||
}
|
|
||||||
await client.createGuild(newGuild)
|
|
||||||
} catch (err) {
|
|
||||||
client.logger.error('Failed to create DB entry for existing guild: ' + err)
|
|
||||||
}
|
}
|
||||||
|
data.guildData = await client.findOrCreateGuild(message.guild)
|
||||||
}
|
}
|
||||||
|
|
||||||
const settings = await client.getGuild(message.guild)
|
const prefixes = [data.userData.prefix, data.guildData.prefix]
|
||||||
|
|
||||||
let prefix = settings.prefix
|
let prefix
|
||||||
|
|
||||||
const myMention = `<@&${client.user.id}>`
|
const prefixMention = new RegExp(`^<@!?${client.user.id}> `)
|
||||||
const myMention2 = `<@!${client.user.id}>`
|
if (message.content.match(prefixMention) ? message.content.match(prefixMention)[0] : '!') {
|
||||||
|
prefix = message.content.match(prefixMention) ? message.content.match(prefixMention)[0] : '!'
|
||||||
|
}
|
||||||
|
|
||||||
if (message.content.startsWith(myMention) || message.content.startsWith(myMention2)) {
|
for (const thisPrefix of prefixes) {
|
||||||
if (message.content.length > myMention.length + 1 && (message.content.substr(0, myMention.length + 1) === myMention + ' ' || message.content.substr(0, myMention2.length + 1) === myMention2 + ' ')) {
|
if (message.content.startsWith(thisPrefix)) prefix = thisPrefix
|
||||||
prefix = message.content.substr(0, myMention.length) + ' '
|
}
|
||||||
} else {
|
|
||||||
return message.channel.send(`Current prefix: \`${prefix}\``)
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
if (message.content.indexOf(prefix) !== 0) return
|
if (message.content.indexOf(prefix) !== 0) return
|
||||||
|
|
||||||
|
@ -36,19 +34,35 @@ module.exports = async (client, message) => {
|
||||||
|
|
||||||
if (message.guild && !message.member) await message.guild.fetchMember(message.author)
|
if (message.guild && !message.member) await message.guild.fetchMember(message.author)
|
||||||
|
|
||||||
const level = client.permlevel(message, settings)
|
const level = client.permlevel(message, data.guildSettings)
|
||||||
|
|
||||||
const cmd = client.commands.get(command) || client.commands.get(client.aliases.get(command))
|
const cmd = client.commands.get(command) || client.commands.get(client.aliases.get(command))
|
||||||
if (!cmd) return
|
if (!cmd) return
|
||||||
|
|
||||||
|
if (!cmd.conf.enabled) {
|
||||||
|
if (data.guildData.systemNotice.enabled === true) {
|
||||||
|
return message.channel.send('This command has been disabled by my developers.')
|
||||||
|
} else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (cmd && !message.guild && cmd.conf.guildOnly) {
|
if (cmd && !message.guild && cmd.conf.guildOnly) {
|
||||||
return message.channel.send('This command is unavailable via private message. Please run this command in a guild.')
|
return message.channel.send('This command is unavailable via private message. Please run this command in a guild.')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (message.guild) {
|
||||||
|
var missing = cmd.conf.requiredPerms.filter(p => !message.channel.permissionsFor(client.user).has(p))
|
||||||
|
if (missing.length > 0) {
|
||||||
|
missing = '`' + (missing.join('`, `')) + '`'
|
||||||
|
return message.channel.send(`Missing permissions: ${missing}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Dev perm level is separate so dev's don't get owner perms where they shouldn't have them
|
// Dev perm level is separate so dev's don't get owner perms where they shouldn't have them
|
||||||
if (cmd.conf.permLevel === 'Developer') {
|
if (cmd.conf.permLevel === 'Developer') {
|
||||||
if (!client.config.devs.includes(message.author.id)) {
|
if (!client.config.devs.includes(message.author.id)) {
|
||||||
if (settings.systemNotice === true) {
|
if (data.guildData.systemNotice.enabled === 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!')
|
||||||
} else {
|
} else {
|
||||||
return
|
return
|
||||||
|
@ -57,7 +71,7 @@ module.exports = async (client, message) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (level < client.levelCache[cmd.conf.permLevel]) {
|
if (level < client.levelCache[cmd.conf.permLevel]) {
|
||||||
if (settings.systemNotice === true) {
|
if (data.guildData.systemNotice.enabled === 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!')
|
||||||
} else {
|
} else {
|
||||||
return
|
return
|
||||||
|
@ -88,5 +102,5 @@ module.exports = async (client, message) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
client.logger.log(`Command ran: ${cmd.help.name}`)
|
client.logger.log(`Command ran: ${cmd.help.name}`)
|
||||||
cmd.run(client, message, args, level, settings)
|
cmd.run(client, message, args, level, data)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,12 +2,12 @@ module.exports = (client) => {
|
||||||
const activities = client.commands.keyArray()
|
const activities = client.commands.keyArray()
|
||||||
let activity = activities.random()
|
let activity = activities.random()
|
||||||
|
|
||||||
client.user.setActivity(`${client.config.defaultGuildSettings.prefix + activity} | v${client.version.number}`, { type: 'PLAYING' })
|
client.user.setActivity(`${client.config.defaultPrefix + activity} | v${client.version.number}`, { type: 'PLAYING' })
|
||||||
|
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
activity = activities.random()
|
activity = activities.random()
|
||||||
if (client.lockActivity === false) {
|
if (client.lockActivity === false) {
|
||||||
client.user.setActivity(`${client.config.defaultGuildSettings.prefix + activity} | v${client.version.number}`, { type: 'PLAYING' })
|
client.user.setActivity(`${client.config.defaultPrefix + activity} | v${client.version.number}`, { type: 'PLAYING' })
|
||||||
};
|
};
|
||||||
}, 30000)
|
}, 30000)
|
||||||
|
|
||||||
|
|
28
index.js
28
index.js
|
@ -8,12 +8,20 @@ if (Number(process.version.slice(1).split('.')[0]) < 12) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Libraries
|
// Libraries
|
||||||
|
const Discord = require('discord.js')
|
||||||
|
const client = new Discord.Client({ disabledEvents: ['TYPING_START'] })
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
const colors = require('colors')
|
const colors = require('colors')
|
||||||
const isDocker = require('is-docker')
|
const isDocker = require('is-docker')
|
||||||
const Discord = require('discord.js')
|
|
||||||
const client = new Discord.Client({ disabledEvents: ['TYPING_START'] })
|
|
||||||
|
|
||||||
|
// Helpers
|
||||||
|
client.config = require('./config')
|
||||||
|
client.version = require('./version.json')
|
||||||
|
client.db = require('./helpers/mongoose')
|
||||||
|
require('./helpers/_functions')(client)
|
||||||
|
require('./helpers/music')(client)
|
||||||
|
|
||||||
|
// Initialise logger
|
||||||
client.logger = require('tracer').colorConsole({
|
client.logger = require('tracer').colorConsole({
|
||||||
transport: function (data) {
|
transport: function (data) {
|
||||||
console.log(data.output)
|
console.log(data.output)
|
||||||
|
@ -39,24 +47,13 @@ client.logger = require('tracer').colorConsole({
|
||||||
filters: [colors.white]
|
filters: [colors.white]
|
||||||
})
|
})
|
||||||
|
|
||||||
// Check to make sure config exists
|
// Create caches for permissions, commands, cooldowns and aliases
|
||||||
if (fs.existsSync('./config.js') === false) {
|
|
||||||
client.logger.fatal('The config.js file is missing! Please create a config.js file.')
|
|
||||||
process.exit()
|
|
||||||
}
|
|
||||||
|
|
||||||
client.levelCache = {}
|
client.levelCache = {}
|
||||||
client.commands = new Discord.Collection()
|
client.commands = new Discord.Collection()
|
||||||
client.cooldown = new Discord.Collection()
|
client.cooldown = new Discord.Collection()
|
||||||
client.aliases = new Discord.Collection()
|
client.aliases = new Discord.Collection()
|
||||||
|
|
||||||
client.config = require('./config')
|
// Main initialisation function
|
||||||
client.version = require('./version.json')
|
|
||||||
client.db = require('./util/mongoose')
|
|
||||||
require('./util/functions')(client)
|
|
||||||
require('./util/music')(client)
|
|
||||||
|
|
||||||
// Initialization function
|
|
||||||
const init = async () => {
|
const init = async () => {
|
||||||
// Command handler
|
// Command handler
|
||||||
fs.readdir('./commands', (err, files) => {
|
fs.readdir('./commands', (err, files) => {
|
||||||
|
@ -98,6 +95,7 @@ const init = async () => {
|
||||||
client.levelCache[thisLevel.name] = thisLevel.level
|
client.levelCache[thisLevel.name] = thisLevel.level
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if Woomy is running inside a Docker container
|
||||||
if (isDocker() === true) {
|
if (isDocker() === true) {
|
||||||
client.devmode = true
|
client.devmode = true
|
||||||
client.logger.warn('Running in development mode.')
|
client.logger.warn('Running in development mode.')
|
||||||
|
|
|
@ -1,35 +1,90 @@
|
||||||
const mongoose = require('mongoose')
|
const { Schema, model } = require('mongoose')
|
||||||
const Schema = mongoose.Schema
|
const { defaultPrefix } = require('../config')
|
||||||
const { defaultGuildSettings: defaults } = require('../config')
|
|
||||||
|
|
||||||
module.exports = mongoose.model('Guild', new Schema({
|
module.exports = model('Guild', new Schema({
|
||||||
_id: mongoose.Schema.Types.ObjectId,
|
_id: Schema.Types.ObjectId,
|
||||||
guildID: String,
|
guildID: String,
|
||||||
guildName: String,
|
|
||||||
|
|
||||||
prefix: {
|
prefix: {
|
||||||
type: String,
|
type: String,
|
||||||
default: defaults.prefix
|
default: defaultPrefix
|
||||||
},
|
|
||||||
|
|
||||||
systemNotice: {
|
|
||||||
type: Boolean,
|
|
||||||
default: defaults.systemNotice
|
|
||||||
},
|
},
|
||||||
|
|
||||||
modRole: {
|
modRole: {
|
||||||
type: String,
|
type: String,
|
||||||
default: defaults.modRole
|
default: null
|
||||||
},
|
},
|
||||||
|
|
||||||
adminRole: {
|
adminRole: {
|
||||||
type: String,
|
type: String,
|
||||||
default: defaults.adminRole
|
default: null
|
||||||
},
|
},
|
||||||
|
|
||||||
mutedRole: {
|
mutedRole: {
|
||||||
type: String,
|
type: String,
|
||||||
default: defaults.mutedRole
|
default: null
|
||||||
|
},
|
||||||
|
|
||||||
|
autoRole: {
|
||||||
|
type: String,
|
||||||
|
default: null
|
||||||
|
},
|
||||||
|
|
||||||
|
systemNotice: {
|
||||||
|
type: Object,
|
||||||
|
default: {
|
||||||
|
enabled: true,
|
||||||
|
autoDelete: 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
plugins: {
|
||||||
|
type: Object,
|
||||||
|
default: {
|
||||||
|
welcome: {
|
||||||
|
enabled: false,
|
||||||
|
channel: null,
|
||||||
|
message: null
|
||||||
|
},
|
||||||
|
goodbye: {
|
||||||
|
enabled: false,
|
||||||
|
channel: null,
|
||||||
|
message: null
|
||||||
|
},
|
||||||
|
chatLogs: {
|
||||||
|
enabled: false,
|
||||||
|
channel: null
|
||||||
|
},
|
||||||
|
modLogs: {
|
||||||
|
enabled: false,
|
||||||
|
channel: null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
botChannels: {
|
||||||
|
type: Array,
|
||||||
|
default: []
|
||||||
|
},
|
||||||
|
|
||||||
|
blacklisted: {
|
||||||
|
type: Array,
|
||||||
|
default: []
|
||||||
|
},
|
||||||
|
|
||||||
|
customCommands: {
|
||||||
|
type: Array,
|
||||||
|
default: []
|
||||||
|
},
|
||||||
|
|
||||||
|
disabledCommands: {
|
||||||
|
type: Array,
|
||||||
|
default: []
|
||||||
|
},
|
||||||
|
|
||||||
|
disabledCategories: {
|
||||||
|
type: Array,
|
||||||
|
default: []
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
const { Schema, model } = require('mongoose')
|
||||||
|
|
||||||
|
module.exports = model('Member', new Schema({
|
||||||
|
_id: Schema.Types.ObjectId,
|
||||||
|
userID: String
|
||||||
|
|
||||||
|
// Will chuck in some stuff like timed mutes, warning system, levelling, etc
|
||||||
|
}))
|
|
@ -0,0 +1,28 @@
|
||||||
|
const { Schema, model } = require('mongoose')
|
||||||
|
const { defaultPrefix } = require('../config')
|
||||||
|
|
||||||
|
module.exports = model('User', new Schema({
|
||||||
|
_id: Schema.Types.ObjectId,
|
||||||
|
userID: String,
|
||||||
|
|
||||||
|
prefix: {
|
||||||
|
type: String,
|
||||||
|
default: defaultPrefix
|
||||||
|
},
|
||||||
|
|
||||||
|
profile: {
|
||||||
|
type: Object,
|
||||||
|
default: {
|
||||||
|
bio: 'I should run ~setbio :P',
|
||||||
|
birthdate: null,
|
||||||
|
pronouns: null,
|
||||||
|
favColour: null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// polyamory uwu
|
||||||
|
marriages: {
|
||||||
|
type: Array,
|
||||||
|
default: []
|
||||||
|
}
|
||||||
|
}))
|
Loading…
Reference in a new issue