-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: use standard js linter and semantic release
Remove eslint and configuration and replace with standard lint. Try using semantic release for release and tag in github.
- Loading branch information
Showing
12 changed files
with
7,690 additions
and
530 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
module.exports = { | ||
name: 'beep', | ||
description: 'Beep!', | ||
execute(message, args) { | ||
message.channel.send('Beep.'); | ||
} | ||
} | ||
name: 'beep', | ||
description: 'Beep!', | ||
execute (message, args) { | ||
message.channel.send('Beep.') | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,46 @@ | ||
const { prefix } = require('../config.js'); | ||
const { prefix } = require('../config.js') | ||
|
||
module.exports = { | ||
name: 'help', | ||
description: 'List all of my command or info about a specific command.', | ||
aliases: ['commands'], | ||
usage: '[command name]', | ||
cooldown: 5, | ||
execute(message, args) { | ||
const data = []; | ||
const { commands } = message.client; | ||
|
||
if (!args.length) { | ||
data.push('Here\'s a list of all my commands:'); | ||
data.push(commands.map(command => command.name).join(', ')); | ||
data.push(`\nYou can send \`${prefix}help [command name]\` to get info on a specific command!`); | ||
|
||
return message.author.send(data, { split: true }) | ||
.then(() => { | ||
if (message.channel.type == 'dm') return; | ||
message.reply('I\'ve sent you a DM with all my commands!'); | ||
}) | ||
.catch(error => { | ||
console.error(`Could not send help DM to ${message.author.tag}.\n`, error); | ||
message.reply('it seems like it can\'t DM you! Do you have DMs disabled?'); | ||
}) | ||
} | ||
|
||
const name = args[0].toLowerCase(); | ||
const command = commands.get(name) || commands.find(c => c.aliases && c.aliases.includes(name)); | ||
|
||
if (!command) { | ||
return message.reply('that\'s not a valid command!'); | ||
} | ||
|
||
data.push(`**Name:** ${command.name}`); | ||
|
||
if (command.aliases) data.push(`**Aliases:** ${command.aliases.join(', ')}`); | ||
if (command.description) data.push(`**Description:** ${command.description}`); | ||
if (command.usage) data.push(`**Usage:** \`${prefix}${command.name} ${command.usage}\``); | ||
|
||
data.push(`**Cooldown:** ${command.cooldown || 3} second(s)`); | ||
|
||
message.channel.send(data, { split: true }); | ||
}, | ||
}; | ||
name: 'help', | ||
description: 'List all of my command or info about a specific command.', | ||
aliases: ['commands'], | ||
usage: '[command name]', | ||
cooldown: 5, | ||
execute (message, args) { | ||
const data = [] | ||
const { commands } = message.client | ||
|
||
if (!args.length) { | ||
data.push('Here\'s a list of all my commands:') | ||
data.push(commands.map(command => command.name).join(', ')) | ||
data.push(`\nYou can send \`${prefix}help [command name]\` to get info on a specific command!`) | ||
|
||
return message.author.send(data, { split: true }) | ||
.then(() => { | ||
if (message.channel.type === 'dm') return | ||
message.reply('I\'ve sent you a DM with all my commands!') | ||
}) | ||
.catch(error => { | ||
console.error(`Could not send help DM to ${message.author.tag}.\n`, error) | ||
message.reply('it seems like it can\'t DM you! Do you have DMs disabled?') | ||
}) | ||
} | ||
|
||
const name = args[0].toLowerCase() | ||
const command = commands.get(name) || commands.find(c => c.aliases && c.aliases.includes(name)) | ||
|
||
if (!command) { | ||
return message.reply('that\'s not a valid command!') | ||
} | ||
|
||
data.push(`**Name:** ${command.name}`) | ||
|
||
if (command.aliases) data.push(`**Aliases:** ${command.aliases.join(', ')}`) | ||
if (command.description) data.push(`**Description:** ${command.description}`) | ||
if (command.usage) data.push(`**Usage:** \`${prefix}${command.name} ${command.usage}\``) | ||
|
||
data.push(`**Cooldown:** ${command.cooldown || 3} second(s)`) | ||
|
||
message.channel.send(data, { split: true }) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,145 +1,144 @@ | ||
const { Permissions } = require('discord.js'); | ||
const { adjectives, pass_exclaimations, fail_exclaimations } = require('./phrases.json'); | ||
const { Permissions } = require('discord.js') | ||
const { adjectives, passExclaimations, failExclaimations } = require('./phrases.json') | ||
// Time to wait for a peition | ||
const { waitTime } = require('../config.js'); | ||
const { waitTime } = require('../config.js') | ||
|
||
module.exports = { | ||
name: 'new-role', | ||
description: 'Creates a petition for a new role. This will create a role without any permissions.', | ||
aliases: ['nr', 'grovel-4-role', 'beg-4-role'], | ||
usage: '<role-name> <user-mentions>', | ||
args: true, | ||
execute: newRoleForUsers, | ||
}; | ||
cooldown: 90000, | ||
execute: newRoleForUsers | ||
} | ||
|
||
function newRoleForUsers(message, args) { | ||
const roleName = args.find(arg => !getUserFromArg(message.client.users.cache, arg)); | ||
const aGuild = message.guild; | ||
const mentionedMembers = message.mentions.members; | ||
function newRoleForUsers (message, args) { | ||
const roleName = args.find(arg => !getUserFromArg(message.client.users.cache, arg)) | ||
const aGuild = message.guild | ||
const mentionedMembers = message.mentions.members | ||
|
||
const usageHelp = 'Use `!help nr` to see how to usage.'; | ||
const usageHelp = 'Use `!help nr` to see how to usage.' | ||
if (mentionedMembers.size < 1) { | ||
return message.channel.send(`<@${message.author.id}>, you didn't mention anyone to add a role to!\n${usageHelp}.`); | ||
} | ||
else if (!roleName) { | ||
return message.channel.send(`<@${message.author.id}>, you didn't provided a role-name!\n${usageHelp}.`); | ||
return message.channel.send(`<@${message.author.id}>, you didn't mention anyone to add a role to!\n${usageHelp}.`) | ||
} else if (!roleName) { | ||
return message.channel.send(`<@${message.author.id}>, you didn't provided a role-name!\n${usageHelp}.`) | ||
} | ||
|
||
sendPetitionMessage(message.channel, roleName, message.author, mentionedMembers) | ||
.then((petitionMsg) => { | ||
const roleAdminAppovedFilter = (reaction, user) => { | ||
return reaction.emoji.name === '👍' | ||
&& aGuild.members.resolve(user).hasPermission(Permissions.FLAGS.MANAGE_ROLES); | ||
}; | ||
return reaction.emoji.name === '👍' && | ||
aGuild.members.resolve(user).hasPermission(Permissions.FLAGS.MANAGE_ROLES) | ||
} | ||
|
||
const collector = petitionMsg.createReactionCollector(roleAdminAppovedFilter, | ||
{ time: waitTime }); | ||
{ time: waitTime }) | ||
|
||
collector.on('collect', () => collector.stop('role admin approved')); | ||
collector.on('collect', () => collector.stop('role admin approved')) | ||
collector.on('end', (collected, reason) => { | ||
if (reason === 'role admin approved') { | ||
approvedRoleCreation(aGuild, petitionMsg.channel, roleName, mentionedMembers); | ||
} | ||
else { | ||
sendUnapprovedMessage(petitionMsg.channel, roleName); | ||
approvedRoleCreation(aGuild, petitionMsg.channel, roleName, mentionedMembers) | ||
} else { | ||
sendUnapprovedMessage(petitionMsg.channel, roleName) | ||
} | ||
}); | ||
}); | ||
}) | ||
}) | ||
} | ||
|
||
function sendPetitionMessage(channel, roleName, requestor, users) { | ||
function sendPetitionMessage (channel, roleName, requestor, users) { | ||
const usersLine = users.map(member => { | ||
return `<@${member.id}>`; | ||
}).join(' '); | ||
return `<@${member.id}>` | ||
}).join(' ') | ||
|
||
const anAdjective = randomFrom(adjectives); | ||
const anAdjective = randomFrom(adjectives) | ||
return channel.send( | ||
'**New Role Petition**:\n' + | ||
`<@${requestor.id}> would like to create a new *${anAdjective}* role ${roleName} for ${usersLine}\n` + | ||
'Members may show support however they like.\n' + | ||
'A role admin please approve by reacting with a 👍 to approve this petition.\n', | ||
{ allowedMentions: { parse: ['users'] } }, | ||
); | ||
{ allowedMentions: { parse: ['users'] } } | ||
) | ||
} | ||
|
||
function approvedRoleCreation(aGuild, channel, roleName, users) { | ||
let roleId = ''; | ||
function approvedRoleCreation (aGuild, channel, roleName, users) { | ||
let roleId = '' | ||
createNewRole(aGuild, roleName) | ||
.then((role) => { | ||
console.log(`Created new role named ${role.name}`); | ||
roleId = role.id; | ||
return applyRole(role, users); | ||
console.log(`Created new role named ${role.name}`) | ||
roleId = role.id | ||
return applyRole(role, users) | ||
}) | ||
.then((mArray) => { | ||
console.log(`Applied new role to users ${mArray}`); | ||
sendSuccessMessage(channel, roleId, mArray); | ||
console.log(`Applied new role to users ${mArray}`) | ||
sendSuccessMessage(channel, roleId, mArray) | ||
}) | ||
.catch((error) => { | ||
console.error(error); | ||
sendErrorMessage(error); | ||
console.error(error) | ||
sendErrorMessage(error) | ||
}) | ||
.finally(() => { | ||
console.log('Finished adding roles and appling to user.'); | ||
}); | ||
console.log('Finished adding roles and appling to user.') | ||
}) | ||
} | ||
|
||
function getUserFromArg(users, arg) { | ||
if (!arg) return; | ||
function getUserFromArg (users, arg) { | ||
if (!arg) return | ||
|
||
if (arg.startsWith('<@') && arg.endsWith('>')) { | ||
arg = arg.slice(2, -1); | ||
arg = arg.slice(2, -1) | ||
|
||
if (arg.startsWith('!')) { | ||
arg = arg.slice(1); | ||
arg = arg.slice(1) | ||
} | ||
|
||
return users.get(arg); | ||
return users.get(arg) | ||
} | ||
} | ||
|
||
function createNewRole(aGuild, name) { | ||
function createNewRole (aGuild, name) { | ||
return aGuild.roles | ||
.create({ | ||
data: { | ||
name: name, | ||
permissions: 0, | ||
permissions: 0 | ||
}, | ||
reason: 'Petition for new role was approved.', | ||
}); | ||
reason: 'Petition for new role was approved.' | ||
}) | ||
} | ||
|
||
function applyRole(role, members) { | ||
function applyRole (role, members) { | ||
return Promise.all( | ||
members.each(member => member.roles.add(role.id)), | ||
); | ||
members.each(member => member.roles.add(role.id)) | ||
) | ||
} | ||
|
||
function sendSuccessMessage(channel, roleId, membersWithRole) { | ||
function sendSuccessMessage (channel, roleId, membersWithRole) { | ||
const usersLine = membersWithRole.map(member => { | ||
return `<@${member[1].id}>`; | ||
}).join(' '); | ||
const anExclaimation = randomFrom(pass_exclaimations); | ||
return `<@${member[1].id}>` | ||
}).join(' ') | ||
const anExclaimation = randomFrom(passExclaimations) | ||
return channel.send( | ||
'**Petition APPROVED**\n' + | ||
`*${anExclaimation}*\n` + | ||
`New role <@&${roleId}> has been create for ${usersLine}`, | ||
{ allowedMentions: { parse: ['roles', 'users'] } }, | ||
); | ||
{ allowedMentions: { parse: ['roles', 'users'] } } | ||
) | ||
} | ||
|
||
function sendErrorMessage(channel, error) { | ||
return channel.send(`There was a problem creating a new role: ${error}`); | ||
function sendErrorMessage (channel, error) { | ||
return channel.send(`There was a problem creating a new role: ${error}`) | ||
} | ||
|
||
function sendUnapprovedMessage(channel, roleName) { | ||
const anExclaimation = randomFrom(fail_exclaimations); | ||
function sendUnapprovedMessage (channel, roleName) { | ||
const anExclaimation = randomFrom(failExclaimations) | ||
return channel.send( | ||
'**Petition FAILED!**\n' + | ||
`*${anExclaimation}*\n` + | ||
`${roleName} was not created because the petition did not pass.`, | ||
{ allowedMentions: { parse: ['roles', 'users'] } }); | ||
{ allowedMentions: { parse: ['roles', 'users'] } }) | ||
} | ||
|
||
function randomFrom(anArray) { | ||
return anArray[Math.floor(Math.random() * anArray.length)]; | ||
function randomFrom (anArray) { | ||
return anArray[Math.floor(Math.random() * anArray.length)] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.