fix hiro's fuckups
parent
0961729a1d
commit
f40dae8b4d
|
@ -29,6 +29,7 @@ export { default as npm } from './npm';
|
|||
export { default as offer } from './offer';
|
||||
export { default as page } from './page';
|
||||
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 roleinfo } from './roleinfo';
|
||||
|
|
|
@ -1,17 +1,22 @@
|
|||
import { Message } from 'eris';
|
||||
import { Client, Command } from '../class';
|
||||
|
||||
import Profile_Bio from './profile_bio';
|
||||
import Profile_GitHub from './profile_github';
|
||||
import Profile_Gitlab from './profile_gitlab';
|
||||
|
||||
export default class Profile extends Command {
|
||||
constructor(client: Client) {
|
||||
super(client);
|
||||
this.name = 'profile';
|
||||
this.description = 'Manages your profile on CR';
|
||||
this.usage = 'profile <bio/github/gitlab> <new value>';
|
||||
this.description = 'Manages your profile on CR.';
|
||||
this.usage = 'profile <bio/github/gitlab> <new value>\n*Provide no value in subcommand to clear data.';
|
||||
this.permissions = 0;
|
||||
this.enabled = true;
|
||||
this.subcmds = [Profile_Bio, Profile_GitHub, Profile_Gitlab];
|
||||
}
|
||||
|
||||
public async run(message: Message, args: string[]) {
|
||||
public async run(message: Message) {
|
||||
if (!await this.client.db.Member.exists({ userID: message.author.id })) {
|
||||
await this.client.db.Member.create({ userID: message.author.id });
|
||||
}
|
||||
|
|
|
@ -15,16 +15,25 @@ export default class Profile_Bio extends Command {
|
|||
if (!await this.client.db.Member.exists({ userID: message.author.id })) {
|
||||
await this.client.db.Member.create({ userID: message.author.id });
|
||||
}
|
||||
if (!args[0]) return this.error(message.channel, 'No new bio content was provided.');
|
||||
const member = await this.client.db.Member.findOne({ userID: message.author.id });
|
||||
|
||||
if (!args[0]) {
|
||||
await member.updateOne({
|
||||
additional: {
|
||||
...member.additional,
|
||||
bio: null,
|
||||
},
|
||||
});
|
||||
return message.addReaction('modSuccess:578750988907970567');
|
||||
}
|
||||
const bio = args.join(' ');
|
||||
if (bio.length >= 256) return this.error(message.channel, 'Bio too long. It must be less than or equal to 256 characters.');
|
||||
|
||||
const member = await this.client.db.Member.findOne({ userID: message.author.id });
|
||||
await member.updateOne({
|
||||
additional: {
|
||||
...member.additional,
|
||||
bio,
|
||||
},
|
||||
});
|
||||
return message.addReaction('modSuccess:578750988907970567');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,16 @@ export default class Profile_GitHub extends Command {
|
|||
if (!await this.client.db.Member.exists({ userID: message.author.id })) {
|
||||
await this.client.db.Member.create({ userID: message.author.id });
|
||||
}
|
||||
if (!args[0]) return this.error(message.channel, 'No GitHub profile URL was provided.');
|
||||
const member = await this.client.db.Member.findOne({ userID: message.author.id });
|
||||
if (!args[0]) {
|
||||
await member.updateOne({
|
||||
additional: {
|
||||
...member.additional,
|
||||
github: null,
|
||||
},
|
||||
});
|
||||
return message.addReaction('modSuccess:578750988907970567');
|
||||
}
|
||||
const urlRegex = new RegExp(
|
||||
'^(https?:\\/\\/)?'
|
||||
+ '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|'
|
||||
|
@ -27,12 +36,12 @@ export default class Profile_GitHub extends Command {
|
|||
);
|
||||
if (!urlRegex.test(args[0]) || !args[0].startsWith('https://github.com/')) return this.error(message.channel, 'Invalid GitHub profile URL.');
|
||||
|
||||
const member = await this.client.db.Member.findOne({ userID: message.author.id });
|
||||
await member.updateOne({
|
||||
additional: {
|
||||
...member.additional,
|
||||
github: args[0],
|
||||
},
|
||||
});
|
||||
return message.addReaction('modSuccess:578750988907970567');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,16 @@ export default class Profile_GitLab extends Command {
|
|||
await this.client.db.Member.create({ userID: message.author.id });
|
||||
}
|
||||
if (!args[0]) return this.error(message.channel, 'No GitLab profile URL was provided.');
|
||||
const member = await this.client.db.Member.findOne({ userID: message.author.id });
|
||||
if (!args[0]) {
|
||||
await member.updateOne({
|
||||
additional: {
|
||||
...member.additional,
|
||||
gitlab: null,
|
||||
},
|
||||
});
|
||||
return message.addReaction('modSuccess:578750988907970567');
|
||||
}
|
||||
const urlRegex = new RegExp(
|
||||
'^(https?:\\/\\/)?'
|
||||
+ '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|'
|
||||
|
@ -25,14 +35,14 @@ export default class Profile_GitLab extends Command {
|
|||
+ '(\\#[-a-z\\d_]*)?$',
|
||||
'i',
|
||||
);
|
||||
if (!urlRegex.test(args[0]) || !args[0].startsWith('https://gitlab.com/')) return this.error(message.channel, 'Invalid GitLab profile URL.');
|
||||
if (!urlRegex.test(args[0])) return this.error(message.channel, 'Invalid GitLab profile URL.');
|
||||
|
||||
const member = await this.client.db.Member.findOne({ userID: message.author.id });
|
||||
await member.updateOne({
|
||||
additional: {
|
||||
...member.additional,
|
||||
gitlab: args[0],
|
||||
},
|
||||
});
|
||||
return message.addReaction('modSuccess:578750988907970567');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ export default class Whois extends Command {
|
|||
if (ackResolve?.extension) {
|
||||
description += `☎️ ${ackResolve.extension}\n`;
|
||||
}
|
||||
const memberProfile = await this.client.db.Member.findOne({ userID: message.author.id });
|
||||
const memberProfile = await this.client.db.Member.findOne({ userID: message.author.id }).lean().exec();
|
||||
if (memberProfile?.additional?.gitlab) {
|
||||
description += `${emotes.gitlab} ${memberProfile?.additional.gitlab}\n`;
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ export interface MemberInterface extends Document {
|
|||
gitlab: string,
|
||||
bio: string,
|
||||
},
|
||||
bio: string,
|
||||
}
|
||||
|
||||
const Member: Schema = new Schema({
|
||||
|
@ -21,7 +20,6 @@ const Member: Schema = new Schema({
|
|||
gitlab: String,
|
||||
bio: String,
|
||||
},
|
||||
bio: String,
|
||||
});
|
||||
|
||||
export default model<MemberInterface>('Member', Member);
|
||||
|
|
Loading…
Reference in New Issue