コード例 #1
0
        public async Task LeaveChannel(CommandContext ctx,
                                       [RemainingText, Description("나갈 채널 이름.")]
                                       string name = "")
        {
            name = RefineChannelName(name);

            await ctx.TriggerTypingAsync();

            if (ctx.Guild == null)
            {
                await ctx.RespondAsync("서버에서 명령을 사용해주세요.");

                return;
            }

            if (string.IsNullOrWhiteSpace(name))
            {
                await ctx.RespondAsync("채널 이름은 공백일 수 없습니다.");

                return;
            }

            await GlobalMessenger.PushMessage("Subchannel", "LeaveChannel",
                                              CommandContextAdv.Create(ctx, name));
        }
コード例 #2
0
        public async Task QueryKeyword(CommandContext ctx,
                                       [RemainingText, Description("추가할 키워드. 이미 존재하면 삭제하며 생략시 목록을 보여줍니다.")]
                                       string keyword = "")
        {
            await ctx.TriggerTypingAsync();

            await GlobalMessenger.PushMessage("Keyword", "QueryKeyword",
                                              CommandContextAdv.Create(ctx, keyword));
        }
コード例 #3
0
        public async Task EditProfile(CommandContext ctx,
                                      [RemainingText, Description("프로필에 표시될 내용.")]
                                      string description)
        {
            await ctx.TriggerTypingAsync();

            await GlobalMessenger.PushMessage("Membership", "EditProfile",
                                              CommandContextAdv.Create(ctx, description ?? string.Empty));
        }
コード例 #4
0
        public async Task ShowProfile(CommandContext ctx,
                                      [RemainingText, Description("볼 회원 언급. 비워두면 자신의 프로필을 봅니다.")]
                                      string user = "")
        {
            await ctx.TriggerTypingAsync();

            await GlobalMessenger.PushMessage("Membership", "ShowProfile",
                                              CommandContextAdv.Create(ctx));
        }
コード例 #5
0
        public async Task CloseChannel(CommandContext ctx,
                                       [RemainingText, Description("채널 이름.")]
                                       string name = "")
        {
            name = RefineChannelName(name);

            await ctx.TriggerTypingAsync();

            if (ctx.Guild == null)
            {
                await ctx.RespondAsync("서버에서 명령을 사용해주세요.");

                return;
            }

            if (string.IsNullOrWhiteSpace(name))
            {
                await ctx.RespondAsync("채널 이름은 공백일 수 없습니다.");

                return;
            }


            await ctx.RespondAsync($"정말로 '{name}' 채널을 영구적으로 삭제할까요? (Y/N)");

            var interactivity = ctx.Client.GetInteractivity();
            var msg           = (await interactivity.WaitForMessageAsync(xm => xm.Author.Id == ctx.User.Id, TimeSpan.FromMinutes(2)))
                                .Result;

            if (msg == null)
            {
                await ctx.RespondAsync($"'{name}' 채널 삭제가 취소되었습니다.");

                return;
            }

            string res = msg.Content.ToLower();

            await ctx.TriggerTypingAsync();

            if (res == "y")
            {
                await GlobalMessenger.PushMessage("Subchannel", "CloseChannel",
                                                  CommandContextAdv.Create(ctx, name));
            }
            else
            {
                await ctx.RespondAsync("채널 삭제가 취소되었습니다.");
            }
        }
コード例 #6
0
        public async Task ListChannels(CommandContext ctx)
        {
            await ctx.TriggerTypingAsync();

            if (ctx.Guild == null)
            {
                await ctx.RespondAsync("서버에서 명령을 사용해주세요.");

                return;
            }

            await GlobalMessenger.PushMessage("Subchannel", "ListChannels",
                                              CommandContextAdv.Create(ctx));
        }
コード例 #7
0
        public async Task ReleaseUser(CommandContext ctx,
                                      [RemainingText, Description("대상 멤버 언급.")]
                                      string mention)
        {
            await ctx.TriggerTypingAsync();

            var users = ctx.Message.MentionedUsers;

            if (users.Count == 1)
            {
                await GlobalMessenger.PushMessage("Judge", "ReleaseUser",
                                                  CommandContextAdv.Create(ctx));

                await ctx.RespondAsync("처리 완료.");
            }
            else
            {
                await ctx.RespondAsync("대상을 하나만 지정해주세요.");
            }
        }
コード例 #8
0
        public async Task PunishUser(CommandContext ctx,
                                     [Description("대상 멤버 언급.")]
                                     string mention,
                                     [Description("정지시킬 시간(초). 음수일 경우 무기한 정지합니다.")]
                                     int time)
        {
            await ctx.TriggerTypingAsync();

            var users = ctx.Message.MentionedUsers;

            if (users.Count == 1)
            {
                await GlobalMessenger.PushMessage("Judge", "PunishUser",
                                                  CommandContextAdv.Create(ctx, time));

                await ctx.RespondAsync("처리 완료.");
            }
            else
            {
                await ctx.RespondAsync("대상을 하나만 지정해주세요.");
            }
        }
コード例 #9
0
        public async Task CreateChannel(CommandContext ctx,
                                        [RemainingText, Description("채널 이름. 10자 이하이며 영어(소문자), 한글 등의 문자와 붙임표(-)만 허용됩니다.")]
                                        string name = "")
        {
            name = RefineChannelName(name);

            await ctx.TriggerTypingAsync();


            if (ctx.Guild == null)
            {
                await ctx.RespondAsync("서버에서 명령을 사용해주세요.");

                return;
            }


            if (string.IsNullOrWhiteSpace(name))
            {
                await ctx.RespondAsync("채널 이름은 공백일 수 없습니다.");

                return;
            }
            else if (name.Length > 10)
            {
                await ctx.RespondAsync("채널 이름의 길이가 제한을 초과하였습니다.");

                return;
            }
            else if (!name.ToCharArray().All((ch) => ch == '-' || char.IsLetterOrDigit(ch)))
            {
                await ctx.RespondAsync("채널 이름에 유효하지 않은 기호가 있습니다.");

                return;
            }


            await ctx.RespondAsync($@"'{name}' 채널의 주제는 무엇으로 할까요?
이 정보는 `channels` 명령을 통해 다른 사람이 볼 수 있습니다.
무엇을 하는 채널인지 쉽게 알 수 있도록 간단명료하게 작성해주세요.");

            var interactivity = ctx.Client.GetInteractivity();
            var msg           = (await interactivity.WaitForMessageAsync(xm => xm.Author.Id == ctx.User.Id, TimeSpan.FromMinutes(10)))
                                .Result;

            if (msg == null)
            {
                await ctx.RespondAsync($"'{name}' 채널 생성이 취소되었습니다.");

                return;
            }


            string subject = msg.Content.Replace('\n', ' ');

            await ctx.TriggerTypingAsync();

            await ctx.RespondAsync($@"입력하신 정보가 맞나요? (Y/N)
채널명 : '{name}'
주제 : '{subject}'");

            msg = (await interactivity.WaitForMessageAsync(xm => xm.Author.Id == ctx.User.Id, TimeSpan.FromMinutes(2)))
                  .Result;

            if (msg == null)
            {
                await ctx.RespondAsync($"'{name}' 채널 생성이 취소되었습니다.");

                return;
            }
            else
            {
                string res = msg.Content.ToLower();

                var yesList = new[] { "y", "yes", "ㅇ", "ㅇㅇ", "네", "예", "응", "어", "넹", "넵", "그래" };

                if (!yesList.Contains(res))
                {
                    await ctx.RespondAsync($"'{name}' 채널 생성이 취소되었습니다.");

                    return;
                }
            }


            // 요청자가 스탭이 아니면 스탭의 허락을 구함.
            if (!ctx.Member.Roles.Any((role) => role.Id == DiscordConstants.StaffRoleId))
            {
                await ctx.TriggerTypingAsync();

                await ctx.RespondAsync($"<@&{DiscordConstants.StaffRoleId}>" + "의 수락을 기다리는 중입니다. (Y/N)");

                msg = (await interactivity.WaitForMessageAsync(xm =>
                {
                    // 요청한 채널에서
                    if (xm.ChannelId == ctx.Channel.Id)
                    {
                        string res = xm.Content.ToLower();
                        if (res != "y" && res != "n")
                        {
                            return(false);
                        }

                        // 스탭이 말을 했으면
                        var member = ctx.Guild.GetMemberAsync(xm.Author.Id).Result;
                        if (member.Roles.Any((role) => role.Id == DiscordConstants.StaffRoleId))
                        {
                            return(true);
                        }
                    }

                    return(false);
                }, TimeSpan.FromMinutes(30))).Result;

                if (msg == null)
                {
                    await ctx.RespondAsync($"'{name}' 채널 생성이 취소되었습니다.");

                    return;
                }
                else
                {
                    string res = msg.Content.ToLower();

                    if (res == "y")
                    {
                        await ctx.RespondAsync("채널 생성이 수락되었습니다.");
                    }
                    else
                    {
                        await ctx.RespondAsync("채널 생성이 거부되었습니다.");

                        return;
                    }
                }
            }


            await ctx.TriggerTypingAsync();

            await GlobalMessenger.PushMessage("Subchannel", "CreateChannel",
                                              CommandContextAdv.Create(ctx, name, subject));
        }