Simplication

merge-requests/6/merge
Bsian 2020-06-09 23:19:20 +01:00
parent f9753b25fb
commit 7a3ccd7bd7
No known key found for this signature in database
GPG Key ID: 097FB9A291026091
6 changed files with 12 additions and 12 deletions

View File

@ -1,5 +1,5 @@
import moment, { unitOfTime } from 'moment'; import moment, { unitOfTime } from 'moment';
import { Message, User } from 'eris'; import { Message, User, GuildTextableChannel } from 'eris';
import { Client, Command } from '../class'; import { Client, Command } from '../class';
export default class Ban extends Command { export default class Ban extends Command {
@ -16,7 +16,7 @@ export default class Ban extends Command {
public async run(message: Message, args: string[]) { public async run(message: Message, args: string[]) {
try { try {
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]); if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
const member = this.client.util.resolveMember(args[0], this.client.guilds.get(this.client.config.guildID)); const member = this.client.util.resolveMember(args[0], message.guild);
let user: User; let user: User;
if (!member) { if (!member) {
try { try {
@ -28,7 +28,7 @@ export default class Ban extends Command {
user = member.user; user = member.user;
} }
try { try {
await this.client.guilds.get(this.client.config.guildID).getBan(args[0]); await message.guild.getBan(args[0]);
return this.error(message.channel, 'This user is already banned.'); return this.error(message.channel, 'This user is already banned.');
} catch {} // eslint-disable-line no-empty } catch {} // eslint-disable-line no-empty
if (member && !this.client.util.moderation.checkPermissions(member, message.member)) return this.error(message.channel, 'Permission Denied.'); if (member && !this.client.util.moderation.checkPermissions(member, message.member)) return this.error(message.channel, 'Permission Denied.');

View File

@ -27,7 +27,7 @@ export default class Game extends Command {
let member: Member; let member: Member;
if (!args[0]) member = message.member; if (!args[0]) member = message.member;
else { else {
member = this.client.util.resolveMember(args.join(' '), this.client.guilds.get(this.client.config.guildID)); member = this.client.util.resolveMember(args.join(' '), message.guild);
if (!member) { if (!member) {
return this.error(message.channel, 'Member not found.'); return this.error(message.channel, 'Member not found.');
} }

View File

@ -15,7 +15,7 @@ export default class Kick extends Command {
public async run(message: Message, args: string[]) { public async run(message: Message, args: string[]) {
try { try {
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]); if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
let user: Member = this.client.util.resolveMember(args[0], this.client.guilds.get(this.client.config.guildID)); let user: Member = this.client.util.resolveMember(args[0], message.guild);
if (!user) { if (!user) {
try { try {
user = await this.client.getRESTGuildMember(this.client.config.guildID, args[0]); user = await this.client.getRESTGuildMember(this.client.config.guildID, args[0]);

View File

@ -17,9 +17,9 @@ export default class Roleinfo extends Command {
try { try {
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]); if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
let role: Role = this.client.guilds.get(this.client.config.guildID).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 if (!role) { // if it's a role name
role = this.client.guilds.get(this.client.config.guildID).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.'); if (!role) return this.error(message.channel, 'Could not find role.');

View File

@ -22,7 +22,7 @@ export default class Unban extends Command {
return this.error(message.channel, 'Could find find user.'); return this.error(message.channel, 'Could find find user.');
} }
try { try {
await this.client.guilds.get(this.client.config.guildID).getBan(args[0]); await message.guild.getBan(args[0]);
} catch { } catch {
return this.error(message.channel, 'This user is not banned.'); return this.error(message.channel, 'This user is not banned.');
} }

View File

@ -21,7 +21,7 @@ export default class Whois extends Command {
let member: Member; let member: Member;
if (!args[0]) member = message.member; if (!args[0]) member = message.member;
else { else {
member = this.client.util.resolveMember(args.join(' '), this.client.guilds.get(this.client.config.guildID)); member = this.client.util.resolveMember(args.join(' '), message.guild);
} }
if (!member) { if (!member) {
@ -59,7 +59,7 @@ export default class Whois extends Command {
description += `\n<@${member.id}>`; description += `\n<@${member.id}>`;
embed.setDescription(description); embed.setDescription(description);
for (const role of member.roles.map((r) => this.client.guilds.get(this.client.config.guildID).roles.get(r)).sort((a, b) => b.position - a.position)) { for (const role of member.roles.map((r) => message.guild.roles.get(r)).sort((a, b) => b.position - a.position)) {
if (role?.color !== 0) { if (role?.color !== 0) {
embed.setColor(role.color); embed.setColor(role.color);
break; break;
@ -80,12 +80,12 @@ export default class Whois extends Command {
embed.addField('Joined At', `${moment(new Date(member.joinedAt)).format('dddd, MMMM Do YYYY, h:mm:ss A')} ET`, true); embed.addField('Joined At', `${moment(new Date(member.joinedAt)).format('dddd, MMMM Do YYYY, h:mm:ss A')} ET`, true);
embed.addField('Created At', `${moment(new Date(member.user.createdAt)).format('dddd, MMMM Do YYYY, h:mm:ss A')} ET`, true); embed.addField('Created At', `${moment(new Date(member.user.createdAt)).format('dddd, MMMM Do YYYY, h:mm:ss A')} ET`, true);
if (member.roles.length > 0) { if (member.roles.length > 0) {
embed.addField(`Roles [${member.roles.length}]`, member.roles.map((r) => this.client.guilds.get(this.client.config.guildID).roles.get(r)).sort((a, b) => b.position - a.position).map((r) => `<@&${r.id}>`).join(', ')); embed.addField(`Roles [${member.roles.length}]`, member.roles.map((r) => message.guild.roles.get(r)).sort((a, b) => b.position - a.position).map((r) => `<@&${r.id}>`).join(', '));
} }
const permissions: string[] = []; const permissions: string[] = [];
const serverAcknowledgements: string[] = []; const serverAcknowledgements: string[] = [];
const bit = member.permission.allow; const bit = member.permission.allow;
if (this.client.guilds.get(this.client.config.guildID).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 | 8) === bit) { permissions.push('Administrator'); serverAcknowledgements.push('Server Admin'); }
if ((bit | 32) === bit) { permissions.push('Manage Server'); serverAcknowledgements.push('Server Manager'); } if ((bit | 32) === bit) { permissions.push('Manage Server'); serverAcknowledgements.push('Server Manager'); }
if ((bit | 16) === bit) permissions.push('Manage Channels'); if ((bit | 16) === bit) permissions.push('Manage Channels');