Merge branch 'dev'
commit
fd03f418ef
|
@ -40,7 +40,8 @@
|
|||
"no-underscore-dangle": "off",
|
||||
"keyword-spacing": "off",
|
||||
"no-multiple-empty-lines": "off",
|
||||
"consistent-return": "off"
|
||||
"consistent-return": "off",
|
||||
"no-continue": "off"
|
||||
},
|
||||
"ignorePatterns": "**/*.js"
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ export { default as ping } from './ping';
|
|||
export { default as profile } from './profile';
|
||||
export { default as pulldata } from './pulldata';
|
||||
export { default as rank } from './rank';
|
||||
export { default as role } from './role';
|
||||
export { default as roleinfo } from './roleinfo';
|
||||
export { default as score } from './score';
|
||||
export { default as sip } from './sip';
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
import { Message, Role as DRole } from 'eris';
|
||||
import { Client, Command } from '../class';
|
||||
|
||||
export default class Role extends Command {
|
||||
constructor(client: Client) {
|
||||
super(client);
|
||||
this.name = 'role';
|
||||
this.description = 'Manage the roles of a member.';
|
||||
this.usage = `${this.client.config.prefix}role <user> <roles>`;
|
||||
this.permissions = 6;
|
||||
this.enabled = true;
|
||||
}
|
||||
|
||||
public async run(message: Message, args: string[]) {
|
||||
try {
|
||||
if (args.length < 2) return this.client.commands.get('help').run(message, [this.name]);
|
||||
const member = this.client.util.resolveMember(args[0], this.mainGuild);
|
||||
if (!member) return this.error(message.channel, 'Member not found');
|
||||
// if (!this.client.util.moderation.checkPermissions(member, message.member)) return this.error(message.channel, 'Permission denied.');
|
||||
const rolesList = args.slice(1).join(' ').split(', ');
|
||||
const rolesToAdd = [];
|
||||
const rolesToRemove = [];
|
||||
let stop = false;
|
||||
for (const arg of rolesList) {
|
||||
const action = arg[0];
|
||||
let role: DRole;
|
||||
if (action !== '+' && action !== '-') {
|
||||
role = this.client.util.resolveRole(arg, this.mainGuild);
|
||||
if (!role) {
|
||||
stop = true;
|
||||
return this.error(message.channel, `Role \`${arg}\` not found.`);
|
||||
}
|
||||
if (member.roles.includes(role.id)) return rolesToRemove.push(role);
|
||||
rolesToAdd.push(role);
|
||||
continue;
|
||||
}
|
||||
if (action === '+') {
|
||||
role = this.client.util.resolveRole(arg.slice(1), this.mainGuild);
|
||||
if (!role) {
|
||||
stop = true;
|
||||
return this.error(message.channel, `Role \`${arg.slice(1)}\` not found.`);
|
||||
}
|
||||
if (member.roles.includes(role.id)) {
|
||||
stop = true;
|
||||
return this.error(message.channel, `You already have the role \`${role.name}\`.`);
|
||||
}
|
||||
rolesToAdd.push(role);
|
||||
continue;
|
||||
}
|
||||
if (action === '-') {
|
||||
role = this.client.util.resolveRole(arg.slice(1), this.mainGuild);
|
||||
if (!role) {
|
||||
stop = true;
|
||||
return this.error(message.channel, `Role \`${arg.slice(1)}\` not found.`);
|
||||
}
|
||||
if (!member.roles.includes(role.id)) {
|
||||
stop = true;
|
||||
return this.error(message.channel, `You don't have the role \`${role.name}\``);
|
||||
}
|
||||
rolesToRemove.push(role);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// eslint-disable-next-line
|
||||
// if (stop) return;
|
||||
rolesToAdd.forEach((role) => member.addRole(role.id));
|
||||
rolesToRemove.forEach((role) => member.removeRole(role.id));
|
||||
return this.success(message.channel, `Changed the roles for ${member.username}#${member.discriminator}${rolesToAdd.length > 0 ? `, added \`${rolesToAdd.map((r) => r.name).join('`, `')}\`` : ''}${rolesToRemove.length > 0 ? `, removed \`${rolesToRemove.map((r) => r.name).join('`, `')}\`` : ''}`);
|
||||
} catch (err) {
|
||||
return this.client.util.handleError(err, message, this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -23,14 +23,20 @@ export default class SIP extends Command {
|
|||
|
||||
const bridge = await this.client.pbx.ari.Bridge().create();
|
||||
let receiver: Channel = this.client.pbx.ari.Channel();
|
||||
const sender = await this.client.pbx.ari.channels.originate({
|
||||
endpoint: `PJSIP/${staff.extension}`,
|
||||
extension: staff.extension,
|
||||
callerId: 'LOC PBX AUTO OPERATOR <operator>',
|
||||
context: 'from-internal',
|
||||
priority: 1,
|
||||
app: 'cr-zero',
|
||||
});
|
||||
let sender: Channel = this.client.pbx.ari.Channel();
|
||||
|
||||
try {
|
||||
sender = await this.client.pbx.ari.channels.originate({
|
||||
endpoint: `PJSIP/${staff.extension}`,
|
||||
extension: staff.extension,
|
||||
callerId: 'LOC PBX OPERATOR <operator>',
|
||||
context: 'from-internal',
|
||||
priority: 1,
|
||||
app: 'cr-zero',
|
||||
});
|
||||
} catch {
|
||||
return this.error(message.channel, 'Unable to dial your extension.');
|
||||
}
|
||||
|
||||
sender.once('StasisStart', async () => {
|
||||
await Misc.play(this.client.pbx, sender, 'sound:pls-hold-while-try');
|
||||
|
@ -39,7 +45,7 @@ export default class SIP extends Command {
|
|||
try {
|
||||
receiver = await receiver.originate({
|
||||
endpoint: `SIP/${args.join(' ')}`,
|
||||
callerId: 'LOC PBX AUTO OPERATOR <operator>',
|
||||
callerId: 'LOC PBX OPERATOR <operator>',
|
||||
context: 'from-internal',
|
||||
priority: 1,
|
||||
app: 'cr-zero',
|
||||
|
|
Loading…
Reference in New Issue