more improvements

merge-requests/9/merge
Bsian 2020-04-17 14:45:18 +01:00
parent 2c6cf8e552
commit 1a41999e42
No known key found for this signature in database
GPG Key ID: 097FB9A291026091
7 changed files with 11 additions and 16 deletions

View File

@ -19,7 +19,7 @@
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2018,
"ecmaVersion": 2020,
"sourceType": "module"
},
"plugins": [

View File

@ -22,7 +22,7 @@
},
"dependencies": {
"axios": "^0.19.2",
"eris": "abalabahaha/eris#dev",
"eris": "bsian03/eris#bsian",
"moment": "^2.24.0",
"mongoose": "^5.9.9",
"signale": "^1.4.0",

View File

@ -15,8 +15,7 @@ export default class Ban extends Command {
public async run(message: Message, args: string[]) {
try {
const guild = this.client.util.guildFromMessage(message);
const member = this.client.util.resolveMember(args[0], guild);
const member = this.client.util.resolveMember(args[0], message.guild);
let user: User;
if (!member) {
try {
@ -26,7 +25,7 @@ export default class Ban extends Command {
}
}
try {
await guild.getBan(args[0]);
await message.guild.getBan(args[0]);
return this.error(message.channel, 'This user is already banned.');
} catch {} // eslint-disable-line no-empty
if (member && !this.client.util.moderation.checkPermissions(member, message.member)) return this.error(message.channel, 'Permission Denied.');

View File

@ -24,11 +24,10 @@ export default class Game extends Command {
public async run(message: Message, args: string[]) {
try {
const guild = this.client.util.guildFromMessage(message);
let member: Member;
if (!args[0]) member = message.member;
else {
member = this.client.util.resolveMember(args.join(' '), guild);
member = this.client.util.resolveMember(args.join(' '), message.guild);
if (!member) {
return this.error(message.channel, 'Member not found.');
}

View File

@ -14,12 +14,11 @@ export default class Roleinfo extends Command {
public async run(message: Message, args: string[]) {
try {
const guild = this.client.util.guildFromMessage(message);
if (!args[0]) return this.error(message.channel, 'You need to specifiy a role ID or a role name.');
let role: Role = guild.roles.find((r: Role) => r.id === args[0]);
let role: Role = message.guild.roles.find((r: Role) => r.id === args[0]);
if (!role) { // if it's a role name
role = guild.roles.find((r: Role) => r.name.toLowerCase().includes(args.join(' ').toLowerCase()));
role = message.guild.roles.find((r: Role) => r.name.toLowerCase().includes(args.join(' ').toLowerCase()));
}
if (!role) return this.error(message.channel, 'Could not find role.');

View File

@ -14,7 +14,6 @@ export default class Unban extends Command {
public async run(message: Message, args: string[]) {
try {
const guild = this.client.util.guildFromMessage(message);
let user: User;
try {
user = await this.client.getRESTUser(args[0]);
@ -22,7 +21,7 @@ export default class Unban extends Command {
return this.error(message.channel, 'Could find find user.');
}
try {
await guild.getBan(args[0]);
await message.guild.getBan(args[0]);
} catch {
return this.error(message.channel, 'This user is not banned.');
}

View File

@ -18,11 +18,10 @@ export default class Whois extends Command {
public async run(message: Message, args: string[]) {
try {
const guild = this.client.util.guildFromMessage(message);
let member: Member;
if (!args[0]) member = message.member;
else {
member = this.client.util.resolveMember(args.join(' '), guild);
member = this.client.util.resolveMember(args.join(' '), message.guild);
}
if (!member) {
@ -62,7 +61,7 @@ export default class Whois extends Command {
description += `\n<@${member.id}>`;
embed.setDescription(description);
const roles = member.roles.map((r) => guild.roles.get(r)).sort((a, b) => b.position - a.position);
const roles = member.roles.map((r) => message.guild.roles.get(r)).sort((a, b) => b.position - a.position);
const { color } = roles.find((r) => r.color);
embed.setColor(color);
@ -73,7 +72,7 @@ export default class Whois extends Command {
const permissions: string[] = [];
const serverAcknowledgements: string[] = [];
const bit = member.permission.allow;
if (guild.ownerID === member.id) serverAcknowledgements.push('Server Owner');
if (message.guild.ownerID === member.id) serverAcknowledgements.push('Server Owner');
if ((bit | 8) === bit) { permissions.push('Administrator'); serverAcknowledgements.push('Server Admin'); }
if ((bit | 20) === bit) { permissions.push('Manage Server'); serverAcknowledgements.push('Server Manager'); }
if ((bit | 10) === bit) permissions.push('Manage Channels');