forked from embee/woomy
Added some stuff, changed how usererrs are called
This commit is contained in:
parent
9fd2c873ca
commit
b36a746bb4
8 changed files with 149 additions and 21 deletions
33
commands/8ball.js
Normal file
33
commands/8ball.js
Normal file
|
@ -0,0 +1,33 @@
|
|||
exports.conf = {
|
||||
enabled: true,
|
||||
guildOnly: false,
|
||||
aliases: [],
|
||||
permLevel: 'User',
|
||||
requiredPerms: [],
|
||||
cooldown: 2000
|
||||
}
|
||||
|
||||
exports.help = {
|
||||
name: '8ball',
|
||||
category: 'Fun',
|
||||
description: 'Retrieves an answer to your question from the almighty 8ball.',
|
||||
usage: '`8ball [question]` - Retrieves an answer from 8ball based on the question or sentence provided.',
|
||||
parameters: '`question` - the question you want to ask'
|
||||
}
|
||||
|
||||
exports.run = async (client, message, args, level, data) => {
|
||||
|
||||
// Finish later
|
||||
const responses = [
|
||||
'No darndested clue.',
|
||||
'¯\\_(ツ)_/¯',
|
||||
'Stupid question. You should be ashamed of yourself for even asking.',
|
||||
'Yes!',
|
||||
'Not in your wildest dreams!',
|
||||
'No chance.',
|
||||
'Never.',
|
||||
'Possibly.',
|
||||
'There\'s a high chance.',
|
||||
'I\'d rather not say.'
|
||||
]
|
||||
}
|
|
@ -16,7 +16,7 @@ exports.help = {
|
|||
|
||||
exports.run = async (client, message, args) => {
|
||||
if (!args[0]) {
|
||||
return message.channel.send(client.userError(exports, 'Missing argument, the `emoji` argument is required!'))
|
||||
return client.userError(message, exports, 'Missing argument, the `emoji` argument is required!')
|
||||
};
|
||||
|
||||
var ID
|
||||
|
|
|
@ -34,14 +34,18 @@ exports.run = (client, message, args, level, data) => {
|
|||
|
||||
if (!args[0]) {
|
||||
let uPrefix = '`' + data.user.prefix + '`'
|
||||
let gPrefix = '`' + data.guild.prefix + '`'
|
||||
let gPrefix = ''
|
||||
|
||||
if (client.config.defaultPrefix === data.user.prefix) {
|
||||
uPrefix = 'None set, use: `~myprefix'
|
||||
}
|
||||
|
||||
if (client.config.defaultPrefix === data.guild.prefix) {
|
||||
gPrefix = 'None set, use: `~prefix`'
|
||||
if (message.guild) {
|
||||
gPrefix = 'Server Prefix: `' + data.guild.prefix + '`'
|
||||
|
||||
if (client.config.defaultPrefix === data.guild.prefix) {
|
||||
gPrefix = 'Server Prefix: None set, use: `~prefix`'
|
||||
}
|
||||
}
|
||||
|
||||
embed.setTitle('Help & Commands')
|
||||
|
@ -49,7 +53,7 @@ exports.run = (client, message, args, level, data) => {
|
|||
if (client.version.news.length > 0) {
|
||||
embed.addField('**News**', client.version.news)
|
||||
}
|
||||
embed.addField('**Prefixes**', `Default Prefix: \`${client.config.defaultPrefix}\`\nServer Prefix: ${gPrefix}\nUser Prefix: ${uPrefix}`)
|
||||
embed.addField('**Prefixes**', `Default Prefix: \`${client.config.defaultPrefix}\`\nUser Prefix: ${uPrefix}\nServer Prefix: ${gPrefix}`)
|
||||
embed.addField('**Command Syntax**', 'For arguments in commands:\n» Arguments in `[]` brackets are required.\n» Arguments in `<>` brackets are optional.\n» Arguments prefixed with `-` are flags, and are placed at the start of the command (`avatar -jpg mudkipscience`)')
|
||||
embed.addField('**Commands**', `Use \`${message.prefix}help all\` to view all commands, or \`${message.prefix}help <command>\` for more information on a specific command.\n\n[Bot Invite](https://discordapp.com/oauth2/authorize?client_id=${client.user.id}&permissions=2134240503&scope=bot) | [Discord Server](https://discord.gg/HCF8mdv) | [GitHub](https://github.com/mudkipscience/woomy) | [Vote for me!](https://top.gg/bot/435961704145485835/vote)`)
|
||||
|
||||
|
@ -79,7 +83,7 @@ exports.run = (client, message, args, level, data) => {
|
|||
aliases = '`' + cmd.conf.aliases.join('`, `') + '`'
|
||||
}
|
||||
|
||||
embed.setTitle(cmd.help.category.toLowerCase() + ':' + cmd.help.name)
|
||||
embed.setTitle(`${cmd.help.category} -> ${cmd.help.name}`)
|
||||
embed.setDescription(cmd.help.description)
|
||||
embed.addField('**Usage**', cmd.help.usage)
|
||||
if (cmd.help.parameters.length > 0) {
|
||||
|
|
34
commands/myprefix.js
Normal file
34
commands/myprefix.js
Normal file
|
@ -0,0 +1,34 @@
|
|||
exports.conf = {
|
||||
enabled: true,
|
||||
guildOnly: false,
|
||||
aliases: [],
|
||||
permLevel: 'User',
|
||||
requiredPerms: [],
|
||||
cooldown: 2000 // miliseconds
|
||||
}
|
||||
|
||||
exports.help = {
|
||||
name: 'myprefix',
|
||||
category: 'Settings',
|
||||
description: 'Shows or changes the prefix Woomy uses for you.',
|
||||
usage: '`myprefix` <prefix | "reset">',
|
||||
parameters: ''
|
||||
}
|
||||
|
||||
exports.run = async (client, message, args, level, data) => {
|
||||
const prefix = args.join(' ')
|
||||
|
||||
if (!prefix) {
|
||||
return message.channel.send(`Your current prefix is: \`${data.user.prefix}\``)
|
||||
}
|
||||
|
||||
if (prefix.toLowerCase() === 'reset') {
|
||||
await client.updateUser(message.author, { prefix: client.config.defaultPrefix })
|
||||
|
||||
return message.channel.send('Your prefix has been reset.')
|
||||
}
|
||||
|
||||
await client.updateUser(message.author, { prefix: prefix })
|
||||
|
||||
message.channel.send(`Your prefix has been updated: \`${prefix}\``)
|
||||
}
|
34
commands/prefix.js
Normal file
34
commands/prefix.js
Normal file
|
@ -0,0 +1,34 @@
|
|||
exports.conf = {
|
||||
enabled: true,
|
||||
guildOnly: false,
|
||||
aliases: [],
|
||||
permLevel: 'User',
|
||||
requiredPerms: [],
|
||||
cooldown: 2000 // miliseconds
|
||||
}
|
||||
|
||||
exports.help = {
|
||||
name: 'prefix',
|
||||
category: 'Settings',
|
||||
description: 'Shows or changes the prefix Woomy uses for this server.',
|
||||
usage: 'prefix ',
|
||||
params: ''
|
||||
}
|
||||
|
||||
exports.run = async (client, message, args, level, data) => {
|
||||
const prefix = args.join(' ')
|
||||
|
||||
if (!prefix) {
|
||||
return message.channel.send(`Current server prefix: \`${data.guild.prefix}\``)
|
||||
}
|
||||
|
||||
if (prefix.toLowerCase() === 'reset') {
|
||||
await client.updateGuild(message.guild, { prefix: client.config.defaultPrefix })
|
||||
|
||||
return message.channel.send('Server prefix has been reset.')
|
||||
}
|
||||
|
||||
await client.updateGuild(message.guild, { prefix: prefix })
|
||||
|
||||
message.channel.send(`The server prefix has been updated: \`${prefix}\``)
|
||||
}
|
|
@ -20,7 +20,7 @@ const Discord = require('discord.js')
|
|||
exports.run = (client, message, args) => {
|
||||
const flag = args[0]
|
||||
if (!flag) {
|
||||
return message.channel.send(client.userError(exports, 'Missing argument, the `flag` argument is required!'))
|
||||
return client.userError(message, exports, 'Missing argument, the `flag` argument is required!')
|
||||
}
|
||||
|
||||
const available = ['lesbian', 'gay', 'bisexual', 'pansexual', 'trans', 'asexual', 'aromantic', 'ally']
|
||||
|
|
|
@ -8,11 +8,6 @@ module.exports = async (client, message) => {
|
|||
const prefixes = [data.user.prefix]
|
||||
|
||||
if (message.guild) {
|
||||
if (!message.channel.permissionsFor(client.user).has('SEND_MESSAGES')) {
|
||||
try {
|
||||
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) {}
|
||||
}
|
||||
data.guild = await client.findOrCreateGuild(message.guild)
|
||||
prefixes.push(data.guild.prefix)
|
||||
}
|
||||
|
@ -27,7 +22,6 @@ module.exports = async (client, message) => {
|
|||
|
||||
if (message.content.indexOf(prefix) !== 0) return
|
||||
|
||||
console.log(prefix)
|
||||
if (prefix === `<@${client.user.id}> ` || prefix === `<@!${client.user.id}> `) {
|
||||
message.prefix = '@Woomy '
|
||||
} else {
|
||||
|
@ -44,6 +38,26 @@ module.exports = async (client, message) => {
|
|||
const cmd = client.commands.get(command) || client.commands.get(client.aliases.get(command))
|
||||
if (!cmd) return
|
||||
|
||||
if (message.guild) {
|
||||
if (!message.channel.permissionsFor(client.user).has('SEND_MESSAGES')) {
|
||||
try {
|
||||
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) {}
|
||||
}
|
||||
|
||||
if (data.guild.disabledCommands.includes(cmd.help.name)) {
|
||||
if (data.guild.systemNotice.enabled === true) {
|
||||
return message.channel.send('This command has been disabled in this server.')
|
||||
}
|
||||
}
|
||||
|
||||
if (data.guild.disabledCategories.includes(cmd.help.category)) {
|
||||
if (data.guild.systemNotice.enabled === true) {
|
||||
return message.channel.send('This category has been disabled in this server.')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!cmd.conf.enabled) {
|
||||
if (data.guild.systemNotice.enabled === true) {
|
||||
return message.channel.send('This command has been disabled by my developers.')
|
||||
|
@ -53,7 +67,7 @@ module.exports = async (client, message) => {
|
|||
}
|
||||
|
||||
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 in direct messages! Please run this command in a server.')
|
||||
}
|
||||
|
||||
if (message.guild) {
|
||||
|
@ -100,7 +114,6 @@ module.exports = async (client, message) => {
|
|||
|
||||
message.author.permLevel = level
|
||||
|
||||
// Might use this
|
||||
message.flags = []
|
||||
while (args[0] && args[0][0] === '-') {
|
||||
message.flags.push(args.shift().slice(1))
|
||||
|
|
|
@ -35,7 +35,7 @@ module.exports = client => {
|
|||
|
||||
// Update guild settings
|
||||
client.updateGuild = async (guild, settings) => {
|
||||
let data = await client.getGuild(guild)
|
||||
let data = await client.findOrCreateGuild(guild)
|
||||
|
||||
if (typeof data !== 'object') data = {}
|
||||
for (const key in settings) {
|
||||
|
@ -49,7 +49,7 @@ module.exports = client => {
|
|||
|
||||
// Delete guild settings
|
||||
client.deleteGuild = async (guild) => {
|
||||
const data = await client.getGuild(guild)
|
||||
const data = await client.findOrCreateGuild(guild)
|
||||
if (data) {
|
||||
data.deleteOne({ guildID: guild.id })
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ module.exports = client => {
|
|||
|
||||
// Update user settings
|
||||
client.updateUser = async (user, settings) => {
|
||||
let data = await client.getUser(user)
|
||||
let data = await client.findOrCreateUser(user)
|
||||
|
||||
if (typeof data !== 'object') data = {}
|
||||
for (const key in settings) {
|
||||
|
@ -83,7 +83,7 @@ module.exports = client => {
|
|||
|
||||
// Delete user settings
|
||||
client.deleteUser = async (user) => {
|
||||
const data = await client.getUser(user)
|
||||
const data = await client.findOrCreateUser(user)
|
||||
if (data) {
|
||||
data.deleteOne({ userID: user.id })
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ module.exports = client => {
|
|||
}
|
||||
|
||||
// Creates an embed for when commands are used incorrectly
|
||||
client.userError = (cmd, err) => {
|
||||
client.userError = (msg, cmd, err) => {
|
||||
const embed = new MessageEmbed()
|
||||
embed.setColor('#EF5350')
|
||||
embed.setTitle(cmd.help.name + ':' + cmd.help.category.toLowerCase())
|
||||
|
@ -141,7 +141,9 @@ module.exports = client => {
|
|||
embed.addField('**Usage**', cmd.help.usage)
|
||||
embed.addField('**Parameters**', cmd.help.parameters)
|
||||
embed.setFooter(`Run 'help ${cmd.help.name}' for more information.`)
|
||||
return embed
|
||||
msg.channel.send(embed).then(msg => {
|
||||
msg.delete({ timeout: 60000 })
|
||||
})
|
||||
}
|
||||
|
||||
// Clean up input to remove @everyone, token, etc
|
||||
|
@ -185,6 +187,14 @@ module.exports = client => {
|
|||
}
|
||||
}
|
||||
|
||||
// Capitalises the first letter of every word in a string
|
||||
// eslint-disable-next-line no-extend-native
|
||||
Object.defineProperty(String.prototype, 'toProperCase', {
|
||||
value: function () {
|
||||
return this.replace(/([^\W_]+[^\s-]*) */g, (txt) => txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase())
|
||||
}
|
||||
})
|
||||
|
||||
// Returns a random int between min and max
|
||||
client.intBetween = function (min, max) {
|
||||
return Math.floor((Math.random() * (max - min)) + min)
|
||||
|
|
Loading…
Reference in a new issue