Exemplo n.º 1
0
        private Task RoleDeleted(SocketRole socketRole)
        {
            // Get RoleContainer if it exists.
            List <RoleContainer> roleContainers = Data.GetContainers <RoleContainer>(Data.FILE_PATH + Data.ROLE_FILE);
            RoleContainer        roleContainer  = roleContainers.FirstOrDefault(rc => rc.name.ToLower() == socketRole.Name.ToLower());

            if (roleContainer != null)
            {
                // Remove RoleContainer.
                Data.RemoveContainer(roleContainer, Data.FILE_PATH + Data.ROLE_FILE);
            }

            return(Task.CompletedTask);
        }
        public string RemoveRequest(int index)
        {
            string path = Data.FILE_PATH + Data.REQUEST_FILE;

            List <string> existingRequests = Data.GetContainers <string>(path);
            string        request          = existingRequests[index];

            if (existingRequests != null)
            {
                Data.RemoveContainer(request, path);
            }

            index++; //So the number matches the list, starting at 1 again.
            return("The request at the `" + index + Data.GetIndexEnding(index) + "` position have been denied and removed from the list.\nDenied request:\n`" + request + "`");
        }
Exemplo n.º 3
0
        public async Task RemoveRoleAsync(
            [Summary("The name of the role the user wishes to remove")]
            [Example("Overwatch")]
            [Remainder]
            string role)
        {
            IMessage m;
            // Get RoleContainer if it exists.
            List <RoleContainer> roleContainers = Data.GetContainers <RoleContainer>(Data.FILE_PATH + Data.ROLE_FILE);
            RoleContainer        roleContainer  = roleContainers.FirstOrDefault(rc => rc.name.ToLower() == role.ToLower());

            if (roleContainer != null)
            {
                // Remove RoleContainer.
                Data.RemoveContainer(roleContainer, Data.FILE_PATH + Data.ROLE_FILE);

                // Return feedback message.
                m = await ReplyAsync(
                    embed : new EmbedBuilder()
                    .WithColor(Data.COLOR_ERROR)
                    .WithTitle("Role removed")
                    .WithDescription($"The `{roleContainer.name}` role has been successfully removed from the database.")
                    .WithAutoDeletionFooter()
                    .Build());
            }
            else
            {
                m = await ReplyAsync(
                    embed : new EmbedBuilder()
                    .WithColor(Data.COLOR_ERROR)
                    .WithTitle("ERROR: Role not found").WithDescription($"The `{role}` role you specified does not exist in the database.")
                    .WithAutoDeletionFooter()
                    .Build());
            }

            // Delete prompt and feedback messages.
            await Task.Delay(Data.MESSAGE_DELETE_DELAY * 1000);

            await Context.Message.DeleteAsync();

            await m.DeleteAsync();
        }
Exemplo n.º 4
0
 private void buttonTokenRemove_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(comboBoxToken.Text))
     {
         TokenContainer tc = Data.GetContainers <TokenContainer>(Data.FILE_PATH + Data.TOKEN_FILE).FirstOrDefault(x => x.name == comboBoxToken.Text || x.token == comboBoxToken.Text);
         if (tc != null)
         {
             Data.RemoveContainer(tc, Data.FILE_PATH + Data.TOKEN_FILE);
             comboBoxToken.Items.Remove(comboBoxToken.Text);
             comboBoxToken.Text = "";
         }
         else
         {
             MessageBox.Show("The token you entered does not exist.", "ERROR: Could not find token!");
         }
     }
     else
     {
         MessageBox.Show("You need to select a token before using this button.", "ERROR: Missing token!");
     }
 }