Exemplo n.º 1
0
        public async Task AddHomework([Remainder] string homeworkName)
        {
            var User = Context.User as SocketGuildUser;

            var commandsDescriptions = new DescriptionCommands();

            if (!commandsDescriptions.AvailabilityCheck("AddHomework", User.Roles))
            {
                return;
            }

            var attachments = Context.Message.Attachments.ToList();

            if (attachments.Count != 2)
            {
                return;
            }

            if ((attachments[0].Filename == String.Format(homeworkName + ".txt") &&
                 attachments[1].Filename == String.Format(homeworkName + "(Answers).txt")) ||
                (attachments[1].Filename == String.Format(homeworkName + ".txt") &&
                 attachments[0].Filename == String.Format(homeworkName + "(Answers).txt")))
            {
                using (var client = new HttpClient())
                {
                }
            }
        }
Exemplo n.º 2
0
        private async Task AddDescriptionCommand()
        {
            var contentsList = new List <string>();

            var command = new DescriptionCommands();

            using (var client = new HttpClient())
            {
                var content = await client.GetStringAsync(Context.Message.Attachments.First().Url);

                contentsList = content.Split("\r\n").ToList();
            }

            for (int i = 0; i < contentsList.Count; i += 4)
            {
                await command.AddCommandAsync(new Command()
                {
                    name        = contentsList[i],
                    description = new Description()
                    {
                        parameters  = contentsList[i + 1].Split('\t').ToList(),
                        description = contentsList[i + 2],
                        roles       = contentsList[i + 3].Split('\t').ToList()
                    }
                });
            }
        }
Exemplo n.º 3
0
        public async Task HelpCommand()
        {
            var helper = new DescriptionCommands();

            var commands = helper.GetCommandsDescriptions();

            foreach (var elem in commands)
            {
                await ReplyAsync($"Команда: !{elem.name}\nОписание команды: {elem.description.description}\n");
            }
        }
Exemplo n.º 4
0
        /// <summary>
        ///  определение принадлежности юзера к роли
        /// </summary>
        /// <param name="user"> юзер для проверки </param>
        /// <param name="role"> название роли </param>
        /// <returns> true or false </returns>
        private bool RoleMembership(SocketGuildUser user, List <string> roles)
        {
            var User = Context.User as SocketGuildUser;

            var commandDescription = new DescriptionCommands();

            SocketRole Role;

            foreach (var role in roles)
            {
                Role = Context.Guild.Roles.FirstOrDefault(x => x.Name == role);

                if (User.Roles.Contains(Role))
                {
                    return(true);
                }
            }

            return(false);
        }