-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update material-ui, revert AVA update (see desc) and port more commands.
More commands have been ported to the newer, custom architecture. Next.js uses Babel 7.0.0-beta.47 and AVA used Babel 7.0.0-rc.1 (approx). Somehow there was a conflict, which is why AVA version is reverted. Latest AVA and Next.js 7 (canary) both use Babel 7 stable. When Next.js 7 is released we will update and resolve conflict. Breakage: bot callback does not run if no command was evaluated. Fix: move callback for the client into the main callback. Breakage: warn command non-functional. Fix: N/A
- Loading branch information
Showing
14 changed files
with
1,117 additions
and
1,028 deletions.
There are no files selected for viewing
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
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
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 |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import { Command } from '../imports/types' | ||
import { getInsult, getUser } from '../imports/tools' | ||
import { checkRolePosition } from '../imports/permissions' | ||
import { Message } from 'eris' | ||
// export { handleGiverole, handleTakerole } from './admin/roles' | ||
export { handleWarn, handleWarnings, handleClearwarns, handleRemovewarn } from './admin/warn' | ||
// export { handleMute, handleUnmute } from './admin/mute' | ||
export { handleBan, handleUnban } from './admin/ban' | ||
|
||
export const handlePurge: Command = { | ||
name: 'purge', | ||
opts: { | ||
description: 'Bulk delete a set of messages.', | ||
fullDescription: 'Bulk delete messages newer than 2 weeks.', | ||
usage: '/purge <number greater than 0 and less than 100>', | ||
example: '/purge 10', | ||
guildOnly: true, | ||
deleteCommand: true, | ||
requirements: { | ||
permissions: { 'manageMessages': true }, | ||
custom: (message) => ( | ||
message.member.guild.channels.find(i => i.id === message.channel.id) | ||
.permissionsOf(message.author.id).has('manageMessages') | ||
) | ||
} | ||
}, | ||
generators: (client) => ({ | ||
generator: async (message, args) => { | ||
// Check if usage is correct. | ||
if ( | ||
isNaN(+args[0]) || args.length !== 1 || +args[0] <= 0 || +args[0] > 100 | ||
) { return 'Correct usage: /purge <number greater than 0 and less than 100>' } | ||
// Pre-defined variables. | ||
let messages: Array<Message> | ||
// Get the list of messages. | ||
try { | ||
messages = await client.getMessages(message.channel.id, +args.shift(), message.id) | ||
} catch (e) { return 'Could not retrieve messages.' } | ||
// Delete the messages. | ||
try { | ||
client.deleteMessages(message.channel.id, messages.map(i => i.id), args.join(' ') || 'Purge') | ||
} catch (e) { return 'Could not delete messages. Are the messages older than 2 weeks?' } | ||
} | ||
}) | ||
} | ||
|
||
export const handleKick: Command = { | ||
name: 'kick', | ||
opts: { | ||
description: 'Kick someone.', | ||
fullDescription: 'Kick someone.', | ||
usage: '/kick <user by ID/username/mention> (reason)', | ||
guildOnly: true, | ||
example: '/kick voldemort you is suck', | ||
requirements: { permissions: { 'kickMembers': true } } | ||
}, | ||
generators: (client) => ({ | ||
generator: async (message, args) => { | ||
// Find the user ID. | ||
let user = getUser(message, args.shift()) | ||
if (!user) return `Specify a valid member of this guild, ${getInsult()}.` | ||
// If the user cannot kick the person.. | ||
if ( | ||
checkRolePosition(message.member.guild.members.find(i => i.user === user)) >= | ||
checkRolePosition(message.member) | ||
) { | ||
return `You cannot kick this person, you ${getInsult()}.` | ||
} | ||
// Now we kick the person. | ||
try { | ||
await client.kickGuildMember(message.member.guild.id, user.id, args.join(' ')) | ||
} catch (e) { return 'I am unable to kick that user.' } | ||
client.createMessage((await client.getDMChannel(user.id)).id, args.length !== 0 | ||
? `You have been kicked from ${message.member.guild.name} for ${args.join(' ')}.` | ||
: `You have been kicked from ${message.member.guild.name}.` | ||
) | ||
// WeChill | ||
if (message.member.guild.id === '402423671551164416') { | ||
client.createMessage('402437089557217290', args.length !== 0 | ||
? `**${user.username}#${user.discriminator}** has been kicked for **${args.join(' ')}**.` | ||
: `**${user.username}#${user.discriminator}** has been kicked for not staying chill >:L ` | ||
) | ||
} | ||
return `**${user.username}#${user.discriminator}** has been kicked. **rip.**` | ||
} | ||
}) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import { User } from 'eris' | ||
import { Command, FalseUser } from '../../imports/types' | ||
import { checkRolePosition } from '../../imports/permissions' | ||
import { getInsult, getUser } from '../../imports/tools' | ||
|
||
export const handleBan: Command = { | ||
name: 'ban', | ||
opts: { | ||
description: 'Ban someone.', | ||
fullDescription: 'Ban someone.', | ||
usage: '/ban <user by ID/username/mention> (reason)', | ||
guildOnly: true, | ||
example: '/ban voldemort you is suck', | ||
requirements: { permissions: { 'banMembers': true } } | ||
}, | ||
aliases: ['banana', 'nuke'], | ||
generators: (client) => ({ | ||
generator: async (message, args) => { | ||
// Find the user ID. | ||
const userSpecified = args.shift() | ||
let user: FalseUser|User = getUser(message, userSpecified) | ||
if (!user && client.users.find(i => i.username === userSpecified)) { | ||
user = client.users.find(i => i.username === userSpecified) | ||
} else if (!user && client.users.find(i => i.id === userSpecified)) { | ||
user = client.users.find(i => i.id === userSpecified) | ||
} else if (!user && userSpecified.length === 18 && !isNaN(+userSpecified)) { | ||
user = { id: userSpecified, username: 'Unknown', discriminator: 'user' } | ||
} else return 'I cannot find that user.' | ||
if (!user) return `Specify a valid member of this guild, ${getInsult()}.` | ||
// If the user cannot ban the person.. | ||
if ( | ||
checkRolePosition(message.member.guild.members.find(i => i.user === user)) >= | ||
checkRolePosition(message.member) | ||
) { | ||
return `You cannot ban this person, you ${getInsult()}.` | ||
} | ||
// Now we ban the person. | ||
try { | ||
await client.banGuildMember(message.member.guild.id, user.id, 0, args.join(' ')) | ||
} catch (e) { return 'That person could not be banned.' } | ||
client.createMessage((await client.getDMChannel(user.id)).id, args.length !== 0 | ||
? `You have been banned from ${message.member.guild.name} for ${args.join(' ')}.` | ||
: `You have been banned from ${message.member.guild.name}.` | ||
) | ||
// WeChill | ||
if (message.member.guild.id === '402423671551164416') { | ||
client.createMessage('402437089557217290', args.length !== 0 | ||
? `**${user.username}#${user.discriminator}** has been banned for **${args.join(' ')}**.` | ||
: `**${user.username}#${user.discriminator}** has been banned for not staying chill >:L ` | ||
) | ||
} | ||
return `**${user.username}#${user.discriminator}** has been banned. **rip.**` | ||
} | ||
}) | ||
} | ||
|
||
export const handleUnban: Command = { | ||
name: 'unban', | ||
opts: { | ||
description: 'Unban someone.', | ||
fullDescription: 'Unban someone.', | ||
usage: '/unban <user by ID/username/mention> (reason)', | ||
example: '/unban voldemort wrong person', | ||
guildOnly: true, | ||
requirements: { permissions: { 'banMembers': true } } | ||
}, | ||
generators: (client) => ({ | ||
generator: async (message, args) => { | ||
// Find the user ID. | ||
const userSpecified = args.shift() | ||
let user: User | ||
if (client.users.find(i => i.username === userSpecified)) { | ||
user = client.users.find(i => i.username === userSpecified) | ||
} else if (client.users.find(i => i.id === userSpecified)) { | ||
user = client.users.find(i => i.id === userSpecified) | ||
} else return 'I cannot find that user.' | ||
// Now we unban the person. | ||
try { | ||
await client.unbanGuildMember(message.member.guild.id, user.id, args.join(' ')) | ||
} catch (e) { return 'That user could not be unbanned.' } | ||
return `**${user.username}#${user.discriminator}** has been unbanned.` | ||
} | ||
}) | ||
} |
Oops, something went wrong.