Exemplo n.º 1
0
        public async Task RequestRenameAsync
        (
            [Name("type")]
            [Summary("Where the rename should take place.\r\nValid Types are: spreadsheet|discord|both")]
            string type,

            [Name("newName")]
            [Summary("What the nickname should be updated to.")]
            [Remainder] string newName
        )
        {
            // Hardcoded to #request-name-change channel
            if (Context.Channel.Id != 841778660246945902)
            {
                return;
            }

            IGuildUser user = Context.User as IGuildUser;

            type = type.ToLower();
            switch (type)
            {
            case "discord":
            case "both":
            {
                if (newName.Length > 32)
                {
                    await Context.Channel.SendMessageAsync("", false, Embeds.NameTooLong(user, newName)).ConfigureAwait(false);

                    return;
                }
                break;
            }

            case "spreadsheet":
                break;

            default:
            {
                await Context.Channel.SendMessageAsync("", false, Embeds.UnknownRenameType(type)).ConfigureAwait(false);

                return;
            }
            }

            var message = await Context.Channel.SendMessageAsync("", false, Embeds.RequestRename(user, type, newName)).ConfigureAwait(false);

            ulong messageId = message.Id;

            await message.AddReactionsAsync(new IEmote[] { new Emoji("✅"), new Emoji("❎") }).ConfigureAwait(false);

            // Create rename request
            RenameRequest req = new RenameRequest
            {
                Type      = type,
                NewName   = newName,
                MessageId = messageId,
                GuildUser = user
            };

            _commands.AddRenameRequest(req);
        }