summaryrefslogtreecommitdiff
path: root/commands/vainsocial/me.js
blob: 8679a65c7cc076af69e19593cf826513c77e9ac5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/node
/* jshint esnext:true */
"use strict";

const Commando = require("discord.js-commando"),
    oneLine = require("common-tags").oneLine,
    api = require("../../api"),
    util = require("../../util"),
    RegisterView = require("../../views/register");

module.exports = class RegisterUserCommand extends Commando.Command {
    constructor(client) {
        super(client, {
            name: "vainsocial-me",
            aliases: ["vme", "vgme"],
            group: "vainsocial",
            memberName: "vainsocial-me",
            description: "Register a users's in game name.",
            details: oneLine`
Store your in game name for quicker access to other commands and for Guild management.
            `,
            examples: ["vme shutterfly"],

            args: [ {
                key: "name",
                label: "name",
                prompt: "Please specify your in game name (Case Sensitive).",
                type: "string",
                min: 3,
                max: 16
            } ]
        });
    }
    // register a Discord account at VainSocial
    async run(msg, args) {
        util.trackAction(msg, "vainsocial-me", args.name);
        const registerView = new RegisterView(msg, args.name);
        try {
            await api.upsearchPlayerSync(args.name);
            await api.setUser(msg.author.id, args.name);
        } catch (err) {
            console.log(err);
            return await registerView.error(err.error.err);
        }
        await registerView.respond();
    }
};